Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed bug in json HX response #1058

Merged
merged 4 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
package neqsim.processSimulation.processEquipment.heatExchanger;

import java.util.UUID;
import com.google.gson.GsonBuilder;
import neqsim.processSimulation.conditionMonitor.ConditionMonitorSpecifications;
import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface;
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.processSimulation.util.monitor.HXResponse;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

Expand Down Expand Up @@ -279,8 +281,9 @@ public void run(UUID id) {
// streamToCalculate = 1;
// streamToSet = 0;
// }

// Make sure these streams to run because of the issues with enthalpy calculations if not run

// Make sure these streams to run because of the issues with enthalpy
// calculations if not run
for (StreamInterface stream : inStream) {
stream.run();
}
Expand Down Expand Up @@ -626,4 +629,11 @@ public double getHotColdDutyBalance() {
public void setHotColdDutyBalance(double hotColdDutyBalance) {
this.hotColdDutyBalance = hotColdDutyBalance;
}

/** {@inheritDoc} */
@Override
public String toJson() {
return new GsonBuilder().serializeSpecialFloatingPointValues().create()
.toJson(new HXResponse(this));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class HXResponse {
public Double dischargeTemperature2;

public Double dutyBalance;
public Double duty;
public Double UAvalue;

/**
* <p>
Expand All @@ -34,19 +36,18 @@ public HXResponse() {}
* Constructor for HXResponse.
* </p>
*
* @param inputHeatExchenger a {@link neqsim.processSimulation.processEquipment.heatExchanger.HeatExchanger} object
* @param inputHeatExchanger a
* {@link neqsim.processSimulation.processEquipment.heatExchanger.HeatExchanger} object
*/
public HXResponse(HeatExchanger inputHeatExchenger) {
name = inputHeatExchenger.getName();

feedTemperature1 = inputHeatExchenger.getInStream(0).getTemperature("C");
dischargeTemperature1 = inputHeatExchenger.getOutStream(0).getTemperature("C");

feedTemperature2 = inputHeatExchenger.getInStream(1).getTemperature("C");
dischargeTemperature2 = inputHeatExchenger.getOutStream(1).getTemperature("C");

HXthermalEfectiveness = inputHeatExchenger.getThermalEffectiveness();

dutyBalance = inputHeatExchenger.getHotColdDutyBalance();
public HXResponse(HeatExchanger inputHeatExchanger) {
name = inputHeatExchanger.getName();
feedTemperature1 = inputHeatExchanger.getInStream(0).getTemperature("C");
dischargeTemperature1 = inputHeatExchanger.getOutStream(0).getTemperature("C");
feedTemperature2 = inputHeatExchanger.getInStream(1).getTemperature("C");
dischargeTemperature2 = inputHeatExchanger.getOutStream(1).getTemperature("C");
HXthermalEfectiveness = inputHeatExchanger.getThermalEffectiveness();
dutyBalance = inputHeatExchanger.getHotColdDutyBalance();
duty = inputHeatExchanger.getDuty();
UAvalue = inputHeatExchanger.getUAvalue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.junit.jupiter.api.Test;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import neqsim.processSimulation.processEquipment.heatExchanger.HeatExchanger;
import neqsim.processSimulation.processEquipment.separator.Separator;
import neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator;
import neqsim.processSimulation.processEquipment.stream.Stream;
Expand Down Expand Up @@ -37,13 +38,22 @@ void testWrite() {
new ThreePhaseSeparator("three phase separator", inletStream);
separator3phase.setInternalDiameter(0.05);

HeatExchanger hx1 = new HeatExchanger(separator3phase.getGasOutStream());
hx1.setName("E-100");
hx1.setGuessOutTemperature(273.15 + 35.0);
hx1.setUAvalue(444000.2);
hx1.setFeedStream(1, inletStream);

processOps.add(inletStream);
processOps.add(separator);
processOps.add(separator3phase);
processOps.add(hx1);

processOps.run();

String sepjson = separator.toJson();
String sep3json = separator3phase.toJson();
String hxjson = hx1.toJson();
JsonObject jsonObject = JsonParser.parseString(sep3json).getAsJsonObject();
Double reldens = jsonObject.getAsJsonObject("feed").getAsJsonObject("properties")
.getAsJsonObject("oil").getAsJsonObject("relative density").get("value").getAsDouble();
Expand Down