diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/FlowSetter.java b/src/main/java/neqsim/processSimulation/processEquipment/util/FlowSetter.java index 9dd57dcfef..2a05775405 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/FlowSetter.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/FlowSetter.java @@ -131,22 +131,113 @@ public void setTemperature(double temperature, String unitT) { this.unitT = unitT; } + /** + *
+ * Get setGasFlowRate + *
+ * + * @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; } + /** + *+ * Get getGasFlowRate + *
+ * + * @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; } + /** + *+ * Get setOilFlowRate + *
+ * + * @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; } + /** + *+ * Get getOilFlowRate + *
+ * + * @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) { @@ -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); @@ -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) { diff --git a/src/main/java/neqsim/statistics/dataAnalysis/dataSmoothing/DataSmoother.java b/src/main/java/neqsim/statistics/dataanalysis/datasmoothing/DataSmoother.java similarity index 100% rename from src/main/java/neqsim/statistics/dataAnalysis/dataSmoothing/DataSmoother.java rename to src/main/java/neqsim/statistics/dataanalysis/datasmoothing/DataSmoother.java diff --git a/src/test/java/neqsim/processSimulation/processEquipment/util/FlowSetterTest.java b/src/test/java/neqsim/processSimulation/processEquipment/util/FlowSetterTest.java index d19909e31e..63b788a2b2 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/util/FlowSetterTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/util/FlowSetterTest.java @@ -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; @@ -22,21 +23,20 @@ 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(); @@ -44,5 +44,8 @@ void testMain() { operations.add(multiPhaseMeter); operations.add(flowset); operations.run(); + + assertEquals(flowset.getOutletStream().getFlowRate("kg/sec"), stream_1.getFlowRate("kg/sec"), + 1.0); } }