From 07cf51475b61888f41f1491223708a8bb5698f70 Mon Sep 17 00:00:00 2001
From: Even Solbraa <41290109+EvenSol@users.noreply.github.com>
Date: Tue, 3 May 2022 16:33:28 +0200
Subject: [PATCH 1/3] first version of component splitter
---
.../splitter/ComponentSplitter.java | 115 ++++++++++++++++++
.../splitter/ComponentSplitterTest.java | 54 ++++++++
2 files changed, 169 insertions(+)
create mode 100644 src/main/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitter.java
create mode 100644 src/test/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitterTest.java
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitter.java b/src/main/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitter.java
new file mode 100644
index 000000000..385861cf0
--- /dev/null
+++ b/src/main/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitter.java
@@ -0,0 +1,115 @@
+package neqsim.processSimulation.processEquipment.splitter;
+
+import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass;
+import neqsim.processSimulation.processEquipment.stream.Stream;
+import neqsim.processSimulation.processEquipment.stream.StreamInterface;
+import neqsim.thermo.system.SystemInterface;
+import neqsim.thermodynamicOperations.ThermodynamicOperations;
+
+/**
+ *
+ * Splitter class.
+ *
+ *
+ * @author Even Solbraa
+ * @version $Id: $Id
+ */
+public class ComponentSplitter extends ProcessEquipmentBaseClass {
+ private static final long serialVersionUID = 1000;
+
+ SystemInterface thermoSystem;
+ StreamInterface inletStream;
+ StreamInterface[] splitStream;
+ protected int splitNumber = 1;
+ double[] splitFactor = new double[1];
+
+ /**
+ *
+ * Constructor for Splitter.
+ *
+ */
+ public ComponentSplitter() {
+ super("Component Splitter");
+ }
+
+ /**
+ * Constructor for Splitter.
+ *
+ * @param name
+ */
+ public ComponentSplitter(String name) {
+ super(name);
+ }
+
+ /**
+ *
+ * Constructor for Splitter.
+ *
+ *
+ * @param name a {@link java.lang.String} object
+ * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface}
+ * object
+ * @param i a int
+ */
+ public ComponentSplitter(String name, StreamInterface inletStream) {
+ this(name);
+ this.setInletStream(inletStream);
+ }
+
+ public void setSplitFactors(double[] factors) {
+ splitFactor = factors;
+ }
+
+ public void setInletStream(StreamInterface inletStream) {
+ this.inletStream = inletStream;
+ splitStream = new Stream[2];
+ try {
+ for (int i = 0; i < splitStream.length; i++) {
+ splitStream[i] = new Stream("Split Stream", inletStream.getThermoSystem().clone());
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public StreamInterface getSplitStream(int i) {
+ return splitStream[i];
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void run() {
+ for (int i = 0; i < 2; i++) {
+ thermoSystem = inletStream.getThermoSystem().clone();
+ thermoSystem.removeMoles();
+ if (i == 0) {
+ for (int k = 0; k < thermoSystem.getNumberOfComponents(); k++) {
+ thermoSystem.addComponent(k,
+ inletStream.getThermoSystem().getComponent(k).getNumberOfmoles() * splitFactor[k]);
+ }
+ } else {
+ for (int k = 0; k < thermoSystem.getNumberOfComponents(); k++) {
+ thermoSystem.addComponent(k,
+ inletStream.getThermoSystem().getComponent(k).getNumberOfmoles()
+ * (1.0 - splitFactor[k]));
+ }
+ }
+
+ thermoSystem.init(0);
+ splitStream[i].setThermoSystem(thermoSystem);
+ ThermodynamicOperations thermoOps =
+ new ThermodynamicOperations(splitStream[i].getThermoSystem());
+ thermoOps.TPflash();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void displayResult() {}
+
+ /** {@inheritDoc} */
+ @Override
+ public void runTransient(double dt) {
+ run();
+ }
+}
diff --git a/src/test/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitterTest.java b/src/test/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitterTest.java
new file mode 100644
index 000000000..93a3e2d48
--- /dev/null
+++ b/src/test/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitterTest.java
@@ -0,0 +1,54 @@
+package neqsim.processSimulation.processEquipment.splitter;
+
+import static org.junit.jupiter.api.Assertions.*;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import neqsim.processSimulation.processEquipment.stream.Stream;
+import neqsim.processSimulation.processEquipment.stream.StreamInterface;
+import neqsim.processSimulation.processSystem.ProcessSystem;
+import neqsim.thermo.system.SystemSrkEos;
+
+class ComponentSplitterTest {
+
+ static neqsim.thermo.system.SystemInterface testSystem = null;
+ double pressure_inlet = 85.0;
+ double temperature_inlet = 35.0;
+ double gasFlowRate = 5.0;
+ ProcessSystem processOps = null;
+
+ @BeforeEach
+ public void setUpBeforeClass() throws Exception {
+ testSystem = new SystemSrkEos(298.0, 10.0);
+ testSystem.addComponent("methane", 100.0);
+ testSystem.addComponent("ethane", 10.0);
+ testSystem.addComponent("propane", 10.0);
+ processOps = new ProcessSystem();
+ Stream inletStream = new Stream("inletStream", testSystem);
+ inletStream.setName("inlet stream");
+ inletStream.setPressure(pressure_inlet, "bara");
+ inletStream.setTemperature(temperature_inlet, "C");
+ inletStream.setFlowRate(gasFlowRate, "MSm3/day");
+
+ ComponentSplitter splitter = new ComponentSplitter("splitter", inletStream);
+ splitter.setSplitFactors(new double[] {1.00, 0.0, 0.0});
+
+ StreamInterface stream1 = new Stream("stream 1", splitter.getSplitStream(0));
+ StreamInterface stream2 = new Stream("stream 2",splitter.getSplitStream(1));
+
+ processOps.add(inletStream);
+ processOps.add(splitter);
+ processOps.add(stream1);
+ processOps.add(stream2);
+ }
+
+ @Test
+ public void testRun() {
+ processOps.run();
+ //((StreamInterface)processOps.getUnit("stream 1")).displayResult();
+ //((StreamInterface)processOps.getUnit("stream 2")).displayResult();
+ assertEquals(((StreamInterface)processOps.getUnit("stream 1")).getFluid().getComponent("methane").getx(), 1.0, 1e-6);
+ assertEquals(((StreamInterface)processOps.getUnit("stream 2")).getFluid().getComponent("methane").getx(), 0.0, 1e-6);
+ }
+
+}
From 8ad9277114cd3f30d8f8f726e1ecc2f42a873396 Mon Sep 17 00:00:00 2001
From: EvenSol
Date: Tue, 3 May 2022 23:00:22 +0200
Subject: [PATCH 2/3] various updates
---
.../processEquipment/separator/Separator.java | 8 +-
.../gasQuality/Standard_ISO6976.java | 2 +-
.../gasQuality/Standard_ISO6976_2016.java | 2 +-
.../gasQuality/Standard_ISO6976Test.java | 214 ++++++++++--------
4 files changed, 126 insertions(+), 100 deletions(-)
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java
index 64d35a3fc..0ec3e7a39 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java
@@ -198,8 +198,12 @@ public void run() {
} else {
liquidOutStream.setThermoSystem(thermoSystem2.getEmptySystemClone());
}
- gasOutStream.run();
- liquidOutStream.run();
+ if (thermoSystem2.hasPhaseType("gas")) {
+ gasOutStream.run();
+ }
+ if (thermoSystem2.hasPhaseType("aqueous") || thermoSystem2.hasPhaseType("oil")) {
+ liquidOutStream.run();
+ }
// liquidOutStream.setThermoSystemFromPhase(thermoSystem2, "aqueous");
try {
thermoSystem = thermoSystem2.clone();
diff --git a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java
index bc89807d2..7d0e1ecc2 100644
--- a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java
+++ b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java
@@ -93,7 +93,7 @@ public Standard_ISO6976(String name, String description, SystemInterface thermoS
try {
String compName = "inert";
String compType = this.thermoSystem.getPhase(0).getComponent(i).getComponentType();
- if (compType.equals("HC") || compType.equals("TPB") || compType.equals("plus")) {
+ if (compType.equals("HC") || compType.equals("TBP") || compType.equals("plus")) {
compName = "n-heptane";
} else if (compType.equals("alcohol") || compType.equals("glycol")) {
compName = "methanol";
diff --git a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976_2016.java b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976_2016.java
index 215cc42be..9b55e5e17 100644
--- a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976_2016.java
+++ b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976_2016.java
@@ -79,7 +79,7 @@ public Standard_ISO6976_2016(SystemInterface thermoSystem) {
String compType =
this.thermoSystem.getPhase(0).getComponent(i).getComponentType();
- if (compType.equals("HC") || compType.equals("TPB")
+ if (compType.equals("HC") || compType.equals("TBP")
|| compType.equals("plus")) {
compName = "n-heptane";
} else if (compType.equals("alcohol") || compType.equals("glycol")) {
diff --git a/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976Test.java b/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976Test.java
index 2078df96d..161b3f3cf 100644
--- a/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976Test.java
+++ b/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976Test.java
@@ -15,111 +15,133 @@
* @author ESOL
*
*/
-class Standard_ISO6976Test extends neqsim.NeqSimTest{
- static SystemInterface testSystem = null;
- /**
- * @throws java.lang.Exception
- */
- @BeforeAll
- static void setUpBeforeClass() throws Exception {
- testSystem = new SystemSrkEos(273.15 + 20.0, 1.0);
- testSystem.addComponent("methane", 0.931819);
- testSystem.addComponent("ethane", 0.025618);
- testSystem.addComponent("nitrogen", 0.010335);
- testSystem.addComponent("CO2", 0.015391);
- testSystem.setMixingRule("classic");
- ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
- testOps.TPflash();
- }
+class Standard_ISO6976Test extends neqsim.NeqSimTest {
+ static SystemInterface testSystem = null;
- /**
- * Test method for {@link neqsim.standards.gasQuality.Standard_ISO6976#calculate()}.
- */
- @Test
- void testCalculate() {
- Standard_ISO6976 standard = new Standard_ISO6976(testSystem, 0, 15.55, "volume");
- standard.setReferenceState("real");
- standard.setReferenceType("volume");
- standard.calculate();
- double GCV = standard.getValue("GCV");
- double WI = standard.getValue("WI");
- assertEquals(39614.56783352743, GCV, 0.01);
- assertEquals(44.61477915805513, WI, 0.01);
- }
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
+ testSystem = new SystemSrkEos(273.15 + 20.0, 1.0);
+ testSystem.addComponent("methane", 0.931819);
+ testSystem.addComponent("ethane", 0.025618);
+ testSystem.addComponent("nitrogen", 0.010335);
+ testSystem.addComponent("CO2", 0.015391);
+ testSystem.setMixingRule("classic");
+ ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
+ testOps.TPflash();
+ }
- @Test
- void testCalculate2() {
- SystemInterface testSystem = new SystemSrkEos(273.15 - 150.0, 1.0);
- testSystem.addComponent("methane", 0.931819);
- testSystem.addComponent("ethane", 0.025618);
- testSystem.addComponent("nitrogen", 0.010335);
- testSystem.addComponent("CO2", 0.015391);
+ /**
+ * Test method for {@link neqsim.standards.gasQuality.Standard_ISO6976#calculate()}.
+ */
+ @Test
+ void testCalculate() {
+ Standard_ISO6976 standard = new Standard_ISO6976(testSystem, 0, 15.55, "volume");
+ standard.setReferenceState("real");
+ standard.setReferenceType("volume");
+ standard.calculate();
+ double GCV = standard.getValue("GCV");
+ double WI = standard.getValue("WI");
+ assertEquals(39614.56783352743, GCV, 0.01);
+ assertEquals(44.61477915805513, WI, 0.01);
+ }
- // ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
- /*
- * testSystem.addComponent("methane", 0.922393); testSystem.addComponent("ethane",
- * 0.025358); testSystem.addComponent("propane", 0.01519);
- * testSystem.addComponent("n-butane", 0.000523); testSystem.addComponent("i-butane",
- * 0.001512); testSystem.addComponent("n-pentane", 0.002846);
- * testSystem.addComponent("i-pentane", 0.002832); testSystem.addComponent("22-dim-C3",
- * 0.001015); testSystem.addComponent("n-hexane", 0.002865);
- * testSystem.addComponent("nitrogen", 0.01023); testSystem.addComponent("CO2", 0.015236);
- *
- */
+ /**
+ * Test method for {@link neqsim.standards.gasQuality.Standard_ISO6976#calculate()}.
+ */
+ @Test
+ void testCalculateWithPSeudo() {
+ SystemSrkEos testSystem = new SystemSrkEos(273.15 + 20.0, 1.0);
+ testSystem.addComponent("methane", 0.931819);
+ testSystem.addComponent("ethane", 0.025618);
+ testSystem.addComponent("nitrogen", 0.010335);
+ testSystem.addComponent("CO2", 0.015391);
+ testSystem.addTBPfraction("C10", 0.015391, 90.0 / 1000.0, 0.82);
+ testSystem.setMixingRule("classic");
+ ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
+ testOps.TPflash();
+ Standard_ISO6976 standard = new Standard_ISO6976(testSystem, 0, 15.55, "volume");
+ standard.setReferenceState("real");
+ standard.setReferenceType("volume");
+ standard.calculate();
+ double GCV = standard.getValue("GCV");
+ double WI = standard.getValue("WI");
+ assertEquals(42377.76099372482, GCV, 0.01);
+ }
- /*
- *
- * testSystem.addComponent("methane", 0.9247); testSystem.addComponent("ethane", 0.035);
- * testSystem.addComponent("propane", 0.0098); testSystem.addComponent("n-butane", 0.0022);
- * testSystem.addComponent("i-butane", 0.0034); testSystem.addComponent("n-pentane",
- * 0.0006); testSystem.addComponent("nitrogen", 0.0175); testSystem.addComponent("CO2",
- * 0.0068);
- *
- */
+ @Test
+ void testCalculate2() {
+ SystemInterface testSystem = new SystemSrkEos(273.15 - 150.0, 1.0);
+ testSystem.addComponent("methane", 0.931819);
+ testSystem.addComponent("ethane", 0.025618);
+ testSystem.addComponent("nitrogen", 0.010335);
+ testSystem.addComponent("CO2", 0.015391);
- // testSystem.addComponent("water", 0.016837);
+ // ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
+ /*
+ * testSystem.addComponent("methane", 0.922393); testSystem.addComponent("ethane", 0.025358);
+ * testSystem.addComponent("propane", 0.01519); testSystem.addComponent("n-butane", 0.000523);
+ * testSystem.addComponent("i-butane", 0.001512); testSystem.addComponent("n-pentane",
+ * 0.002846); testSystem.addComponent("i-pentane", 0.002832);
+ * testSystem.addComponent("22-dim-C3", 0.001015); testSystem.addComponent("n-hexane",
+ * 0.002865); testSystem.addComponent("nitrogen", 0.01023); testSystem.addComponent("CO2",
+ * 0.015236);
+ *
+ */
- /*
- * testSystem.addComponent("n-hexane", 0.0); testSystem.addComponent("n-heptane", 0.0);
- * testSystem.addComponent("n-octane", 0.0); testSystem.addComponent("n-nonane", 0.0);
- * testSystem.addComponent("nC10", 0.0);
- *
- * testSystem.addComponent("CO2", 0.68); testSystem.addComponent("H2S", 0.0);
- * testSystem.addComponent("water", 0.0); testSystem.addComponent("oxygen", 0.0);
- * testSystem.addComponent("carbonmonoxide", 0.0); testSystem.addComponent("nitrogen",
- * 1.75);
- */
- // testSystem.addComponent("MEG", 1.75);
- testSystem.createDatabase(true);
- testSystem.setMixingRule(2);
+ /*
+ *
+ * testSystem.addComponent("methane", 0.9247); testSystem.addComponent("ethane", 0.035);
+ * testSystem.addComponent("propane", 0.0098); testSystem.addComponent("n-butane", 0.0022);
+ * testSystem.addComponent("i-butane", 0.0034); testSystem.addComponent("n-pentane", 0.0006);
+ * testSystem.addComponent("nitrogen", 0.0175); testSystem.addComponent("CO2", 0.0068);
+ *
+ */
- testSystem.init(0);
- Standard_ISO6976 standard = new Standard_ISO6976(testSystem, 0, 15.55, "volume");
- standard.setReferenceState("real");
- standard.setReferenceType("volume");
- standard.calculate();
- Assertions.assertEquals(0.9974432506378011, standard.getValue("CompressionFactor"));
- Assertions.assertEquals(39614.56783352743, standard.getValue("SuperiorCalorificValue"));
- Assertions.assertEquals(35693.92161464964, standard.getValue("InferiorCalorificValue"));
- Assertions.assertEquals(39614.56783352743, standard.getValue("GCV"));
+ // testSystem.addComponent("water", 0.016837);
- Assertions.assertEquals(51701.01275822569, standard.getValue("SuperiorWobbeIndex"));
- Assertions.assertEquals(46584.17339159412, standard.getValue("InferiorWobbeIndex"));
+ /*
+ * testSystem.addComponent("n-hexane", 0.0); testSystem.addComponent("n-heptane", 0.0);
+ * testSystem.addComponent("n-octane", 0.0); testSystem.addComponent("n-nonane", 0.0);
+ * testSystem.addComponent("nC10", 0.0);
+ *
+ * testSystem.addComponent("CO2", 0.68); testSystem.addComponent("H2S", 0.0);
+ * testSystem.addComponent("water", 0.0); testSystem.addComponent("oxygen", 0.0);
+ * testSystem.addComponent("carbonmonoxide", 0.0); testSystem.addComponent("nitrogen", 1.75);
+ */
+ // testSystem.addComponent("MEG", 1.75);
+ testSystem.createDatabase(true);
+ testSystem.setMixingRule(2);
- Assertions.assertEquals(0.5870995452263126, standard.getValue("RelativeDensity"));
- Assertions.assertEquals(0.9974432506378011, standard.getValue("CompressionFactor"));
- Assertions.assertEquals(16.972142879156355, standard.getValue("MolarMass"));
+ testSystem.init(0);
+ Standard_ISO6976 standard = new Standard_ISO6976(testSystem, 0, 15.55, "volume");
+ standard.setReferenceState("real");
+ standard.setReferenceType("volume");
+ standard.calculate();
+ Assertions.assertEquals(0.9974432506378011, standard.getValue("CompressionFactor"));
+ Assertions.assertEquals(39614.56783352743, standard.getValue("SuperiorCalorificValue"));
+ Assertions.assertEquals(35693.92161464964, standard.getValue("InferiorCalorificValue"));
+ Assertions.assertEquals(39614.56783352743, standard.getValue("GCV"));
- //standard.display("test");
- /*
- * StandardInterface standardUK = new UKspecifications_ICF_SI(testSystem);
- * standardUK.calculate(); System.out.println("ICF " +
- * standardUK.getValue("IncompleteCombustionFactor", ""));
- *
- * System.out.println("HID " + testSystem.getPhase(0).getComponent("methane").getHID(273.15
- * - 150.0)); System.out.println("Hres " +
- * testSystem.getPhase(0).getComponent("methane").getHresTP(273.15 - 150.0));
- */
- }
+ Assertions.assertEquals(51701.01275822569, standard.getValue("SuperiorWobbeIndex"));
+ Assertions.assertEquals(46584.17339159412, standard.getValue("InferiorWobbeIndex"));
+
+ Assertions.assertEquals(0.5870995452263126, standard.getValue("RelativeDensity"));
+ Assertions.assertEquals(0.9974432506378011, standard.getValue("CompressionFactor"));
+ Assertions.assertEquals(16.972142879156355, standard.getValue("MolarMass"));
+
+ // standard.display("test");
+ /*
+ * StandardInterface standardUK = new UKspecifications_ICF_SI(testSystem);
+ * standardUK.calculate(); System.out.println("ICF " +
+ * standardUK.getValue("IncompleteCombustionFactor", ""));
+ *
+ * System.out.println("HID " + testSystem.getPhase(0).getComponent("methane").getHID(273.15 -
+ * 150.0)); System.out.println("Hres " +
+ * testSystem.getPhase(0).getComponent("methane").getHresTP(273.15 - 150.0));
+ */
+ }
}
From e265073652eb981fb35f7c5dcaa32b2220618229 Mon Sep 17 00:00:00 2001
From: EvenSol
Date: Tue, 3 May 2022 23:50:54 +0200
Subject: [PATCH 3/3] Update GORfitter.java
---
.../processEquipment/util/GORfitter.java | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java b/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java
index 84f65c956..15f01713a 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java
@@ -145,6 +145,21 @@ public void setTemperature(double temperature, String unitT) {
public void run() {
SystemInterface tempFluid = inletStream.getThermoSystem().clone();
double flow = tempFluid.getFlowRate("kg/sec");
+ if(flow<1e-6) {
+ outletStream.setThermoSystem(tempFluid);
+ return;
+ }
+ if(GOR==0 && tempFluid.hasPhaseType("gas")) {
+ tempFluid.removePhase(0);
+ ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid);
+ try {
+ thermoOps.TPflash();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ outletStream.setThermoSystem(tempFluid);
+ return;
+ }
if (!getReferenceConditions().equals("actual")) {
tempFluid.setTemperature(15.0, "C");
tempFluid.setPressure(1.01325, "bara");