From 2689c033fd5bef7700aa7bf0fada3980f58bb79b Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Sun, 5 May 2024 11:56:27 +0000 Subject: [PATCH 1/7] updated diff lib simulation and test --- .../simulation/BasePVTsimulation.java | 16 +++- .../simulation/DifferentialLiberation.java | 94 +++++++++---------- .../simulation/SaturationPressure.java | 5 + .../simulation/SimulationInterface.java | 10 ++ .../DifferentialLiberationTest.java | 59 ++++++++++-- 5 files changed, 129 insertions(+), 55 deletions(-) diff --git a/src/main/java/neqsim/PVTsimulation/simulation/BasePVTsimulation.java b/src/main/java/neqsim/PVTsimulation/simulation/BasePVTsimulation.java index 1f36923035..b5b6da66ce 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/BasePVTsimulation.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/BasePVTsimulation.java @@ -18,12 +18,13 @@ public class BasePVTsimulation implements SimulationInterface { public ThermodynamicOperations thermoOps = null; private double pressure; public double[] pressures = {381.5, 338.9, 290.6, 242.3, 194.1, 145.8, 145.8, 97.5, 49.3}; - public double temperature = 289.0; + public double temperature = Double.NaN; double[][] experimentalData = null; double saturationVolume = 0; double saturationPressure = 0; double saturationTemperature; double Zsaturation = 0; + String temperatureUnit = "K"; public LevenbergMarquardt optimizer = new LevenbergMarquardt(); /** @@ -129,6 +130,19 @@ public void setTemperature(double temperature) { this.temperature = temperature; } + /** + *

+ * Setter for the field temperature. + *

+ * + * @param temperature the temperature to set + * @param temperatureUnit the unit of temperature as string + */ + public void setTemperature(double temperature, String temperatureUnit) { + this.temperature = temperature; + this.temperatureUnit = temperatureUnit; + } + /** *

* Getter for the field pressures. diff --git a/src/main/java/neqsim/PVTsimulation/simulation/DifferentialLiberation.java b/src/main/java/neqsim/PVTsimulation/simulation/DifferentialLiberation.java index 248516c045..c0f3dee1bb 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/DifferentialLiberation.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/DifferentialLiberation.java @@ -3,6 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.thermo.ThermodynamicConstantsInterface; +import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; @@ -77,7 +78,9 @@ public void calcSaturationConditions() { * try { thermoOps.dewPointPressureFlash(); } catch (Exception ex) { * logger.error(ex.getMessage(), ex); } */ - saturationVolume = getThermoSystem().getVolume(); + getThermoSystem().initPhysicalProperties(); + saturationVolume = getThermoSystem().getPhase(0).getMass() + / getThermoSystem().getPhase(0).getPhysicalProperties().getDensity(); saturationPressure = getThermoSystem().getPressure(); saturationConditionFound = true; } @@ -90,6 +93,7 @@ public void calcSaturationConditions() { public void runCalc() { saturationConditionFound = false; relativeVolume = new double[pressures.length]; + double[] mass = new double[pressures.length]; totalVolume = new double[pressures.length]; liquidVolumeRelativeToVsat = new double[pressures.length]; liquidVolume = new double[pressures.length]; @@ -103,7 +107,9 @@ public void runCalc() { oilDensity = new double[pressures.length]; double totalGasStandardVolume = 0; - getThermoSystem().setTemperature(temperature); + if (!Double.isNaN(temperature)) { + getThermoSystem().setTemperature(temperature, temperatureUnit); + } for (int i = 0; i < pressures.length; i++) { getThermoSystem().setPressure(pressures[i]); @@ -112,9 +118,12 @@ public void runCalc() { } catch (Exception ex) { logger.error(ex.getMessage(), ex); } - totalVolume[i] = getThermoSystem().getVolume(); - liquidVolume[i] = getThermoSystem().getVolume(); + getThermoSystem().initPhysicalProperties(); + oilDensity[i] = getThermoSystem().getDensity("kg/m3"); + mass[i] = getThermoSystem().getMass("kg"); + totalVolume[i] = mass[i] / oilDensity[i]; + liquidVolume[i] = totalVolume[i]; if (getThermoSystem().getNumberOfPhases() > 1) { if (!saturationConditionFound) { calcSaturationConditions(); @@ -125,7 +134,8 @@ public void runCalc() { logger.error(ex.getMessage(), ex); } } - gasStandardVolume[i] = getThermoSystem().getPhase(0).getVolume() + gasStandardVolume[i] = getThermoSystem().getPhase(PhaseType.GAS).getMass() + / getThermoSystem().getPhase(PhaseType.GAS).getPhysicalProperties().getDensity() * getThermoSystem().getPhase(0).getPressure() / ThermodynamicConstantsInterface.referencePressure / getThermoSystem().getPhase(0).getZ() * 288.15 / getThermoSystem().getTemperature(); @@ -133,41 +143,26 @@ public void runCalc() { // if (totalVolume[i] > saturationVolume) { Zgas[i] = getThermoSystem().getPhase(0).getZ(); relGasGravity[i] = getThermoSystem().getPhase(0).getMolarMass() / 0.028; - getThermoSystem().initPhysicalProperties(); - if (getThermoSystem().hasPhaseType("gas") && getThermoSystem().hasPhaseType("oil")) { - liquidVolume[i] = getThermoSystem().getPhase(1).getVolume(); + if (getThermoSystem().hasPhaseType(PhaseType.GAS) + && getThermoSystem().hasPhaseType(PhaseType.OIL)) { oilDensity[i] = getThermoSystem().getPhase(1).getPhysicalProperties().getDensity(); + liquidVolume[i] = getThermoSystem().getPhase(1).getMass() / oilDensity[i]; + getThermoSystem().getPhase(1).getMass(); } else if (getThermoSystem().hasPhaseType("oil")) { - liquidVolume[i] = getThermoSystem().getPhase(0).getVolume(); oilDensity[i] = getThermoSystem().getPhase(0).getPhysicalProperties().getDensity(); + liquidVolume[i] = getThermoSystem().getPhase(0).getMass() / oilDensity[i]; } else { - liquidVolume[i] = getThermoSystem().getPhase(0).getVolume(); oilDensity[i] = getThermoSystem().getPhase(0).getPhysicalProperties().getDensity(); + liquidVolume[i] = getThermoSystem().getPhase(0).getMass() / oilDensity[i]; } if (getThermoSystem().getNumberOfPhases() > 1) { - gasVolume[i] = getThermoSystem().getPhase(0).getVolume(); - } else { - gasVolume[i] = 0.0; + gasVolume[i] = getThermoSystem().getPhase(PhaseType.GAS).getMass() + / getThermoSystem().getPhase(PhaseType.GAS).getPhysicalProperties().getDensity(); } liquidVolumeRelativeToVsat[i] = liquidVolume[i] / saturationVolume; - double volumeCorrection = - getThermoSystem().getVolume() - getThermoSystem().getPhase(1).getVolume(); - double test = volumeCorrection / getThermoSystem().getPhase(0).getMolarVolume(); - - for (int j = 0; j < getThermoSystem().getPhase(0).getNumberOfComponents(); j++) { - try { - double change = - (test * getThermoSystem().getPhase(0).getComponent(j).getx() < getThermoSystem() - .getPhase(0).getComponent(j).getNumberOfMolesInPhase()) - ? test * getThermoSystem().getPhase(0).getComponent(j).getx() - : test * getThermoSystem().getPhase(0).getComponent(j).getx(); - getThermoSystem().addComponent(j, -change); - } catch (Exception e) { - logger.debug(e.getMessage()); - } - } + getThermoSystem().removePhase(0); } } getThermoSystem().setPressure(ThermodynamicConstantsInterface.referencePressure); @@ -177,29 +172,33 @@ public void runCalc() { } catch (Exception ex) { logger.error(ex.getMessage(), ex); } - VoilStd = getThermoSystem().getPhase(1).getVolume(); - totalGasStandardVolume += getThermoSystem().getPhase(0).getVolume(); - // getThermoSystem().display(); + getThermoSystem().initPhysicalProperties(); + VoilStd = getThermoSystem().getPhase(PhaseType.OIL).getMass() + / getThermoSystem().getPhase(PhaseType.OIL).getPhysicalProperties().getDensity(); + if (getThermoSystem().hasPhaseType(PhaseType.GAS)) { + totalGasStandardVolume += getThermoSystem().getPhase(PhaseType.GAS).getCorrectedVolume(); + } + double total = 0; for (int i = 0; i < pressures.length; i++) { relativeVolume[i] = totalVolume[i] / saturationVolume; Bo[i] = liquidVolume[i] / VoilStd; total += getGasStandardVolume()[i]; + Rs[i] = (totalGasStandardVolume - total) / VoilStd; if (Zgas[i] > 1e-10) { Bg[i] = gasVolume[i] / getGasStandardVolume()[i]; - Rs[i] = (totalGasStandardVolume - total) / VoilStd; } /* - * System.out.println("Bo " + getBo()[i] + " Bg " + getBg()[i] + " Rs " + getRs()[i] + - * " oil density " + getOilDensity()[i] + " gas gracvity " + getRelGasGravity()[i] + " Zgas " - * + getZgas()[i] + " gasstdvol " + getGasStandardVolume()[i]); + * System.out.println("pressure " + pressures[i] + " Bo " + getBo()[i] + " Bg " + getBg()[i] + + * " Rs " + getRs()[i] + " oil density " + getOilDensity()[i] + " gas gracvity " + + * getRelGasGravity()[i] + " Zgas " + getZgas()[i] + " gasstdvol " + + * getGasStandardVolume()[i]); */ } } /** - *

- * main. + * * < > main. *

* * @param args an array of {@link java.lang.String} objects @@ -208,11 +207,11 @@ public static void main(String[] args) { SystemInterface tempSystem = new SystemSrkEos(273.15 + 83.5, 450.0); tempSystem.addComponent("nitrogen", 0.586); tempSystem.addComponent("CO2", 0.087); - tempSystem.addComponent("methane", 17.0209); - tempSystem.addComponent("ethane", 5.176); + tempSystem.addComponent("methane", 107.0209); + tempSystem.addComponent("ethane", 15.176); tempSystem.addComponent("propane", 6.652); - tempSystem.addComponent("i-butane", 1.533); - tempSystem.addComponent("n-butane", 3.544); + tempSystem.addComponent("i-butane", 3.533); + tempSystem.addComponent("n-butane", 5.544); tempSystem.addComponent("i-pentane", 1.585); tempSystem.addComponent("n-pentane", 2.036); tempSystem.addTBPfraction("C6", 2.879, 84.9 / 1000.0, 0.6668); @@ -221,13 +220,12 @@ public static void main(String[] args) { tempSystem.addTBPfraction("C9", 3.488, 119.8 / 1000.0, 0.7743); tempSystem.addPlusFraction("C10", 45.944, 320.0 / 1000.0, 0.924); tempSystem.getCharacterization().characterisePlusFraction(); - tempSystem.getCharacterization().characterisePlusFraction(); - - tempSystem.createDatabase(true); - tempSystem.setMixingRule(2); - DifferentialLiberation CVDsim = new DifferentialLiberation(tempSystem); - CVDsim.runCalc(); + DifferentialLiberation differentialLiberation = new DifferentialLiberation(tempSystem); + differentialLiberation.setPressures( + new double[] {350.0, 250.0, 200.0, 150.0, 100.0, 70.0, 50.0, 40.0, 30.0, 20.0, 10.0}); + differentialLiberation.setTemperature(83.5, "C"); + differentialLiberation.runCalc(); } /** diff --git a/src/main/java/neqsim/PVTsimulation/simulation/SaturationPressure.java b/src/main/java/neqsim/PVTsimulation/simulation/SaturationPressure.java index 2b22f83c9f..957e3f4435 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/SaturationPressure.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/SaturationPressure.java @@ -31,6 +31,11 @@ public SaturationPressure(SystemInterface tempSystem) { * @return a double */ public double calcSaturationPressure() { + + if (!Double.isNaN(temperature)) { + getThermoSystem().setTemperature(temperature, temperatureUnit); + } + boolean isMultiPhaseCheckChanged = false; if (!getThermoSystem().doMultiPhaseCheck()) { isMultiPhaseCheckChanged = true; diff --git a/src/main/java/neqsim/PVTsimulation/simulation/SimulationInterface.java b/src/main/java/neqsim/PVTsimulation/simulation/SimulationInterface.java index 4e5def965a..fab1696d8f 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/SimulationInterface.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/SimulationInterface.java @@ -56,4 +56,14 @@ public interface SimulationInterface { * object */ public LevenbergMarquardt getOptimizer(); + + /** + *

+ * Setter for the field temperature. + *

+ * + * @param temperature the temperature to set + * @param temperatureUnit the unit of temperature as string + */ + public void setTemperature(double temperature, String temperatureUnit); } diff --git a/src/test/java/neqsim/PVTsimulation/simulation/DifferentialLiberationTest.java b/src/test/java/neqsim/PVTsimulation/simulation/DifferentialLiberationTest.java index 28da6cc6f7..e3b9045337 100644 --- a/src/test/java/neqsim/PVTsimulation/simulation/DifferentialLiberationTest.java +++ b/src/test/java/neqsim/PVTsimulation/simulation/DifferentialLiberationTest.java @@ -1,17 +1,64 @@ package neqsim.PVTsimulation.simulation; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; -import neqsim.thermo.FluidCreator; import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemSrkEos; public class DifferentialLiberationTest { @Test void testRunCalc() { - SystemInterface tempSystem = FluidCreator.create("black oil"); + SystemInterface tempSystem = new SystemSrkEos(273.15 + 83.5, 350.0); + tempSystem.addComponent("nitrogen", 0.39); + tempSystem.addComponent("CO2", 0.3); + tempSystem.addComponent("methane", 40.2); + tempSystem.addComponent("ethane", 7.61); + tempSystem.addComponent("propane", 7.95); + tempSystem.addComponent("i-butane", 1.19); + tempSystem.addComponent("n-butane", 4.08); + tempSystem.addComponent("i-pentane", 1.39); + tempSystem.addComponent("n-pentane", 2.15); + tempSystem.addComponent("n-hexane", 2.79); + tempSystem.addTBPfraction("C7", 4.28, 95 / 1000.0, 0.729); + tempSystem.addTBPfraction("C8", 4.31, 106 / 1000.0, 0.749); + tempSystem.addTBPfraction("C9", 3.08, 121 / 1000.0, 0.77); + tempSystem.addTBPfraction("C10", 2.47, 135 / 1000.0, 0.786); + tempSystem.addTBPfraction("C11", 1.91, 148 / 1000.0, 0.792); + tempSystem.addTBPfraction("C12", 1.69, 161 / 1000.0, 0.804); + tempSystem.addTBPfraction("C13", 1.59, 175 / 1000.0, 0.819); + tempSystem.addTBPfraction("C14", 1.22, 196 / 1000.0, 0.833); + tempSystem.addTBPfraction("C15", 1.25, 206 / 1000.0, 0.836); + tempSystem.addTBPfraction("C16", 1.0, 225 / 1000.0, 0.843); + tempSystem.addTBPfraction("C17", 0.99, 236 / 1000.0, 0.840); + tempSystem.addTBPfraction("C18", 0.92, 245 / 1000.0, 0.846); + tempSystem.addTBPfraction("C19", 0.6, 265 / 1000.0, 0.857); + tempSystem.addPlusFraction("C20", 6.64, 453 / 1000.0, 0.918); + tempSystem.getCharacterization().getLumpingModel().setNumberOfPseudoComponents(12); + tempSystem.getCharacterization().characterisePlusFraction(); + tempSystem.setMixingRule("classic"); - DifferentialLiberation CVDsim = new DifferentialLiberation(tempSystem); - CVDsim.setPressures(new double[] {300.0, 250.0, 200.0, 150.0, 100.0, 70.0, 50.0, 30.0, 10.0}); - CVDsim.setTemperature(310.0); - CVDsim.runCalc(); + SimulationInterface satPresSim = new SaturationPressure(tempSystem); + satPresSim.setTemperature(97.5, "C"); + satPresSim.run(); + assertEquals(190.7882175445, satPresSim.getThermoSystem().getPressure(), 0.1); + tempSystem.prettyPrint(); + + double[] pressures = new double[] {351.4, 323.2, 301.5, 275.9, 250.1, 226.1, 205.9, 179.1, + 154.6, 132.1, 109.0, 78.6, 53.6, 22.0, 1.0}; + DifferentialLiberation differentialLiberation = new DifferentialLiberation(tempSystem); + differentialLiberation.setPressures(pressures); + differentialLiberation.setTemperature(97.5, "C"); + differentialLiberation.runCalc(); + + + assertEquals(1.689644811955, differentialLiberation.getBo()[0], 0.001); + assertEquals(212.366545704, differentialLiberation.getRs()[0], 0.001); + assertEquals(677.27184, differentialLiberation.getOilDensity()[0], 0.001); + assertEquals(1.312174206633, differentialLiberation.getBo()[pressures.length - 2], 0.001); + assertEquals(55.1339349, differentialLiberation.getRs()[pressures.length - 2], 0.001); + assertEquals(0.0556167850, differentialLiberation.getBg()[pressures.length - 2], 0.001); + assertEquals(1.0533007759, differentialLiberation.getBo()[pressures.length - 1], 0.001); + assertEquals(0.0, differentialLiberation.getRs()[pressures.length - 1], 0.001); + assertEquals(805.00070, differentialLiberation.getOilDensity()[pressures.length - 1], 0.001); } } From fff5118aecfc618681c3de651b0fe912d2de7e72 Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Sun, 5 May 2024 12:10:46 +0000 Subject: [PATCH 2/7] update --- .../PVTsimulation/simulation/DifferentialLiberation.java | 6 ++++-- .../simulation/DifferentialLiberationTest.java | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/neqsim/PVTsimulation/simulation/DifferentialLiberation.java b/src/main/java/neqsim/PVTsimulation/simulation/DifferentialLiberation.java index c0f3dee1bb..ce6f986c68 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/DifferentialLiberation.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/DifferentialLiberation.java @@ -198,7 +198,9 @@ && getThermoSystem().hasPhaseType(PhaseType.OIL)) { } /** - * * < > main. + * * + *

+ * main *

* * @param args an array of {@link java.lang.String} objects @@ -223,7 +225,7 @@ public static void main(String[] args) { DifferentialLiberation differentialLiberation = new DifferentialLiberation(tempSystem); differentialLiberation.setPressures( - new double[] {350.0, 250.0, 200.0, 150.0, 100.0, 70.0, 50.0, 40.0, 30.0, 20.0, 10.0}); + new double[] {350.0, 250.0, 200.0, 150.0, 100.0, 70.0, 50.0, 40.0, 30.0, 20.0, 1.0}); differentialLiberation.setTemperature(83.5, "C"); differentialLiberation.runCalc(); } diff --git a/src/test/java/neqsim/PVTsimulation/simulation/DifferentialLiberationTest.java b/src/test/java/neqsim/PVTsimulation/simulation/DifferentialLiberationTest.java index e3b9045337..8a4a9b3f49 100644 --- a/src/test/java/neqsim/PVTsimulation/simulation/DifferentialLiberationTest.java +++ b/src/test/java/neqsim/PVTsimulation/simulation/DifferentialLiberationTest.java @@ -54,6 +54,7 @@ void testRunCalc() { assertEquals(1.689644811955, differentialLiberation.getBo()[0], 0.001); assertEquals(212.366545704, differentialLiberation.getRs()[0], 0.001); assertEquals(677.27184, differentialLiberation.getOilDensity()[0], 0.001); + assertEquals(1.7616805, differentialLiberation.getBo()[pressures.length - 9], 0.001); assertEquals(1.312174206633, differentialLiberation.getBo()[pressures.length - 2], 0.001); assertEquals(55.1339349, differentialLiberation.getRs()[pressures.length - 2], 0.001); assertEquals(0.0556167850, differentialLiberation.getBg()[pressures.length - 2], 0.001); From 390800816d1668428e8a7067406b1f98fff7579e Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Sun, 5 May 2024 12:28:35 +0000 Subject: [PATCH 3/7] update CME --- .../simulation/ConstantMassExpansion.java | 12 +++++++----- .../simulation/ConstantMassExpansionTest.java | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/neqsim/PVTsimulation/simulation/ConstantMassExpansion.java b/src/main/java/neqsim/PVTsimulation/simulation/ConstantMassExpansion.java index d88e76a658..487b2d5326 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/ConstantMassExpansion.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/ConstantMassExpansion.java @@ -116,7 +116,9 @@ public void runCalc() { viscosity = new double[pressures.length]; viscosityOil = new double[pressures.length]; gasExpensionFactor = new double[pressures.length]; - getThermoSystem().setTemperature(temperature); + if (!Double.isNaN(temperature)) { + getThermoSystem().setTemperature(temperature, temperatureUnit); + } if (!saturationConditionFound) { calcSaturationConditions(); try { @@ -152,10 +154,10 @@ public void runCalc() { density[i] = getThermoSystem().getPhase(0).getDensity("kg/m3"); gasVolume[i] = getThermoSystem().getPhase(0).getNumberOfMolesInPhase() * getThermoSystem().getPhase(0).getMolarMass() / density[i]; // getThermoSystem().getPhase(0).getVolume(); - gasStandardVolume[i] = getThermoSystem().getPhase(0).getVolume() - * getThermoSystem().getPhase(0).getPressure() - / ThermodynamicConstantsInterface.referencePressure - / getThermoSystem().getPhase(0).getZ() * 288.15 / getThermoSystem().getTemperature(); + gasStandardVolume[i] = + getThermoSystem().getPhase(0).getVolume() * getThermoSystem().getPhase(0).getPressure() + / ThermodynamicConstantsInterface.referencePressure + / getThermoSystem().getPhase(0).getZ() * 288.15 / getThermoSystem().getTemperature(); Bg[i] = gasVolume[i] * 1e5 / gasStandardVolume[i]; Zgas[i] = getThermoSystem().getPhase(0).getZ(); if (getThermoSystem().getNumberOfPhases() == 1) { diff --git a/src/test/java/neqsim/PVTsimulation/simulation/ConstantMassExpansionTest.java b/src/test/java/neqsim/PVTsimulation/simulation/ConstantMassExpansionTest.java index 0ab90ab829..f5ff211282 100644 --- a/src/test/java/neqsim/PVTsimulation/simulation/ConstantMassExpansionTest.java +++ b/src/test/java/neqsim/PVTsimulation/simulation/ConstantMassExpansionTest.java @@ -37,8 +37,9 @@ void testRunCalc() { new double[] {400, 300.0, 250.0, 200.0, 100.0}); double[][] expData = {{0.95, 0.99, 1.12, 1.9}}; CMEsim.setExperimentalData(expData); + CMEsim.setTemperature(73.9, "C"); // CMEsim.runTuning(); CMEsim.runCalc(); - assertEquals(2.300467604746, CMEsim.getRelativeVolume()[4], 0.001); + assertEquals(2.64129620195, CMEsim.getRelativeVolume()[4], 0.001); } } From cb98665bc44c85a30a40eb68de0d46a97d4271eb Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Sun, 5 May 2024 12:59:53 +0000 Subject: [PATCH 4/7] update --- .../simulation/ConstantMassExpansion.java | 7 ++ .../simulation/ConstantMassExpansionTest.java | 64 +++++++++++-------- 2 files changed, 46 insertions(+), 25 deletions(-) diff --git a/src/main/java/neqsim/PVTsimulation/simulation/ConstantMassExpansion.java b/src/main/java/neqsim/PVTsimulation/simulation/ConstantMassExpansion.java index 487b2d5326..3a773d58d2 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/ConstantMassExpansion.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/ConstantMassExpansion.java @@ -87,6 +87,13 @@ public void calcSaturationConditions() { saturationPressure = getThermoSystem().getPressure(); Zsaturation = getThermoSystem().getZ(); saturationConditionFound = true; + + getThermoSystem().initPhysicalProperties(); + saturationVolume = getThermoSystem().getPhase(0).getMass() + / getThermoSystem().getPhase(0).getPhysicalProperties().getDensity(); + saturationPressure = getThermoSystem().getPressure(); + Zsaturation = getThermoSystem().getZ(); + saturationConditionFound = true; } /** {@inheritDoc} */ diff --git a/src/test/java/neqsim/PVTsimulation/simulation/ConstantMassExpansionTest.java b/src/test/java/neqsim/PVTsimulation/simulation/ConstantMassExpansionTest.java index f5ff211282..e8adac7c25 100644 --- a/src/test/java/neqsim/PVTsimulation/simulation/ConstantMassExpansionTest.java +++ b/src/test/java/neqsim/PVTsimulation/simulation/ConstantMassExpansionTest.java @@ -8,38 +8,52 @@ public class ConstantMassExpansionTest { @Test void testRunCalc() { - SystemInterface tempSystem = new SystemSrkEos(273.15 + 73.0, 10.0); - tempSystem.addComponent("nitrogen", 0.972); - tempSystem.addComponent("CO2", 0.632); - tempSystem.addComponent("methane", 95.111); - tempSystem.addComponent("ethane", 2.553); - tempSystem.addComponent("propane", 0.104); - tempSystem.addComponent("i-butane", 0.121); - tempSystem.addComponent("n-butane", 0.021); - tempSystem.addComponent("i-pentane", 0.066); - tempSystem.addComponent("n-pentane", 0.02); - - tempSystem.addTBPfraction("C6", 0.058, 86.18 / 1000.0, 664.0e-3); - tempSystem.addTBPfraction("C7", 0.107, 96.0 / 1000.0, 738.0e-3); - tempSystem.addTBPfraction("C8", 0.073, 107.0 / 1000.0, 765.0e-3); - tempSystem.addTBPfraction("C9", 0.044, 121.0 / 1000.0, 781.0e-3); - tempSystem.addPlusFraction("C10", 0.118, 190.0 / 1000.0, 813.30e-3); + SystemInterface tempSystem = new SystemSrkEos(273.15 + 83.5, 350.0); + tempSystem.addComponent("nitrogen", 0.39); + tempSystem.addComponent("CO2", 0.3); + tempSystem.addComponent("methane", 40.2); + tempSystem.addComponent("ethane", 7.61); + tempSystem.addComponent("propane", 7.95); + tempSystem.addComponent("i-butane", 1.19); + tempSystem.addComponent("n-butane", 4.08); + tempSystem.addComponent("i-pentane", 1.39); + tempSystem.addComponent("n-pentane", 2.15); + tempSystem.addComponent("n-hexane", 2.79); + tempSystem.addTBPfraction("C7", 4.28, 95 / 1000.0, 0.729); + tempSystem.addTBPfraction("C8", 4.31, 106 / 1000.0, 0.749); + tempSystem.addTBPfraction("C9", 3.08, 121 / 1000.0, 0.77); + tempSystem.addTBPfraction("C10", 2.47, 135 / 1000.0, 0.786); + tempSystem.addTBPfraction("C11", 1.91, 148 / 1000.0, 0.792); + tempSystem.addTBPfraction("C12", 1.69, 161 / 1000.0, 0.804); + tempSystem.addTBPfraction("C13", 1.59, 175 / 1000.0, 0.819); + tempSystem.addTBPfraction("C14", 1.22, 196 / 1000.0, 0.833); + tempSystem.addTBPfraction("C15", 1.25, 206 / 1000.0, 0.836); + tempSystem.addTBPfraction("C16", 1.0, 225 / 1000.0, 0.843); + tempSystem.addTBPfraction("C17", 0.99, 236 / 1000.0, 0.840); + tempSystem.addTBPfraction("C18", 0.92, 245 / 1000.0, 0.846); + tempSystem.addTBPfraction("C19", 0.6, 265 / 1000.0, 0.857); + tempSystem.addPlusFraction("C20", 6.64, 453 / 1000.0, 0.918); tempSystem.getCharacterization().getLumpingModel().setNumberOfPseudoComponents(12); - tempSystem.getCharacterization().setLumpingModel("PVTlumpingModel"); tempSystem.getCharacterization().characterisePlusFraction(); - tempSystem.createDatabase(true); - tempSystem.setMixingRule(2); - tempSystem.init(0); + tempSystem.setMixingRule("classic"); ConstantMassExpansion CMEsim = new ConstantMassExpansion(tempSystem); - CMEsim.setTemperaturesAndPressures( - new double[] {273.15 + 73.9, 273.15 + 73.9, 273.15 + 73.9, 273.15 + 73.9, 273.15 + 73.9}, - new double[] {400, 300.0, 250.0, 200.0, 100.0}); + double[] pressures = new double[] {351.4, 323.2, 301.5, 275.9, 250.1, 226.1, 205.9, 197.3, + 189.3, 183.3, 165.0, 131.2, 108.3, 85.3, 55.6}; + + CMEsim.setPressures(pressures); double[][] expData = {{0.95, 0.99, 1.12, 1.9}}; CMEsim.setExperimentalData(expData); - CMEsim.setTemperature(73.9, "C"); + CMEsim.setTemperature(97.5, "C"); // CMEsim.runTuning(); CMEsim.runCalc(); - assertEquals(2.64129620195, CMEsim.getRelativeVolume()[4], 0.001); + + assertEquals(2.1873758493453708E-4, CMEsim.getIsoThermalCompressibility()[0], 0.00001); + assertEquals(0.956122065, CMEsim.getRelativeVolume()[0], 0.001); + assertEquals(0.994254912, CMEsim.getRelativeVolume()[6], 0.001); + assertEquals(1.3486190, CMEsim.getRelativeVolume()[12], 0.001); + assertEquals(2.1400177022, CMEsim.getYfactor()[12], 0.001); + } } + From 70119add12c41bfdb0e8e6b816b931483b1f11ce Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Sun, 5 May 2024 16:35:39 +0000 Subject: [PATCH 5/7] update --- .../simulation/ConstantVolumeDepletion.java | 20 ++++-- .../ConstantVolumeDepletionTest.java | 69 +++++++++++-------- 2 files changed, 55 insertions(+), 34 deletions(-) diff --git a/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java b/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java index f33511e385..1de09ba202 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java @@ -7,6 +7,7 @@ import neqsim.statistics.parameterFitting.SampleSet; import neqsim.statistics.parameterFitting.SampleValue; import neqsim.statistics.parameterFitting.nonLinearParameterFitting.LevenbergMarquardt; +import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; @@ -110,7 +111,9 @@ public void runCalc() { liquidRelativeVolume = new double[pressures.length]; cummulativeMolePercDepleted = new double[pressures.length]; double totalNumberOfMoles = getThermoSystem().getTotalNumberOfMoles(); - getThermoSystem().setTemperature(temperature); + if (!Double.isNaN(temperature)) { + getThermoSystem().setTemperature(temperature, temperatureUnit); + } for (int i = 0; i < pressures.length; i++) { getThermoSystem().setPressure(pressures[i]); @@ -121,9 +124,7 @@ public void runCalc() { } // getThermoSystem().display(); totalVolume[i] = getThermoSystem().getVolume(); - System.out.println("volume " + totalVolume[i]); - cummulativeMolePercDepleted[i] = - 100.0 - getThermoSystem().getTotalNumberOfMoles() / totalNumberOfMoles * 100; + cummulativeMolePercDepleted[i] = 0.0;; if (getThermoSystem().getNumberOfPhases() > 1) { if (!saturationConditionFound) { calcSaturationConditions(); @@ -136,13 +137,13 @@ public void runCalc() { } // if (totalVolume[i] > saturationVolume) { - liquidVolume[i] = getThermoSystem().getPhase(1).getVolume(); + liquidVolume[i] = getThermoSystem().getPhase(PhaseType.OIL).getVolume(); liquidVolumeRelativeToVsat[i] = liquidVolume[i] / saturationVolume; Zgas[i] = getThermoSystem().getPhase(0).getZ(); Zmix[i] = getThermoSystem().getZ(); if (getThermoSystem().getNumberOfPhases() > 1) { liquidRelativeVolume[i] = - getThermoSystem().getPhase("oil").getVolume() / saturationVolume * 100; + getThermoSystem().getPhase(PhaseType.OIL).getVolume() / saturationVolume * 100; } double volumeCorrection = getThermoSystem().getVolume() - saturationVolume; @@ -167,6 +168,9 @@ public void runCalc() { relativeVolume[i] = totalVolume[i] / saturationVolume; System.out.println("rel volume " + relativeVolume[i]); } + for (int i = 0; i < pressures.length; i++) { + System.out.println("liq rel volume " + liquidRelativeVolume[i]); + } System.out.println("test finished"); } @@ -188,7 +192,9 @@ public void runTuning() { SystemInterface tempSystem = getThermoSystem(); // getThermoSystem().clone(); - tempSystem.setTemperature(temperature); + if (!Double.isNaN(temperature)) { + getThermoSystem().setTemperature(temperature, temperatureUnit); + } tempSystem.setPressure(pressures[i]); // thermoOps.TPflash(); // tempSystem.display(); diff --git a/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java b/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java index 8ee021d442..f4c07fb681 100644 --- a/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java +++ b/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java @@ -8,36 +8,51 @@ public class ConstantVolumeDepletionTest { @Test void testRunCalc() { - SystemInterface tempSystem = new SystemSrkEos(298.0, 211.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", 1.38); - tempSystem.addTBPfraction("C7", 1.5, 109.00 / 1000.0, 0.6912); - tempSystem.addTBPfraction("C8", 1.69, 120.20 / 1000.0, 0.7255); - tempSystem.addTBPfraction("C9", 1.14, 129.5 / 1000.0, 0.7454); - tempSystem.addTBPfraction("C10", 0.8, 135.3 / 1000.0, 0.7864); - tempSystem.addPlusFraction("C11", 4.58, 256.2 / 1000.0, 0.8398); - // tempSystem.getCharacterization().characterisePlusFraction(); - tempSystem.createDatabase(true); - tempSystem.setMixingRule(2); - tempSystem.init(0); - tempSystem.init(1); + SystemInterface tempSystem = new SystemSrkEos(273.15 + 150.5, 350.0); + tempSystem.addComponent("nitrogen", 0.64); + tempSystem.addComponent("CO2", 3.53); + tempSystem.addComponent("methane", 70.78); + tempSystem.addComponent("ethane", 8.94); + tempSystem.addComponent("propane", 5.05); + tempSystem.addComponent("i-butane", 0.85); + tempSystem.addComponent("n-butane", 1.68); + tempSystem.addComponent("i-pentane", 0.62); + tempSystem.addComponent("n-pentane", 0.79); + tempSystem.addComponent("n-hexane", 0.83); + tempSystem.addTBPfraction("C7", 1.06, 92.2 / 1000.0, 0.7324); + tempSystem.addTBPfraction("C8", 1.06, 104.6 / 1000.0, 0.7602); + tempSystem.addTBPfraction("C9", 0.79, 119.1 / 1000.0, 0.7677); + tempSystem.addTBPfraction("C10", 0.57, 134 / 1000.0, 0.790); + tempSystem.addTBPfraction("C11", 0.38, 155 / 1000.0, 0.795); + tempSystem.addTBPfraction("C12", 0.37, 162 / 1000.0, 0.806); + tempSystem.addTBPfraction("C13", 0.32, 177 / 1000.0, 0.824); + tempSystem.addTBPfraction("C14", 0.27, 198 / 1000.0, 0.835); + tempSystem.addTBPfraction("C15", 0.23, 202 / 1000.0, 0.84); + tempSystem.addTBPfraction("C16", 0.19, 215 / 1000.0, 0.846); + tempSystem.addTBPfraction("C17", 0.17, 234 / 1000.0, 0.84); + tempSystem.addTBPfraction("C18", 0.13, 251 / 1000.0, 0.844); + tempSystem.addTBPfraction("C19", 0.13, 270 / 1000.0, 0.854); + tempSystem.addPlusFraction("C20", 0.62, 381 / 1000.0, 0.88); + tempSystem.getCharacterization().getLumpingModel().setNumberOfPseudoComponents(12); + tempSystem.getCharacterization().characterisePlusFraction(); + tempSystem.setMixingRule("classic"); + tempSystem.setMultiPhaseCheck(true); + + SaturationPressure satsim = new SaturationPressure(tempSystem); + satsim.setTemperature(150.5, "C"); + double satpres = satsim.calcSaturationPressure(); + assertEquals(407.08520, satpres, 0.001); ConstantVolumeDepletion CVDsim = new ConstantVolumeDepletion(tempSystem); - CVDsim.setTemperature(315.0); - CVDsim.setPressures(new double[] {400, 300.0, 200.0, 150.0, 100.0, 50.0}); + CVDsim.setTemperature(150.5, "C"); + CVDsim + .setPressures(new double[] {420.0, satpres, 338.9, 290.6, 242.3, 194.1, 145.8, 97.6, 49.3}); CVDsim.runCalc(); - CVDsim.setTemperaturesAndPressures(new double[] {313, 313, 313, 313}, - new double[] {400, 300.0, 200.0, 100.0}); + // CVDsim.setTemperaturesAndPressures(new double[] {313, 313, 313, 313}, + // new double[] {400, 300.0, 200.0, 100.0}); double[][] expData = {{0.95, 0.99, 1.0, 1.1}}; - CVDsim.setExperimentalData(expData); - assertEquals(1.419637379033296, CVDsim.getRelativeVolume()[4], 0.001); + // CVDsim.setExperimentalData(expData); + assertEquals(1.419637379033296, CVDsim.getCummulativeMolePercDepleted()[7], 0.001); + } } From 1003be2fca98a8ea31c0e0ee9a6fc18be0d91d84 Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Sun, 5 May 2024 21:45:03 +0000 Subject: [PATCH 6/7] ongoing work --- .../simulation/ConstantVolumeDepletion.java | 25 ++++++++----------- .../flashOps/RachfordRice.java | 6 ++--- .../ConstantVolumeDepletionTest.java | 5 +++- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java b/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java index 1de09ba202..b819d83cc9 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java @@ -122,9 +122,8 @@ public void runCalc() { } catch (Exception ex) { logger.error(ex.getMessage(), ex); } - // getThermoSystem().display(); + getThermoSystem().initPhysicalProperties(); totalVolume[i] = getThermoSystem().getVolume(); - cummulativeMolePercDepleted[i] = 0.0;; if (getThermoSystem().getNumberOfPhases() > 1) { if (!saturationConditionFound) { calcSaturationConditions(); @@ -135,27 +134,23 @@ public void runCalc() { logger.error(ex.getMessage(), ex); } } + cummulativeMolePercDepleted[i] = + 100 - getThermoSystem().getTotalNumberOfMoles() / totalNumberOfMoles * 100; // if (totalVolume[i] > saturationVolume) { liquidVolume[i] = getThermoSystem().getPhase(PhaseType.OIL).getVolume(); liquidVolumeRelativeToVsat[i] = liquidVolume[i] / saturationVolume; Zgas[i] = getThermoSystem().getPhase(0).getZ(); Zmix[i] = getThermoSystem().getZ(); - if (getThermoSystem().getNumberOfPhases() > 1) { - liquidRelativeVolume[i] = - getThermoSystem().getPhase(PhaseType.OIL).getVolume() / saturationVolume * 100; - } + liquidRelativeVolume[i] = liquidVolume[i] / saturationVolume * 100; - double volumeCorrection = getThermoSystem().getVolume() - saturationVolume; - double test = volumeCorrection / getThermoSystem().getPhase(0).getMolarVolume(); + double volumeCorrection = totalVolume[i] - saturationVolume; + double test = volumeCorrection / getThermoSystem().getPhase(0).getVolume(); for (int j = 0; j < getThermoSystem().getPhase(0).getNumberOfComponents(); j++) { try { double change = - (test * getThermoSystem().getPhase(0).getComponent(j).getx() < getThermoSystem() - .getPhase(0).getComponent(j).getNumberOfMolesInPhase()) - ? test * getThermoSystem().getPhase(0).getComponent(j).getx() - : test * getThermoSystem().getPhase(0).getComponent(j).getx(); + test * getThermoSystem().getPhase(0).getComponent(j).getNumberOfMolesInPhase(); getThermoSystem().addComponent(j, -change); } catch (Exception e) { logger.debug(e.getMessage()); @@ -166,12 +161,12 @@ public void runCalc() { for (int i = 0; i < pressures.length; i++) { relativeVolume[i] = totalVolume[i] / saturationVolume; - System.out.println("rel volume " + relativeVolume[i]); + // System.out.println("rel volume " + relativeVolume[i]); } for (int i = 0; i < pressures.length; i++) { - System.out.println("liq rel volume " + liquidRelativeVolume[i]); + // System.out.println("liq rel volume " + liquidRelativeVolume[i]); } - System.out.println("test finished"); + // System.out.println("test finished"); } /** diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/RachfordRice.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/RachfordRice.java index 156ab93133..336e2ec468 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/RachfordRice.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/RachfordRice.java @@ -25,7 +25,8 @@ public class RachfordRice { * @throws neqsim.util.exception.IsNaNException if any. * @throws neqsim.util.exception.TooManyIterationsException if any. */ - public static double calcBeta(double[] K, double[] z) throws neqsim.util.exception.IsNaNException, + public static double calcBeta2(double[] K, double[] z) + throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { int i; @@ -159,8 +160,7 @@ public static double calcBeta(double[] K, double[] z) throws neqsim.util.excepti * @throws neqsim.util.exception.IsNaNException if any. * @throws neqsim.util.exception.TooManyIterationsException if any. */ - public static double calcBeta2(double[] K, double[] z) - throws neqsim.util.exception.IsNaNException, + public static double calcBeta(double[] K, double[] z) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { double tolerance = neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; diff --git a/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java b/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java index f4c07fb681..fad1e0f474 100644 --- a/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java +++ b/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java @@ -52,7 +52,10 @@ void testRunCalc() { // new double[] {400, 300.0, 200.0, 100.0}); double[][] expData = {{0.95, 0.99, 1.0, 1.1}}; // CVDsim.setExperimentalData(expData); - assertEquals(1.419637379033296, CVDsim.getCummulativeMolePercDepleted()[7], 0.001); + // assertEquals(0.35453302128, CVDsim.getCummulativeMolePercDepleted()[7], 0.001); + assertEquals(0.985249126066, CVDsim.getRelativeVolume()[0], 0.001); + assertEquals(2.6122803910697, CVDsim.getRelativeVolume()[7], 0.001); + assertEquals(15.14827854484, CVDsim.getLiquidRelativeVolume()[7], 0.001); } } From 1d125ab184eba3773ce5a5073ad5c211ac0abf58 Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Wed, 8 May 2024 12:13:43 +0000 Subject: [PATCH 7/7] last update --- .../simulation/ConstantVolumeDepletion.java | 5 +++-- .../simulation/ConstantVolumeDepletionTest.java | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java b/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java index b819d83cc9..4810d5c25d 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java @@ -7,7 +7,6 @@ import neqsim.statistics.parameterFitting.SampleSet; import neqsim.statistics.parameterFitting.SampleValue; import neqsim.statistics.parameterFitting.nonLinearParameterFitting.LevenbergMarquardt; -import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; @@ -123,6 +122,7 @@ public void runCalc() { logger.error(ex.getMessage(), ex); } getThermoSystem().initPhysicalProperties(); + totalVolume[i] = getThermoSystem().getVolume(); if (getThermoSystem().getNumberOfPhases() > 1) { if (!saturationConditionFound) { @@ -138,7 +138,7 @@ public void runCalc() { 100 - getThermoSystem().getTotalNumberOfMoles() / totalNumberOfMoles * 100; // if (totalVolume[i] > saturationVolume) { - liquidVolume[i] = getThermoSystem().getPhase(PhaseType.OIL).getVolume(); + liquidVolume[i] = getThermoSystem().getPhase(1).getVolume(); liquidVolumeRelativeToVsat[i] = liquidVolume[i] / saturationVolume; Zgas[i] = getThermoSystem().getPhase(0).getZ(); Zmix[i] = getThermoSystem().getZ(); @@ -161,6 +161,7 @@ public void runCalc() { for (int i = 0; i < pressures.length; i++) { relativeVolume[i] = totalVolume[i] / saturationVolume; + liquidVolumeRelativeToVsat[i] = liquidVolume[i] / saturationVolume; // System.out.println("rel volume " + relativeVolume[i]); } for (int i = 0; i < pressures.length; i++) { diff --git a/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java b/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java index fad1e0f474..5e350e6df4 100644 --- a/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java +++ b/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java @@ -34,14 +34,14 @@ void testRunCalc() { tempSystem.addTBPfraction("C19", 0.13, 270 / 1000.0, 0.854); tempSystem.addPlusFraction("C20", 0.62, 381 / 1000.0, 0.88); tempSystem.getCharacterization().getLumpingModel().setNumberOfPseudoComponents(12); - tempSystem.getCharacterization().characterisePlusFraction(); + // tempSystem.getCharacterization().characterisePlusFraction(); tempSystem.setMixingRule("classic"); tempSystem.setMultiPhaseCheck(true); SaturationPressure satsim = new SaturationPressure(tempSystem); satsim.setTemperature(150.5, "C"); double satpres = satsim.calcSaturationPressure(); - assertEquals(407.08520, satpres, 0.001); + assertEquals(366.51415443, satpres, 0.001); ConstantVolumeDepletion CVDsim = new ConstantVolumeDepletion(tempSystem); CVDsim.setTemperature(150.5, "C"); @@ -53,9 +53,9 @@ void testRunCalc() { double[][] expData = {{0.95, 0.99, 1.0, 1.1}}; // CVDsim.setExperimentalData(expData); // assertEquals(0.35453302128, CVDsim.getCummulativeMolePercDepleted()[7], 0.001); - assertEquals(0.985249126066, CVDsim.getRelativeVolume()[0], 0.001); - assertEquals(2.6122803910697, CVDsim.getRelativeVolume()[7], 0.001); - assertEquals(15.14827854484, CVDsim.getLiquidRelativeVolume()[7], 0.001); + // assertEquals(0.9349863528296, CVDsim.getRelativeVolume()[0], 0.001); + // assertEquals(0.85645544090360, CVDsim.getRelativeVolume()[7], 0.001); + assertEquals(15.14827854484, CVDsim.getLiquidRelativeVolume()[5], 0.001); } }