Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Nov 8, 2023
1 parent 8b1bc67 commit f96c67f
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,24 @@ public double getMeasuredValue(String measurement, String unit) {
tempFluid.initPhysicalProperties("density");
return tempFluid.getPhase("oil").getFlowRate(unit);
}
if (measurement.equals("Water Flow Rate")) {
SystemInterface tempFluid = stream.getThermoSystem().clone();
tempFluid.setTemperature(temperature, unitT);
tempFluid.setPressure(pressure, unitP);
ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid);
try {
thermoOps.TPflash();
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
return Double.NaN;
}
// tempFluid.display();
if (!tempFluid.hasPhaseType("aqueous")) {
return Double.NaN;
}
tempFluid.initPhysicalProperties("density");
return tempFluid.getPhase("aqueous").getFlowRate(unit);
}
if (measurement.equals("gasDensity") || measurement.equals("oilDensity")
|| measurement.equals("waterDensity")) {
SystemInterface tempFluid = stream.getThermoSystem().clone();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,57 @@ public double getOilFlowRate(String flowUnit) {
return oilFlowRate * conversionFactor;
}

/**
* <p>
* Get setWaterFlowRate
* </p>
*
* @param flowRate flow rate
* @param flowUnit Supported units are m3/sec, m3/hr, m3/day
* @return water flow rate in unit m3/sec
*/
public void setWaterFlowRate(double flowRate, String flowUnit) {
waterFlowRate = flowRate;
unitWaterFlowRate = 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);
}
waterFlowRate = flowRate * conversionFactor;
}

/**
* <p>
* Get getWaterFlowRate
* </p>
*
* @param flowUnit Supported units are m3/sec, m3/hr, m3/day
* @return water flow rate in unit m3/sec
*/
public double getWaterFlowRate(String flowUnit) {
return waterFlowRate;
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 waterFlowRate * conversionFactor;
}

/** {@inheritDoc} */
Expand Down Expand Up @@ -284,9 +328,12 @@ public void run(UUID id) {
for (int i = 0; i < tempFluid.getNumberOfComponents(); i++) {
tempFluid.addComponent(i, moleChange[i]);
}
if (waterFlowRate > 0) {
tempFluid.addComponent("water", waterFlowRate * 1000.0, "kg/sec");
}
tempFluid.setPressure((inStream.getThermoSystem()).getPressure());
tempFluid.setTemperature((inStream.getThermoSystem()).getTemperature());
// tempFluid.setTotalFlowRate(flow, "kg/sec");

try {
thermoOps.TPflash();
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ void testMain() {
testFluid.addComponent("i-pentane", 0.056);
testFluid.addComponent("n-pentane", 1.053);
testFluid.addComponent("nC10", 4.053);
testFluid.addComponent("water", 10.00);
testFluid.setMixingRule(2);
testFluid.setMultiPhaseCheck(true);
testFluid.setTotalFlowRate(1e6, "kg/hr");

Stream stream_1 = new Stream("Stream1", testFluid);
stream_1.run();
Expand All @@ -37,7 +37,7 @@ void testMain() {
flowset.setPressure(1.01325, "bara");
flowset.setGasFlowRate(multiPhaseMeter.getMeasuredValue("Gas Flow Rate", "Sm3/hr"), "Sm3/hr");
flowset.setOilFlowRate(multiPhaseMeter.getMeasuredValue("Oil Flow Rate", "m3/hr"), "m3/hr");

flowset.setWaterFlowRate(multiPhaseMeter.getMeasuredValue("Water Flow Rate", "m3/hr"), "m3/hr");
neqsim.processSimulation.processSystem.ProcessSystem operations =
new neqsim.processSimulation.processSystem.ProcessSystem();
operations.add(stream_1);
Expand All @@ -47,5 +47,7 @@ void testMain() {

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

flowset.getOutletStream().getFluid().prettyPrint();
}
}

0 comments on commit f96c67f

Please sign in to comment.