From 2180e839b4f8266c879b985499192e793c211312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= <34712686+asmfstatoil@users.noreply.github.com> Date: Fri, 10 Jan 2025 22:35:39 +0100 Subject: [PATCH] refact: replace PhaseType.byValue with PhaseType enum --- .../nonlinearsolver/SysNewtonRhapson.java | 4 ++-- .../thermo/component/ComponentHydrate.java | 2 +- .../component/ComponentHydrateBallard.java | 2 +- .../thermo/component/ComponentHydrateGF.java | 2 +- .../component/ComponentHydratePVTsim.java | 4 ++-- .../thermo/component/ComponentSolid.java | 6 +++--- .../neqsim/thermo/component/ComponentWax.java | 2 +- .../thermo/component/ComponentWaxWilson.java | 2 +- .../thermo/component/ComponentWonWax.java | 2 +- .../thermo/mixingrule/EosMixingRules.java | 6 +++--- .../neqsim/thermo/system/SystemInterface.java | 6 +++++- .../neqsim/thermo/system/SystemThermo.java | 18 +++++++++--------- .../flashops/Flash.java | 4 ++-- .../flashops/SolidFlash.java | 8 ++++---- .../flashops/SolidFlash1.java | 8 ++++---- .../flashops/SolidFlash12.java | 8 ++++---- .../flashops/TPflash.java | 14 +++++++------- .../flashops/saturationops/FreezeOut.java | 2 +- .../flashops/saturationops/FugTestConstP.java | 2 +- .../OLGApropertyTableGenerator.java | 6 +++--- .../OLGApropertyTableGeneratorWater.java | 4 ++-- ...LGApropertyTableGeneratorWaterStudents.java | 4 ++-- ...ApropertyTableGeneratorWaterStudentsPH.java | 4 ++-- .../thermo/util/example/TPMultiFlash.java | 12 +++++++----- .../thermo/util/example/TPflashMembrane.java | 2 +- 25 files changed, 70 insertions(+), 64 deletions(-) diff --git a/src/main/java/neqsim/mathlib/nonlinearsolver/SysNewtonRhapson.java b/src/main/java/neqsim/mathlib/nonlinearsolver/SysNewtonRhapson.java index 8e4750f33..2ea087e69 100644 --- a/src/main/java/neqsim/mathlib/nonlinearsolver/SysNewtonRhapson.java +++ b/src/main/java/neqsim/mathlib/nonlinearsolver/SysNewtonRhapson.java @@ -361,8 +361,8 @@ public void calcInc2(int np) { PC2 = Math.exp(u.get(numberOfComponents + 1, 0)); system.setTC((TC1 + TC2) * 0.5); system.setPC((PC1 + PC2) * 0.5); - system.setPhaseType(0, PhaseType.byValue(1)); - system.setPhaseType(1, PhaseType.byValue(0)); + system.setPhaseType(0, PhaseType.GAS); + system.setPhaseType(1, PhaseType.LIQUID); return; } else if ((xlnkmax < avscp && testcrit != 1) && (np != ic03p && !etterCP)) { // System.out.println("hei fra her"); diff --git a/src/main/java/neqsim/thermo/component/ComponentHydrate.java b/src/main/java/neqsim/thermo/component/ComponentHydrate.java index 24ba5b47a..96de453f2 100644 --- a/src/main/java/neqsim/thermo/component/ComponentHydrate.java +++ b/src/main/java/neqsim/thermo/component/ComponentHydrate.java @@ -659,7 +659,7 @@ public void setSolidRefFluidPhase(PhaseInterface phase) { refPhase.setTemperature(273.0); refPhase.setPressure(1.0); refPhase.addComponent("water", 10.0, 10.0, 0); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 0, PhaseType.byValue(1), 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 0, PhaseType.GAS, 1.0); } catch (Exception ex) { logger.error("error occured", ex); } diff --git a/src/main/java/neqsim/thermo/component/ComponentHydrateBallard.java b/src/main/java/neqsim/thermo/component/ComponentHydrateBallard.java index e23e18d11..303b7b4d0 100644 --- a/src/main/java/neqsim/thermo/component/ComponentHydrateBallard.java +++ b/src/main/java/neqsim/thermo/component/ComponentHydrateBallard.java @@ -56,7 +56,7 @@ public double fugcoef(PhaseInterface phase, int numberOfComps, double temp, doub if (componentName.equals("water")) { refPhase.setTemperature(temp); refPhase.setPressure(pres); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, PhaseType.byValue(0), 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, PhaseType.LIQUID, 1.0); double refWaterFugacity = refPhase.getComponent("water").fugcoef(refPhase) * pres; double alphaWater = reffug[getComponentNumber()]; double wateralphaRef = Math.log(refWaterFugacity / alphaWater); diff --git a/src/main/java/neqsim/thermo/component/ComponentHydrateGF.java b/src/main/java/neqsim/thermo/component/ComponentHydrateGF.java index 3f39df23a..583037f59 100644 --- a/src/main/java/neqsim/thermo/component/ComponentHydrateGF.java +++ b/src/main/java/neqsim/thermo/component/ComponentHydrateGF.java @@ -87,7 +87,7 @@ public double fugcoef(PhaseInterface phase, int numberOfComps, double temp, doub refPhase.setTemperature(temp); refPhase.setPressure(pres); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, PhaseType.byValue(0), 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, PhaseType.LIQUID, 1.0); double refWaterFugacityCoef = Math.log(refPhase.getComponent("water").fugcoef(refPhase)); double dhf = 6010.0; diff --git a/src/main/java/neqsim/thermo/component/ComponentHydratePVTsim.java b/src/main/java/neqsim/thermo/component/ComponentHydratePVTsim.java index 8c687e3d5..de5d5e9f5 100644 --- a/src/main/java/neqsim/thermo/component/ComponentHydratePVTsim.java +++ b/src/main/java/neqsim/thermo/component/ComponentHydratePVTsim.java @@ -87,7 +87,7 @@ public double fugcoef(PhaseInterface phase, int numberOfComps, double temp, doub stableStructure = -1; refPhase.setTemperature(temp); refPhase.setPressure(pres); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, PhaseType.byValue(0), 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, PhaseType.LIQUID, 1.0); double refWaterFugacityCoef = Math.log(refPhase.getComponent("water").fugcoef(refPhase)); @@ -117,7 +117,7 @@ public double fugcoef(PhaseInterface phase, int numberOfComps, double temp, doub if (componentName.equals("water")) { refPhase.setTemperature(temp); refPhase.setPressure(pres); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, PhaseType.byValue(0), 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, PhaseType.LIQUID, 1.0); double refWaterFugacity = refPhase.getComponent("water").fugcoef(refPhase) * pres; diff --git a/src/main/java/neqsim/thermo/component/ComponentSolid.java b/src/main/java/neqsim/thermo/component/ComponentSolid.java index 2db361c62..160be987b 100644 --- a/src/main/java/neqsim/thermo/component/ComponentSolid.java +++ b/src/main/java/neqsim/thermo/component/ComponentSolid.java @@ -111,7 +111,7 @@ public double fugcoef(double temp, double pres) { refPhase.setTemperature(temp); refPhase.setPressure(PvapSolid); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.byValue(1), 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.GAS, 1.0); refPhase.getComponent(0).fugcoef(refPhase); // System.out.println("ref co2 fugcoef " + @@ -142,7 +142,7 @@ public double fugcoef2(PhaseInterface phase1) { refPhase.setTemperature(phase1.getTemperature()); refPhase.setPressure(phase1.getPressure()); try { - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.byValue(0), 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.LIQUID, 1.0); } catch (Exception ex) { logger.error(ex.getMessage()); } @@ -256,7 +256,7 @@ public void setSolidRefFluidPhase(PhaseInterface phase) { } refPhase.getComponent(componentName) .setAttractiveTerm(phase.getComponent(componentName).getAttractiveTermNumber()); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 0, PhaseType.byValue(1), 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 0, PhaseType.GAS, 1.0); // } } catch (Exception ex) { logger.error("error occured", ex); diff --git a/src/main/java/neqsim/thermo/component/ComponentWax.java b/src/main/java/neqsim/thermo/component/ComponentWax.java index 496af4c3d..faad946ba 100644 --- a/src/main/java/neqsim/thermo/component/ComponentWax.java +++ b/src/main/java/neqsim/thermo/component/ComponentWax.java @@ -54,7 +54,7 @@ public double fugcoef2(PhaseInterface phase1) { logger.error(ex.getMessage(), ex); } refPhase.setPressure(phase1.getPressure()); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.byValue(0), 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.LIQUID, 1.0); refPhase.getComponent(0).fugcoef(refPhase); double liquidPhaseFugacity = diff --git a/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java b/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java index ada600f26..eb2feb503 100644 --- a/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java +++ b/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java @@ -50,7 +50,7 @@ public double fugcoef(PhaseInterface phase1) { public double fugcoef2(PhaseInterface phase1) { refPhase.setTemperature(phase1.getTemperature()); refPhase.setPressure(phase1.getPressure()); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.byValue(0), 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.LIQUID, 1.0); refPhase.getComponent(0).fugcoef(refPhase); double liquidPhaseFugacity = diff --git a/src/main/java/neqsim/thermo/component/ComponentWonWax.java b/src/main/java/neqsim/thermo/component/ComponentWonWax.java index 24f01b373..c5f8d3271 100644 --- a/src/main/java/neqsim/thermo/component/ComponentWonWax.java +++ b/src/main/java/neqsim/thermo/component/ComponentWonWax.java @@ -49,7 +49,7 @@ public double fugcoef(PhaseInterface phase1) { public double fugcoef2(PhaseInterface phase1) { refPhase.setTemperature(phase1.getTemperature()); refPhase.setPressure(phase1.getPressure()); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.byValue(0), 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.LIQUID, 1.0); refPhase.getComponent(0).fugcoef(refPhase); double liquidPhaseFugacity = diff --git a/src/main/java/neqsim/thermo/mixingrule/EosMixingRules.java b/src/main/java/neqsim/thermo/mixingrule/EosMixingRules.java index 1ea4f0cf7..7a36e55ae 100644 --- a/src/main/java/neqsim/thermo/mixingrule/EosMixingRules.java +++ b/src/main/java/neqsim/thermo/mixingrule/EosMixingRules.java @@ -1057,7 +1057,7 @@ public SRKHuronVidal(PhaseInterface phase, double[][] HValpha, double[][] HVDij, / (1.0 + compArray[0].getDeltaEosParameters()[0])); gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, mixRule, intparam); gePhase.getExcessGibbsEnergy(phase, phase.getNumberOfComponents(), phase.getTemperature(), - phase.getPressure(), PhaseType.byValue(1)); + phase.getPressure(), PhaseType.GAS); gePhase.setProperties(phase); } @@ -1071,7 +1071,7 @@ public SRKHuronVidal(PhaseInterface phase, double[][] HValpha, double[][] HVDij, / (1.0 + compArray[0].getDeltaEosParameters()[0])); gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, HVDijT, mixRule, intparam); gePhase.getExcessGibbsEnergy(phase, phase.getNumberOfComponents(), phase.getTemperature(), - phase.getPressure(), PhaseType.byValue(1)); + phase.getPressure(), PhaseType.GAS); gePhase.setProperties(phase); } @@ -1145,7 +1145,7 @@ public double calcA(PhaseInterface phase, double temperature, double pressure, i } A = calcB(phase, temperature, pressure, numbcomp) * (A - phase.getNumberOfMolesInPhase() * gePhase.getExcessGibbsEnergy(phase, phase.getNumberOfComponents(), - phase.getTemperature(), phase.getPressure(), PhaseType.byValue(0)) + phase.getTemperature(), phase.getPressure(), PhaseType.LIQUID) / gePhase.getNumberOfMolesInPhase() / hwfc); Atot = A; return A; diff --git a/src/main/java/neqsim/thermo/system/SystemInterface.java b/src/main/java/neqsim/thermo/system/SystemInterface.java index 023637324..c9670cc04 100644 --- a/src/main/java/neqsim/thermo/system/SystemInterface.java +++ b/src/main/java/neqsim/thermo/system/SystemInterface.java @@ -1865,7 +1865,11 @@ public default void initThermoProperties() { public void normalizeBeta(); /** - * Order phases by density. + * Order phases 0-3, as many as there are, by density such that getPhase(0) is lightest. + * + *
+ * Typically GAS, LIQUID for two-phase or GAS, OIL, AQUEOUS for multiphase . + *
*/ public void orderByDensity(); diff --git a/src/main/java/neqsim/thermo/system/SystemThermo.java b/src/main/java/neqsim/thermo/system/SystemThermo.java index 000c58cee..6ea3cfbf4 100644 --- a/src/main/java/neqsim/thermo/system/SystemThermo.java +++ b/src/main/java/neqsim/thermo/system/SystemThermo.java @@ -1321,8 +1321,8 @@ public void chemicalReactionInit() { @Override public void clearAll() { setTotalNumberOfMoles(0); - phaseType[0] = PhaseType.byValue(1); - phaseType[1] = PhaseType.byValue(0); + phaseType[0] = PhaseType.GAS; + phaseType[1] = PhaseType.LIQUID; numberOfComponents = 0; setNumberOfPhases(2); beta[0] = 1.0; @@ -3903,10 +3903,10 @@ public void reInitPhaseInformation() { /** {@inheritDoc} */ @Override public void reInitPhaseType() { - phaseType[0] = PhaseType.byValue(1); - phaseType[1] = PhaseType.byValue(0); - phaseType[2] = PhaseType.byValue(0); - phaseType[3] = PhaseType.byValue(0); + phaseType[0] = PhaseType.GAS; + phaseType[1] = PhaseType.LIQUID; + phaseType[2] = PhaseType.LIQUID; + phaseType[3] = PhaseType.LIQUID; // TODO: why stop at 3 and not iterate through MAX_PHASES elements? } @@ -4751,10 +4751,10 @@ public void invertPhaseTypes() { */ for (int i = 0; i < getMaxNumberOfPhases(); i++) { - if (phaseType[i] == PhaseType.byValue(0)) { - phaseType[i] = PhaseType.byValue(1); + if (phaseType[i] == PhaseType.LIQUID) { + phaseType[i] = PhaseType.GAS; } else { - phaseType[i] = PhaseType.byValue(0); + phaseType[i] = PhaseType.LIQUID; } } } diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/Flash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/Flash.java index 870dd5af5..6cc8c59b6 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/Flash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/Flash.java @@ -361,9 +361,9 @@ public boolean stabilityCheck() { system.setNumberOfPhases(1); if (lowestGibbsEnergyPhase == 0) { - system.setPhaseType(0, PhaseType.byValue(1)); + system.setPhaseType(0, PhaseType.GAS); } else { - system.setPhaseType(0, PhaseType.byValue(0)); + system.setPhaseType(0, PhaseType.LIQUID); } system.init(1); if (solidCheck && !system.doMultiPhaseCheck()) { diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash.java index f5aef2d29..2848fb179 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash.java @@ -294,16 +294,16 @@ public void checkGibbs() { double gibbs1 = 0; double gibbs2 = 0; for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { - system.setPhaseType(i, PhaseType.byValue(0)); + system.setPhaseType(i, PhaseType.LIQUID); system.init(1); gibbs1 = system.getPhase(i).getGibbsEnergy(); - system.setPhaseType(i, PhaseType.byValue(1)); + system.setPhaseType(i, PhaseType.GAS); system.init(1); gibbs2 = system.getPhase(i).getGibbsEnergy(); if (gibbs1 < gibbs2) { - system.setPhaseType(i, PhaseType.byValue(0)); + system.setPhaseType(i, PhaseType.LIQUID); } else { - system.setPhaseType(i, PhaseType.byValue(1)); + system.setPhaseType(i, PhaseType.GAS); } system.init(1); } diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash1.java b/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash1.java index beceb6204..a2f1aead0 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash1.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash1.java @@ -339,16 +339,16 @@ public void checkGibbs() { double gibbs1 = 0; double gibbs2 = 0; for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { - system.setPhaseType(i, PhaseType.byValue(0)); + system.setPhaseType(i, PhaseType.LIQUID); system.init(1); gibbs1 = system.getPhase(i).getGibbsEnergy(); - system.setPhaseType(i, PhaseType.byValue(1)); + system.setPhaseType(i, PhaseType.GAS); system.init(1); gibbs2 = system.getPhase(i).getGibbsEnergy(); if (gibbs1 < gibbs2) { - system.setPhaseType(i, PhaseType.byValue(0)); + system.setPhaseType(i, PhaseType.LIQUID); } else { - system.setPhaseType(i, PhaseType.byValue(1)); + system.setPhaseType(i, PhaseType.GAS); } system.init(1); } diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash12.java b/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash12.java index d38b5360e..4c6761197 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash12.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/SolidFlash12.java @@ -266,16 +266,16 @@ public void checkGibbs() { double gibbs1 = 0; double gibbs2 = 0; for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { - system.setPhaseType(i, PhaseType.byValue(0)); + system.setPhaseType(i, PhaseType.LIQUID); system.init(1); gibbs1 = system.getPhase(i).getGibbsEnergy(); - system.setPhaseType(i, PhaseType.byValue(1)); + system.setPhaseType(i, PhaseType.GAS); system.init(1); gibbs2 = system.getPhase(i).getGibbsEnergy(); if (gibbs1 < gibbs2) { - system.setPhaseType(i, PhaseType.byValue(0)); + system.setPhaseType(i, PhaseType.LIQUID); } else { - system.setPhaseType(i, PhaseType.byValue(1)); + system.setPhaseType(i, PhaseType.GAS); } system.init(1); } diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/TPflash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/TPflash.java index 69de69b59..a8e4d6955 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/TPflash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/TPflash.java @@ -376,12 +376,12 @@ public void run() { // Checks if gas or oil is the most stable phase double gasgib = system.getPhase(0).getGibbsEnergy(); - system.setPhaseType(0, PhaseType.byValue(0)); + system.setPhaseType(0, PhaseType.LIQUID); system.init(1, 0); double liqgib = system.getPhase(0).getGibbsEnergy(); if (gasgib * (1.0 - Math.signum(gasgib) * 1e-8) < liqgib) { - system.setPhaseType(0, PhaseType.byValue(1)); + system.setPhaseType(0, PhaseType.GAS); } system.init(1); @@ -472,25 +472,25 @@ public void run() { TPmultiflash operation = new TPmultiflash(system, system.doSolidPhaseCheck()); operation.run(); } else { - // Checks if gas or oil is the most stable phase try { + // Checks if gas or oil is the most stable phase if (system.getPhase(0).getType() == PhaseType.GAS) { gasgib = system.getPhase(0).getGibbsEnergy(); - system.setPhaseType(0, PhaseType.byValue(0)); + system.setPhaseType(0, PhaseType.LIQUID); system.init(1, 0); liqgib = system.getPhase(0).getGibbsEnergy(); } else { liqgib = system.getPhase(0).getGibbsEnergy(); - system.setPhaseType(0, PhaseType.byValue(1)); + system.setPhaseType(0, PhaseType.GAS); system.init(1, 0); gasgib = system.getPhase(0).getGibbsEnergy(); } if (gasgib * (1.0 - Math.signum(gasgib) * 1e-8) < liqgib) { - system.setPhaseType(0, PhaseType.byValue(1)); + system.setPhaseType(0, PhaseType.GAS); } } catch (Exception e) { - system.setPhaseType(0, PhaseType.byValue(1)); + system.setPhaseType(0, PhaseType.GAS); } system.init(1); diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezeOut.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezeOut.java index a982aeb3e..b5dc0d167 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezeOut.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FreezeOut.java @@ -86,7 +86,7 @@ public void run() { SystemInterface testSystem2 = new SystemSrkSchwartzentruberEos(216, 1); ThermodynamicOperations testOps2 = new ThermodynamicOperations(testSystem2); testSystem2.addComponent(testSystem.getPhase(0).getComponent(k).getComponentName(), 1); - testSystem2.setPhaseType(0, PhaseType.byValue(1)); + testSystem2.setPhaseType(0, PhaseType.GAS); noFreezeliq = true; SolidFug = 0.0; FluidFug = 0.0; diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FugTestConstP.java b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FugTestConstP.java index 1335cafc4..fdaced019 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FugTestConstP.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/saturationops/FugTestConstP.java @@ -72,7 +72,7 @@ public FugTestConstP(SystemInterface system, double pres) { public void initTestSystem2(int K) { this.testSystem2 = new SystemSrkSchwartzentruberEos(temp, pres); this.testSystem2.addComponent(compName, 1); - this.testSystem2.setPhaseType(0, PhaseType.byValue(1)); + this.testSystem2.setPhaseType(0, PhaseType.GAS); this.testOps2 = new ThermodynamicOperations(testSystem2); } diff --git a/src/main/java/neqsim/thermodynamicoperations/propertygenerator/OLGApropertyTableGenerator.java b/src/main/java/neqsim/thermodynamicoperations/propertygenerator/OLGApropertyTableGenerator.java index e9d52b334..bc0fd9715 100644 --- a/src/main/java/neqsim/thermodynamicoperations/propertygenerator/OLGApropertyTableGenerator.java +++ b/src/main/java/neqsim/thermodynamicoperations/propertygenerator/OLGApropertyTableGenerator.java @@ -166,7 +166,7 @@ public void run() { if (!thermoSystem.hasPhaseType("gas")) { thermoSystem.setPhaseType(thermoSystem.getPhaseNumberOfPhase(PhaseType.OIL), - PhaseType.byValue(1)); + PhaseType.GAS); thermoSystem.init(3); thermoSystem.initPhysicalProperties(); @@ -176,7 +176,7 @@ public void run() { if (!thermoSystem.hasPhaseType("oil")) { thermoSystem.setPhaseType(thermoSystem.getPhaseNumberOfPhase(PhaseType.GAS), - PhaseType.byValue(1)); + PhaseType.GAS); thermoSystem.init(3); thermoSystem.initPhysicalProperties(); @@ -185,7 +185,7 @@ public void run() { } if (!thermoSystem.hasPhaseType("aqueous")) { - thermoSystem.setPhaseType(1, PhaseType.byValue(1)); + thermoSystem.setPhaseType(1, PhaseType.GAS); thermoSystem.init(3); thermoSystem.initPhysicalProperties(); diff --git a/src/main/java/neqsim/thermodynamicoperations/propertygenerator/OLGApropertyTableGeneratorWater.java b/src/main/java/neqsim/thermodynamicoperations/propertygenerator/OLGApropertyTableGeneratorWater.java index e5bf06099..5bab1941e 100644 --- a/src/main/java/neqsim/thermodynamicoperations/propertygenerator/OLGApropertyTableGeneratorWater.java +++ b/src/main/java/neqsim/thermodynamicoperations/propertygenerator/OLGApropertyTableGeneratorWater.java @@ -577,7 +577,7 @@ public void run() { } while (k < 17); // names[k] = "GAS DENSITY"; // units[k] = "KG/M3"; } else { - oilSystem.setPhaseType(0, PhaseType.byValue(0)); + oilSystem.setPhaseType(0, PhaseType.LIQUID); oilSystem.setTemperature(temperatures[j]); oilSystem.setPressure(pressures[i]); oilSystem.init(3); @@ -715,7 +715,7 @@ public void run() { } else { waterSystem.setTemperature(temperatures[j]); waterSystem.setPressure(pressures[i]); - waterSystem.setPhaseType(0, PhaseType.byValue(0)); + waterSystem.setPhaseType(0, PhaseType.LIQUID); waterSystem.init(3); waterSystem.initPhysicalProperties(); diff --git a/src/main/java/neqsim/thermodynamicoperations/propertygenerator/OLGApropertyTableGeneratorWaterStudents.java b/src/main/java/neqsim/thermodynamicoperations/propertygenerator/OLGApropertyTableGeneratorWaterStudents.java index 51d1d9461..54cbf6222 100644 --- a/src/main/java/neqsim/thermodynamicoperations/propertygenerator/OLGApropertyTableGeneratorWaterStudents.java +++ b/src/main/java/neqsim/thermodynamicoperations/propertygenerator/OLGApropertyTableGeneratorWaterStudents.java @@ -735,7 +735,7 @@ public void run() { } while (k < 17); // names[k] = "GAS DENSITY"; // units[k] = "KG/M3"; } else { - oilSystem.setPhaseType(0, PhaseType.byValue(0)); + oilSystem.setPhaseType(0, PhaseType.LIQUID); oilSystem.setTemperature(temperatures[j]); oilSystem.setPressure(pressures[i]); oilSystem.init(3); @@ -935,7 +935,7 @@ public void run() { } else { waterSystem.setTemperature(temperatures[j]); waterSystem.setPressure(pressures[i]); - waterSystem.setPhaseType(0, PhaseType.byValue(0)); + waterSystem.setPhaseType(0, PhaseType.LIQUID); waterSystem.init(3); waterSystem.initPhysicalProperties(); diff --git a/src/main/java/neqsim/thermodynamicoperations/propertygenerator/OLGApropertyTableGeneratorWaterStudentsPH.java b/src/main/java/neqsim/thermodynamicoperations/propertygenerator/OLGApropertyTableGeneratorWaterStudentsPH.java index bf05961ff..307c9ef2c 100644 --- a/src/main/java/neqsim/thermodynamicoperations/propertygenerator/OLGApropertyTableGeneratorWaterStudentsPH.java +++ b/src/main/java/neqsim/thermodynamicoperations/propertygenerator/OLGApropertyTableGeneratorWaterStudentsPH.java @@ -734,7 +734,7 @@ public void run() { } while (k < 17); // names[k] = "GAS DENSITY"; // units[k] = "KG/M3"; } else { - oilSystem.setPhaseType(0, PhaseType.byValue(0)); + oilSystem.setPhaseType(0, PhaseType.LIQUID); // oilSystem.setTemperature(enthalpies[j]); oilSystem.setPressure(pressures[i]); oilSystem.init(3); @@ -928,7 +928,7 @@ public void run() { } else { waterSystem.setTemperature(enthalpies[j]); waterSystem.setPressure(pressures[i]); - waterSystem.setPhaseType(0, PhaseType.byValue(0)); + waterSystem.setPhaseType(0, PhaseType.LIQUID); waterSystem.init(3); waterSystem.initPhysicalProperties(); diff --git a/src/test/java/neqsim/thermo/util/example/TPMultiFlash.java b/src/test/java/neqsim/thermo/util/example/TPMultiFlash.java index 8d2ebe510..ae4dc3b6a 100644 --- a/src/test/java/neqsim/thermo/util/example/TPMultiFlash.java +++ b/src/test/java/neqsim/thermo/util/example/TPMultiFlash.java @@ -81,7 +81,7 @@ public static void main(String[] args) { // testSystem.setMixingRule(1); try { - int phase = 0; + PhaseType pt = PhaseType.LIQUID; testSystem.init(0); testSystem.useVolumeCorrection(true); @@ -94,13 +94,15 @@ public static void main(String[] args) { testSystem.init(0, 0); testSystem.setTemperature(298); testSystem.setPressure(10); - if (phase == 1) { - phase = 0; + + // Change phasetype each run + if (pt == PhaseType.GAS) { + pt = PhaseType.LIQUID; } else { - phase = 1; + pt = PhaseType.LIQUID; } - testSystem.setPhaseType(0, PhaseType.byValue(phase)); + testSystem.setPhaseType(0, pt); testSystem.init(2, 0); testSystem.initPhysicalProperties(); } diff --git a/src/test/java/neqsim/thermo/util/example/TPflashMembrane.java b/src/test/java/neqsim/thermo/util/example/TPflashMembrane.java index d25bdef74..042ace249 100644 --- a/src/test/java/neqsim/thermo/util/example/TPflashMembrane.java +++ b/src/test/java/neqsim/thermo/util/example/TPflashMembrane.java @@ -49,7 +49,7 @@ public static void main(String args[]) { testSystem.init_x_y(); testSystem.getPhase(0).setPressure(30.0); testSystem.getPhase(1).setPressure(2.0); - testSystem.setAllPhaseType(PhaseType.byValue(1)); + testSystem.setAllPhaseType(PhaseType.GAS); testSystem.allowPhaseShift(false); try {