From 3ae379458ff9a4b9f0e9cf38d85098f21fc5b5c2 Mon Sep 17 00:00:00 2001
From: Even Solbraa <41290109+EvenSol@users.noreply.github.com>
Date: Thu, 21 Dec 2023 09:25:26 +0100
Subject: [PATCH 01/15] added test for umrpru (#886)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* added test for umrpru
* updated
* update
* fix bug saturation temperature and add test
* update name
* Update src/main/java/neqsim/PVTsimulation/simulation/SaturationTemperature.java
good suggestion
Co-authored-by: Jørgen Engelsen
* Update src/test/java/neqsim/PVTsimulation/simulation/SaturationTemperatureTest.java
Co-authored-by: Jørgen Engelsen
* Update src/main/java/neqsim/PVTsimulation/simulation/SaturationPressure.java
Co-authored-by: Jørgen Engelsen
* Update SaturationTemperature.java
* Update SaturationPressure.java
---------
Co-authored-by: Jørgen Engelsen
---
.../simulation/SaturationPressure.java | 10 +-
.../simulation/SaturationTemperature.java | 9 +-
.../simulation/SaturationPressureTest.java | 42 +++---
.../simulation/SaturationTemperatureTest.java | 126 +++++++++++++-----
.../system/SystemUMRPRUMCEosNewTest.java | 58 ++++++++
5 files changed, 188 insertions(+), 57 deletions(-)
diff --git a/src/main/java/neqsim/PVTsimulation/simulation/SaturationPressure.java b/src/main/java/neqsim/PVTsimulation/simulation/SaturationPressure.java
index b20bb57dcc..b82cbcf3d3 100644
--- a/src/main/java/neqsim/PVTsimulation/simulation/SaturationPressure.java
+++ b/src/main/java/neqsim/PVTsimulation/simulation/SaturationPressure.java
@@ -31,7 +31,12 @@ public SaturationPressure(SystemInterface tempSystem) {
* @return a double
*/
public double calcSaturationPressure() {
- getThermoSystem().isImplementedCompositionDeriativesofFugacity(false);
+ boolean isMultiPhaseCheckChanged = false;
+ if (!getThermoSystem().doMultiPhaseCheck()) {
+ isMultiPhaseCheckChanged = true;
+ getThermoSystem().setMultiPhaseCheck(true);
+ }
+ // getThermoSystem().isImplementedCompositionDeriativesofFugacity(false);
getThermoSystem().setPressure(1.0);
do {
getThermoSystem().setPressure(getThermoSystem().getPressure() + 10.0);
@@ -62,6 +67,9 @@ public double calcSaturationPressure() {
} while (Math.abs(maxPres - minPres) > 1e-5 && iteration < 500);
getThermoSystem().setPressure(maxPres);
thermoOps.TPflash();
+ if (isMultiPhaseCheckChanged) {
+ getThermoSystem().setMultiPhaseCheck(false);
+ }
return getThermoSystem().getPressure();
}
diff --git a/src/main/java/neqsim/PVTsimulation/simulation/SaturationTemperature.java b/src/main/java/neqsim/PVTsimulation/simulation/SaturationTemperature.java
index 85a9dd37ce..7cd1761062 100644
--- a/src/main/java/neqsim/PVTsimulation/simulation/SaturationTemperature.java
+++ b/src/main/java/neqsim/PVTsimulation/simulation/SaturationTemperature.java
@@ -31,7 +31,11 @@ public SaturationTemperature(SystemInterface tempSystem) {
* @return a double
*/
public double calcSaturationTemperature() {
- getThermoSystem().isImplementedCompositionDeriativesofFugacity(false);
+ boolean isMultiPhaseCheckChanged = false;
+ if (!getThermoSystem().doMultiPhaseCheck()) {
+ isMultiPhaseCheckChanged = true;
+ getThermoSystem().setMultiPhaseCheck(true);
+ }
do {
getThermoSystem().setTemperature(getThermoSystem().getTemperature() - 10.0);
thermoOps.TPflash();
@@ -57,6 +61,9 @@ public double calcSaturationTemperature() {
} while (Math.abs(maxTemp - minTemp) > 1e-5 && iteration < 500);
getThermoSystem().setTemperature(maxTemp);
thermoOps.TPflash();
+ if (isMultiPhaseCheckChanged) {
+ getThermoSystem().setMultiPhaseCheck(false);
+ }
return getThermoSystem().getTemperature();
}
diff --git a/src/test/java/neqsim/PVTsimulation/simulation/SaturationPressureTest.java b/src/test/java/neqsim/PVTsimulation/simulation/SaturationPressureTest.java
index f72e964ae9..abb20d024d 100644
--- a/src/test/java/neqsim/PVTsimulation/simulation/SaturationPressureTest.java
+++ b/src/test/java/neqsim/PVTsimulation/simulation/SaturationPressureTest.java
@@ -10,27 +10,27 @@ class SaturationPressureTest extends neqsim.NeqSimTest {
@BeforeAll
static void setUpBeforeClass() throws Exception {}
-
+
@Test
void testCalcSaturationPressure() {
- SystemInterface tempSystem = new SystemSrkEos(273.15 + 20, 10.0);
- tempSystem.addComponent("nitrogen", 0.34);
- tempSystem.addComponent("CO2", 0.59);
- tempSystem.addComponent("methane", 87.42);
- tempSystem.addComponent("ethane", 3.02);
- tempSystem.addComponent("propane", 4.31);
- tempSystem.addComponent("i-butane", 0.93);
- tempSystem.addComponent("n-butane", 1.71);
- tempSystem.addComponent("i-pentane", 0.74);
- tempSystem.addComponent("n-pentane", 0.85);
- tempSystem.addComponent("n-hexane", 0.38);
- tempSystem.addTBPfraction("C7", 0.05, 109.00 / 1000.0, 0.6912);
- tempSystem.addTBPfraction("C8", 0.069, 120.20 / 1000.0, 0.7255);
- tempSystem.addTBPfraction("C9", 0.014, 129.5 / 1000.0, 0.7454);
- tempSystem.addTBPfraction("C10", 0.0078, 135.3 / 1000.0, 0.7864);
- tempSystem.setMixingRule(2);
- SimulationInterface satPresSim = new SaturationPressure(tempSystem);
- satPresSim.run();
- assertEquals(satPresSim.getThermoSystem().getPressure(), 122.28338813781738, 0.1);
- }
+ SystemInterface tempSystem = new SystemSrkEos(273.15 + 20, 10.0);
+ tempSystem.addComponent("nitrogen", 0.34);
+ tempSystem.addComponent("CO2", 0.59);
+ tempSystem.addComponent("methane", 87.42);
+ tempSystem.addComponent("ethane", 3.02);
+ tempSystem.addComponent("propane", 4.31);
+ tempSystem.addComponent("i-butane", 0.93);
+ tempSystem.addComponent("n-butane", 1.71);
+ tempSystem.addComponent("i-pentane", 0.74);
+ tempSystem.addComponent("n-pentane", 0.85);
+ tempSystem.addComponent("n-hexane", 0.38);
+ tempSystem.addTBPfraction("C7", 0.05, 109.00 / 1000.0, 0.6912);
+ tempSystem.addTBPfraction("C8", 0.069, 120.20 / 1000.0, 0.7255);
+ tempSystem.addTBPfraction("C9", 0.014, 129.5 / 1000.0, 0.7454);
+ tempSystem.addTBPfraction("C10", 0.0078, 135.3 / 1000.0, 0.7864);
+ tempSystem.setMixingRule(2);
+ SimulationInterface satPresSim = new SaturationPressure(tempSystem);
+ satPresSim.run();
+ assertEquals(satPresSim.getThermoSystem().getPressure(), 126.1631355285644, 0.1);
+ }
}
diff --git a/src/test/java/neqsim/PVTsimulation/simulation/SaturationTemperatureTest.java b/src/test/java/neqsim/PVTsimulation/simulation/SaturationTemperatureTest.java
index f80fce67b8..b43432f72d 100644
--- a/src/test/java/neqsim/PVTsimulation/simulation/SaturationTemperatureTest.java
+++ b/src/test/java/neqsim/PVTsimulation/simulation/SaturationTemperatureTest.java
@@ -1,51 +1,109 @@
package neqsim.PVTsimulation.simulation;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;
+import neqsim.thermo.system.SystemUMRPRUMCEos;
+import neqsim.thermodynamicOperations.ThermodynamicOperations;
/**
* @author ESOL
*
*/
class SaturationTemperatureTest extends neqsim.NeqSimTest {
- /**
- * @throws java.lang.Exception
- */
- @BeforeAll
- static void setUpBeforeClass() throws Exception {}
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {}
- /**
- * Test method for
- * {@link neqsim.PVTsimulation.simulation.SaturationTemperature#calcSaturationTemperature()}.
- */
- @Test
- void testCalcSaturationTemperature() {
- SystemInterface tempSystem = new SystemSrkEos(273.15 + 220, 60.0);
- tempSystem.addComponent("nitrogen", 0.34);
- tempSystem.addComponent("CO2", 3.59);
- tempSystem.addComponent("methane", 67.42);
- tempSystem.addComponent("ethane", 9.02);
- tempSystem.addComponent("propane", 4.31);
- tempSystem.addComponent("i-butane", 0.93);
- tempSystem.addComponent("n-butane", 1.71);
- tempSystem.addComponent("i-pentane", 0.74);
- tempSystem.addComponent("n-pentane", 0.85);
- tempSystem.addComponent("n-hexane", 0.38);
- tempSystem.addTBPfraction("C7", 0.5, 109.00 / 1000.0, 0.6912);
- tempSystem.addTBPfraction("C8", 0.69, 120.20 / 1000.0, 0.7255);
- tempSystem.addTBPfraction("C9", 0.14, 129.5 / 1000.0, 0.7454);
- tempSystem.addTBPfraction("C10", 0.08, 135.3 / 1000.0, 0.7864);
- // tempSystem.createDatabase(true);
- tempSystem.setMixingRule(2); // "HV", "UNIFAC_UMRPRU");
- tempSystem.init(0);
- tempSystem.init(1);
- // tempSystem.saveFluid(928);
+ /**
+ * Test method for
+ * {@link neqsim.PVTsimulation.simulation.SaturationTemperature#calcSaturationTemperature()}.
+ */
+ @Test
+ void testCalcSaturationTemperature() {
+ SystemInterface tempSystem = new SystemSrkEos(273.15 + 220, 60.0);
+ tempSystem.addComponent("nitrogen", 0.34);
+ tempSystem.addComponent("CO2", 3.59);
+ tempSystem.addComponent("methane", 67.42);
+ tempSystem.addComponent("ethane", 9.02);
+ tempSystem.addComponent("propane", 4.31);
+ tempSystem.addComponent("i-butane", 0.93);
+ tempSystem.addComponent("n-butane", 1.71);
+ tempSystem.addComponent("i-pentane", 0.74);
+ tempSystem.addComponent("n-pentane", 0.85);
+ tempSystem.addComponent("n-hexane", 0.38);
+ tempSystem.addTBPfraction("C7", 0.5, 109.00 / 1000.0, 0.6912);
+ tempSystem.addTBPfraction("C8", 0.69, 120.20 / 1000.0, 0.7255);
+ tempSystem.addTBPfraction("C9", 0.14, 129.5 / 1000.0, 0.7454);
+ tempSystem.addTBPfraction("C10", 0.08, 135.3 / 1000.0, 0.7864);
+ // tempSystem.createDatabase(true);
+ tempSystem.setMixingRule(2); // "HV", "UNIFAC_UMRPRU");
+ tempSystem.init(0);
+ tempSystem.init(1);
+ // tempSystem.saveFluid(928);
- SimulationInterface satPresSim = new SaturationTemperature(tempSystem);
- satPresSim.run();
- assertEquals(tempSystem.getTemperature(), 380.3071922, 0.1);
+ SimulationInterface satPresSim = new SaturationTemperature(tempSystem);
+ satPresSim.run();
+ assertEquals(tempSystem.getTemperature(), 380.3071922, 0.1);
+ }
+
+ /**
+ *
+ * checkSaturationTemperatureToPhaseEnvelope.
+ *
+ *
+ * @throws Exception
+ */
+ @Test
+ @DisplayName("calculate phase envelope using UMR")
+ public void checkSaturationTemperatureToPhaseEnvelope() throws Exception {
+ SystemUMRPRUMCEos testSystem = new neqsim.thermo.system.SystemUMRPRUMCEos(298.0, 10.0);
+ testSystem.addComponent("N2", 0.00675317857);
+ testSystem.addComponent("CO2", .02833662296);
+ testSystem.addComponent("methane", 0.8363194562);
+ testSystem.addComponent("ethane", 0.06934307324);
+ testSystem.addComponent("propane", 0.03645246567);
+ testSystem.addComponent("i-butane", 0.0052133558);
+ testSystem.addComponent("n-butane", 0.01013260919);
+ testSystem.addComponent("i-pentane", 0.00227310164);
+ testSystem.addComponent("n-pentane", 0.00224658464);
+ testSystem.addComponent("2-m-C5", 0.00049491);
+ testSystem.addComponent("3-m-C5", 0.00025783);
+ testSystem.addComponent("n-hexane", 0.00065099);
+ testSystem.addComponent("c-hexane", .00061676);
+ testSystem.addComponent("n-heptane", 0.00038552);
+ testSystem.addComponent("benzene", 0.00016852);
+ testSystem.addComponent("n-octane", 0.00007629);
+ testSystem.addComponent("c-C7", 0.0002401);
+ testSystem.addComponent("toluene", 0.0000993);
+ testSystem.addComponent("n-nonane", 0.00001943);
+ testSystem.addComponent("c-C8", 0.00001848);
+ testSystem.addComponent("m-Xylene", 0.00002216);
+ testSystem.addComponent("nC10", 0.00000905);
+ testSystem.addComponent("nC11", 0.000000001);
+ testSystem.addComponent("nC12", 0.000000001);
+
+ testSystem.setMixingRule("HV", "UNIFAC_UMRPRU");
+ testSystem.init(0);
+ ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
+ try {
+ testOps.calcPTphaseEnvelope();
+ } catch (Exception ex) {
+ assertTrue(false);
+ throw new Exception(ex);
}
+ assertEquals((testOps.get("cricondentherm")[0] - 273.15), 23.469, 0.02);
+ assertEquals(testOps.get("cricondentherm")[1], 46.9326702068279, 0.02);
+
+ testSystem.setPressure(testOps.get("cricondentherm")[1], "bara");
+ SaturationTemperature satTempSim = new SaturationTemperature(testSystem);
+ satTempSim.run();
+ assertEquals(satTempSim.getThermoSystem().getTemperature() - 273.15, 23.469396812206867, 0.001);
+ }
}
diff --git a/src/test/java/neqsim/thermo/system/SystemUMRPRUMCEosNewTest.java b/src/test/java/neqsim/thermo/system/SystemUMRPRUMCEosNewTest.java
index 38393fb617..96925abf07 100644
--- a/src/test/java/neqsim/thermo/system/SystemUMRPRUMCEosNewTest.java
+++ b/src/test/java/neqsim/thermo/system/SystemUMRPRUMCEosNewTest.java
@@ -8,6 +8,7 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import neqsim.PVTsimulation.simulation.SaturationPressure;
import neqsim.thermodynamicOperations.ThermodynamicOperations;
class SystemUMRPRUMCEosNewTest extends neqsim.NeqSimTest {
@@ -214,4 +215,61 @@ public void checkPhaseEnvelope() throws Exception {
}
assertEquals(testOps.get("cricondenbar")[1], 130.686140727503, 0.02);
}
+
+ /**
+ *
+ * checkPhaseEnvelope2.
+ *
+ *
+ * @throws Exception
+ */
+ @Test
+ @DisplayName("calculate phase envelope using UMR")
+ public void checkPhaseEnvelope2() throws Exception {
+ testSystem = new neqsim.thermo.system.SystemUMRPRUMCEos(298.0, 10.0);
+ testSystem.addComponent("N2", 0.00675317857);
+ testSystem.addComponent("CO2", .02833662296);
+ testSystem.addComponent("methane", 0.8363194562);
+ testSystem.addComponent("ethane", 0.06934307324);
+ testSystem.addComponent("propane", 0.03645246567);
+ testSystem.addComponent("i-butane", 0.0052133558);
+ testSystem.addComponent("n-butane", 0.01013260919);
+ testSystem.addComponent("i-pentane", 0.00227310164);
+ testSystem.addComponent("n-pentane", 0.00224658464);
+ testSystem.addComponent("2-m-C5", 0.00049491);
+ testSystem.addComponent("3-m-C5", 0.00025783);
+ testSystem.addComponent("n-hexane", 0.00065099);
+ testSystem.addComponent("c-hexane", .00061676);
+ testSystem.addComponent("n-heptane", 0.00038552);
+ testSystem.addComponent("benzene", 0.00016852);
+ testSystem.addComponent("n-octane", 0.00007629);
+ testSystem.addComponent("c-C7", 0.0002401);
+ testSystem.addComponent("toluene", 0.0000993);
+ testSystem.addComponent("n-nonane", 0.00001943);
+ testSystem.addComponent("c-C8", 0.00001848);
+ testSystem.addComponent("m-Xylene", 0.00002216);
+ testSystem.addComponent("nC10", 0.00000905);
+ testSystem.addComponent("nC11", 0.000000001);
+ testSystem.addComponent("nC12", 0.000000001);
+
+ testSystem.setMixingRule("HV", "UNIFAC_UMRPRU");
+ testSystem.init(0);
+ ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
+ try {
+ testOps.calcPTphaseEnvelope();
+ logger.info("Cricondenbar " + (testOps.get("cricondenbar")[0] - 273.15) + " "
+ + testOps.get("cricondenbar")[1]);
+ } catch (Exception ex) {
+ assertTrue(false);
+ throw new Exception(ex);
+ }
+ assertEquals((testOps.get("cricondenbar")[0] - 273.15), -11.09948347, 0.02);
+ assertEquals(testOps.get("cricondenbar")[1], 104.75329137038476, 0.02);
+
+ testSystem.setTemperature(-11.09948347, "C");
+ SaturationPressure satPresSim = new SaturationPressure(testSystem);
+ satPresSim.run();
+ assertEquals(satPresSim.getThermoSystem().getPressure(), 104.7532, 0.001);
+
+ }
}
From 85c580ec22bc85519ff13e7953c557e0005854bd Mon Sep 17 00:00:00 2001
From: Even Solbraa <41290109+EvenSol@users.noreply.github.com>
Date: Thu, 21 Dec 2023 09:42:58 +0100
Subject: [PATCH 02/15] Update pom.xml (#888)
* Update pom.xml
* Update pomJava8.xml
---
pom.xml | 2 +-
pomJava8.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index e249b2ed28..d3cca03453 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
${revision}${sha1}${changelist}
- 2.5.12
+ 2.5.13
UTF-8
UTF-8
diff --git a/pomJava8.xml b/pomJava8.xml
index 50ffba3cc5..afdb86d51f 100644
--- a/pomJava8.xml
+++ b/pomJava8.xml
@@ -10,7 +10,7 @@
${revision}${sha1}${changelist}-Java8
- 2.5.12
+ 2.5.13
UTF-8
UTF-8
From c09f001a88c1e4bda503ae38cab90bc01765171d Mon Sep 17 00:00:00 2001
From: Even Solbraa <41290109+EvenSol@users.noreply.github.com>
Date: Thu, 21 Dec 2023 13:10:03 +0100
Subject: [PATCH 03/15] added compressor test and initial code (#877)
* added compressor test and initial code
* some more work
* some further work to get dynamic compressor to work
* strugling to find error
* improve compressor calcs
* added compressor mointor
* further work in dynamic compressors
* update
* updates
* updated
* further work
* update dynamic
* update
* update
* update
* update
* update
* update
* update
* update
* update power
* add maxminspeed setters
* check if controller is active
* removed try catch block and added check for actualFlowRateNew
* removed print to screen in test
---
.../ControllerDeviceBaseClass.java | 19 +
.../ControllerDeviceInterface.java | 16 +
.../measurementDevice/CompressorMonitor.java | 58 ++
.../compressor/Compressor.java | 99 ++-
.../compressor/CompressorChart.java | 26 +
.../CompressorChartAlternativeMapLookup.java | 6 +
.../compressor/CompressorChartGenerator.java | 30 +-
.../compressor/CompressorChartInterface.java | 3 +
.../compressor/CompressorInterface.java | 10 +
.../heatExchanger/Heater.java | 19 +-
.../processEquipment/splitter/Splitter.java | 26 +
.../processEquipment/util/SetPoint.java | 2 +-
.../valve/ThrottlingValve.java | 6 +-
.../util/monitor/CompressorResponse.java | 100 ++--
.../ProcessSystemRunTransientTest.java | 566 ++++++++++++++++--
15 files changed, 869 insertions(+), 117 deletions(-)
create mode 100644 src/main/java/neqsim/processSimulation/measurementDevice/CompressorMonitor.java
diff --git a/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClass.java b/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClass.java
index f45586669d..78f8766259 100644
--- a/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClass.java
+++ b/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClass.java
@@ -44,6 +44,7 @@ public class ControllerDeviceBaseClass extends NamedBaseClass implements Control
// Internal state of integration contribution
private double TintValue = 0.0;
+ boolean isActive = true;
/**
*
@@ -54,6 +55,19 @@ public ControllerDeviceBaseClass() {
this("controller");
}
+
+ /** {@inheritDoc} */
+ @Override
+ public void setActive(boolean isActive) {
+ this.isActive = isActive;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean isActive() {
+ return isActive;
+ }
+
/**
*
* Constructor for ControllerDeviceBaseClass.
@@ -80,6 +94,11 @@ public double getMeasuredValue() {
/** {@inheritDoc} */
@Override
public void runTransient(double initResponse, double dt, UUID id) {
+ if (!isActive) {
+ response = initResponse;
+ calcIdentifier = id;
+ return;
+ }
if (isReverseActing()) {
propConstant = -1;
}
diff --git a/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java b/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java
index 4f2052ea56..d123546982 100644
--- a/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java
+++ b/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java
@@ -128,4 +128,20 @@ public default void runTransient(double initResponse, double dt) {
/** {@inheritDoc} */
@Override
public int hashCode();
+
+ /**
+ *
+ * setActive
+ *
+ * Set if controller is active
+ */
+ public void setActive(boolean isActive);
+
+ /**
+ *
+ * isActive
+ *
+ * Specifies if controller is active
+ */
+ public boolean isActive();
}
diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/CompressorMonitor.java b/src/main/java/neqsim/processSimulation/measurementDevice/CompressorMonitor.java
new file mode 100644
index 0000000000..cc304c9a69
--- /dev/null
+++ b/src/main/java/neqsim/processSimulation/measurementDevice/CompressorMonitor.java
@@ -0,0 +1,58 @@
+package neqsim.processSimulation.measurementDevice;
+
+import neqsim.processSimulation.processEquipment.compressor.Compressor;
+
+/**
+ *
+ * CompressorMonitor class.
+ *
+ *
+ * @author ESOL
+ * @version $Id: $Id
+ */
+public class CompressorMonitor extends MeasurementDeviceBaseClass {
+ private static final long serialVersionUID = 1000;
+ protected Compressor compressor = null;
+
+ /**
+ *
+ * Constructor for CompressorMonitor.
+ *
+ *
+ * @param compressor a {@link neqsim.processSimulation.processEquipment.compressor.Compressor}
+ * object
+ */
+ public CompressorMonitor(Compressor compressor) {
+ this("Compressor Monitor", compressor);
+ }
+
+ /**
+ *
+ * Constructor for CompressorMonitor.
+ *
+ *
+ * @param name Name of Compressor
+ * @param compressor a {@link neqsim.processSimulation.processEquipment.compressor.Compressor}
+ */
+ public CompressorMonitor(String name, Compressor compressor) {
+ super(name, "rpm");
+ this.compressor = compressor;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void displayResult() {
+ System.out.println("measured speed " + compressor.getSpeed());
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double getMeasuredValue(String unit) {
+ if (unit.equals("distance to surge")) {
+ return compressor.getDistanceToSurge();
+ } else {
+ return compressor.getDistanceToSurge();
+ // return compressor.getSpeed();
+ }
+ }
+}
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java
index f7c9517964..7c040f06f6 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java
@@ -38,7 +38,9 @@ public class Compressor extends TwoPortEquipment implements CompressorInterface
public double dH = 0.0;
public double inletEnthalpy = 0;
public double pressure = 0.0;
- private int speed = 3000;
+ private double speed = 3000;
+ private double maxspeed = 30000;
+ private double minspeed = 0;
public double isentropicEfficiency = 1.0;
public double polytropicEfficiency = 1.0;
public boolean usePolytropicCalc = false;
@@ -670,6 +672,50 @@ public void run(UUID id) {
setCalculationIdentifier(id);
}
+ /** {@inheritDoc} */
+ @Override
+ public void runTransient(double dt, UUID id) {
+ if (getCalculateSteadyState()) {
+ run(id);
+ increaseTime(dt);
+ return;
+ }
+ runController(dt, id);
+
+ inStream.getThermoSystem().init(3);
+ outStream.getThermoSystem().init(3);
+ double head = (outStream.getThermoSystem().getEnthalpy("kJ/kg")
+ - inStream.getThermoSystem().getEnthalpy("kJ/kg"));
+ double guessFlow = inStream.getFluid().getFlowRate("m3/hr");
+ double actualFlowRateNew = getCompressorChart().getFlow(head, getSpeed(), guessFlow);
+ if (actualFlowRateNew < 0.0 || Double.isNaN(actualFlowRateNew)) {
+ logger.error(
+ "actual flow rate is negative or NaN and would lead to failure of calculation: actual flow rate "
+ + actualFlowRateNew);
+ }
+ inStream.setFlowRate(actualFlowRateNew, "Am3/hr");
+
+ inStream.getThermoSystem().init(3);
+ inStream.getThermoSystem().initPhysicalProperties("density");
+ inStream.run(id);
+ inStream.getThermoSystem().init(3);
+
+ outStream.setFlowRate(inStream.getFlowRate("kg/hr"), "kg/hr");
+ outStream.run();
+ outStream.getThermoSystem().init(3);
+
+ inletEnthalpy = inStream.getFluid().getEnthalpy();
+ thermoSystem = outStream.getThermoSystem().clone();
+ thermoSystem.initPhysicalProperties("density");
+
+ polytropicEfficiency =
+ compressorChart.getPolytropicEfficiency(inStream.getFlowRate("m3/hr"), speed) / 100.0;
+ polytropicFluidHead = head * polytropicEfficiency;
+ dH = polytropicFluidHead * 1000.0 * thermoSystem.getMolarMass() / getPolytropicEfficiency()
+ * inStream.getThermoSystem().getTotalNumberOfMoles();
+ setCalculationIdentifier(id);
+ }
+
/**
*
* generateCompressorCurves.
@@ -955,6 +1001,12 @@ public boolean isSurge(double flow, double head) {
return getAntiSurge().isSurge();
}
+ public double getDistanceToSurge() {
+ return (getInletStream().getFlowRate("m3/hr")
+ - getCompressorChart().getSurgeCurve().getSurgeFlow(getPolytropicFluidHead()))
+ / getCompressorChart().getSurgeCurve().getSurgeFlow(getPolytropicFluidHead());
+ }
+
/**
*
* isStoneWall.
@@ -985,9 +1037,9 @@ public void setAntiSurge(AntiSurge antiSurge) {
* Getter for the field speed
.
*
*
- * @return a int
+ * @return a double
*/
- public int getSpeed() {
+ public double getSpeed() {
return speed;
}
@@ -998,7 +1050,7 @@ public int getSpeed() {
*
* @param speed a int
*/
- public void setSpeed(int speed) {
+ public void setSpeed(double speed) {
this.speed = speed;
}
@@ -1256,6 +1308,29 @@ public void setPropertyProfile(CompressorPropertyProfile propertyProfile) {
this.propertyProfile = propertyProfile;
}
+ /**
+ *
+ * runController.
+ *
+ *
+ * @param dt a double
+ * @param id Calculation identifier
+ */
+ public void runController(double dt, UUID id) {
+ if (hasController && getController().isActive()) {
+ getController().runTransient(this.speed, dt, id);
+ this.speed = getController().getResponse();
+ if (this.speed > maxspeed) {
+ this.speed = maxspeed;
+ }
+ if (this.speed < minspeed) {
+ this.speed = minspeed;
+ }
+ // System.out.println("valve opening " + this.percentValveOpening + " %");
+ }
+ setCalculationIdentifier(id);
+ }
+
/** {@inheritDoc} */
@Override
public int hashCode() {
@@ -1310,4 +1385,20 @@ public boolean equals(Object obj) {
&& usePolytropicCalc == other.usePolytropicCalc
&& useRigorousPolytropicMethod == other.useRigorousPolytropicMethod;
}
+
+ public void setMaximumSpeed(double maxSpeed) {
+ this.maxspeed = maxSpeed;
+ }
+
+ public void setMinimumSpeed(double minspeed) {
+ this.minspeed = minspeed;
+ }
+
+ public double getMaximumSpeed() {
+ return maxspeed;
+ }
+
+ public double getMinimumSpeed() {
+ return minspeed;
+ }
}
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChart.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChart.java
index 9aea592a78..845cd4fd74 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChart.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChart.java
@@ -162,6 +162,32 @@ public int getSpeed(double flow, double head) {
return (int) Math.round(newspeed);
}
+ /** {@inheritDoc} */
+ @Override
+ public double getFlow(double head, double speed, double guessFlow) {
+ int iter = 1;
+ double error = 1.0;
+ double derrordspeed = 1.0;
+ double newflow = guessFlow;
+ double newhead = 0.0;
+ double oldflow = newflow * 1.1;
+ double oldhead = getPolytropicHead(oldflow, speed);
+ double olderror = oldhead - head;
+ do {
+ iter++;
+ newhead =
+ getPolytropicHead(newflow, speed) / (getPolytropicEfficiency(newflow, speed) / 100.0);
+ error = newhead - head;
+ derrordspeed = (error - olderror) / (newflow - oldflow);
+ newflow -= error / derrordspeed;
+ // System.out.println("newflow " + newflow);
+ } while (Math.abs(error) > 1e-6 && iter < 100);
+
+ // change speed to minimize
+ // Math.abs(head - reducedHeadFitterFunc.value(flow / speed) * speed * speed);
+ return newflow;
+ }
+
/**
*
* addSurgeCurve.
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartAlternativeMapLookup.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartAlternativeMapLookup.java
index 04f0df49d9..7f6228d226 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartAlternativeMapLookup.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartAlternativeMapLookup.java
@@ -541,4 +541,10 @@ public static int bisect_left(Double[] A, double x, int lo, int hi) {
/** {@inheritDoc} */
@Override
public void plot() {}
+
+ /** {@inheritDoc} */
+ @Override
+ public double getFlow(double head, double speed, double guessFlow) {
+ return 0.0;
+ }
}
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartGenerator.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartGenerator.java
index 4a58c6fef4..6aa50411b0 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartGenerator.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartGenerator.java
@@ -21,25 +21,31 @@ public CompressorChart generateCompressorChart(String generationOption) {
double[] chartConditions = new double[3];
chartConditions[0] = compressor.getOutletStream().getFluid().getMolarMass("kg/mol");
- int refspeed = compressor.getSpeed();
+ double refspeed = compressor.getSpeed();
double[] speed = new double[1];
speed[0] = refspeed;
double minSpeed = refspeed / 2.0;
double maxSpeed = refspeed * 2.0;
+ compressor.getInletStream().getFluid().initPhysicalProperties("density");
double refflow = compressor.getInletStream().getFlowRate("m3/hr");
- double[][] flow = new double[1][1];
- flow[0][0] = refflow;
+ double[][] flow = new double[1][3];
+ flow[0][0] = refflow * 0.7;
+ flow[0][1] = refflow * 1.0;
+ flow[0][2] = refflow * 1.43;
double minFlow = refflow / 2.0;
double maxFlow = refflow * 2.0;
- double refhead = compressor.getPolytropicHead("kJ/kg");
- double[][] head = new double[1][1];
- head[0][0] = refhead;
-
- double[][] polyEff = new double[1][1];
- polyEff[0][0] = compressor.getPolytropicEfficiency() * 100.0;
+ double refhead = compressor.getPolytropicFluidHead();
+ double[][] head = new double[1][3];
+ head[0][0] = refhead * 1.5;
+ head[0][1] = refhead;
+ head[0][2] = refhead * 0.5;
+ double[][] polyEff = new double[1][3];
+ polyEff[0][0] = compressor.getPolytropicEfficiency() * 100.0 * 0.9;
+ polyEff[0][1] = compressor.getPolytropicEfficiency() * 100.0;
+ polyEff[0][2] = compressor.getPolytropicEfficiency() * 100.0 * 0.85;
CompressorChart compChart = new CompressorChart();
compChart.setUseCompressorChart(true);
compChart.setHeadUnit("kJ/kg");
@@ -47,9 +53,9 @@ public CompressorChart generateCompressorChart(String generationOption) {
// Generating surge curve
- double minFlowSurgeFlow = 0.3 * refflow;
- double refSurgeFlow = 0.5 * refflow;
- double maxSurgeFlow = 0.8 * refflow;
+ double minFlowSurgeFlow = 0.7 * refflow;
+ double refSurgeFlow = 0.8 * refflow;
+ double maxSurgeFlow = 0.9 * refflow;
double headSurgeRef = compChart.getPolytropicHead(refSurgeFlow, refspeed);
double headSurgeMin = compChart.getPolytropicHead(minFlow, minSpeed);
double headSurgeMax = compChart.getPolytropicHead(maxSurgeFlow, maxSpeed);
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartInterface.java
index 1c3f72efa2..53e7507da1 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartInterface.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartInterface.java
@@ -166,4 +166,7 @@ public void setReferenceConditions(double refMW, double refTemperature, double r
/** {@inheritDoc} */
@Override
public int hashCode();
+
+ /** {@inheritDoc} */
+ public double getFlow(double head, double speed, double guessFlow);
}
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorInterface.java
index 1fea5d6015..a746e80f1f 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorInterface.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorInterface.java
@@ -71,4 +71,14 @@ public interface CompressorInterface extends ProcessEquipmentInterface, TwoPortI
* @return a {@link neqsim.processSimulation.processEquipment.compressor.AntiSurge} object
*/
public AntiSurge getAntiSurge();
+
+ public double getDistanceToSurge();
+
+ public void setMaximumSpeed(double maxSpeed);
+
+ public void setMinimumSpeed(double minspeed);
+
+ public double getMaximumSpeed();
+
+ public double getMinimumSpeed();
}
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Heater.java b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Heater.java
index b2eb357720..70d196ec35 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Heater.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Heater.java
@@ -7,7 +7,6 @@
package neqsim.processSimulation.processEquipment.heatExchanger;
import java.util.UUID;
-
import neqsim.processSimulation.processEquipment.TwoPortEquipment;
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
@@ -221,6 +220,24 @@ public void run(UUID id) {
setCalculationIdentifier(id);
}
+ /** {@inheritDoc} */
+ @Override
+ public void runTransient(double dt, UUID id) {
+ if (getCalculateSteadyState()) {
+ run(id);
+ increaseTime(dt);
+ return;
+ } else {
+ inStream.setPressure(outStream.getPressure());
+ inStream.run();
+ run(id);
+ increaseTime(dt);
+ return;
+ }
+
+ }
+
+
/** {@inheritDoc} */
@Override
public void displayResult() {
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/splitter/Splitter.java b/src/main/java/neqsim/processSimulation/processEquipment/splitter/Splitter.java
index 7daf913ba9..765833c95c 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/splitter/Splitter.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/splitter/Splitter.java
@@ -4,6 +4,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass;
+import neqsim.processSimulation.processEquipment.mixer.Mixer;
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.thermo.system.SystemInterface;
@@ -241,6 +242,31 @@ public void run(UUID id) {
setCalculationIdentifier(id);
}
+ /** {@inheritDoc} */
+ @Override
+ public void runTransient(double dt, UUID id) {
+ if (getCalculateSteadyState()) {
+ run(id);
+ increaseTime(dt);
+ return;
+ } else {
+
+ Mixer mixer = new Mixer();
+ for (int i = 0; i < splitStream.length; i++) {
+ splitStream[i].setPressure(inletStream.getPressure());
+ splitStream[i].setTemperature(inletStream.getTemperature("C"), "C");
+ splitStream[i].run();
+ mixer.addStream(splitStream[i]);
+ }
+ mixer.run();
+
+ inletStream.setThermoSystem(mixer.getThermoSystem());
+ inletStream.run();
+ setCalculationIdentifier(id);
+ return;
+ }
+ }
+
/** {@inheritDoc} */
@Override
public void displayResult() {}
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/SetPoint.java b/src/main/java/neqsim/processSimulation/processEquipment/util/SetPoint.java
index 1333e42f65..6213a8d209 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/util/SetPoint.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/util/SetPoint.java
@@ -71,7 +71,7 @@ public SetPoint(String name, ProcessEquipmentInterface targetEquipment, String t
this.targetEquipment = targetEquipment;
this.targetVariable = targetVariable;
this.sourceEquipment = sourceEquipment;
- run();
+ // run();
}
/**
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java b/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java
index 746329e155..9441f872a1 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java
@@ -298,14 +298,14 @@ public void runTransient(double dt, UUID id) {
try {
inStream.getThermoSystem().setTotalNumberOfMoles(molarFlow);
inStream.getThermoSystem().init(1);
- // inStream.run(id);
+ inStream.run(id);
} catch (Exception e) {
logger.error(e.getMessage());
}
try {
outStream.getThermoSystem().setTotalNumberOfMoles(molarFlow);
outStream.getThermoSystem().init(1);
- // outStream.run(id);
+ outStream.run(id);
} catch (Exception e) {
logger.error(e.getMessage());
}
@@ -327,7 +327,7 @@ public void runTransient(double dt, UUID id) {
* @param id Calculation identifier
*/
public void runController(double dt, UUID id) {
- if (hasController) {
+ if (hasController && getController().isActive()) {
getController().runTransient(this.percentValveOpening, dt, id);
this.percentValveOpening = getController().getResponse();
if (this.percentValveOpening > maxValveOpening) {
diff --git a/src/main/java/neqsim/processSimulation/util/monitor/CompressorResponse.java b/src/main/java/neqsim/processSimulation/util/monitor/CompressorResponse.java
index 15adb97bac..77c2ecea31 100644
--- a/src/main/java/neqsim/processSimulation/util/monitor/CompressorResponse.java
+++ b/src/main/java/neqsim/processSimulation/util/monitor/CompressorResponse.java
@@ -3,60 +3,66 @@
import neqsim.processSimulation.processEquipment.compressor.Compressor;
/**
- *
CompressorResponse class.
+ *
+ * CompressorResponse class.
+ *
*
* @author asmund
* @version $Id: $Id
*/
public class CompressorResponse {
- public String name = "test";
+ public String name = "test";
- public Double suctionTemperature;
- public Double dischargeTemperature;
- public Double suctionPressure;
- public Double dischargePressure;
- public Double polytropicHead;
- public Double polytropicEfficiency;
- public Double power;
- public Double suctionVolumeFlow;
- public Double internalVolumeFlow;
- public Double dischargeVolumeFlow;
- public Double molarMass;
- public Double suctionMassDensity;
- public Double dischargeMassDensity;
- public Double massflow;
- public Integer speed;
+ public Double suctionTemperature;
+ public Double dischargeTemperature;
+ public Double suctionPressure;
+ public Double dischargePressure;
+ public Double polytropicHead;
+ public Double polytropicEfficiency;
+ public Double power;
+ public Double suctionVolumeFlow;
+ public Double internalVolumeFlow;
+ public Double dischargeVolumeFlow;
+ public Double molarMass;
+ public Double suctionMassDensity;
+ public Double dischargeMassDensity;
+ public Double massflow;
+ public Double speed;
- /**
- * Constructor for CompressorResponse.
- */
- public CompressorResponse() {
- }
+ /**
+ *
+ * Constructor for CompressorResponse.
+ *
+ */
+ public CompressorResponse() {}
- /**
- * Constructor for CompressorResponse.
- *
- * @param inputCompressor a {@link neqsim.processSimulation.processEquipment.compressor.Compressor} object
- */
- public CompressorResponse(Compressor inputCompressor){
- name = inputCompressor.getName();
- molarMass = inputCompressor.getInletStream().getFluid().getMolarMass();
- suctionMassDensity = inputCompressor.getInletStream().getFluid().getDensity("kg/m3");
- dischargeMassDensity = inputCompressor.getOutletStream().getFluid().getDensity("kg/m3");
- massflow = inputCompressor.getInletStream().getFluid().getFlowRate("kg/hr");
- suctionVolumeFlow = inputCompressor.getInletStream().getFluid().getFlowRate("m3/hr");
- dischargeVolumeFlow = inputCompressor.getOutletStream().getFluid().getFlowRate("m3/hr");
- suctionPressure = inputCompressor.getInletStream().getPressure("bara");
- suctionTemperature = inputCompressor.getInletStream().getTemperature("C");
- dischargeTemperature = inputCompressor.getOutletStream().getTemperature("C");
- dischargePressure = inputCompressor.getOutletStream().getPressure("bara");
- polytropicHead = inputCompressor.getPolytropicFluidHead();
- polytropicEfficiency = inputCompressor.getPolytropicEfficiency();
- power = inputCompressor.getPower("kW");
- speed = inputCompressor.getSpeed();
- if (inputCompressor.getAntiSurge().isActive()) {
- internalVolumeFlow = inputCompressor.getCompressorChart().getSurgeCurve()
- .getSurgeFlow(polytropicHead);
- }
+ /**
+ *
+ * Constructor for CompressorResponse.
+ *
+ *
+ * @param inputCompressor a
+ * {@link neqsim.processSimulation.processEquipment.compressor.Compressor} object
+ */
+ public CompressorResponse(Compressor inputCompressor) {
+ name = inputCompressor.getName();
+ molarMass = inputCompressor.getInletStream().getFluid().getMolarMass();
+ suctionMassDensity = inputCompressor.getInletStream().getFluid().getDensity("kg/m3");
+ dischargeMassDensity = inputCompressor.getOutletStream().getFluid().getDensity("kg/m3");
+ massflow = inputCompressor.getInletStream().getFluid().getFlowRate("kg/hr");
+ suctionVolumeFlow = inputCompressor.getInletStream().getFluid().getFlowRate("m3/hr");
+ dischargeVolumeFlow = inputCompressor.getOutletStream().getFluid().getFlowRate("m3/hr");
+ suctionPressure = inputCompressor.getInletStream().getPressure("bara");
+ suctionTemperature = inputCompressor.getInletStream().getTemperature("C");
+ dischargeTemperature = inputCompressor.getOutletStream().getTemperature("C");
+ dischargePressure = inputCompressor.getOutletStream().getPressure("bara");
+ polytropicHead = inputCompressor.getPolytropicFluidHead();
+ polytropicEfficiency = inputCompressor.getPolytropicEfficiency();
+ power = inputCompressor.getPower("kW");
+ speed = inputCompressor.getSpeed();
+ if (inputCompressor.getAntiSurge().isActive()) {
+ internalVolumeFlow =
+ inputCompressor.getCompressorChart().getSurgeCurve().getSurgeFlow(polytropicHead);
}
+ }
}
diff --git a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java
index b203204600..255b9028cf 100644
--- a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java
+++ b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java
@@ -7,11 +7,17 @@
import neqsim.processSimulation.SimulationInterface;
import neqsim.processSimulation.controllerDevice.ControllerDeviceBaseClass;
import neqsim.processSimulation.controllerDevice.ControllerDeviceInterface;
+import neqsim.processSimulation.measurementDevice.CompressorMonitor;
import neqsim.processSimulation.measurementDevice.LevelTransmitter;
import neqsim.processSimulation.measurementDevice.PressureTransmitter;
import neqsim.processSimulation.measurementDevice.VolumeFlowTransmitter;
+import neqsim.processSimulation.processEquipment.compressor.Compressor;
+import neqsim.processSimulation.processEquipment.heatExchanger.Cooler;
import neqsim.processSimulation.processEquipment.separator.Separator;
+import neqsim.processSimulation.processEquipment.splitter.Splitter;
import neqsim.processSimulation.processEquipment.stream.Stream;
+import neqsim.processSimulation.processEquipment.util.Recycle;
+import neqsim.processSimulation.processEquipment.util.SetPoint;
import neqsim.processSimulation.processEquipment.valve.ThrottlingValve;
import neqsim.thermo.system.SystemInterface;
@@ -223,92 +229,554 @@ public void testDynamicCalculation2() {
}
@Test
- public void testDynamicCalculation3() {
+ public void testDynamicCompressor() {
neqsim.thermo.system.SystemInterface testSystem2 =
new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00);
testSystem2.addComponent("methane", 1.1);
testSystem2.addComponent("ethane", 0.1);
testSystem2.setMixingRule(2);
- neqsim.thermo.system.SystemInterface testSystem3 =
+ Stream stream1 = new Stream("Stream1", testSystem2);
+ stream1.setFlowRate(501.0, "kg/hr");
+ stream1.setPressure(100.0, "bara");
+ stream1.setTemperature(55.0, "C");
+
+ ThrottlingValve valve1 = new ThrottlingValve("valve_1", stream1);
+ valve1.setOutletPressure(50.0);
+ valve1.setPercentValveOpening(50);
+ valve1.setCalculateSteadyState(false);
+
+ Separator separator1 = new Separator("separator_1");
+ separator1.addStream(valve1.getOutletStream());
+ separator1.setCalculateSteadyState(false);
+ separator1.setSeparatorLength(3.0);
+ separator1.setInternalDiameter(0.8);
+ separator1.setLiquidLevel(0.0);
+
+ Compressor compressor1 = new Compressor(separator1.getGasOutStream());
+ compressor1.setCalculateSteadyState(false);
+ compressor1.setOutletPressure(100.0);
+
+ Separator separator2 = new Separator("separator_2");
+ separator2.addStream(compressor1.getOutletStream());
+ separator2.setCalculateSteadyState(false);
+ separator2.setSeparatorLength(3.0);
+ separator2.setInternalDiameter(0.8);
+ separator2.setLiquidLevel(0.0);
+
+ ThrottlingValve valve2 = new ThrottlingValve("valve_2", separator2.getGasOutStream());
+ valve2.setOutletPressure(50.0);
+ valve2.setPercentValveOpening(50);
+ valve2.setCalculateSteadyState(false);
+
+ p.add(stream1);
+ p.add(valve1);
+ p.add(separator1);
+ p.add(compressor1);
+ p.add(separator2);
+ p.add(valve2);
+
+ p.run();
+ /*
+ * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) +
+ * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure());
+ */
+ assertEquals(100.0, compressor1.getOutletStream().getPressure(), 0.01);
+
+ neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator =
+ new neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator(
+ compressor1);
+ compressor1.setCompressorChart(compchartgenerator.generateCompressorChart("normal"));
+ compressor1.getCompressorChart().setUseCompressorChart(true);
+ // compressor1.setCalculateSteadyState(true);
+ p.run();
+ /*
+ * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) +
+ * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure());
+ */
+
+ assertEquals(102.7, compressor1.getOutletStream().getPressure(), 2.01);
+ assertEquals(50.0, separator1.getGasOutStream().getPressure(), 0.01);
+ // System.out.println("speed " + compressor1.getSpeed());
+ p.setTimeStep(10.0);
+ p.runTransient();
+ /*
+ * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) +
+ * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure());
+ */
+ compressor1.setSpeed(compressor1.getSpeed() + 500);
+ for (int i = 0; i < 2000; i++) {
+ /*
+ * System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure())
+ * + " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure());
+ */
+ p.runTransient();
+ }
+
+ compressor1.setSpeed(compressor1.getSpeed() - 500);
+ for (int i = 0; i < 2000; i++) {
+ /*
+ * System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure())
+ * + " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure());
+ */
+ p.runTransient();
+ }
+ }
+
+ @Test
+ public void testDynamicCompressor22() {
+ neqsim.thermo.system.SystemInterface testSystem2 =
new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00);
- testSystem3.addComponent("methane", 1.1);
+ testSystem2.addComponent("methane", 1.1);
testSystem2.addComponent("ethane", 0.1);
- testSystem3.setMixingRule(2);
+ testSystem2.setMixingRule(2);
Stream stream1 = new Stream("Stream1", testSystem2);
- stream1.setFlowRate(100.0, "kg/hr");
- stream1.setPressure(10.0, "bara");
- stream1.setTemperature(25.0, "C");
-
- Stream streamPurge = new Stream("StreamPurge", testSystem3);
- streamPurge.setFlowRate(5.0, "kg/hr");
- streamPurge.setPressure(10.0, "bara");
- streamPurge.setTemperature(25.0, "C");
+ stream1.setFlowRate(501.0, "kg/hr");
+ stream1.setPressure(100.0, "bara");
+ stream1.setTemperature(55.0, "C");
ThrottlingValve valve1 = new ThrottlingValve("valve_1", stream1);
- valve1.setOutletPressure(7.0);
+ valve1.setOutletPressure(50.0);
valve1.setPercentValveOpening(50);
valve1.setCalculateSteadyState(false);
- ThrottlingValve valvePurge = new ThrottlingValve("valve_purge", streamPurge);
- valvePurge.setOutletPressure(7.0);
- valvePurge.setPercentValveOpening(50);
- valvePurge.setCalculateSteadyState(false);
+ Compressor compressor1 = new Compressor(valve1.getOutStream());
+ compressor1.setCalculateSteadyState(false);
+ compressor1.setOutletPressure(100.0);
+
+ ThrottlingValve valve2 = new ThrottlingValve("valve_2", compressor1.getOutStream());
+ valve2.setOutletPressure(50.0);
+ valve2.setPercentValveOpening(50);
+ valve2.setCalculateSteadyState(false);
+
+ p.add(stream1);
+ p.add(valve1);
+ p.add(compressor1);
+ p.add(valve2);
+
+ p.run();
+ /*
+ * System.out.println(" steady staate no compressor curves....."); System.out.println(" speed "
+ * + compressor1.getSpeed() + "feed flow " + stream1.getFlowRate("kg/hr") +
+ * " compressor flow rate " + compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) +
+ * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure());
+ */
+ assertEquals(100.0, compressor1.getOutletStream().getPressure(), 0.01);
+
+
+
+ // System.out.println("steady state with compressor curves.....");
+ neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator =
+ new neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator(
+ compressor1);
+ compressor1.setCompressorChart(compchartgenerator.generateCompressorChart("normal"));
+ compressor1.getCompressorChart().setUseCompressorChart(true);
+ // compressor1.setCalculateSteadyState(true);
+ p.run();
+ /*
+ * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) +
+ * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure());
+ */
+
+ // System.out.println("dynamic first step state with compressor curves.....");
+ p.setTimeStep(1.0);
+ p.runTransient();
+ /*
+ * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) +
+ * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure());
+ */
+
+ // System.out.println("dynamic seccond step state with compressor curves.....");
+ p.runTransient();
+ /*
+ * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) +
+ * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure());
+ */
+
+ }
+
+ @Test
+ public void testDynamicCompressorSpeedControl() {
+ neqsim.thermo.system.SystemInterface testSystem2 =
+ new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00);
+ testSystem2.addComponent("methane", 1.1);
+ testSystem2.addComponent("ethane", 0.1);
+ testSystem2.setMixingRule(2);
+
+ Stream stream1 = new Stream("Stream1", testSystem2);
+ stream1.setFlowRate(501.0, "kg/hr");
+ stream1.setPressure(100.0, "bara");
+ stream1.setTemperature(55.0, "C");
+
+ ThrottlingValve valve1 = new ThrottlingValve("valve_1", stream1);
+ valve1.setOutletPressure(50.0);
+ valve1.setPercentValveOpening(50);
+ valve1.setCalculateSteadyState(false);
Separator separator1 = new Separator("separator_1");
separator1.addStream(valve1.getOutletStream());
- separator1.addStream(valvePurge.getOutletStream());
separator1.setCalculateSteadyState(false);
separator1.setSeparatorLength(3.0);
separator1.setInternalDiameter(0.8);
separator1.setLiquidLevel(0.0);
- ThrottlingValve valve3 = new ThrottlingValve("valve_3", separator1.getGasOutStream());
- valve3.setOutletPressure(1.0);
- valve3.setPercentValveOpening(50);
- valve3.setCalculateSteadyState(false);
- valve3.setMinimumValveOpening(1.0);
+ Compressor compressor1 = new Compressor(separator1.getGasOutStream());
+ compressor1.setCalculateSteadyState(false);
+ compressor1.setOutletPressure(100.0);
+
+ Separator separator2 = new Separator("separator_2");
+ separator2.addStream(compressor1.getOutletStream());
+ separator2.setCalculateSteadyState(false);
+ separator2.setSeparatorLength(3.0);
+ separator2.setInternalDiameter(0.8);
+ separator2.setLiquidLevel(0.0);
+
+ ThrottlingValve valve2 = new ThrottlingValve("valve_2", separator2.getGasOutStream());
+ valve2.setOutletPressure(50.0);
+ valve2.setPercentValveOpening(50);
+ valve2.setCalculateSteadyState(false);
PressureTransmitter separatorPressureTransmitter =
- new PressureTransmitter(separator1.getGasOutStream());
- separatorPressureTransmitter.setUnit("bar");
- separatorPressureTransmitter.setMaximumValue(10.0);
- separatorPressureTransmitter.setMinimumValue(1.0);
+ new PressureTransmitter(separator2.getGasOutStream());
- ControllerDeviceInterface separatorPressureController = new ControllerDeviceBaseClass();
- separatorPressureController.setTransmitter(separatorPressureTransmitter);
- separatorPressureController.setReverseActing(false);
- separatorPressureController.setControllerSetPoint(5.0);
- separatorPressureController.setControllerParameters(1, 200.0, 0.0);
+
+ ControllerDeviceInterface speedController = new ControllerDeviceBaseClass();
+ speedController.setReverseActing(true);
+ speedController.setTransmitter(separatorPressureTransmitter);
+ speedController.setControllerSetPoint(100.0);
+ speedController.setControllerParameters(0.1, 500.0, 0.0);
p.add(stream1);
- p.add(streamPurge);
p.add(valve1);
- p.add(valvePurge);
p.add(separator1);
- p.add(valve3);
-
+ p.add(compressor1);
+ p.add(separator2);
p.add(separatorPressureTransmitter);
- valve3.setController(separatorPressureController);
+ p.add(valve2);
+ compressor1.setController(speedController);
- p.run();
- for (SimulationInterface sim : p.getUnitOperations()) {
- assertEquals(sim.getCalculationIdentifier(), p.getCalculationIdentifier());
- }
- // p.displayResult();
+
+ p.run();
+ /*
+ * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) +
+ * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure());
+ */
+ assertEquals(100.0, compressor1.getOutletStream().getPressure(), 0.01);
+
+ neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator =
+ new neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator(
+ compressor1);
+ compressor1.setCompressorChart(compchartgenerator.generateCompressorChart("normal"));
+ compressor1.getCompressorChart().setUseCompressorChart(true);
+ // compressor1.setCalculateSteadyState(true);
+ p.run();
+ /*
+ * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) +
+ * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure());
+ */
+
+ assertEquals(102.7, compressor1.getOutletStream().getPressure(), 2.01);
+ assertEquals(50.0, separator1.getGasOutStream().getPressure(), 0.01);
+ // System.out.println("speed " + compressor1.getSpeed());
p.setTimeStep(10.0);
+ p.runTransient();
+ /*
+ * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) +
+ * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure());
+ */
+ // compressor1.setSpeed(compressor1.getSpeed() + 500);
+ for (int i = 0; i < 200; i++) {
+ /*
+ * System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure())
+ * + " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure());
+ */
+ p.runTransient();
+ }
+ speedController.setControllerSetPoint(120.0);
for (int i = 0; i < 500; i++) {
- // System.out.println("pressure " + separator1.getGasOutStream().getPressure() + " flow "
- // + separator1.getGasOutStream().getFlowRate("kg/hr") + "valve3 opening "
- // + valve3.getPercentValveOpening());
+ /*
+ * System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure())
+ * + " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure());
+ */
p.runTransient();
- for (SimulationInterface sim : p.getUnitOperations()) {
- assertEquals(p.getCalculationIdentifier(), sim.getCalculationIdentifier());
- }
}
- assertEquals(5.0, separator1.getGasOutStream().getPressure(), 0.01);
+ }
+ @Test
+ public void testAntiSurgeControl() {
+ neqsim.thermo.system.SystemInterface testSystem2 =
+ new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00);
+ testSystem2.addComponent("methane", 1.1);
+ testSystem2.addComponent("ethane", 0.1);
+ testSystem2.setMixingRule(2);
+
+ Stream stream1 = new Stream("Stream1", testSystem2);
+ stream1.setFlowRate(500.0, "kg/hr");
+ stream1.setPressure(100.0, "bara");
+ stream1.setTemperature(55.0, "C");
+
+ ThrottlingValve valve1 = new ThrottlingValve("valve_1", stream1);
+ valve1.setOutletPressure(50.0);
+ valve1.setPercentValveOpening(20);
+ valve1.setCalculateSteadyState(false);
+
+ Stream resycstream = stream1.clone();
+ resycstream.setFlowRate(0.01, "kg/hr");
+
+ Separator separator1 = new Separator("separator_1");
+ separator1.addStream(valve1.getOutletStream());
+ separator1.addStream(resycstream);
+ separator1.setCalculateSteadyState(false);
+ separator1.setSeparatorLength(3.0);
+ separator1.setInternalDiameter(0.8);
+ separator1.setLiquidLevel(0.0);
+
+ Compressor compressor1 = new Compressor(separator1.getGasOutStream());
+ compressor1.setCalculateSteadyState(false);
+ compressor1.setOutletPressure(100.0);
+ CompressorMonitor surgemonitor = new CompressorMonitor(compressor1);
+ surgemonitor.setMaximumValue(5.0);
+ surgemonitor.setMinimumValue(-5.0);
+
+ Cooler aftercooler = new Cooler("after cooler", compressor1.getOutletStream());
+ aftercooler.setOutTemperature(30.0, "C");
+ aftercooler.setCalculateSteadyState(false);
+
+ Separator separator2 = new Separator("separator_2");
+ separator2.addStream(aftercooler.getOutletStream());
+ separator2.setCalculateSteadyState(false);
+ separator2.setSeparatorLength(3.0);
+ separator2.setInternalDiameter(0.5);
+ separator2.setLiquidLevel(0.0);
+
+ Stream gasfromsep2 = new Stream("gas from sep", separator2.getGasOutStream());
+
+ Splitter splitter = new Splitter("splitter1", gasfromsep2);
+ splitter.setSplitFactors(new double[] {0.99, 0.01});
+ splitter.setCalculateSteadyState(false);
+
+ ThrottlingValve recycleValve =
+ new ThrottlingValve("anti surge valve", splitter.getSplitStream(1));
+ recycleValve.setPressure(50.0);
+ recycleValve.setCalculateSteadyState(false);
+ recycleValve.setMinimumValveOpening(1.0);
+ recycleValve.setPercentValveOpening(10);
+
+ SetPoint pressureset =
+ new SetPoint("HP pump set", recycleValve, "pressure", separator1.getGasOutStream());
+
+ Recycle recycle = new Recycle("resycle 1");
+ recycle.addStream(recycleValve.getOutletStream());
+ recycle.setOutletStream(resycstream);
+ recycle.setFlowAccuracy(1e-4);
+
+ ThrottlingValve valve2 = new ThrottlingValve("valve_2", splitter.getSplitStream(0));
+ valve2.setOutletPressure(50.0);
+ valve2.setPercentValveOpening(50);
+ valve2.setCalculateSteadyState(false);
+ valve2.setMinimumValveOpening(1.0);
+
+ ControllerDeviceInterface surgeController = new ControllerDeviceBaseClass();
+ surgeController.setReverseActing(true);
+ surgeController.setTransmitter(surgemonitor);
+ surgeController.setControllerSetPoint(0.0);
+ surgeController.setControllerParameters(1.0, 200.0, 10.0);
+ surgeController.setActive(true);
+
+ p.add(stream1);
+ p.add(resycstream);
+ p.add(valve1);
+ p.add(separator1);
+ p.add(compressor1);
+ p.add(surgemonitor);
+ p.add(aftercooler);
+ p.add(separator2);
+ p.add(gasfromsep2);
+ p.add(splitter);
+ p.add(recycleValve);
+ p.add(pressureset);
+ p.add(recycle);
+ p.add(valve2);
+ recycleValve.setController(surgeController);
+
+ p.run();
+ assertEquals(100.0, compressor1.getOutletStream().getPressure(), 0.01);
+ recycleValve.setCv(valve2.getCv());
+ /*
+ * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) +
+ * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure() + " distancetosurge ");
+ */
+ neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator =
+ new neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator(
+ compressor1);
+ compressor1.setCompressorChart(compchartgenerator.generateCompressorChart("normal"));
+ compressor1.getCompressorChart().setUseCompressorChart(true);
+ p.run();
+ /*
+ * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) +
+ * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure() + " distancetosurge " +
+ * surgemonitor.getMeasuredValue("distance to surge") + " antisurgeflow " +
+ * recycleValve.getOutletStream().getFlowRate("kg/hr") + " antisurgevalveopening " +
+ * recycleValve.getPercentValveOpening() + " compressorouttemperature " +
+ * compressor1.getOutStream().getTemperature("C") + " power " + compressor1.getPower("kW"));
+ */
+
+ // System.out.println("speed " + compressor1.getSpeed());
+ p.setTimeStep(1.0);
+
+ recycleValve.setPercentValveOpening(1.0);
+ valve2.setPercentValveOpening(100.0);
+
+ for (int i = 0; i < 100; i++) {
+ /*
+ * System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure())
+ * + " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure() + " distancetosurge " +
+ * surgemonitor.getMeasuredValue("distance to surge") + " antisurgeflow " +
+ * recycleValve.getOutletStream().getFlowRate("kg/hr") + " antisurgevalveopening " +
+ * recycleValve.getPercentValveOpening() + " compressorouttemperature " +
+ * compressor1.getOutStream().getTemperature("C") + " surgeflow " +
+ * compressor1.getCompressorChart().getSurgeCurve()
+ * .getSurgeFlow(compressor1.getPolytropicFluidHead()) + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("m3/hr") + " fluid head " +
+ * compressor1.getPolytropicFluidHead() + " power " + compressor1.getPower("kW"));
+ */
+ p.runTransient();
+ }
+
+
+ valve1.setPercentValveOpening(1.0);
+ valve2.setPercentValveOpening(1.0);
+
+ for (int i = 0; i < 100; i++) {
+ /*
+ * System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure())
+ * + " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure() + " distancetosurge " +
+ * surgemonitor.getMeasuredValue("distance to surge") + " antisurgeflow " +
+ * recycleValve.getOutletStream().getFlowRate("kg/hr") + " antisurgevalveopening " +
+ * recycleValve.getPercentValveOpening() + " compressorouttemperature " +
+ * compressor1.getOutStream().getTemperature("C") + " surgeflow " +
+ * compressor1.getCompressorChart().getSurgeCurve()
+ * .getSurgeFlow(compressor1.getPolytropicFluidHead()) + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("m3/hr") + " fluid head " +
+ * compressor1.getPolytropicFluidHead() + " power " + compressor1.getPower("kW"));
+ */
+ p.runTransient();
+ }
+
+ valve1.setPercentValveOpening(50.0);
+ valve2.setPercentValveOpening(50.0);
+
+ for (int i = 0; i < 100; i++) {
+ /*
+ * System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow " +
+ * stream1.getFlowRate("kg/hr") + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " +
+ * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " +
+ * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure())
+ * + " pres inn " + compressor1.getInletStream().getPressure() + " pres out " +
+ * compressor1.getOutletStream().getPressure() + " distancetosurge " +
+ * surgemonitor.getMeasuredValue("distance to surge") + " antisurgeflow " +
+ * recycleValve.getOutletStream().getFlowRate("kg/hr") + " antisurgevalveopening " +
+ * recycleValve.getPercentValveOpening() + " compressorouttemperature " +
+ * compressor1.getOutStream().getTemperature("C") + " surgeflow " +
+ * compressor1.getCompressorChart().getSurgeCurve()
+ * .getSurgeFlow(compressor1.getPolytropicFluidHead()) + " compressor flow rate " +
+ * compressor1.getInletStream().getFlowRate("m3/hr") + " fluid head " +
+ * compressor1.getPolytropicFluidHead() + " power " + compressor1.getPower("kW"));
+ */
+
+ p.runTransient();
+ }
}
+
}
From 45a72ee1c6bd56d6d2c07e6fa3edfe70161c8166 Mon Sep 17 00:00:00 2001
From: Even Solbraa <41290109+EvenSol@users.noreply.github.com>
Date: Thu, 21 Dec 2023 13:11:44 +0100
Subject: [PATCH 04/15] Update pom.xml (#889)
* Update pom.xml
* Update pomJava8.xml
---
pom.xml | 2 +-
pomJava8.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index d3cca03453..2144e1f99b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
${revision}${sha1}${changelist}
- 2.5.13
+ 2.5.14
UTF-8
UTF-8
diff --git a/pomJava8.xml b/pomJava8.xml
index afdb86d51f..dc3831cd13 100644
--- a/pomJava8.xml
+++ b/pomJava8.xml
@@ -10,7 +10,7 @@
${revision}${sha1}${changelist}-Java8
- 2.5.13
+ 2.5.14
UTF-8
UTF-8
From 8e45f5acfe084e2d38272878ef647a310045656b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?=
<34712686+asmfstatoil@users.noreply.github.com>
Date: Fri, 22 Dec 2023 12:02:12 +0100
Subject: [PATCH 05/15] doc: fix javadoc (#891)
* doc: fix javadoc
---
.../chemicalReactions/ChemicalReactionOperations.java | 1 +
.../flowNode/twoPhaseNode/TwoPhaseFlowNode.java | 5 +++++
.../controllerDevice/ControllerDeviceInterface.java | 8 ++++++--
src/main/java/neqsim/thermo/ThermodynamicModelTest.java | 5 +----
src/main/java/neqsim/util/unit/LengthUnit.java | 4 ++--
src/main/java/neqsim/util/unit/TimeUnit.java | 4 ++--
.../flashOps/PHFlashGERG2008Test.java | 3 ---
.../thermodynamicOperations/flashOps/PHFlashTest.java | 3 ---
8 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/src/main/java/neqsim/chemicalReactions/ChemicalReactionOperations.java b/src/main/java/neqsim/chemicalReactions/ChemicalReactionOperations.java
index 3c28a545aa..ba4f589a80 100644
--- a/src/main/java/neqsim/chemicalReactions/ChemicalReactionOperations.java
+++ b/src/main/java/neqsim/chemicalReactions/ChemicalReactionOperations.java
@@ -453,6 +453,7 @@ public boolean solveChemEq(int phase, int type) {
solver = new ChemicalEquilibrium(Amatrix, bVector, system, components, phase);
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
+ // todo: Will this crash below?
}
return solver.solve();
}
diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/TwoPhaseFlowNode.java b/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/TwoPhaseFlowNode.java
index 7291beba3f..be313ef672 100644
--- a/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/TwoPhaseFlowNode.java
+++ b/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/TwoPhaseFlowNode.java
@@ -401,6 +401,11 @@ public void update() {
}
}
+ /**
+ * update.
+ *
+ * @param deltaTime a double
+ */
public void update(double deltaTime) {
for (int componentNumber = 0; componentNumber < getBulkSystem().getPhases()[0]
.getNumberOfComponents(); componentNumber++) {
diff --git a/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java b/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java
index d123546982..9b7f9fd2b6 100644
--- a/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java
+++ b/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java
@@ -131,17 +131,21 @@ public default void runTransient(double initResponse, double dt) {
/**
*
- * setActive
+ * setActive.
*
* Set if controller is active
+ *
+ * @param isActive Set true to make controller active.
*/
public void setActive(boolean isActive);
/**
*
- * isActive
+ * isActive.
*
* Specifies if controller is active
+ *
+ * @return a boolean
*/
public boolean isActive();
}
diff --git a/src/main/java/neqsim/thermo/ThermodynamicModelTest.java b/src/main/java/neqsim/thermo/ThermodynamicModelTest.java
index ba800413ed..6cf11e0c12 100644
--- a/src/main/java/neqsim/thermo/ThermodynamicModelTest.java
+++ b/src/main/java/neqsim/thermo/ThermodynamicModelTest.java
@@ -424,11 +424,8 @@ public boolean checkNumerically() {
}
/**
- *
*
- * @param maxErr Maximum error before test will report failed Set maximum allowed error in model
- * check
- *
+ * @param maxErr before test will report failed Set maximum allowed error in model check
*/
public void setMaxError(double maxErr) {
this.maxError = maxErr;
diff --git a/src/main/java/neqsim/util/unit/LengthUnit.java b/src/main/java/neqsim/util/unit/LengthUnit.java
index f19048778a..007b6b6edf 100644
--- a/src/main/java/neqsim/util/unit/LengthUnit.java
+++ b/src/main/java/neqsim/util/unit/LengthUnit.java
@@ -23,8 +23,8 @@ public class LengthUnit extends neqsim.util.unit.BaseUnit {
* Constructor for LengthUnit.
*
*
- * @param value
- * @param name
+ * @param value Numeric value
+ * @param name Name of unit
*/
public LengthUnit(double value, String name) {
super(value, name);
diff --git a/src/main/java/neqsim/util/unit/TimeUnit.java b/src/main/java/neqsim/util/unit/TimeUnit.java
index 2635ed108f..28c293b628 100644
--- a/src/main/java/neqsim/util/unit/TimeUnit.java
+++ b/src/main/java/neqsim/util/unit/TimeUnit.java
@@ -22,8 +22,8 @@ public class TimeUnit extends neqsim.util.unit.BaseUnit {
* Constructor for TimeUnit.
*
*
- * @param value
- * @param name
+ * @param value Numeric value
+ * @param name Name of unit
*/
public TimeUnit(double value, String name) {
super(value, name);
diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashGERG2008Test.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashGERG2008Test.java
index 46ed812aed..ee0a6020ad 100644
--- a/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashGERG2008Test.java
+++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashGERG2008Test.java
@@ -28,9 +28,6 @@ void setUp() throws Exception {
testSystem.initProperties();
}
- /**
- * Test method for {@link neqsim.thermodynamicOperations.flashOps.PHFlashGERG2008#run()}.
- */
@Test
void testRun() {
double[] gergProps = testSystem.getPhase(0).getProperties_GERG2008();
diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashTest.java
index 61f54b2937..406dc3ddef 100644
--- a/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashTest.java
+++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashTest.java
@@ -31,9 +31,6 @@ void setUp() throws Exception {
testSystem.setMixingRule("classic");
}
- /**
- * Test method for {@link neqsim.thermodynamicOperations.flashOps.PHFlash#run()}.
- */
@Test
void testRun() {
testOps = new ThermodynamicOperations(testSystem);
From 20730e972824424a25f7ed4559fe3c78d50dce27 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?=
<34712686+asmfstatoil@users.noreply.github.com>
Date: Fri, 22 Dec 2023 17:11:12 +0100
Subject: [PATCH 06/15] chore: remove non-implemented FileWriter classes (#848)
---
.../fluidMechanics/flowSystem/FlowSystem.java | 8 ------
.../flowSystem/FlowSystemInterface.java | 12 --------
.../FileWriterBaseClass.java | 20 -------------
.../FileWriterInterface.java | 12 --------
.../OnePhaseFileWriter.java | 28 -------------------
.../PipeFlowFileWriter.java | 28 -------------------
.../TwoPhaseFileWriter.java | 22 ---------------
.../TwoPhasePipeFlowFileWriter.java | 22 ---------------
8 files changed, 152 deletions(-)
delete mode 100644 src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/FileWriterBaseClass.java
delete mode 100644 src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/FileWriterInterface.java
delete mode 100644 src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/OnePhaseFileWriter.java
delete mode 100644 src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/pipeFlowFileWriter/PipeFlowFileWriter.java
delete mode 100644 src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/twoPhaseFileWriter/TwoPhaseFileWriter.java
delete mode 100644 src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/twoPhaseFileWriter/twoPhasePipeFlowFileWriter/TwoPhasePipeFlowFileWriter.java
diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/FlowSystem.java b/src/main/java/neqsim/fluidMechanics/flowSystem/FlowSystem.java
index 9028cc0fb0..e3de8d23c3 100644
--- a/src/main/java/neqsim/fluidMechanics/flowSystem/FlowSystem.java
+++ b/src/main/java/neqsim/fluidMechanics/flowSystem/FlowSystem.java
@@ -5,7 +5,6 @@
import neqsim.fluidMechanics.flowNode.FlowNodeInterface;
import neqsim.fluidMechanics.flowSolver.FlowSolverInterface;
import neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface;
-import neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.FileWriterInterface;
import neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.FlowSystemVisualizationInterface;
import neqsim.fluidMechanics.util.timeSeries.TimeSeries;
import neqsim.thermo.system.SystemInterface;
@@ -29,7 +28,6 @@ public abstract class FlowSystem implements FlowSystemInterface, java.io.Seriali
protected FlowNodeInterface[] flowNode;
protected FlowLegInterface[] flowLeg;
- protected FileWriterInterface[] fileWriter;
protected String initFlowPattern = "annular";
protected FlowSystemVisualizationInterface display;
protected TimeSeries timeSeries = new TimeSeries();
@@ -250,12 +248,6 @@ public FlowSystemVisualizationInterface getDisplay() {
return display;
}
- /** {@inheritDoc} */
- @Override
- public FileWriterInterface getFileWriter(int i) {
- return fileWriter[i];
- }
-
/** {@inheritDoc} */
@Override
public void setNumberOfNodesInLeg(int numberOfNodesInLeg) {
diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/FlowSystemInterface.java b/src/main/java/neqsim/fluidMechanics/flowSystem/FlowSystemInterface.java
index e5a5a5f9f0..40fe2474aa 100644
--- a/src/main/java/neqsim/fluidMechanics/flowSystem/FlowSystemInterface.java
+++ b/src/main/java/neqsim/fluidMechanics/flowSystem/FlowSystemInterface.java
@@ -10,7 +10,6 @@
import neqsim.fluidMechanics.flowNode.FlowNodeInterface;
import neqsim.fluidMechanics.flowSolver.FlowSolverInterface;
import neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface;
-import neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.FileWriterInterface;
import neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.FlowSystemVisualizationInterface;
import neqsim.fluidMechanics.util.timeSeries.TimeSeries;
import neqsim.thermo.system.SystemInterface;
@@ -79,17 +78,6 @@ public default void solveTransient(int type) {
*/
public FlowSystemVisualizationInterface getDisplay();
- /**
- *
- * getFileWriter.
- *
- *
- * @param i a int
- * @return a {@link neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.FileWriterInterface}
- * object
- */
- public FileWriterInterface getFileWriter(int i);
-
/**
*
* getSolver.
diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/FileWriterBaseClass.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/FileWriterBaseClass.java
deleted file mode 100644
index 3151769c9c..0000000000
--- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/FileWriterBaseClass.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package neqsim.fluidMechanics.util.fluidMechanicsDataHandeling;
-
-/**
- *
- * FileWriterBaseClass class.
- *
- *
- * @author esol
- * @version $Id: $Id
- */
-public class FileWriterBaseClass implements java.io.Serializable {
- private static final long serialVersionUID = 1000;
-
- /**
- *
- * Constructor for FileWriterBaseClass.
- *
- */
- public FileWriterBaseClass() {}
-}
diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/FileWriterInterface.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/FileWriterInterface.java
deleted file mode 100644
index 754c7be7a2..0000000000
--- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/FileWriterInterface.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package neqsim.fluidMechanics.util.fluidMechanicsDataHandeling;
-
-/**
- *
- * FileWriterInterface interface.
- *
- *
- * @author esol
- * @version $Id: $Id
- */
-public interface FileWriterInterface {
-}
diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/OnePhaseFileWriter.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/OnePhaseFileWriter.java
deleted file mode 100644
index 8774324987..0000000000
--- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/OnePhaseFileWriter.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * OnePhaseFileWriter.java
- *
- * Created on 27. oktober 2000, 22:27
- */
-
-package neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.onePhaseFileWriter;
-
-import neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.FileWriterBaseClass;
-
-/**
- *
- * OnePhaseFileWriter class.
- *
- *
- * @author esol
- * @version $Id: $Id
- */
-public class OnePhaseFileWriter extends FileWriterBaseClass {
- private static final long serialVersionUID = 1000;
-
- /**
- *
- * Constructor for OnePhaseFileWriter.
- *
- */
- public OnePhaseFileWriter() {}
-}
diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/pipeFlowFileWriter/PipeFlowFileWriter.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/pipeFlowFileWriter/PipeFlowFileWriter.java
deleted file mode 100644
index 8ec0b7b82d..0000000000
--- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/pipeFlowFileWriter/PipeFlowFileWriter.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * PipeFlowFileWriter.java
- *
- * Created on 27. oktober 2000, 22:29
- */
-
-package neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.onePhaseFileWriter.pipeFlowFileWriter;
-
-import neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.onePhaseFileWriter.OnePhaseFileWriter;
-
-/**
- *
- * PipeFlowFileWriter class.
- *
- *
- * @author esol
- * @version $Id: $Id
- */
-public class PipeFlowFileWriter extends OnePhaseFileWriter {
- private static final long serialVersionUID = 1000;
-
- /**
- *
- * Constructor for PipeFlowFileWriter.
- *
- */
- public PipeFlowFileWriter() {}
-}
diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/twoPhaseFileWriter/TwoPhaseFileWriter.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/twoPhaseFileWriter/TwoPhaseFileWriter.java
deleted file mode 100644
index 9dbeacd2e3..0000000000
--- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/twoPhaseFileWriter/TwoPhaseFileWriter.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.twoPhaseFileWriter;
-
-import neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.FileWriterBaseClass;
-
-/**
- *
- * TwoPhaseFileWriter class.
- *
- *
- * @author esol
- * @version $Id: $Id
- */
-public class TwoPhaseFileWriter extends FileWriterBaseClass {
- private static final long serialVersionUID = 1000;
-
- /**
- *
- * Constructor for TwoPhaseFileWriter.
- *
- */
- public TwoPhaseFileWriter() {}
-}
diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/twoPhaseFileWriter/twoPhasePipeFlowFileWriter/TwoPhasePipeFlowFileWriter.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/twoPhaseFileWriter/twoPhasePipeFlowFileWriter/TwoPhasePipeFlowFileWriter.java
deleted file mode 100644
index 0f3341d53e..0000000000
--- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/twoPhaseFileWriter/twoPhasePipeFlowFileWriter/TwoPhasePipeFlowFileWriter.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.twoPhaseFileWriter.twoPhasePipeFlowFileWriter;
-
-import neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.twoPhaseFileWriter.TwoPhaseFileWriter;
-
-/**
- *
- * TwoPhasePipeFlowFileWriter class.
- *
- *
- * @author esol
- * @version $Id: $Id
- */
-public class TwoPhasePipeFlowFileWriter extends TwoPhaseFileWriter {
- private static final long serialVersionUID = 1000;
-
- /**
- *
- * Constructor for TwoPhasePipeFlowFileWriter.
- *
- */
- public TwoPhasePipeFlowFileWriter() {}
-}
From 5b5248ff998b771fb012b2c7c14eb0de1b53f2a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?=
<34712686+asmfstatoil@users.noreply.github.com>
Date: Fri, 22 Dec 2023 11:19:27 +0100
Subject: [PATCH 07/15] chore: build with java 21 update dependencies and
github workflows
---
.github/workflows/release_with_jars.yml | 27 +-
.github/workflows/verify_build.yml | 22 +-
pom.xml | 16 +-
pomJava21.xml | 275 ++++++++++++++
pomJava8.xml | 483 ++++++++++++------------
5 files changed, 570 insertions(+), 253 deletions(-)
create mode 100644 pomJava21.xml
diff --git a/.github/workflows/release_with_jars.yml b/.github/workflows/release_with_jars.yml
index a31bdd8406..7b4fff81c7 100644
--- a/.github/workflows/release_with_jars.yml
+++ b/.github/workflows/release_with_jars.yml
@@ -90,7 +90,32 @@ jobs:
with:
name: jarfiles
path: staging
-
+
+ compile_java_21:
+ name: Build Neqsim ${{ needs.get_versions.outputs.version }} with java 21
+ needs: get_versions
+
+ if: ${{ needs.get_versions.outputs.version_8 == needs.get_versions.outputs.version }}
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Check out neqsim java project
+ uses: actions/checkout@v3
+ - name: Set up JDK 21 environment
+ uses: actions/setup-java@v3
+ with:
+ distribution: 'temurin'
+ java-version: '21'
+ cache: 'maven'
+ - name: Build java 21 version with Maven
+ run: mvn -B package --file pomJava21.xml
+ - name: Copy jar file to staging
+ run: mkdir staging && cp target/neqsim*Java21.jar staging
+ - uses: actions/upload-artifact@v2
+ with:
+ name: jarfiles
+ path: staging
+
create_release:
name: Create release v${{ needs.get_versions.outputs.version_8 }}
runs-on: ubuntu-latest
diff --git a/.github/workflows/verify_build.yml b/.github/workflows/verify_build.yml
index 6d2a96b89d..a082c92012 100644
--- a/.github/workflows/verify_build.yml
+++ b/.github/workflows/verify_build.yml
@@ -11,7 +11,7 @@ on:
- master
jobs:
- test_javadoc:
+ test_java_11:
name: Assert tests and javadoc with java 11
runs-on: ubuntu-latest
steps:
@@ -36,9 +36,9 @@ jobs:
tags: coverage
test_java_8:
- name: Assert tests and javadoc with java 8
+ name: Assert tests with java 8
runs-on: ubuntu-latest
- needs: test_javadoc
+ needs: test_java_11
steps:
- uses: actions/checkout@v3
@@ -51,3 +51,19 @@ jobs:
- name: Run tests
run: mvn -B test --file pomJava8.xml -ntp
+
+ test_java_21:
+ name: Assert tests with java 21
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up JDK 21
+ uses: actions/setup-java@v3
+ with:
+ distribution: 'temurin'
+ java-version: '21'
+ cache: 'maven'
+ - name: Generate javadoc
+ run: mvn javadoc:javadoc
+ - name: Run tests
+ run: mvn -B test --file pomJava21.xml -ntp
diff --git a/pom.xml b/pom.xml
index 2144e1f99b..2a24fe486d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,7 +49,7 @@
org.junit.jupiter
junit-jupiter
- 5.9.3
+ 5.10.1
test
@@ -102,7 +102,7 @@
com.google.code.gson
gson
- 2.9.0
+ 2.10.1
test
@@ -143,7 +143,7 @@
org.codehaus.mojo
flatten-maven-plugin
- 1.3.0
+ 1.5.0
true
@@ -167,7 +167,7 @@
org.apache.maven.plugins
maven-shade-plugin
- 3.4.0
+ 3.5.1
package
@@ -180,7 +180,7 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.10.1
+ 3.12.0
11
${project.build.sourceEncoding}
@@ -195,7 +195,7 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 3.4.1
+ 3.6.3
private
true
@@ -211,7 +211,7 @@
maven-surefire-plugin
- 3.0.0-M7
+ 3.2.3
maven-failsafe-plugin
@@ -220,7 +220,7 @@
org.jacoco
jacoco-maven-plugin
- 0.8.8
+ 0.8.11
neqsim/physicalProperties/util/parameterFitting/**/*
diff --git a/pomJava21.xml b/pomJava21.xml
new file mode 100644
index 0000000000..2bfd6e902c
--- /dev/null
+++ b/pomJava21.xml
@@ -0,0 +1,275 @@
+
+
+
+ 4.0.0
+ com.equinor
+ neqsim
+ jar
+ ${revision}${sha1}${changelist}
+
+
+ 2.5.14
+ UTF-8
+ UTF-8
+
+
+
+
+
+
+ central
+ https://repo1.maven.org/maven2/
+
+
+
+
+
+
+ com.h2database
+ h2
+ 2.2.224
+
+
+ com.thoughtworks.xstream
+ xstream
+ 1.4.20
+
+
+ org.apache.logging.log4j
+ log4j-api
+ 2.22.0
+
+
+ org.apache.logging.log4j
+ log4j-core
+ 2.22.0
+
+
+ org.junit.jupiter
+ junit-jupiter
+ 5.10.1
+ test
+
+
+ colt
+ colt
+ 1.2.0
+ provided
+
+
+ commons-lang
+ commons-lang
+ 2.6
+
+
+ org.apache.commons
+ commons-math3
+ 3.6.1
+
+
+ org.ejml
+ ejml-all
+ 0.43.1
+
+
+ gov.nist.math
+ jama
+ 1.0.3
+
+
+ org.jfree
+ jcommon
+ 1.0.24
+
+
+ org.jfree
+ jfreechart
+ 1.5.4
+
+
+ com.googlecode.matrix-toolkits-java
+ mtj
+ 1.0.4
+
+
+ org.ojalgo
+ ojalgo
+ 53.1.1
+ provided
+
+
+ com.google.code.gson
+ gson
+ 2.10.1
+ test
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+ 3.1.0
+
+
+ enforce-maven
+
+ enforce
+
+
+
+
+ 3.3.9
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.3.0
+
+
+
+ neqsim.thermo.util.benchmark.TPflash_benchmark
+
+
+
+
+
+ org.codehaus.mojo
+ flatten-maven-plugin
+ 1.5.0
+
+ true
+
+
+
+ flatten
+ process-resources
+
+ flatten
+
+
+
+ flatten.clean
+ clean
+
+ clean
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.5.1
+
+
+ package
+
+ shade
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.12.0
+
+ 21
+ ${project.build.sourceEncoding}
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 3.6.3
+
+ private
+ true
+
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+
+ maven-surefire-plugin
+ 3.2.3
+
+
+ maven-failsafe-plugin
+ 3.2.3
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.11
+
+
+ neqsim/physicalProperties/util/parameterFitting/**/*
+ neqsim/statistics/util/parameterFitting/**/*
+ neqsim/PVTsimulation/util/parameterfitting/**/*
+
+
+
+
+
+ prepare-agent
+
+
+
+ report
+ prepare-package
+
+ report
+
+
+
+ generate-report-after-test
+ test
+
+ report
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 3.3.0
+
+
+ attach-sources
+
+ jar-no-fork
+
+
+
+
+
+
+
+
+ github
+ GitHub Equinor Apache Maven Packages
+ https://maven.pkg.github.com/Equinor/neqsim
+
+
+
diff --git a/pomJava8.xml b/pomJava8.xml
index dc3831cd13..fc22d72c74 100644
--- a/pomJava8.xml
+++ b/pomJava8.xml
@@ -1,248 +1,249 @@
- 4.0.0
- com.equinor.neqsim
- neqsim
- jar
- ${revision}${sha1}${changelist}-Java8
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ 4.0.0
+ com.equinor.neqsim
+ neqsim
+ jar
+ ${revision}${sha1}${changelist}-Java8
-
- 2.5.14
- UTF-8
- UTF-8
-
-
-
+
+ 2.5.14
+ UTF-8
+ UTF-8
+
+
+
-
-
- central
- https://repo1.maven.org/maven2/
-
-
+
+
+ central
+ https://repo1.maven.org/maven2/
+
+
-
-
- org.apache.logging.log4j
- log4j-api
- 2.20.0
-
-
- org.apache.logging.log4j
- log4j-core
- 2.20.0
-
-
- com.thoughtworks.xstream
- xstream
- 1.4.20
-
-
- org.junit.jupiter
- junit-jupiter
- 5.9.3
- test
-
-
- colt
- colt
- 1.2.0
- provided
-
-
- commons-lang
- commons-lang
- 2.6
-
-
- org.apache.commons
- commons-math3
- 3.6.1
-
-
-
- com.h2database
- h2
- 2.1.214
-
-
- org.ejml
- ejml-all
- 0.41
-
-
- gov.nist.math
- jama
- 1.0.3
-
-
- org.jfree
- jcommon
- 1.0.24
-
-
- org.jfree
- jfreechart
- 1.5.3
-
-
- com.googlecode.matrix-toolkits-java
- mtj
- 1.0.4
-
-
- org.ojalgo
- ojalgo
- 48.4.2
- provided
-
-
- com.google.code.gson
- gson
- 2.9.0
- test
-
-
-
-
-
- org.apache.maven.plugins
- maven-enforcer-plugin
- 3.1.0
-
-
- enforce-maven
-
- enforce
-
-
-
-
- 3.3.9
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- 3.3.0
-
-
-
- neqsim.thermo.util.benchmark.TPflash_benchmark
-
-
-
-
-
- org.codehaus.mojo
- flatten-maven-plugin
- 1.3.0
-
- true
-
-
-
- flatten
- process-resources
-
- flatten
-
-
-
- flatten.clean
- clean
-
- clean
-
-
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 3.4.0
-
-
- package
-
- shade
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.10.1
-
- 1.8
- 1.8
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 3.4.1
-
- private
- true
-
-
-
- maven-surefire-plugin
- 3.0.0-M7
-
-
- maven-failsafe-plugin
- 3.0.0-M7
-
-
- org.jacoco
- jacoco-maven-plugin
- 0.8.8
-
-
- neqsim/physicalProperties/util/parameterFitting/**/*
- neqsim/statistics/util/parameterFitting/**/*
- neqsim/PVTsimulation/util/parameterfitting/**/*
-
-
-
-
-
- prepare-agent
-
-
-
- report
- prepare-package
-
- report
-
-
-
- generate-report-after-test
- test
-
- report
-
-
-
-
-
-
-
-
- github
- GitHub Equinor Apache Maven Packages
- https://maven.pkg.github.com/Equinor/neqsim
-
-
+
+
+ org.apache.logging.log4j
+ log4j-api
+ 2.20.0
+
+
+ org.apache.logging.log4j
+ log4j-core
+ 2.20.0
+
+
+ com.thoughtworks.xstream
+ xstream
+ 1.4.20
+
+
+ org.junit.jupiter
+ junit-jupiter
+ 5.9.3
+ test
+
+
+ colt
+ colt
+ 1.2.0
+ provided
+
+
+ commons-lang
+ commons-lang
+ 2.6
+
+
+ org.apache.commons
+ commons-math3
+ 3.6.1
+
+
+
+ com.h2database
+ h2
+ 2.1.214
+
+
+ org.ejml
+ ejml-all
+ 0.41
+
+
+ gov.nist.math
+ jama
+ 1.0.3
+
+
+ org.jfree
+ jcommon
+ 1.0.24
+
+
+ org.jfree
+ jfreechart
+ 1.5.3
+
+
+ com.googlecode.matrix-toolkits-java
+ mtj
+ 1.0.4
+
+
+ org.ojalgo
+ ojalgo
+ 48.4.2
+ provided
+
+
+ com.google.code.gson
+ gson
+ 2.10.1
+ test
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+ 3.1.0
+
+
+ enforce-maven
+
+ enforce
+
+
+
+
+ 3.3.9
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.3.0
+
+
+
+ neqsim.thermo.util.benchmark.TPflash_benchmark
+
+
+
+
+
+ org.codehaus.mojo
+ flatten-maven-plugin
+ 1.5.0
+
+ true
+
+
+
+ flatten
+ process-resources
+
+ flatten
+
+
+
+ flatten.clean
+ clean
+
+ clean
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.5.1
+
+
+ package
+
+ shade
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.12.0
+
+
+ 1.8
+ 1.8
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 3.6.3
+
+ private
+ true
+
+
+
+ maven-surefire-plugin
+ 3.0.0-M7
+
+
+ maven-failsafe-plugin
+ 3.0.0-M7
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.11
+
+
+ neqsim/physicalProperties/util/parameterFitting/**/*
+ neqsim/statistics/util/parameterFitting/**/*
+ neqsim/PVTsimulation/util/parameterfitting/**/*
+
+
+
+
+
+ prepare-agent
+
+
+
+ report
+ prepare-package
+
+ report
+
+
+
+ generate-report-after-test
+ test
+
+ report
+
+
+
+
+
+
+
+
+ github
+ GitHub Equinor Apache Maven Packages
+ https://maven.pkg.github.com/Equinor/neqsim
+
+
From c830a48fe1c0aa5786505f53101968023632382f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?=
<34712686+asmfstatoil@users.noreply.github.com>
Date: Fri, 22 Dec 2023 17:10:06 +0100
Subject: [PATCH 08/15] Update release_with_jars.yml
indentation error
---
.github/workflows/release_with_jars.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/release_with_jars.yml b/.github/workflows/release_with_jars.yml
index 7b4fff81c7..fc5237d3ce 100644
--- a/.github/workflows/release_with_jars.yml
+++ b/.github/workflows/release_with_jars.yml
@@ -91,7 +91,7 @@ jobs:
name: jarfiles
path: staging
- compile_java_21:
+ compile_java_21:
name: Build Neqsim ${{ needs.get_versions.outputs.version }} with java 21
needs: get_versions
From 151ff7f10b1aeadc5ea3405823531bd68bb58762 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?=
<34712686+asmfstatoil@users.noreply.github.com>
Date: Fri, 22 Dec 2023 18:22:48 +0100
Subject: [PATCH 09/15] Update release_with_jars.yml
---
.github/workflows/release_with_jars.yml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/release_with_jars.yml b/.github/workflows/release_with_jars.yml
index fc5237d3ce..c0c6093e59 100644
--- a/.github/workflows/release_with_jars.yml
+++ b/.github/workflows/release_with_jars.yml
@@ -109,8 +109,10 @@ jobs:
cache: 'maven'
- name: Build java 21 version with Maven
run: mvn -B package --file pomJava21.xml
+ - name: Rename files
+ run: cd target && find . -type f -name "neqsim-*.jar" -exec sh -c 'mv -f $0 ${0%.jar}-Java21.jar.' {} \;
- name: Copy jar file to staging
- run: mkdir staging && cp target/neqsim*Java21.jar staging
+ run: cd .. && mkdir staging && cp target/neqsim*Java21.jar staging
- uses: actions/upload-artifact@v2
with:
name: jarfiles
From 853ab053ea4bfe818b1883208867bed4be1a8646 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?=
<34712686+asmfstatoil@users.noreply.github.com>
Date: Fri, 22 Dec 2023 22:13:27 +0100
Subject: [PATCH 10/15] fix: typo Update release_with_jars.yml
---
.github/workflows/release_with_jars.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/release_with_jars.yml b/.github/workflows/release_with_jars.yml
index c0c6093e59..4685165648 100644
--- a/.github/workflows/release_with_jars.yml
+++ b/.github/workflows/release_with_jars.yml
@@ -110,7 +110,7 @@ jobs:
- name: Build java 21 version with Maven
run: mvn -B package --file pomJava21.xml
- name: Rename files
- run: cd target && find . -type f -name "neqsim-*.jar" -exec sh -c 'mv -f $0 ${0%.jar}-Java21.jar.' {} \;
+ run: cd target && find . -type f -name "neqsim-*.jar" -exec sh -c 'mv -f $0 ${0%.jar}-Java21.jar' {} \;
- name: Copy jar file to staging
run: cd .. && mkdir staging && cp target/neqsim*Java21.jar staging
- uses: actions/upload-artifact@v2
From 0d36609f9681a057661259e3302886926327c3db Mon Sep 17 00:00:00 2001
From: Even Solbraa <41290109+EvenSol@users.noreply.github.com>
Date: Sun, 24 Dec 2023 08:31:28 +0100
Subject: [PATCH 11/15] fix read kij from eclipse (#892)
* fix read kij from eclipse
* fix bug
---
.../thermo/mixingRule/EosMixingRules.java | 9 ++++
.../mixingRule/EosMixingRulesInterface.java | 1 +
.../util/readwrite/EclipseFluidReadWrite.java | 46 +++++++------------
.../thermo/util/readwrite/TablePrinter.java | 36 ++++++++++++++-
.../readwrite/EclipseFluidReadWriteTest.java | 5 ++
5 files changed, 66 insertions(+), 31 deletions(-)
diff --git a/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java b/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java
index f7f505971a..28c1a76623 100644
--- a/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java
+++ b/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java
@@ -132,6 +132,15 @@ public double getBinaryInteractionParameter(int i, int j) {
return intparam[i][j];
}
+ @Override
+ public double[][] getBinaryInteractionParameters() {
+ return intparam;
+ }
+
+ public void prettyPrintKij(){
+
+ }
+
@Override
public double getBinaryInteractionParameterT1(int i, int j) {
if (i == j) {
diff --git a/src/main/java/neqsim/thermo/mixingRule/EosMixingRulesInterface.java b/src/main/java/neqsim/thermo/mixingRule/EosMixingRulesInterface.java
index 781396b92b..086949a171 100644
--- a/src/main/java/neqsim/thermo/mixingRule/EosMixingRulesInterface.java
+++ b/src/main/java/neqsim/thermo/mixingRule/EosMixingRulesInterface.java
@@ -275,6 +275,7 @@ public double calcAiT(int compNumb, PhaseInterface phase, double temperature, do
*/
public PhaseInterface getGEPhase();
+ public double[][] getBinaryInteractionParameters();
// double calcA2(PhaseInterface phase, double temperature, double pressure, int
// numbcomp);
// double calcB2(PhaseInterface phase, double temperature, double pressure, int
diff --git a/src/main/java/neqsim/thermo/util/readwrite/EclipseFluidReadWrite.java b/src/main/java/neqsim/thermo/util/readwrite/EclipseFluidReadWrite.java
index 009145fc27..0f7dfd9bd8 100644
--- a/src/main/java/neqsim/thermo/util/readwrite/EclipseFluidReadWrite.java
+++ b/src/main/java/neqsim/thermo/util/readwrite/EclipseFluidReadWrite.java
@@ -4,6 +4,8 @@
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.thermo.ThermodynamicConstantsInterface;
@@ -250,44 +252,30 @@ public static SystemInterface read(String inputFile) {
}
}
if (st.equals("BIC")) {
- int numb = 0;
- // kij = new double[ZI.size()][ZI.size()];
+ int addedComps = 0;
kij = new double[names.size()][names.size()];
+ int lengthLastLine = 0;
+ List list = new ArrayList();
while ((st = br.readLine().replace("/", "")) != null) {
- numb++;
if (st.startsWith("--") || st.isEmpty()) {
break;
}
-
- // String[] arr = st.replace(" ","").split(" ");
String[] arr = st.split(" ");
- if (arr.length == 1) {
- break;
+ List templist = new ArrayList(Arrays.asList(arr));
+ list.addAll(templist);
+ list.removeAll(Arrays.asList("", null));
+ if (lengthLastLine >= list.size()) {
+ continue;
}
-
- // List list = Arrays.asList(arr);
- for (int i = 0; i < arr.length - 1; i++) {
- BIC.add(Double.parseDouble(arr[i + 1]));
- kij[numb][i] = Double.parseDouble(arr[i + 1]);
- kij[i][numb] = kij[numb][i];
- // kij[numb-1][i] = Double.parseDouble(arr[i+1]);
- // kij[i][numb-1] = kij[numb-1][i] ;
+ lengthLastLine = list.size();
+ for (int i = 0; i < list.size(); i++) {
+ BIC.add(Double.parseDouble(list.get(i)));
+ kij[i][addedComps + 1] = Double.parseDouble(list.get(i));
+ kij[addedComps + 1][i] = kij[i][addedComps + 1];
}
- // numb++;
- Double.parseDouble(arr[1]);
- // System.out.println(list.size());
- // System.out.println(st);
- // BIC.add(Double.parseDouble(st));
+ addedComps++;
+ list.clear();
}
-
- /*
- * numb =0;
- *
- * for (int i = 0; i < names.size(); i++) { for (int j = i; j < names.size(); j++) {
- * if(i==j) continue; //System.out.println("ij " + i + " " + j+ " " + BIC.get(numb));
- * System.out.println("ij " + i + " " + j+ " " + kij[i][j] ); //kij[i][j] = BIC.get(numb);
- * //kij[j][i] = kij[i][j]; numb++; } }
- */
}
}
for (int counter = 0; counter < names.size(); counter++) {
diff --git a/src/main/java/neqsim/thermo/util/readwrite/TablePrinter.java b/src/main/java/neqsim/thermo/util/readwrite/TablePrinter.java
index 590f80893e..9c7f0f0b45 100644
--- a/src/main/java/neqsim/thermo/util/readwrite/TablePrinter.java
+++ b/src/main/java/neqsim/thermo/util/readwrite/TablePrinter.java
@@ -6,6 +6,7 @@
* A utility class for pretty printing a 2D string table.
*/
public class TablePrinter implements Serializable {
+
/**
* Prints a 2D string table in a formatted and visually appealing way.
*
@@ -68,7 +69,7 @@ private static void printHorizontalLine(int[] columnWidths) {
/**
* Prints a row of the table with appropriate padding based on column widths.
*
- * @param row The row of data to be printed.
+ * @param row The row of data to be printed.
* @param columnWidths An array containing the maximum width of each column.
*/
private static void printRow(String[] row, int[] columnWidths) {
@@ -84,4 +85,35 @@ private static void printRow(String[] row, int[] columnWidths) {
}
System.out.println();
}
-}
\ No newline at end of file
+
+ /**
+ * Prints a 2D string table in a formatted and visually appealing way.
+ *
+ * @param table The 2D double table to be printed.
+ */
+ public static void printTable(double[][] table) {
+ printTable(convertDoubleToString(table));
+ }
+
+ /**
+ * Returns a 2D string table in a formatted and visually appealing way.
+ *
+ * @param doubleArray The 2D double table to be printed.
+ */
+ public static String[][] convertDoubleToString(double[][] doubleArray) {
+ // Initialize the 2D String array with the same dimensions as the double array
+ String[][] stringArray = new String[doubleArray.length][];
+
+ for (int i = 0; i < doubleArray.length; i++) {
+ // Initialize the inner array with the same length as the corresponding double array
+ stringArray[i] = new String[doubleArray[i].length];
+
+ for (int j = 0; j < doubleArray[i].length; j++) {
+ // Convert each double value to string and store it
+ stringArray[i][j] = String.valueOf(doubleArray[i][j]);
+ }
+ }
+
+ return stringArray;
+ }
+}
diff --git a/src/test/java/neqsim/thermo/util/readwrite/EclipseFluidReadWriteTest.java b/src/test/java/neqsim/thermo/util/readwrite/EclipseFluidReadWriteTest.java
index e4048296a2..8716c19e8c 100644
--- a/src/test/java/neqsim/thermo/util/readwrite/EclipseFluidReadWriteTest.java
+++ b/src/test/java/neqsim/thermo/util/readwrite/EclipseFluidReadWriteTest.java
@@ -63,6 +63,11 @@ void testReadAndAddFluids2() throws IOException {
testSystem.setPressure(100.0, "bara");
testSystem.setTemperature(25.0, "C");
testOps.TPflash();
+
+ // neqsim.thermo.util.readwrite.TablePrinter.printTable((((PhaseEos
+ // )testSystem.getPhase(0)).getMixingRule().getBinaryInteractionParameters()));
+
+
}
@Test
From e4213376533558a7906daff42259360d82b2a820 Mon Sep 17 00:00:00 2001
From: Even Solbraa <41290109+EvenSol@users.noreply.github.com>
Date: Tue, 26 Dec 2023 09:51:08 +0100
Subject: [PATCH 12/15] add inflow unit (#893)
* add inflow unit
* minor updates
* updates
* update adjuster
* pdate
* update
* finalize test
---
.../compressor/Compressor.java | 16 +-
.../pipeline/PipeBeggsAndBrills.java | 31 ++-
.../processEquipment/reservoir/WellFlow.java | 98 ++++++++-
.../processEquipment/util/Adjuster.java | 59 ++++++
.../processSystem/ProcessSystem.java | 32 +++
.../reservoir/WellFlowTest.java | 192 ++++++++++++++++++
6 files changed, 418 insertions(+), 10 deletions(-)
create mode 100644 src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java
index 7c040f06f6..9ad463572f 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java
@@ -34,6 +34,8 @@ public class Compressor extends TwoPortEquipment implements CompressorInterface
public SystemInterface thermoSystem;
private double outTemperature = 298.15;
private boolean useOutTemperature = false;
+ private double compressionRatio = 2.0;
+ private boolean useCompressionRatio = false;
private CompressorPropertyProfile propertyProfile = new CompressorPropertyProfile();
public double dH = 0.0;
public double inletEnthalpy = 0;
@@ -360,6 +362,9 @@ public void run(UUID id) {
double orginalMolarFLow = thermoSystem.getTotalNumberOfMoles();
double fractionAntiSurge = 0.0;
double kappa = 0.0;
+ if (useCompressionRatio) {
+ setOutletPressure(presinn * compressionRatio);
+ }
if (useOutTemperature) {
if (useRigorousPolytropicMethod) {
solveEfficiency(outTemperature);
@@ -668,7 +673,7 @@ public void run(UUID id) {
polytropicFluidHead =
getPower() / getThermoSystem().getFlowRate("kg/sec") / 1000.0 * getPolytropicEfficiency();
polytropicHeadMeter = polytropicFluidHead * 1000.0 / 9.81;
-
+ compressionRatio = getOutletPressure() / presinn;
setCalculationIdentifier(id);
}
@@ -1401,4 +1406,13 @@ public double getMaximumSpeed() {
public double getMinimumSpeed() {
return minspeed;
}
+
+ public void setCompressionRatio(double compRatio) {
+ this.compressionRatio = compRatio;
+ useCompressionRatio = true;
+ }
+
+ public double getCompressionRatio() {
+ return compressionRatio;
+ }
}
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeBeggsAndBrills.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeBeggsAndBrills.java
index 6f1212fa92..5fec96a788 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeBeggsAndBrills.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeBeggsAndBrills.java
@@ -36,7 +36,7 @@ public class PipeBeggsAndBrills extends Pipeline {
// Roughness of the pipe wall [m]
private double pipeWallRoughness = 1e-5;
- // Flag to run isothermal calculations
+ // Flag to run isothermal calculations
private boolean runIsothermal = false;
// Flow pattern of the fluid in the pipe
@@ -109,7 +109,7 @@ public class PipeBeggsAndBrills extends Pipeline {
private double cumulativeElevation;
- //For segment calculation
+ // For segment calculation
double length;
double elevation;
@@ -340,7 +340,7 @@ public void calculateMissingValue() {
throw new RuntimeException(
new neqsim.util.exception.InvalidInputException("PipeBeggsAndBrills", "calcMissingValue",
"elevation or length or angle", "cannot be null"));
- }
+ }
}
@@ -675,7 +675,7 @@ public void run(UUID id) {
testOps.TPflash();
system.initProperties();
- if (!runIsothermal){
+ if (!runIsothermal) {
enthalpyInlet = system.getEnthalpy();
}
double pipeInletPressure = system.getPressure();
@@ -700,7 +700,7 @@ public void run(UUID id) {
}
system.setPressure(pressureOut);
- if (!runIsothermal){
+ if (!runIsothermal) {
testOps.PHflash(enthalpyInlet);
}
system.initProperties();
@@ -711,6 +711,21 @@ public void run(UUID id) {
outStream.setCalculationIdentifier(id);
}
+ /**
+ * {@inheritDoc}
+ *
+ *
+ * runTransient.
+ *
+ */
+ @Override
+ public void runTransient(double dt, UUID id) {
+ run(id);
+ increaseTime(dt);
+ return;
+
+ }
+
/** {@inheritDoc} */
@Override
public void displayResult() {
@@ -740,14 +755,14 @@ public double getAngle() {
/**
- * @return total length of the pipe in m
+ * @return total length of the pipe in m
*/
public double getLength() {
return cumulativeLength;
}
- /**
- * @return total elevation of the pipe in m
+ /**
+ * @return total elevation of the pipe in m
*/
public double getElevation() {
return cumulativeElevation;
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/WellFlow.java b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/WellFlow.java
index b6a438c12d..f804d1126a 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/WellFlow.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/WellFlow.java
@@ -1,5 +1,13 @@
package neqsim.processSimulation.processEquipment.reservoir;
+import java.util.UUID;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import neqsim.processSimulation.processEquipment.TwoPortEquipment;
+import neqsim.processSimulation.processEquipment.stream.StreamInterface;
+import neqsim.processSimulation.processEquipment.valve.ThrottlingValve;
+import neqsim.thermo.system.SystemInterface;
+
/**
*
* WellFlow class.
@@ -8,5 +16,93 @@
* @author asmund
* @version $Id: $Id
*/
-public class WellFlow {
+public class WellFlow extends TwoPortEquipment {
+ private static final long serialVersionUID = 1000;
+ static Logger logger = LogManager.getLogger(ThrottlingValve.class);
+ SystemInterface thermoSystem;
+ private double wellProductionIndex = 0;
+ double pressureOut = 1.0;
+ String pressureUnit = "bara";
+ boolean useWellProductionIndex = false;
+ boolean calcpressure = true;
+
+
+ /**
+ *
+ * Constructor for WellFlow.
+ *
+ *
+ * @param name a {@link java.lang.String} object
+ */
+ public WellFlow(String name) {
+ super(name);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void setInletStream(StreamInterface stream) {
+ super.setInletStream(stream);
+ StreamInterface outStream = stream.clone();
+ outStream.setName("outStream");
+ super.setOutletStream(outStream);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void run(UUID id) {
+ thermoSystem = getInletStream().getThermoSystem().clone();
+ thermoSystem.setPressure(pressureOut, pressureUnit);
+ outStream.setThermoSystem(thermoSystem);
+ if (useWellProductionIndex) {
+ if (calcpressure) {
+ double presout = 1.0;
+ if (Math.pow(getInletStream().getPressure("bara"), 2.0)
+ - getInletStream().getFlowRate("MSm3/day") / wellProductionIndex > 0) {
+ presout = Math.sqrt(Math.pow(getInletStream().getPressure("bara"), 2.0)
+ - getInletStream().getFlowRate("MSm3/day") / wellProductionIndex);
+ } else {
+ logger.error("pressure lower that 0");
+ throw new RuntimeException(
+ new neqsim.util.exception.InvalidInputException("WellFlow", "run: calcOutletPressure",
+ "pressure", "- Outlet pressure is negative" + pressureOut));
+ }
+ // System.out.println("out pres " + presout);
+ outStream.setPressure(presout, "bara");
+ } else {
+ double flow = wellProductionIndex * (Math.pow(getInletStream().getPressure("bara"), 2.0)
+ - Math.pow(thermoSystem.getPressure("bara"), 2.0));
+ outStream.setFlowRate(flow, "MSm3/day");
+ }
+ } else {
+ wellProductionIndex = getInletStream().getFlowRate("MSm3/day")
+ / (Math.pow(getInletStream().getPressure("bara"), 2.0)
+ - Math.pow(thermoSystem.getPressure("bara"), 2.0));
+ }
+ outStream.run();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void runTransient(double dt, UUID id) {
+ if (getCalculateSteadyState()) {
+ run(id);
+ increaseTime(dt);
+ return;
+ }
+ double flow = wellProductionIndex * (Math.pow(getInletStream().getPressure("bara"), 2.0)
+ - Math.pow(thermoSystem.getPressure("bara"), 2.0));
+
+ outStream.setFlowRate(flow, "MSm3/day");
+ outStream.run();
+ }
+
+ public double getWellProductionIndex() {
+ return wellProductionIndex;
+ }
+
+ public void setWellProductionIndex(double wellProductionIndex) {
+ useWellProductionIndex = true;
+ this.wellProductionIndex = wellProductionIndex;
+ }
+
}
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/Adjuster.java b/src/main/java/neqsim/processSimulation/processEquipment/util/Adjuster.java
index ed9e6970ce..1d1e228047 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/util/Adjuster.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/util/Adjuster.java
@@ -23,6 +23,9 @@ public class Adjuster extends ProcessEquipmentBaseClass {
ProcessEquipmentInterface targetEquipment = null;
String adjustedVariable = "";
+ String adjustedVariableUnit = "";
+ double maxAdjustedValue = 1e10;
+ double minAdjustedValue = -1e10;
String targetVariable = "";
String targetPhase = "";
String targetComponent = "";
@@ -59,6 +62,22 @@ public Adjuster(String name) {
super(name);
}
+ /**
+ *
+ * setAdjustedVariable.
+ *
+ *
+ * @param adjustedEquipment a
+ * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object
+ * @param adjstedVariable a {@link java.lang.String} object
+ */
+ public void setAdjustedVariable(ProcessEquipmentInterface adjustedEquipment,
+ String adjstedVariable, String unit) {
+ this.adjustedEquipment = adjustedEquipment;
+ this.adjustedVariable = adjstedVariable;
+ this.adjustedVariableUnit = unit;
+ }
+
/**
*
* setAdjustedVariable.
@@ -144,6 +163,8 @@ public void run(UUID id) {
if (adjustedVariable.equals("mass flow")) {
inputValue = ((Stream) adjustedEquipment).getThermoSystem().getFlowRate("kg/hr");
+ } else if (adjustedVariable.equals("flow") && adjustedVariableUnit != null) {
+ inputValue = ((Stream) adjustedEquipment).getThermoSystem().getFlowRate(adjustedVariableUnit);
} else {
inputValue = ((Stream) adjustedEquipment).getThermoSystem().getNumberOfMoles();
}
@@ -177,6 +198,9 @@ public void run(UUID id) {
if (adjustedVariable.equals("mass flow")) {
((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue + deviation,
"kg/hr");
+ } else if (adjustedVariable.equals("flow") && adjustedVariableUnit != null) {
+ ((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(
+ inputValue + Math.signum(deviation) * inputValue / 100.0, adjustedVariableUnit);
} else {
((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue + deviation,
"mol/sec");
@@ -184,9 +208,20 @@ public void run(UUID id) {
} else {
double derivate = (error - oldError) / (inputValue - oldInputValue);
double newVal = error / derivate;
+ if (inputValue - newVal > maxAdjustedValue) {
+ newVal = inputValue - maxAdjustedValue;
+ error = 0;
+ }
+ if (inputValue - newVal < minAdjustedValue) {
+ newVal = inputValue - minAdjustedValue;
+ error = 0;
+ }
if (adjustedVariable.equals("mass flow")) {
((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue - newVal,
"kg/hr");
+ } else if (adjustedVariable.equals("flow") && adjustedVariableUnit != null) {
+ ((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue - newVal,
+ adjustedVariableUnit);
} else {
((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue - newVal,
"mol/sec");
@@ -305,4 +340,28 @@ public boolean isActivateWhenLess() {
public void setActivateWhenLess(boolean activateWhenLess) {
this.activateWhenLess = activateWhenLess;
}
+
+ public void setMaxAdjustedValue(double maxVal) {
+ maxAdjustedValue = maxVal;
+ if (maxAdjustedValue < minAdjustedValue) {
+ minAdjustedValue = maxAdjustedValue;
+ }
+ }
+
+ public void setMinAdjustedValue(double minVal) {
+ minAdjustedValue = minVal;
+ if (minAdjustedValue > maxAdjustedValue) {
+ maxAdjustedValue = minAdjustedValue;
+ }
+
+ }
+
+ public double getMaxAdjustedValue() {
+ return maxAdjustedValue;
+ }
+
+ public double getMinAdjustedValue() {
+ return minAdjustedValue;
+ }
+
}
diff --git a/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java b/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java
index c63a5a38f9..0879fb25bc 100644
--- a/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java
+++ b/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java
@@ -95,6 +95,38 @@ public void add(ProcessEquipmentInterface operation) {
}
}
+ /**
+ *
+ * add.
+ *
+ *
+ */
+ public void add(int position, ProcessEquipmentInterface operation) {
+ ArrayList units = this.getUnitOperations();
+
+ for (ProcessEquipmentInterface unit : units) {
+ if (unit == operation) {
+ return;
+ }
+ }
+
+ if (getAllUnitNames().contains(operation.getName())) {
+ String currClass = operation.getClass().getSimpleName();
+ int num = 1;
+ for (ProcessEquipmentInterface unit : units) {
+ if (unit.getClass().getSimpleName().equals(currClass)) {
+ num++;
+ }
+ }
+ operation.setName(currClass + Integer.toString(num));
+ }
+
+ getUnitOperations().add(position, operation);
+ if (operation instanceof ModuleInterface) {
+ ((ModuleInterface) operation).initializeModule();
+ }
+ }
+
/**
*
* add.
diff --git a/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java b/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java
new file mode 100644
index 0000000000..daef85468a
--- /dev/null
+++ b/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java
@@ -0,0 +1,192 @@
+package neqsim.processSimulation.processEquipment.reservoir;
+
+import org.junit.jupiter.api.Test;
+import neqsim.processSimulation.processEquipment.compressor.Compressor;
+import neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills;
+import neqsim.processSimulation.processEquipment.stream.StreamInterface;
+import neqsim.processSimulation.processEquipment.util.Adjuster;
+import neqsim.processSimulation.processEquipment.valve.ThrottlingValve;
+import neqsim.processSimulation.processSystem.ProcessSystem;
+
+public class WellFlowTest {
+ @Test
+ void testRun() {
+
+ neqsim.thermo.system.SystemInterface fluid1 =
+ new neqsim.thermo.system.SystemPrEos(373.15, 100.0);
+ fluid1.addComponent("water", 3.599);
+ fluid1.addComponent("nitrogen", 0.599);
+ fluid1.addComponent("CO2", 0.51);
+ fluid1.addComponent("methane", 62.8);
+ fluid1.addComponent("n-heptane", 12.8);
+ fluid1.setMixingRule(2);
+ fluid1.setMultiPhaseCheck(true);
+
+ SimpleReservoir reservoirOps = new SimpleReservoir("Well 1 reservoir");
+ reservoirOps.setReservoirFluid(fluid1, 1e9, 10.0, 10.0e7);
+
+ StreamInterface producedGasStream = reservoirOps.addGasProducer("gasproducer_1");
+ producedGasStream.setFlowRate(1.0, "MSm3/day");
+
+ WellFlow wellflow = new WellFlow("well flow unit");
+ wellflow.setInletStream(producedGasStream);
+ wellflow.setWellProductionIndex(5.000100751427403E-4);
+
+ ProcessSystem process = new ProcessSystem();
+ process.add(reservoirOps);
+ process.add(wellflow);
+
+ process.run();
+ /*
+ * System.out.println("production index " + wellflow.getWellProductionIndex() +
+ * " MSm3/day/bar^2"); System.out.println("reservoir pressure " +
+ * producedGasStream.getPressure("bara")); System.out .println("pres bottomhole " +
+ * wellflow.getOutletStream().getPressure("bara") + " bara");
+ */
+ }
+
+ @Test
+ void testRunTransient() {
+ neqsim.thermo.system.SystemInterface fluid1 =
+ new neqsim.thermo.system.SystemPrEos(373.15, 100.0);
+ fluid1.addComponent("water", 3.599);
+ fluid1.addComponent("nitrogen", 0.599);
+ fluid1.addComponent("CO2", 0.51);
+ fluid1.addComponent("methane", 62.8);
+ fluid1.setMixingRule(2);
+ fluid1.setMultiPhaseCheck(true);
+
+ SimpleReservoir reservoirOps = new SimpleReservoir("Well 1 reservoir");
+ reservoirOps.setReservoirFluid(fluid1, 1e9, 1.0, 10.0e7);
+ reservoirOps.setLowPressureLimit(10.0, "bara");
+
+ StreamInterface producedGasStream = reservoirOps.addGasProducer("gasproducer_1");
+ producedGasStream.setFlowRate(9.0, "MSm3/day");
+
+ WellFlow wellflow = new WellFlow("well flow unit");
+ wellflow.setInletStream(producedGasStream);
+ wellflow.setWellProductionIndex(10.000100751427403E-3);
+
+ PipeBeggsAndBrills pipe = new PipeBeggsAndBrills(wellflow.getOutletStream());
+ pipe.setPipeWallRoughness(5e-6);
+ pipe.setLength(300.0);
+ pipe.setElevation(300);
+ pipe.setDiameter(0.625);
+
+ PipeBeggsAndBrills pipeline = new PipeBeggsAndBrills(wellflow.getOutletStream());
+ pipeline.setPipeWallRoughness(5e-6);
+ pipeline.setLength(60000.0);
+ pipeline.setElevation(200);
+ pipeline.setDiameter(0.725);
+
+ ThrottlingValve chokeValve = new ThrottlingValve("chocke");
+ chokeValve.setInletStream(pipeline.getOutletStream());
+ chokeValve.setOutletPressure(55.0, "bara");
+
+
+ Adjuster adjuster = new Adjuster("adjuster");
+ adjuster.setTargetVariable(pipeline.getOutletStream(), "pressure",
+ chokeValve.getOutletPressure(), "bara");
+ adjuster.setAdjustedVariable(producedGasStream, "flow", "MSm3/day");
+ adjuster.setMaxAdjustedValue(9.0);
+ adjuster.setMinAdjustedValue(1.0);
+
+ ProcessSystem process = new ProcessSystem();
+ process.add(reservoirOps);
+ process.add(wellflow);
+ process.add(pipe);
+ process.add(pipeline);
+ process.add(adjuster);
+ process.run();
+ /*
+ * System.out.println("production flow rate " + producedGasStream.getFlowRate("MSm3/day"));
+ * System.out.println("production index " + wellflow.getWellProductionIndex() +
+ * " MSm3/day/bar^2"); System.out.println("reservoir pressure " +
+ * producedGasStream.getPressure("bara")); System.out .println("pres bottomhole " +
+ * wellflow.getOutletStream().getPressure("bara") + " bara");
+ * System.out.println("xmas pressure " + pipe.getOutletStream().getPressure("bara") + " bara");
+ * System.out .println("top side pressure " + pipeline.getOutletStream().getPressure("bara") +
+ * " bara");
+ */
+ // process.setTimeStep(60 * 60 * 24 * 365);
+
+ for (int i = 0; i < 10; i++) {
+ reservoirOps.runTransient(60 * 60 * 24 * 365);
+ process.run();
+ /*
+ * System.out.println("production flow rate " + producedGasStream.getFlowRate("MSm3/day"));
+ * System.out.println("reservoir pressure " + wellflow.getInletStream().getPressure("bara"));
+ * System.out .println("pres bottomhole " + wellflow.getOutletStream().getPressure("bara") +
+ * " bara");
+ *
+ * System.out.println("xmas pressure " + pipe.getOutletStream().getPressure("bara") +
+ * " bara"); System.out .println("top side pressure " +
+ * pipeline.getOutletStream().getPressure("bara") + " bara"); System.out
+ * .println("Total produced gas " + reservoirOps.getGasProductionTotal("GMSm3") + " GMSm3");
+ * System.out.println("gas velocity " + pipeline.getSuperficialVelocity());
+ */
+ }
+
+ Compressor compressor = new Compressor("subcomp");
+ compressor.setInletStream(pipe.getOutletStream());
+ compressor.setCompressionRatio(3.0);
+ pipeline.setInletStream(compressor.getOutletStream());
+
+ process.add(3, compressor);
+
+ for (int i = 0; i < 8; i++) {
+ reservoirOps.runTransient(60 * 60 * 24 * 365);
+ process.run();
+ /*
+ * System.out.println("Compressor in pressure " + compressor.getInletStream().getPressure() +
+ * " out pressure " + compressor.getOutletStream().getPressure() + " flow " +
+ * compressor.getInletStream().getFlowRate("m3/hr"));
+ * System.out.println("production flow rate " + producedGasStream.getFlowRate("MSm3/day"));
+ * System.out.println("reservoir pressure " + wellflow.getInletStream().getPressure("bara"));
+ * System.out .println("pres bottomhole " + wellflow.getOutletStream().getPressure("bara") +
+ * " bara");
+ *
+ * System.out.println("xmas pressure " + pipe.getOutletStream().getPressure("bara") +
+ * " bara"); System.out .println("top side pressure " +
+ * pipeline.getOutletStream().getPressure("bara") + " bara"); System.out
+ * .println("Total produced gas " + reservoirOps.getGasProductionTotal("GMSm3") + " GMSm3");
+ * System.out.println("gas velocity " + pipeline.getSuperficialVelocity());
+ */
+
+ }
+
+ adjuster.setMaxAdjustedValue(4.0);
+ adjuster.setTargetVariable(pipeline.getOutletStream(), "pressure", 22.0, "bara");
+ boolean reset = false;
+ for (int i = 0; i < 35; i++) {
+ if (wellflow.getOutletStream().getPressure("bara") > 15 || reset) {
+ reset = false;
+ reservoirOps.runTransient(60 * 60 * 24 * 365);
+ compressor.setOutletPressure(pipe.getOutletPressure() * 3.5);
+ process.run();
+ /*
+ * System.out.println("Compressor in pressure " + compressor.getInletStream().getPressure()
+ * + " out pressure " + compressor.getOutletStream().getPressure() + " flow " +
+ * compressor.getInletStream().getFlowRate("m3/hr"));
+ * System.out.println("production flow rate " + producedGasStream.getFlowRate("MSm3/day"));
+ * System.out.println("reservoir pressure " +
+ * wellflow.getInletStream().getPressure("bara")); System.out .println("pres bottomhole " +
+ * wellflow.getOutletStream().getPressure("bara") + " bara");
+ *
+ * System.out.println("xmas pressure " + pipe.getOutletStream().getPressure("bara") +
+ * " bara"); System.out.println( "top side pressure " +
+ * pipeline.getOutletStream().getPressure("bara") + " bara"); System.out.println(
+ * "Total produced gas " + reservoirOps.getGasProductionTotal("GMSm3") + " GMSm3");
+ * System.out.println("gas velocity " + pipeline.getSuperficialVelocity());
+ */
+ } else {
+ reset = true;
+ adjuster.setMaxAdjustedValue(adjuster.getMaxAdjustedValue() / 2.0);
+ adjuster.setMinAdjustedValue(adjuster.getMinAdjustedValue() / 2.0);
+ }
+
+ }
+ }
+
+
+}
From ba1b3381eb015c04f9651bfb4df3768547b4c160 Mon Sep 17 00:00:00 2001
From: Even Solbraa <41290109+EvenSol@users.noreply.github.com>
Date: Wed, 3 Jan 2024 00:24:28 +0100
Subject: [PATCH 13/15] update (#894)
---
.../reservoir/SimpleReservoir.java | 76 +++++++------------
.../reservoir/WellFlowTest.java | 26 +++++++
2 files changed, 52 insertions(+), 50 deletions(-)
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java
index 622308a51b..e20295fe14 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java
@@ -325,66 +325,42 @@ public void setReservoirFluid(SystemInterface thermoSystem, double gasVolume, do
this.gasVolume = gasVolume;
this.waterVolume = waterVolume;
- if (gasVolume > 1e-10 && oilVolume > 1e-10) {
- ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem);
+ ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem);
+ ops.TPflash();
+
+ if (waterVolume > 1e-10 && !thermoSystem.hasPhaseType("aqueous")) {
+ thermoSystem.addComponent("water", thermoSystem.getTotalNumberOfMoles());
ops.TPflash();
- thermoSystem.initProperties();
- SystemInterface thermoSystem2 = thermoSystem.clone();
- thermoSystem.setEmptyFluid();
- for (int j = 0; j < thermoSystem.getNumberOfPhases(); j++) {
- double relFact = gasVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5);
- if (j >= 1) {
- if (j == 1) {
- relFact = oilVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5);
- // totalliquidVolume += oilVolume / thermoSystem2.getPhase(j).getMolarVolume();
- } else if (j == 2) {
- relFact = waterVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5);
- // totalliquidVolume += waterVolume /
- // thermoSystem2.getPhase(j).getMolarVolume();
- }
- }
- for (int i = 0; i < thermoSystem.getPhase(j).getNumberOfComponents(); i++) {
- thermoSystem.addComponent(thermoSystem.getPhase(j).getComponent(i).getComponentNumber(),
- relFact * thermoSystem2.getPhase(j).getComponent(i).getNumberOfMolesInPhase(), j);
- }
+ }
+
+ thermoSystem.initProperties();
+ SystemInterface thermoSystem2 = thermoSystem.clone();
+ thermoSystem.setEmptyFluid();
+ for (int j = 0; j < thermoSystem.getNumberOfPhases(); j++) {
+ String phaseType = thermoSystem.getPhase(j).getPhaseTypeName();
+ double relFact = gasVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5);
+ if (phaseType.equals("oil")) {
+ relFact = oilVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5);
+ // totalliquidVolume += oilVolume / thermoSystem2.getPhase(j).getMolarVolume();
+ } else if (phaseType.equals("aqueous")) {
+ relFact = waterVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5);
+ } else {
+ relFact = gasVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5);
}
- } else {
- ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem);
- ops.TPflash();
- thermoSystem.initProperties();
- SystemInterface thermoSystem2 = thermoSystem.clone();
- thermoSystem.setEmptyFluid();
- double relFact = (gasVolume + oilVolume) / (thermoSystem2.getPhase("oil").getVolume("m3"));
- for (int i = 0; i < thermoSystem.getNumberOfComponents(); i++) {
- thermoSystem.addComponent(thermoSystem.getComponent(i).getComponentNumber(),
- relFact * thermoSystem2.getComponent(i).getNumberOfMolesInPhase());
+ for (int i = 0; i < thermoSystem.getPhase(j).getNumberOfComponents(); i++) {
+ thermoSystem.addComponent(thermoSystem.getPhase(j).getComponent(i).getComponentNumber(),
+ relFact * thermoSystem2.getPhase(j).getComponent(i).getNumberOfMolesInPhase(), j);
}
- double relFactWater = (waterVolume) / (thermoSystem2.getPhase("aqueous").getVolume("m3"));
- thermoSystem.addComponent("water", relFactWater
- * thermoSystem2.getPhase("aqueous").getComponent("water").getNumberOfMolesInPhase());
}
- /*
- * if (thermoSystem.hasPhaseType("gas")) { thermoSystem.setBeta(gasVolume /
- * thermoSystem2.getPhase(0).getMolarVolume() / (gasVolume /
- * thermoSystem2.getPhase(0).getMolarVolume() + oilVolume /
- * thermoSystem2.getPhase(1).getMolarVolume())); }
- */
+
ThermodynamicOperations ops2 = new ThermodynamicOperations(thermoSystem);
ops2.TPflash();
thermoSystem.initProperties();
- // thermoSystem.display();
- // gasOutStream = new Stream();
- // gasOutStream.setFluid(thermoSystem.phaseToSystem("gas"));
reservoirVolume = gasVolume + oilVolume + waterVolume;
- OOIP =
-
- getOilInPlace("Sm3");
+ OOIP = getOilInPlace("Sm3");
OGIP = getGasInPlace("Sm3");
- // oilOutStream = new Stream();
- // oilOutStream.setFluid(thermoSystem.phaseToSystem("oil"));
-
lowPressureLimit = 50.0;
}
@@ -867,6 +843,6 @@ public void setLowPressureLimit(double value, String unit) {
public double getLowPressureLimit(String unit) {
PressureUnit conver = new PressureUnit(lowPressureLimit, "bara");
- return conver.getValue(unit);
+ return conver.getValue(unit);
}
}
diff --git a/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java b/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java
index daef85468a..7467c8ddcb 100644
--- a/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java
+++ b/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java
@@ -188,5 +188,31 @@ void testRunTransient() {
}
}
+ @Test
+ void testCalcWellFlow() {
+ neqsim.thermo.system.SystemInterface fluid1 =
+ new neqsim.thermo.system.SystemPrEos(373.15, 100.0);
+ fluid1.addComponent("water", 3.599);
+ fluid1.addComponent("nitrogen", 0.599);
+ fluid1.addComponent("CO2", 0.51);
+ fluid1.addComponent("methane", 62.8);
+ fluid1.setMixingRule(2);
+ fluid1.setMultiPhaseCheck(true);
+
+ SimpleReservoir reservoirOps = new SimpleReservoir("Well 1 reservoir");
+ reservoirOps.setReservoirFluid(fluid1, 1e9, 1.0, 10.0e7);
+ reservoirOps.setLowPressureLimit(10.0, "bara");
+
+ StreamInterface producedGasStream = reservoirOps.addGasProducer("gasproducer_1");
+ producedGasStream.setFlowRate(9.0, "MSm3/day");
+
+ WellFlow wellflow = new WellFlow("well flow unit");
+ wellflow.setInletStream(producedGasStream);
+
+ double permeability = 50.0; // milli darcy
+ // wellflow.setDarcyLawParameters(permeability, );
+ // wellflow.setWellProductionIndex(10.000100751427403E-3);
+ }
+
}
From 56300fff96ac3cec73a3acf15e309f77f0e781a8 Mon Sep 17 00:00:00 2001
From: Even Solbraa <41290109+EvenSol@users.noreply.github.com>
Date: Thu, 4 Jan 2024 08:44:56 +0100
Subject: [PATCH 14/15] version 2.5.15 (#895)
* Update pom.xml
* Update pomJava21.xml
* Update pomJava8.xml
---
pom.xml | 2 +-
pomJava21.xml | 2 +-
pomJava8.xml | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index 2a24fe486d..8eb17538ae 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
${revision}${sha1}${changelist}
- 2.5.14
+ 2.5.15
UTF-8
UTF-8
diff --git a/pomJava21.xml b/pomJava21.xml
index 2bfd6e902c..e05bea9a32 100644
--- a/pomJava21.xml
+++ b/pomJava21.xml
@@ -10,7 +10,7 @@
${revision}${sha1}${changelist}
- 2.5.14
+ 2.5.15
UTF-8
UTF-8
diff --git a/pomJava8.xml b/pomJava8.xml
index fc22d72c74..953f0ebd20 100644
--- a/pomJava8.xml
+++ b/pomJava8.xml
@@ -10,7 +10,7 @@
${revision}${sha1}${changelist}-Java8
- 2.5.14
+ 2.5.15
UTF-8
UTF-8
From d41488720c9b785b07c896a68c239ea4f0108b3d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?=
<34712686+asmfstatoil@users.noreply.github.com>
Date: Thu, 4 Jan 2024 14:05:50 +0100
Subject: [PATCH 15/15] Update release_with_jars.yml
---
.github/workflows/release_with_jars.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/release_with_jars.yml b/.github/workflows/release_with_jars.yml
index 4685165648..14e020ea80 100644
--- a/.github/workflows/release_with_jars.yml
+++ b/.github/workflows/release_with_jars.yml
@@ -110,9 +110,9 @@ jobs:
- name: Build java 21 version with Maven
run: mvn -B package --file pomJava21.xml
- name: Rename files
- run: cd target && find . -type f -name "neqsim-*.jar" -exec sh -c 'mv -f $0 ${0%.jar}-Java21.jar' {} \;
+ run: cd target && find . -type f -name "neqsim-*.jar" -exec sh -c 'mv -f $0 ${0%.jar}-Java21.jar' {} \; && cd ..
- name: Copy jar file to staging
- run: cd .. && mkdir staging && cp target/neqsim*Java21.jar staging
+ run: mkdir staging && cp target/neqsim*Java21.jar staging
- uses: actions/upload-artifact@v2
with:
name: jarfiles