From c1be65571b2c61fedaeae736ab767504aaee44cb Mon Sep 17 00:00:00 2001 From: EvenSol Date: Tue, 5 Apr 2022 22:10:39 +0200 Subject: [PATCH 1/4] Create WellAllocator.java --- .../measurementDevice/WellAllocator.java | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 src/main/java/neqsim/processSimulation/measurementDevice/WellAllocator.java diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/WellAllocator.java b/src/main/java/neqsim/processSimulation/measurementDevice/WellAllocator.java new file mode 100644 index 000000000..4e3574456 --- /dev/null +++ b/src/main/java/neqsim/processSimulation/measurementDevice/WellAllocator.java @@ -0,0 +1,123 @@ +package neqsim.processSimulation.measurementDevice; + +import neqsim.processSimulation.processEquipment.separator.Separator; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemSrkEos; + +public class WellAllocator extends MeasurementDeviceBaseClass { + + protected StreamInterface wellStream = null; + protected StreamInterface exportGasStream = null; + protected StreamInterface exportOilStream = null; + + public WellAllocator() { + name = "Well Allocator"; + } + + + public WellAllocator(StreamInterface stream) { + this.wellStream = stream; + } + + public WellAllocator(String name, StreamInterface stream) { + this(stream); + this.name = name; + } + + + public void setExportGasStream(StreamInterface stream) { + this.exportGasStream = stream; + } + + public void setExportOilStream(StreamInterface stream) { + this.exportOilStream = stream; + } + + /** {@inheritDoc} */ + @Override + public double getMeasuredValue() { + return wellStream.getThermoSystem().getFlowRate("kg/hr"); + } + + /** {@inheritDoc} */ + @Override + public double getMeasuredValue(String measurement) { + int numberOfComps = wellStream.getThermoSystem().getNumberOfComponents(); + double[] splitFactors = new double[numberOfComps]; + double gasExportFlow = 0.0; + double oilExportFlow = 0.0; + for (int i = 0; i < numberOfComps; i++) { + splitFactors[i] = exportGasStream.getFluid().getComponent(i).getFlowRate("kg/hr") + / (exportGasStream.getFluid().getComponent(i).getFlowRate("kg/hr") + + exportOilStream.getFluid().getComponent(i).getFlowRate("kg/hr")); + gasExportFlow += wellStream.getFluid().getComponent(i).getTotalFlowRate("kg/hr") * splitFactors[i]; + oilExportFlow += + wellStream.getFluid().getComponent(i).getTotalFlowRate("kg/hr") * (1.0 - splitFactors[i]); + } + + if (measurement.equals("gas export rate")) { + return gasExportFlow; + } + if (measurement.equals("oil export rate")) { + return oilExportFlow; + } + if (measurement.equals("total export rate")) { + return wellStream.getFluid().getFlowRate("kg/hr"); + } + return 0.0; + } + + public static void main(String[] args) { + SystemInterface testFluid = new SystemSrkEos(338.15, 50.0); + testFluid.addComponent("nitrogen", 1.205); + testFluid.addComponent("CO2", 1.340); + testFluid.addComponent("methane", 87.974); + testFluid.addComponent("ethane", 5.258); + testFluid.addComponent("propane", 3.283); + testFluid.addComponent("i-butane", 0.082); + testFluid.addComponent("n-butane", 0.487); + testFluid.addComponent("i-pentane", 0.056); + testFluid.addComponent("n-pentane", 1.053); + testFluid.addComponent("nC10", 14.053); + testFluid.setMixingRule(2); + + testFluid.setTemperature(24.0, "C"); + testFluid.setPressure(48.0, "bara"); + testFluid.setTotalFlowRate(2500.0, "kg/hr"); + + Stream stream_1 = new Stream("Stream1", testFluid); + + SystemInterface testFluid2 = testFluid.clone(); + testFluid2.setMolarComposition(new double[] {0.1, 0.1, 0.9, 0.1, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0}); + Stream stream_2 = new Stream("Stream2", testFluid2); + + Separator sep1 = new Separator("sep1", stream_1); + sep1.addStream(stream_2); + + Stream stream_gasExp = new Stream("gasexp", sep1.getGasOutStream()); + + Stream stream_oilExp = new Stream("gasexp", sep1.getLiquidOutStream()); + + WellAllocator wellAlloc = new WellAllocator("alloc", stream_1); + wellAlloc.setExportGasStream(stream_gasExp); + wellAlloc.setExportOilStream(stream_oilExp); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(stream_2); + operations.add(sep1); + operations.add(stream_gasExp); + operations.add(stream_oilExp); + operations.add(wellAlloc); + operations.run(); + + System.out.println("gas flow " + wellAlloc.getMeasuredValue("gas export rate")); + System.out.println("oil flow " + wellAlloc.getMeasuredValue("oil export rate")); + System.out.println("total flow " + wellAlloc.getMeasuredValue("total export rate")); + + } + +} From 1d522a3c15b8aae7dd265b2742662ab5f953297a Mon Sep 17 00:00:00 2001 From: EvenSol Date: Tue, 5 Apr 2022 22:15:35 +0200 Subject: [PATCH 2/4] Create WellAllocatorResponse.java --- .../util/monitor/WellAllocatorResponse.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/java/neqsim/processSimulation/util/monitor/WellAllocatorResponse.java diff --git a/src/main/java/neqsim/processSimulation/util/monitor/WellAllocatorResponse.java b/src/main/java/neqsim/processSimulation/util/monitor/WellAllocatorResponse.java new file mode 100644 index 000000000..3226b8f6c --- /dev/null +++ b/src/main/java/neqsim/processSimulation/util/monitor/WellAllocatorResponse.java @@ -0,0 +1,38 @@ +package neqsim.processSimulation.util.monitor; + +import neqsim.processSimulation.measurementDevice.MultiPhaseMeter; +import neqsim.processSimulation.measurementDevice.WellAllocator; + +/** + *

+ * MPMResponse class. + *

+ * + * @author asmund + * @version $Id: $Id + */ +public class WellAllocatorResponse { + public String name; + public Double gasExportRate, oilExportRate, totalExportRate; + + /** + *

+ * Constructor for WellAllocatorResponse. + *

+ */ + public WellAllocatorResponse() {} + + /** + *

+ * Constructor for WellAllocatorResponse. + *

+ * + * @param inputMPM a {@link neqsim.processSimulation.measurementDevice.WellAllocator} object + */ + public WellAllocatorResponse(WellAllocator inputAllocator) { + name = inputAllocator.getName(); + gasExportRate = inputAllocator.getMeasuredValue("gas export rate"); + oilExportRate = inputAllocator.getMeasuredValue("oil export rate"); + totalExportRate = inputAllocator.getMeasuredValue("total export rate"); + } +} From e3c9eb30f1293b1afdd2dad8c0ebff3267c5e5be Mon Sep 17 00:00:00 2001 From: EvenSol Date: Tue, 5 Apr 2022 23:05:23 +0200 Subject: [PATCH 3/4] updates --- .../measurementDevice/WellAllocator.java | 17 +++++++++++------ .../util/monitor/WellAllocatorResponse.java | 5 ++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/WellAllocator.java b/src/main/java/neqsim/processSimulation/measurementDevice/WellAllocator.java index 4e3574456..622c87e0c 100644 --- a/src/main/java/neqsim/processSimulation/measurementDevice/WellAllocator.java +++ b/src/main/java/neqsim/processSimulation/measurementDevice/WellAllocator.java @@ -3,6 +3,7 @@ import neqsim.processSimulation.processEquipment.separator.Separator; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.processSimulation.util.monitor.WellAllocatorResponse; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; @@ -18,12 +19,13 @@ public WellAllocator() { public WellAllocator(StreamInterface stream) { + name = "Well Allocator"; this.wellStream = stream; } - public WellAllocator(String name, StreamInterface stream) { + public WellAllocator(String streamname, StreamInterface stream) { this(stream); - this.name = name; + name = streamname; } @@ -90,7 +92,7 @@ public static void main(String[] args) { Stream stream_1 = new Stream("Stream1", testFluid); SystemInterface testFluid2 = testFluid.clone(); - testFluid2.setMolarComposition(new double[] {0.1, 0.1, 0.9, 0.1, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0}); + // testFluid2.setMolarComposition(new double[] {0.1, 0.1, 0.9, 0.1, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0}); Stream stream_2 = new Stream("Stream2", testFluid2); Separator sep1 = new Separator("sep1", stream_1); @@ -114,9 +116,12 @@ public static void main(String[] args) { operations.add(wellAlloc); operations.run(); - System.out.println("gas flow " + wellAlloc.getMeasuredValue("gas export rate")); - System.out.println("oil flow " + wellAlloc.getMeasuredValue("oil export rate")); - System.out.println("total flow " + wellAlloc.getMeasuredValue("total export rate")); + WellAllocatorResponse responsAl = new WellAllocatorResponse(wellAlloc); + + System.out.println("name " + responsAl.name); + System.out.println("gas flow " + responsAl.gasExportRate); + System.out.println("oil flow " + responsAl.oilExportRate); + System.out.println("total flow " + responsAl.totalExportRate); } diff --git a/src/main/java/neqsim/processSimulation/util/monitor/WellAllocatorResponse.java b/src/main/java/neqsim/processSimulation/util/monitor/WellAllocatorResponse.java index 3226b8f6c..38ee830b4 100644 --- a/src/main/java/neqsim/processSimulation/util/monitor/WellAllocatorResponse.java +++ b/src/main/java/neqsim/processSimulation/util/monitor/WellAllocatorResponse.java @@ -1,11 +1,10 @@ package neqsim.processSimulation.util.monitor; -import neqsim.processSimulation.measurementDevice.MultiPhaseMeter; import neqsim.processSimulation.measurementDevice.WellAllocator; /** *

- * MPMResponse class. + * WellAllocatorResponse class. *

* * @author asmund @@ -27,7 +26,7 @@ public WellAllocatorResponse() {} * Constructor for WellAllocatorResponse. *

* - * @param inputMPM a {@link neqsim.processSimulation.measurementDevice.WellAllocator} object + * @param inputAllocator a {@link neqsim.processSimulation.measurementDevice.WellAllocator} object */ public WellAllocatorResponse(WellAllocator inputAllocator) { name = inputAllocator.getName(); From f618c42d8152b329280643414ded4897205135fe Mon Sep 17 00:00:00 2001 From: EvenSol Date: Sat, 9 Apr 2022 16:19:07 +0200 Subject: [PATCH 4/4] update --- .../neqsim/thermo/system/SystemInterface.java | 3 + .../neqsim/thermo/system/SystemThermo.java | 13 ++- .../measurementDevice/WellAllocatorTest.java | 94 +++++++++++++++++++ 3 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 src/test/java/neqsim/processSimulation/measurementDevice/WellAllocatorTest.java diff --git a/src/main/java/neqsim/thermo/system/SystemInterface.java b/src/main/java/neqsim/thermo/system/SystemInterface.java index 41023ab99..7e2e0224b 100644 --- a/src/main/java/neqsim/thermo/system/SystemInterface.java +++ b/src/main/java/neqsim/thermo/system/SystemInterface.java @@ -2484,4 +2484,7 @@ public void setImplementedCompositionDeriativesofFugacity( /** {@inheritDoc} */ @Override public int hashCode(); + + /** {@inheritDoc} */ + public void addToComponentNames(java.lang.String name); } diff --git a/src/main/java/neqsim/thermo/system/SystemThermo.java b/src/main/java/neqsim/thermo/system/SystemThermo.java index bfca2fbac..c1c31489b 100644 --- a/src/main/java/neqsim/thermo/system/SystemThermo.java +++ b/src/main/java/neqsim/thermo/system/SystemThermo.java @@ -3782,7 +3782,18 @@ public java.lang.String getFluidName() { public void setFluidName(java.lang.String fluidName) { this.fluidName = fluidName; } - + + public void addToComponentNames(java.lang.String name) { + for(int j=0;j * setLastTBPasPlus. diff --git a/src/test/java/neqsim/processSimulation/measurementDevice/WellAllocatorTest.java b/src/test/java/neqsim/processSimulation/measurementDevice/WellAllocatorTest.java new file mode 100644 index 000000000..38b4396fe --- /dev/null +++ b/src/test/java/neqsim/processSimulation/measurementDevice/WellAllocatorTest.java @@ -0,0 +1,94 @@ +/** + * + */ +package neqsim.processSimulation.measurementDevice; + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.processEquipment.separator.Separator; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.processSimulation.util.monitor.WellAllocatorResponse; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemSrkEos; + +/** + * @author ESOL + * + */ +class WellAllocatorTest extends neqsim.NeqSimTest{ + + /** + * @throws java.lang.Exception + */ + @BeforeAll + static void setUpBeforeClass() throws Exception {} + + /** + * Test method for {@link neqsim.processSimulation.measurementDevice.WellAllocator#getMeasuredValue(java.lang.String)}. + */ + @Test + void testGetMeasuredValueString() { + SystemInterface testFluid = new SystemSrkEos(338.15, 50.0); + testFluid.addComponent("nitrogen", 1.205); + testFluid.addComponent("CO2", 1.340); + testFluid.addComponent("methane", 87.974); + testFluid.addComponent("ethane", 5.258); + testFluid.addComponent("propane", 3.283); + testFluid.addComponent("i-butane", 0.082); + testFluid.addComponent("n-butane", 0.487); + testFluid.addComponent("i-pentane", 0.056); + testFluid.addComponent("n-pentane", 1.053); + testFluid.addComponent("nC10", 14.053); + testFluid.setMixingRule(2); + + testFluid.addToComponentNames("_well1"); + + testFluid.setTemperature(24.0, "C"); + testFluid.setPressure(48.0, "bara"); + testFluid.setTotalFlowRate(2500.0, "kg/hr"); + + + SystemInterface testFluid2 = testFluid.clone(); + + + testFluid.setTemperature(24.0, "C"); + testFluid.setPressure(48.0, "bara"); + testFluid.setTotalFlowRate(2500.0, "kg/hr"); + + Stream stream_1 = new Stream("Stream1", testFluid); + + Stream stream_2 = new Stream("Stream2", testFluid2); + + Separator sep1 = new Separator("sep1", stream_1); + sep1.addStream(stream_2); + + Stream stream_gasExp = new Stream("gasexp", sep1.getGasOutStream()); + + Stream stream_oilExp = new Stream("gasexp", sep1.getLiquidOutStream()); + + WellAllocator wellAlloc = new WellAllocator("alloc", stream_1); + wellAlloc.setExportGasStream(stream_gasExp); + wellAlloc.setExportOilStream(stream_oilExp); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(stream_2); + operations.add(sep1); + operations.add(stream_gasExp); + operations.add(stream_oilExp); + operations.add(wellAlloc); + operations.run(); + + WellAllocatorResponse responsAl = new WellAllocatorResponse(wellAlloc); + + System.out.println("name " + responsAl.name); + System.out.println("gas flow " + responsAl.gasExportRate); + System.out.println("oil flow " + responsAl.oilExportRate); + System.out.println("total flow " + responsAl.totalExportRate); + // stream_1.displayResult(); + // stream_1.displayResult(); + } + +}