Skip to content

Commit

Permalink
improve setter
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Nov 8, 2023
1 parent acab8bd commit 8b1bc67
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,113 @@ public void setTemperature(double temperature, String unitT) {
this.unitT = unitT;
}

/**
* <p>
* Get setGasFlowRate
* </p>
*
* @param flowRate flow rate
* @param flowUnit Supported units are Sm3/sec, Sm3/hr, Sm3/day, MSm3/day
* @return gas flow rate in unit sm3/sec
*/
public void setGasFlowRate(double flowRate, String flowUnit) {
gasFlowRate = flowRate;
unitGasFlowRate = flowUnit;
double conversionFactor = 1.0;
switch (flowUnit) {
case "Sm3/sec":
conversionFactor = 1.0;
break;
case "Sm3/hr":
conversionFactor = 1.0 / 3600.0;
break;
case "Sm3/day":
conversionFactor = 1.0 / 3600.0 / 24.0;
break;
default:
throw new RuntimeException("unit not supported " + flowUnit);
}
gasFlowRate = flowRate * conversionFactor;
}

/**
* <p>
* Get getGasFlowRate
* </p>
*
* @param flowUnit Supported units are Sm3/sec, Sm3/hr, Sm3/day, MSm3/day
* @return gas flow rate in unit sm3/sec
*/
public double getGasFlowRate(String flowUnit) {
return gasFlowRate;
double conversionFactor = 1.0;
switch (flowUnit) {
case "Sm3/sec":
conversionFactor = 1.0;
break;
case "Sm3/hr":
conversionFactor = 1.0 / 3600.0;
break;
case "Sm3/day":
conversionFactor = 1.0 / 3600.0 / 24.0;
break;
case "MSm3/day":
conversionFactor = 1.0 / 3600.0 / 24.0 / 1e6;
break;
default:
throw new RuntimeException("unit not supported " + flowUnit);
}
return gasFlowRate * conversionFactor;
}

/**
* <p>
* Get setOilFlowRate
* </p>
*
* @param flowRate flow rate
* @param flowUnit Supported units are m3/sec, m3/hr, m3/day
* @return oil flow rate in unit m3/sec
*/
public void setOilFlowRate(double flowRate, String flowUnit) {
oilFlowRate = flowRate;
unitOilFlowRate = flowUnit;
double conversionFactor = 1.0;
switch (flowUnit) {
case "m3/sec":
conversionFactor = 1.0;
break;
case "m3/hr":
conversionFactor = 1.0 / 3600.0;
break;
case "m3/day":
conversionFactor = 1.0 / 3600.0 / 24.0;
break;
default:
throw new RuntimeException("unit not supported " + flowUnit);
}
oilFlowRate = flowRate * conversionFactor;
}

/**
* <p>
* Get getOilFlowRate
* </p>
*
* @param flowUnit Supported units are m3/sec, m3/hr, m3/day
* @return oil flow rate in unit m3/sec
*/
public double getOilFlowRate(String flowUnit) {
return oilFlowRate;
double conversionFactor = 1.0;
switch (flowUnit) {
case "m3/sec":
conversionFactor = 1.0;
break;
case "m3/hr":
conversionFactor = 1.0 / 3600.0;
break;
case "m3/day":
conversionFactor = 1.0 / 3600.0 / 24.0;
break;
default:
throw new RuntimeException("unit not supported " + flowUnit);
}
return oilFlowRate * conversionFactor;
}

public void setWaterFlowRate(double flowRate, String flowUnit) {
Expand Down Expand Up @@ -186,7 +277,7 @@ public void run(UUID id) {
moleChange[i] = tempFluid.getPhase("gas").getComponent(i).getx()
* (getGasFlowRate("Sm3/sec") / tempFluid.getPhase("gas").getMolarVolume("m3/mol"))
+ tempFluid.getPhase("oil").getComponent(i).getx()
* (getOilFlowRate("Sm3/sec") / tempFluid.getPhase("oil").getMolarVolume("m3/mol"))
* (getOilFlowRate("m3/sec") / tempFluid.getPhase("oil").getMolarVolume("m3/mol"))
- tempFluid.getComponent(i).getNumberOfmoles();
}
tempFluid.init(0);
Expand All @@ -195,7 +286,7 @@ public void run(UUID id) {
}
tempFluid.setPressure((inStream.getThermoSystem()).getPressure());
tempFluid.setTemperature((inStream.getThermoSystem()).getTemperature());
tempFluid.setTotalFlowRate(flow, "kg/sec");
// tempFluid.setTotalFlowRate(flow, "kg/sec");
try {
thermoOps.TPflash();
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package neqsim.processSimulation.processEquipment.util;

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import neqsim.processSimulation.measurementDevice.MultiPhaseMeter;
import neqsim.processSimulation.processEquipment.stream.Stream;
Expand All @@ -22,27 +23,29 @@ void testMain() {
testFluid.addComponent("nC10", 4.053);
testFluid.setMixingRule(2);
testFluid.setMultiPhaseCheck(true);

testFluid.setTemperature(90.0, "C");
testFluid.setPressure(60.0, "bara");
testFluid.setTotalFlowRate(1e6, "kg/hr");

Stream stream_1 = new Stream("Stream1", testFluid);
stream_1.run();

MultiPhaseMeter multiPhaseMeter = new MultiPhaseMeter("test", stream_1);
multiPhaseMeter.setTemperature(90.0, "C");
multiPhaseMeter.setPressure(60.0, "bara");
multiPhaseMeter.setTemperature(15.0, "C");
multiPhaseMeter.setPressure(1.01325, "bara");

FlowSetter flowset = new FlowSetter("flowset", stream_1);
flowset.setTemperature(15.0, "C");
flowset.setPressure(1.01325, "bara");
flowset.setGasFlowRate(multiPhaseMeter.getMeasuredValue("Gas Flow Rate", "Sm3/hr"), "Sm3/hr");
flowset.setOilFlowRate(multiPhaseMeter.getMeasuredValue("Oil Flow Rate", "Sm3/hr"), "Sm3/hr");
flowset.setOilFlowRate(multiPhaseMeter.getMeasuredValue("Oil Flow Rate", "m3/hr"), "m3/hr");

neqsim.processSimulation.processSystem.ProcessSystem operations =
new neqsim.processSimulation.processSystem.ProcessSystem();
operations.add(stream_1);
operations.add(multiPhaseMeter);
operations.add(flowset);
operations.run();

assertEquals(flowset.getOutletStream().getFlowRate("kg/sec"), stream_1.getFlowRate("kg/sec"),
1.0);
}
}

0 comments on commit 8b1bc67

Please sign in to comment.