From 38a920770a51acaeeba8c33721752131b7bb4b6f Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Thu, 30 Jun 2022 08:17:23 +0200 Subject: [PATCH 1/5] fixed bug in TPflash. Added TVflash test --- .../flashOps/TPflash.java | 3 +- .../flashOps/TVFlashTest.java | 72 +++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 src/test/java/neqsim/thermodynamicOperations/flashOps/TVFlashTest.java diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPflash.java index 33355ac09..016fccd6e 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPflash.java @@ -166,6 +166,7 @@ public void setNewK() { *

*/ public void resetK() { + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { lnK[i] = lnOldK[i]; system.getPhase(0).getComponents()[i].setK(Math.exp(lnK[i])); @@ -402,7 +403,7 @@ public void run() { gibbsEnergy = system.getGibbsEnergy(); if ((gibbsEnergy - gibbsEnergyOld) / Math.abs(gibbsEnergyOld) > 1e-3 - && !system.isChemicalSystem()) { + && !system.isChemicalSystem() && timeFromLastGibbsFail>0) { resetK(); timeFromLastGibbsFail = 0; // logger.info("gibbs decrease " + (gibbsEnergy - gibbsEnergyOld) / diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/TVFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/TVFlashTest.java new file mode 100644 index 000000000..a396e02a5 --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/TVFlashTest.java @@ -0,0 +1,72 @@ +/** + * + */ +package neqsim.thermodynamicOperations.flashOps; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +/** + * @author ESOL + * + */ +class TVFlashTest { + + static neqsim.thermo.system.SystemInterface testSystem = null; + static neqsim.thermo.system.SystemInterface testSystem2 = null; + static ThermodynamicOperations testOps = null; + + /** + * @throws java.lang.Exception + */ + @BeforeEach + void setUp() throws Exception { + testSystem = new neqsim.thermo.system.SystemUMRPRUMCEos(293.15, 0.1); + testSystem.addComponent("methane", 0.0); + testSystem.addComponent("ethane", 0.0); + testSystem.addComponent("n-pentane", 9E-1); + testSystem.addComponent("nC16", 1E-1); + testSystem.setMixingRule("classic"); + testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + testSystem.setTotalFlowRate(1.0, "kg/sec"); + testOps.TPflash(); + testSystem.initProperties(); + + testSystem2 = new neqsim.thermo.system.SystemUMRPRUMCEos(293.15, 0.1); + testSystem2.addComponent("methane", 8.5E-1); + testSystem2.addComponent("ethane", 1.5E-1); + testSystem2.addComponent("n-pentane", 0); + testSystem2.addComponent("nC16", 0); + testSystem2.setMixingRule("classic"); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem2); + testOps.TPflash(); + testSystem2.initProperties(); + testSystem2.setTotalFlowRate(0.3, "kg/sec"); + testOps.TPflash(); + testSystem2.initProperties(); + } + + @Test + void testTVflash() { + double total_rig_volume = 0.998; + + for(int i=0;i<50;i++) { + testSystem.addFluid(testSystem2); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + try { + testOps.TVflash(total_rig_volume, "m3"); + } + catch(Exception e) { + System.out.println("error iterations " + i); + e.printStackTrace(); + } + } + assertEquals(235263.80103781424, testSystem.getEnthalpy(), 1e-2); + } + + } + From 78f530cb1320f4751c2d26060f219e127cdc54a4 Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Thu, 30 Jun 2022 12:31:33 +0200 Subject: [PATCH 2/5] update splitter/MPM --- .../measurementDevice/MultiPhaseMeter.java | 288 +++++++++--------- .../processEquipment/splitter/Splitter.java | 272 +++++++++-------- 2 files changed, 290 insertions(+), 270 deletions(-) diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java b/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java index b13275182..594dee297 100644 --- a/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java +++ b/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java @@ -1,5 +1,8 @@ package neqsim.processSimulation.measurementDevice; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import neqsim.processSimulation.processEquipment.splitter.Splitter; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermo.system.SystemInterface; @@ -15,106 +18,108 @@ * @version $Id: $Id */ public class MultiPhaseMeter extends MeasurementDeviceBaseClass { - private static final long serialVersionUID = 1000; - - protected StreamInterface stream = null; - double pressure = 10.0, temperature = 298.15; - String unitT, unitP; - - public MultiPhaseMeter() { - name = "Multi Phase Meter"; - } - - /** - *

- * Constructor for MultiPhaseMeter. - *

- * - * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public MultiPhaseMeter(StreamInterface stream) { - this(); - name = "Multi Phase Meter"; - this.stream = stream; - } - - /** - *

- * Constructor for MultiPhaseMeter. - *

- * - * @param name a {@link java.lang.String} object - * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public MultiPhaseMeter(String name, StreamInterface stream) { - this(); - this.name = name; - this.stream = stream; - } - - /** - *

- * Getter for the field pressure. - *

- * - * @return a double - */ - public double getPressure() { - return pressure; - } - - /** - *

- * Setter for the field pressure. - *

- * - * @param pressure a double - * @param unitP a {@link java.lang.String} object - */ - public void setPressure(double pressure, String unitP) { - this.pressure = pressure; - this.unitP = unitP; - } - - /** - *

- * getTemperature. - *

- * - * @return a double - */ - public double getTemperature() { - return temperature; - } - - /** - *

- * Setter for the field temperature. - *

- * - * @param temperature a double - * @param unitT a {@link java.lang.String} object - */ - public void setTemperature(double temperature, String unitT) { - this.temperature = temperature; - this.unitT = unitT; - } - - /** {@inheritDoc} */ - @Override - public double getMeasuredValue() { - return stream.getThermoSystem().getFlowRate("kg/hr"); - } - - /** {@inheritDoc} */ + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(MultiPhaseMeter.class); + protected StreamInterface stream = null; + double pressure = 10.0, temperature = 298.15; + String unitT, unitP; + + public MultiPhaseMeter() { + name = "Multi Phase Meter"; + } + + /** + *

+ * Constructor for MultiPhaseMeter. + *

+ * + * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public MultiPhaseMeter(StreamInterface stream) { + this(); + name = "Multi Phase Meter"; + this.stream = stream; + } + + /** + *

+ * Constructor for MultiPhaseMeter. + *

+ * + * @param name a {@link java.lang.String} object + * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public MultiPhaseMeter(String name, StreamInterface stream) { + this(); + this.name = name; + this.stream = stream; + } + + /** + *

+ * Getter for the field pressure. + *

+ * + * @return a double + */ + public double getPressure() { + return pressure; + } + + /** + *

+ * Setter for the field pressure. + *

+ * + * @param pressure a double + * @param unitP a {@link java.lang.String} object + */ + public void setPressure(double pressure, String unitP) { + this.pressure = pressure; + this.unitP = unitP; + } + + /** + *

+ * getTemperature. + *

+ * + * @return a double + */ + public double getTemperature() { + return temperature; + } + + /** + *

+ * Setter for the field temperature. + *

+ * + * @param temperature a double + * @param unitT a {@link java.lang.String} object + */ + public void setTemperature(double temperature, String unitT) { + this.temperature = temperature; + this.unitT = unitT; + } + + /** {@inheritDoc} */ + @Override + public double getMeasuredValue() { + return stream.getThermoSystem().getFlowRate("kg/hr"); + } + + /** {@inheritDoc} */ @Override public double getMeasuredValue(String measurement) { if (measurement.equals("mass rate")) { return stream.getThermoSystem().getFlowRate("kg/hr"); } - + + if(stream.getThermoSystem().getFlowRate("kg/hr")<1e-10) { + return Double.NaN; + } + if (measurement.equals("GOR")) { SystemInterface tempFluid = stream.getThermoSystem().clone(); tempFluid.setTemperature(temperature, unitT); @@ -123,11 +128,12 @@ public double getMeasuredValue(String measurement) { try { thermoOps.TPflash(); } catch (Exception e) { - e.printStackTrace(); + logger.error(e.getStackTrace()); + return Double.NaN; } // tempFluid.display(); if (!tempFluid.hasPhaseType("gas")) { - return 0.0; + return Double.NaN; } if (!tempFluid.hasPhaseType("oil")) { return Double.NaN; @@ -145,7 +151,8 @@ public double getMeasuredValue(String measurement) { try { thermoOps.TPflash(); } catch (Exception e) { - e.printStackTrace(); + logger.error(e.getStackTrace()); + return Double.NaN; } tempFluid.initPhysicalProperties(); if (measurement.equals("gasDensity")) { @@ -178,11 +185,12 @@ public double getMeasuredValue(String measurement) { try { thermoOps.TPflash(); } catch (Exception e) { - e.printStackTrace(); + logger.error(e.getStackTrace()); + return Double.NaN; } // tempFluid.display(); if (!tempFluid.hasPhaseType("gas")) { - return 0.0; + return Double.NaN; } if (!tempFluid.hasPhaseType("oil")) { return Double.NaN; @@ -194,44 +202,44 @@ public double getMeasuredValue(String measurement) { return 0.0; } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - SystemInterface testFluid = new SystemSrkEos(338.15, 50.0); - testFluid.addComponent("nitrogen", 1.205); - testFluid.addComponent("CO2", 1.340); - testFluid.addComponent("methane", 87.974); - testFluid.addComponent("ethane", 5.258); - testFluid.addComponent("propane", 3.283); - testFluid.addComponent("i-butane", 0.082); - testFluid.addComponent("n-butane", 0.487); - testFluid.addComponent("i-pentane", 0.056); - testFluid.addComponent("n-pentane", 1.053); - testFluid.addComponent("nC10", 4.053); - testFluid.setMixingRule(2); - testFluid.setMultiPhaseCheck(true); - - testFluid.setTemperature(24.0, "C"); - testFluid.setPressure(48.0, "bara"); - testFluid.setTotalFlowRate(4.5, "MSm3/day"); - - Stream stream_1 = new Stream("Stream1", testFluid); - - MultiPhaseMeter multiPhaseMeter = new MultiPhaseMeter("test", stream_1); - multiPhaseMeter.setTemperature(90.0, "C"); - multiPhaseMeter.setPressure(60.0, "bara"); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - operations.add(multiPhaseMeter); - operations.run(); - System.out.println("GOR " + multiPhaseMeter.getMeasuredValue("GOR")); - System.out.println("GOR_std " + multiPhaseMeter.getMeasuredValue("GOR_std")); - } + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + SystemInterface testFluid = new SystemSrkEos(338.15, 50.0); + testFluid.addComponent("nitrogen", 1.205); + testFluid.addComponent("CO2", 1.340); + testFluid.addComponent("methane", 87.974); + testFluid.addComponent("ethane", 5.258); + testFluid.addComponent("propane", 3.283); + testFluid.addComponent("i-butane", 0.082); + testFluid.addComponent("n-butane", 0.487); + testFluid.addComponent("i-pentane", 0.056); + testFluid.addComponent("n-pentane", 1.053); + testFluid.addComponent("nC10", 4.053); + testFluid.setMixingRule(2); + testFluid.setMultiPhaseCheck(true); + + testFluid.setTemperature(24.0, "C"); + testFluid.setPressure(48.0, "bara"); + testFluid.setTotalFlowRate(4.5, "MSm3/day"); + + Stream stream_1 = new Stream("Stream1", testFluid); + + MultiPhaseMeter multiPhaseMeter = new MultiPhaseMeter("test", stream_1); + multiPhaseMeter.setTemperature(90.0, "C"); + multiPhaseMeter.setPressure(60.0, "bara"); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(multiPhaseMeter); + operations.run(); + System.out.println("GOR " + multiPhaseMeter.getMeasuredValue("GOR")); + System.out.println("GOR_std " + multiPhaseMeter.getMeasuredValue("GOR_std")); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/splitter/Splitter.java b/src/main/java/neqsim/processSimulation/processEquipment/splitter/Splitter.java index 4a13f35b6..b44d290b4 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/splitter/Splitter.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/splitter/Splitter.java @@ -1,6 +1,9 @@ package neqsim.processSimulation.processEquipment.splitter; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; +import neqsim.processSimulation.processEquipment.compressor.Compressor; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermo.system.SystemInterface; @@ -15,149 +18,158 @@ * @version $Id: $Id */ public class Splitter extends ProcessEquipmentBaseClass implements SplitterInterface { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(Splitter.class); + SystemInterface thermoSystem, gasSystem, waterSystem, liquidSystem, thermoSystemCloned; + StreamInterface inletStream; + StreamInterface[] splitStream; + protected int splitNumber = 1; + double[] splitFactor = new double[1]; - SystemInterface thermoSystem, gasSystem, waterSystem, liquidSystem, thermoSystemCloned; - StreamInterface inletStream; - StreamInterface[] splitStream; - protected int splitNumber = 1; - double[] splitFactor = new double[1]; + /** + *

+ * Constructor for Splitter. + *

+ */ + public Splitter() { + super("Splitter"); + } - /** - *

- * Constructor for Splitter. - *

- */ - public Splitter() { - super("Splitter"); - } + /** + *

+ * Constructor for Splitter. + *

+ * + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + @Deprecated + public Splitter(StreamInterface inletStream) { + this(); + this.setInletStream(inletStream); + } - /** - *

- * Constructor for Splitter. - *

- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public Splitter(StreamInterface inletStream) { - this(); - this.setInletStream(inletStream); - } + /** + * Constructor for Splitter. + * + * @param name + */ + public Splitter(String name) { + super(name); + } - /** - * Constructor for Splitter. - * - * @param name - */ - public Splitter(String name) { - super(name); - } + /** + * Constructor for Splitter. + * + * @param name + * @param inStream + */ + public Splitter(String name, StreamInterface inStream) { + this(name); + this.setInletStream(inStream); + } - /** - * Constructor for Splitter. - * - * @param name - * @param inStream - */ - public Splitter(String name, StreamInterface inStream) { - this(name); - this.setInletStream(inStream); - } + /** + *

+ * Constructor for Splitter. + *

+ * + * @param name a {@link java.lang.String} object + * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + * @param i a int + */ + public Splitter(String name, StreamInterface inletStream, int i) { + this(name); + setSplitNumber(i); + this.setInletStream(inletStream); + } - /** - *

- * Constructor for Splitter. - *

- * - * @param name a {@link java.lang.String} object - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - * @param i a int - */ - public Splitter(String name, StreamInterface inletStream, int i) { - this(name); - setSplitNumber(i); - this.setInletStream(inletStream); - } + /** {@inheritDoc} */ + @Override + public void setSplitNumber(int i) { + splitNumber = i; + splitFactor = new double[splitNumber]; + splitFactor[0] = 1.0; + } - /** {@inheritDoc} */ - @Override - public void setSplitNumber(int i) { - splitNumber = i; - splitFactor = new double[splitNumber]; - splitFactor[0] = 1.0; + /** + *

+ * setSplitFactors. + *

+ * + * @param splitFact an array of {@link double} objects + */ + public void setSplitFactors(double[] splitFact) { + double sum = 0.0; + for (int i = 0; i < splitFact.length; i++) { + if (splitFact[i] < 0.0) { + splitFact[i] = 0.0; + } + sum += splitFact[i]; } - - /** - *

- * setSplitFactors. - *

- * - * @param splitFact an array of {@link double} objects - */ - public void setSplitFactors(double[] splitFact) { - double sum = 0.0; - for (int i = 0; i < splitFact.length; i++) { - if (splitFact[i] < 0.0) { - splitFact[i] = 0.0; - } - sum += splitFact[i]; - } - splitFactor = new double[splitFact.length]; - for (int i = 0; i < splitFact.length; i++) { - splitFactor[i] = splitFact[i] / sum; - } - splitNumber = splitFact.length; - setInletStream(inletStream); + splitFactor = new double[splitFact.length]; + for (int i = 0; i < splitFact.length; i++) { + splitFactor[i] = splitFact[i] / sum; } + splitNumber = splitFact.length; + setInletStream(inletStream); + } - /** {@inheritDoc} */ - @Override - public void setInletStream(StreamInterface inletStream) { - this.inletStream = inletStream; - splitStream = new Stream[splitNumber]; - try { - for (int i = 0; i < splitNumber; i++) { - // System.out.println("splitting...." + i); - splitStream[i] = new Stream("Split Stream", inletStream.getThermoSystem().clone()); - } - } catch (Exception e) { - e.printStackTrace(); - } + /** {@inheritDoc} */ + @Override + public void setInletStream(StreamInterface inletStream) { + this.inletStream = inletStream; + splitStream = new Stream[splitNumber]; + try { + for (int i = 0; i < splitNumber; i++) { + // System.out.println("splitting...." + i); + splitStream[i] = new Stream("Split Stream", inletStream.getThermoSystem().clone()); + } + } catch (Exception e) { + e.printStackTrace(); } + } - /** {@inheritDoc} */ - @Override - public StreamInterface getSplitStream(int i) { - return splitStream[i]; - } + /** {@inheritDoc} */ + @Override + public StreamInterface getSplitStream(int i) { + return splitStream[i]; + } - /** {@inheritDoc} */ - @Override - public void run() { - for (int i = 0; i < splitNumber; i++) { - thermoSystem = inletStream.getThermoSystem().clone(); - thermoSystem.init(0); - splitStream[i].setThermoSystem(thermoSystem); - for (int j = 0; j < inletStream.getThermoSystem().getPhase(0) - .getNumberOfComponents(); j++) { - int index = inletStream.getThermoSystem().getPhase(0).getComponent(j) - .getComponentNumber(); - double moles = inletStream.getThermoSystem().getPhase(0).getComponent(j) - .getNumberOfmoles(); - splitStream[i].getThermoSystem().addComponent(index, - moles * splitFactor[i] - moles); - } - ThermodynamicOperations thermoOps = - new ThermodynamicOperations(splitStream[i].getThermoSystem()); - thermoOps.TPflash(); - } + /** {@inheritDoc} */ + @Override + public void run() { + double totSplit = 0.0; + for (int i = 0; i < splitNumber; i++) { + if(splitFactor[i]<0) { + logger.debug("split factor negative = " + splitFactor[i]); + splitFactor[i] = 0.0; + } + totSplit += splitFactor[i]; } - - /** {@inheritDoc} */ - @Override - public void displayResult() { + if(Math.abs(totSplit-1.0)>1e-10) { + logger.debug("total split factor different from 0 in splitter - totsplit = " + totSplit); + logger.debug("setting first split to = " + (1.0 - totSplit)); + splitFactor[0] = 1.0 - totSplit; } + + for (int i = 0; i < splitNumber; i++) { + thermoSystem = inletStream.getThermoSystem().clone(); + thermoSystem.init(0); + splitStream[i].setThermoSystem(thermoSystem); + for (int j = 0; j < inletStream.getThermoSystem().getPhase(0).getNumberOfComponents(); j++) { + int index = inletStream.getThermoSystem().getPhase(0).getComponent(j).getComponentNumber(); + double moles = inletStream.getThermoSystem().getPhase(0).getComponent(j).getNumberOfmoles(); + splitStream[i].getThermoSystem().addComponent(index, moles * splitFactor[i] - moles); + } + ThermodynamicOperations thermoOps = + new ThermodynamicOperations(splitStream[i].getThermoSystem()); + thermoOps.TPflash(); + } + } + + /** {@inheritDoc} */ + @Override + public void displayResult() {} } From fe1d6a9595f656bb1975fb1bd965aefcc86d8276 Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Thu, 30 Jun 2022 14:05:22 +0200 Subject: [PATCH 3/5] updates to MPM calc --- .../measurementDevice/MultiPhaseMeter.java | 1 - .../processEquipment/util/GORfitter.java | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java b/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java index 594dee297..51292af95 100644 --- a/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java +++ b/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java @@ -188,7 +188,6 @@ public double getMeasuredValue(String measurement) { logger.error(e.getStackTrace()); return Double.NaN; } - // tempFluid.display(); if (!tempFluid.hasPhaseType("gas")) { return Double.NaN; } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java b/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java index cd336072e..f2a7b10a2 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java @@ -200,9 +200,17 @@ public void run() { e.printStackTrace(); } outStream.setThermoSystem(tempFluid); + if(!tempFluid.hasPhaseType("gas")) { + GVF = 0.0; + } + else if(tempFluid.hasPhaseType("gas") && tempFluid.hasPhaseType("oil")) { GVF = tempFluid.getPhase("gas").getCorrectedVolume() / (tempFluid.getPhase("oil").getCorrectedVolume() + tempFluid.getPhase("gas").getCorrectedVolume()); + } + else { + GVF = Double.NaN; + } return; } From 8625e8d792e8baf02876e30cca82919b3b3085cb Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Fri, 1 Jul 2022 11:25:52 +0200 Subject: [PATCH 4/5] Update TVflash.java --- .../java/neqsim/thermodynamicOperations/flashOps/TVflash.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java index 2499384fc..556d816f7 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java @@ -90,9 +90,7 @@ public double solveQ() { } system.setPressure(nyPres); tpFlash.run(); - // System.out.println(" dQdv " + calcdQdV() + " new pressure " + nyPres + " - // error " + Math.abs((nyPres-oldPres)/(nyPres)) + " - // numberofphases"+system.getNumberOfPhases()); + // System.out.println(" dQdv " + calcdQdV() + " new pressure " + nyPres + " error " + Math.abs((nyPres-oldPres)/(nyPres)) + " numberofphases "+system.getNumberOfPhases()); } while (Math.abs((nyPres - oldPres) / (nyPres)) > 1e-9 && iterations < 1000 || iterations < 3); return nyPres; From ba0304f906988a7312669de8cf35cc2dfddcf1ff Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Thu, 7 Jul 2022 12:21:00 +0200 Subject: [PATCH 5/5] update from master (#459) * fixed bug in TPflash. Added TVflash test (#454) * Fix Splitter/MPM error (#455) * fixed bug in TPflash. Added TVflash test * update splitter/MPM * updates to MPM calc