Skip to content

Commit

Permalink
fixed bug in json HX response (#1058)
Browse files Browse the repository at this point in the history
* work ongoing

* fixed NaN in HX response

* added duty in output

* changed variable name
  • Loading branch information
EvenSol authored Jul 31, 2024
1 parent 422cae4 commit f79c58f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
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));
}
}
27 changes: 14 additions & 13 deletions src/main/java/neqsim/processSimulation/util/monitor/HXResponse.java
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

0 comments on commit f79c58f

Please sign in to comment.