diff --git a/.github/workflows/release_with_jars.yml b/.github/workflows/release_with_jars.yml
index a31bdd8406..14e020ea80 100644
--- a/.github/workflows/release_with_jars.yml
+++ b/.github/workflows/release_with_jars.yml
@@ -90,7 +90,34 @@ 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: Rename files
+ 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: 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 e249b2ed28..8eb17538ae 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
update.
- * getFileWriter.
- *
* 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.
- *
- * Constructor for FileWriterBaseClass.
- *
- * FileWriterInterface interface.
- *
- * OnePhaseFileWriter class.
- *
- * Constructor for OnePhaseFileWriter.
- *
- * PipeFlowFileWriter class.
- *
- * Constructor for PipeFlowFileWriter.
- *
- * TwoPhaseFileWriter class.
- *
- * Constructor for TwoPhaseFileWriter.
- *
- * TwoPhasePipeFlowFileWriter class.
- *
- * Constructor for TwoPhasePipeFlowFileWriter.
- *
@@ -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..9b7f9fd2b6 100644
--- a/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java
+++ b/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java
@@ -128,4 +128,24 @@ public default void runTransient(double initResponse, double dt) {
/** {@inheritDoc} */
@Override
public int hashCode();
+
+ /**
+ *
+ * setActive.
+ *
+ * isActive.
+ *
+ * CompressorMonitor class.
+ *
+ * Constructor for CompressorMonitor.
+ *
+ * Constructor for CompressorMonitor.
+ *
* isStoneWall.
@@ -985,9 +1042,9 @@ public void setAntiSurge(AntiSurge antiSurge) {
* Getter for the field
+ * runController.
+ *
* 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/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.
+ *
* 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.
+ *
+ * setAdjustedVariable.
+ *
* 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/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 e9a6dc02dc..a845fc77b7 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java
@@ -310,14 +310,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());
}
@@ -339,7 +339,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/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.
+ *
* add.
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.
+ * Constructor for CompressorResponse.
+ * Constructor for CompressorResponse.
+ * Constructor for CompressorResponse.
+ * Constructor for CompressorResponse.
+ *
*
- * @param maxErr Maximum error before test will report failed Set maximum allowed error in model
- * check
- * speed
.
*
+ * 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/processSimulation/processEquipment/reservoir/WellFlowTest.java b/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java new file mode 100644 index 0000000000..7467c8ddcb --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java @@ -0,0 +1,218 @@ +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); + } + + } + } + + @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); + } + + +} 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(); + } } + } 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); + + } } 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 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);