From aeaa0286442ee912718467ebc184eafbcd048196 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, 23 Feb 2024 11:51:25 +0100 Subject: [PATCH 1/2] refact: replace use of phasetype as int --- .../thermo/component/ComponentHydrate.java | 3 ++- .../component/ComponentHydrateBallard.java | 3 ++- .../thermo/component/ComponentHydrateGF.java | 3 ++- .../component/ComponentHydratePVTsim.java | 5 +++-- .../thermo/component/ComponentSolid.java | 7 ++++--- .../neqsim/thermo/component/ComponentWax.java | 3 ++- .../thermo/component/ComponentWaxWilson.java | 3 ++- .../thermo/component/ComponentWonWax.java | 3 ++- .../thermo/mixingRule/EosMixingRules.java | 13 ++++++------ .../thermo/phase/PhaseDesmukhMather.java | 4 ++-- .../neqsim/thermo/phase/PhaseDuanSun.java | 7 ++++--- .../java/neqsim/thermo/phase/PhaseGE.java | 20 +++++++++---------- .../neqsim/thermo/phase/PhaseGEInterface.java | 4 ++-- .../java/neqsim/thermo/phase/PhaseGENRTL.java | 4 ++-- .../thermo/phase/PhaseGENRTLmodifiedHV.java | 6 +++--- .../thermo/phase/PhaseGENRTLmodifiedWS.java | 6 +++--- .../neqsim/thermo/phase/PhaseGEUnifac.java | 6 +++--- .../thermo/phase/PhaseGEUnifacPSRK.java | 4 ++-- .../thermo/phase/PhaseGEUnifacUMRPRU.java | 6 +++--- .../neqsim/thermo/phase/PhaseGEUniquac.java | 4 ++-- .../phase/PhaseGEUniquacmodifiedHV.java | 2 +- .../neqsim/thermo/phase/PhaseGEWilson.java | 2 +- .../neqsim/thermo/phase/PhaseInterface.java | 18 ----------------- .../java/neqsim/thermo/phase/PhaseSrkCPA.java | 8 ++++---- 24 files changed, 67 insertions(+), 77 deletions(-) diff --git a/src/main/java/neqsim/thermo/component/ComponentHydrate.java b/src/main/java/neqsim/thermo/component/ComponentHydrate.java index fc5020095a..54a81126a8 100644 --- a/src/main/java/neqsim/thermo/component/ComponentHydrate.java +++ b/src/main/java/neqsim/thermo/component/ComponentHydrate.java @@ -4,6 +4,7 @@ import org.apache.logging.log4j.Logger; import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; import neqsim.util.database.NeqSimDataBase; /** @@ -659,7 +660,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, 1, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 0, PhaseType.byValue(1), 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 d8df593216..a8ab115853 100644 --- a/src/main/java/neqsim/thermo/component/ComponentHydrateBallard.java +++ b/src/main/java/neqsim/thermo/component/ComponentHydrateBallard.java @@ -3,6 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *

@@ -61,7 +62,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, 0, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, PhaseType.byValue(0), 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 652522e8da..8d0c559919 100644 --- a/src/main/java/neqsim/thermo/component/ComponentHydrateGF.java +++ b/src/main/java/neqsim/thermo/component/ComponentHydrateGF.java @@ -3,6 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *

@@ -94,7 +95,7 @@ public double fugcoef(PhaseInterface phase, int numberOfComps, double temp, doub refPhase.setTemperature(temp); refPhase.setPressure(pres); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, 0, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, PhaseType.byValue(0), 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 c5f4a5a4ea..a400ea64e6 100644 --- a/src/main/java/neqsim/thermo/component/ComponentHydratePVTsim.java +++ b/src/main/java/neqsim/thermo/component/ComponentHydratePVTsim.java @@ -3,6 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; import neqsim.util.database.NeqSimDataBase; /** @@ -95,7 +96,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, 0, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, PhaseType.byValue(0), 1.0); double refWaterFugacityCoef = Math.log(refPhase.getComponent("water").fugcoef(refPhase)); @@ -125,7 +126,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, 0, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, PhaseType.byValue(0), 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 16c10f2e91..b8d27c4a4e 100644 --- a/src/main/java/neqsim/thermo/component/ComponentSolid.java +++ b/src/main/java/neqsim/thermo/component/ComponentSolid.java @@ -7,6 +7,7 @@ package neqsim.thermo.component; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *

@@ -108,7 +109,7 @@ public double fugcoef(double temp, double pres) { refPhase.setTemperature(temp); refPhase.setPressure(PvapSolid); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, 1, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.byValue(1), 1.0); refPhase.getComponent(0).fugcoef(refPhase); // System.out.println("ref co2 fugcoef " + @@ -138,7 +139,7 @@ public double fugcoef(double temp, double pres) { public double fugcoef2(PhaseInterface phase1) { refPhase.setTemperature(phase1.getTemperature()); refPhase.setPressure(phase1.getPressure()); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, 0, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.byValue(0), 1.0); refPhase.getComponent(0).fugcoef(refPhase); double liquidPhaseFugacity = @@ -243,7 +244,7 @@ public void setSolidRefFluidPhase(PhaseInterface phase) { } refPhase.getComponent(componentName) .setAttractiveTerm(phase.getComponent(componentName).getAttractiveTermNumber()); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 0, 1, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 0, PhaseType.byValue(1), 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 c30d2dff22..a6f7308d5e 100644 --- a/src/main/java/neqsim/thermo/component/ComponentWax.java +++ b/src/main/java/neqsim/thermo/component/ComponentWax.java @@ -7,6 +7,7 @@ package neqsim.thermo.component; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *

@@ -54,7 +55,7 @@ public double fugcoef2(PhaseInterface phase1) { logger.error(ex.getMessage(), ex); } refPhase.setPressure(phase1.getPressure()); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, 0, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.byValue(0), 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 5a7948be9d..fc8daf3448 100644 --- a/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java +++ b/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java @@ -2,6 +2,7 @@ import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *

@@ -45,7 +46,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, 0, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.byValue(0), 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 74bfcaa1f5..7f5a8509da 100644 --- a/src/main/java/neqsim/thermo/component/ComponentWonWax.java +++ b/src/main/java/neqsim/thermo/component/ComponentWonWax.java @@ -3,6 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *

@@ -45,7 +46,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, 0, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.byValue(0), 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 adabe1e3ea..2bb1ff7a40 100644 --- a/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java +++ b/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java @@ -22,6 +22,7 @@ import neqsim.thermo.phase.PhaseGEUnifacPSRK; import neqsim.thermo.phase.PhaseGEUnifacUMRPRU; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; import neqsim.util.database.NeqSimDataBase; /** @@ -1011,7 +1012,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(), 1); + phase.getPressure(), PhaseType.byValue(1)); gePhase.setProperties(phase); } @@ -1025,7 +1026,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(), 1); + phase.getPressure(), PhaseType.byValue(1)); gePhase.setProperties(phase); } @@ -1090,7 +1091,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(), 0) + phase.getTemperature(), phase.getPressure(), PhaseType.byValue(0)) / gePhase.getNumberOfMolesInPhase() / hwfc); Atot = A; return A; @@ -1308,8 +1309,7 @@ public void init(PhaseInterface phase, double temperature, double pressure, int gePhase.setParams(phase, HValpha, HVDij, HVDijT, classicOrHV, intparam); if (mixingRuleGEModel.equals("NRTL")) { - gePhase.getExcessGibbsEnergy(phase, numbcomp, temperature, pressure, - phase.getType().getValue()); + gePhase.getExcessGibbsEnergy(phase, numbcomp, temperature, pressure, phase.getType()); } else { gePhase.init((phase.getNumberOfMolesInPhase() / phase.getBeta()), phase.getNumberOfComponents(), phase.getInitType(), phase.getType(), phase.getBeta()); @@ -1616,8 +1616,7 @@ public void init(PhaseInterface phase, double temperature, double pressure, int gePhase.setProperties(phase); if (mixingRuleGEModel.equals("NRTL")) { - gePhase.getExcessGibbsEnergy(phase, numbcomp, temperature, pressure, - phase.getType().getValue()); + gePhase.getExcessGibbsEnergy(phase, numbcomp, temperature, pressure, phase.getType()); } else { gePhase.init(phase.getNumberOfMolesInPhase(), phase.getNumberOfComponents(), 3, phase.getType(), phase.getBeta()); diff --git a/src/main/java/neqsim/thermo/phase/PhaseDesmukhMather.java b/src/main/java/neqsim/thermo/phase/PhaseDesmukhMather.java index 911d0c8c7c..9eebc6aa42 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseDesmukhMather.java +++ b/src/main/java/neqsim/thermo/phase/PhaseDesmukhMather.java @@ -178,11 +178,11 @@ public double getExcessGibbsEnergy() { /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType phasetype) { GE = 0; for (int i = 0; i < numberOfComponents; i++) { GE += phase.getComponents()[i].getx() * Math.log(((ComponentDesmukhMather) componentArray[i]) - .getGamma(phase, numberOfComponents, temperature, pressure, phasetype)); + .getGamma(phase, numberOfComponents, temperature, pressure, phasetype.getValue())); } // System.out.println("ge " + GE); return R * temperature * numberOfMolesInPhase * GE; // phase.getNumberOfMolesInPhase()* diff --git a/src/main/java/neqsim/thermo/phase/PhaseDuanSun.java b/src/main/java/neqsim/thermo/phase/PhaseDuanSun.java index 00af4cc77f..cb1a65a2e0 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseDuanSun.java +++ b/src/main/java/neqsim/thermo/phase/PhaseDuanSun.java @@ -70,7 +70,7 @@ public double getExcessGibbsEnergy() { /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType phasetype) { GE = 0; double salinity = 0.0; // double k=0.0; @@ -99,8 +99,9 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, // GE += phase.getComponents()[i].getx()*Math.log(((ComponentGeDuanSun) // componentArray[i]).getGammaNRTL(phase, numberOfComponents, temperature, pressure, // phasetype, alpha, Dij)); - GE += phase.getComponents()[i].getx() * Math.log(((ComponentGeDuanSun) componentArray[i]) - .getGammaPitzer(phase, numberOfComponents, temperature, pressure, phasetype, salinity)); + GE += phase.getComponents()[i].getx() + * Math.log(((ComponentGeDuanSun) componentArray[i]).getGammaPitzer(phase, + numberOfComponents, temperature, pressure, phasetype.getValue(), salinity)); } return R * temperature * numberOfMolesInPhase * GE; // phase.getNumberOfMolesInPhase()* diff --git a/src/main/java/neqsim/thermo/phase/PhaseGE.java b/src/main/java/neqsim/thermo/phase/PhaseGE.java index 1afebf72ff..ddb59ee4d6 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGE.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGE.java @@ -51,17 +51,17 @@ public PhaseGE() { * @param totalNumberOfMoles a double * @param beta a double * @param numberOfComponents a int - * @param type a int + * @param PhaseType a int * @param phase a int */ public void init(double temperature, double pressure, double totalNumberOfMoles, double beta, - int numberOfComponents, int type, int phase) { + int numberOfComponents, PhaseType type, int phase) { if (totalNumberOfMoles <= 0) { new neqsim.util.exception.InvalidInputException(this, "init", "totalNumberOfMoles", "must be larger than zero."); } for (int i = 0; i < numberOfComponents; i++) { - componentArray[i].init(temperature, pressure, totalNumberOfMoles, beta, type); + componentArray[i].init(temperature, pressure, totalNumberOfMoles, beta, type.getValue()); } this.getExcessGibbsEnergy(this, numberOfComponents, temperature, pressure, type); @@ -85,11 +85,11 @@ public void init(double temperature, double pressure, double totalNumberOfMoles, /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType phase, - double beta) { - super.init(totalNumberOfMoles, numberOfComponents, initType, phase, beta); + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, + PhaseType phaseType, double beta) { + super.init(totalNumberOfMoles, numberOfComponents, initType, phaseType, beta); if (initType != 0) { - getExcessGibbsEnergy(this, numberOfComponents, temperature, pressure, phase.getValue()); + getExcessGibbsEnergy(this, numberOfComponents, temperature, pressure, phaseType); } double sumHydrocarbons = 0.0; @@ -190,7 +190,7 @@ public double getExcessGibbsEnergy() { /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType phasetype) { logger.error("this getExcessGibbsEnergy should never be used......."); return 0; } @@ -239,7 +239,7 @@ public double getActivityCoefficientInfDilWater(int k, int p) { refPhase[k].setPressure(pressure); refPhase[k].init(refPhase[k].getNumberOfMolesInPhase(), 2, 1, this.getType(), 1.0); ((PhaseGEInterface) refPhase[k]).getExcessGibbsEnergy(refPhase[k], 2, - refPhase[k].getTemperature(), refPhase[k].getPressure(), refPhase[k].getType().getValue()); + refPhase[k].getTemperature(), refPhase[k].getPressure(), refPhase[k].getType()); return ((ComponentGEInterface) refPhase[k].getComponent(0)).getGamma(); } @@ -258,7 +258,7 @@ public double getActivityCoefficientInfDil(int k) { dilphase.init(dilphase.getNumberOfMolesInPhase(), dilphase.getNumberOfComponents(), 1, dilphase.getType(), 1.0); ((PhaseGEInterface) dilphase).getExcessGibbsEnergy(dilphase, 2, dilphase.getTemperature(), - dilphase.getPressure(), dilphase.getType().getValue()); + dilphase.getPressure(), dilphase.getType()); return ((ComponentGEInterface) dilphase.getComponent(0)).getGamma(); } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEInterface.java b/src/main/java/neqsim/thermo/phase/PhaseGEInterface.java index 1973e130f4..6b09f66d4b 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEInterface.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEInterface.java @@ -24,9 +24,9 @@ public interface PhaseGEInterface { * @param numberOfComponents a int * @param temperature a double * @param pressure a double - * @param phasetype a int + * @param phasetype a PhaseType enum object * @return a double */ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype); + double temperature, double pressure, PhaseType phasetype); } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGENRTL.java b/src/main/java/neqsim/thermo/phase/PhaseGENRTL.java index 6d2b38b84b..76fea9a155 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGENRTL.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGENRTL.java @@ -108,12 +108,12 @@ public double getExcessGibbsEnergy() { /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType phasetype) { GE = 0; for (int i = 0; i < numberOfComponents; i++) { GE += phase.getComponents()[i].getx() * Math.log(((ComponentGEInterface) componentArray[i]).getGamma(phase, numberOfComponents, - temperature, pressure, phasetype, alpha, Dij, intparam, mixRule)); + temperature, pressure, phasetype.getValue(), alpha, Dij, intparam, mixRule)); } return R * temperature * numberOfMolesInPhase * GE; // phase.getNumberOfMolesInPhase()* diff --git a/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHV.java b/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHV.java index 7bdcce29c4..160fd9ac85 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHV.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHV.java @@ -125,17 +125,17 @@ public void setDijT(double[][] DijT) { /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType phasetype) { GE = 0.0; for (int i = 0; i < numberOfComponents; i++) { if (type == 0) { GE += phase.getComponents()[i].getx() * Math .log(((ComponentGEInterface) componentArray[i]).getGamma(phase, numberOfComponents, - temperature, pressure, phasetype, alpha, Dij, intparam, mixRule)); + temperature, pressure, phasetype.getValue(), alpha, Dij, intparam, mixRule)); } else if (type == 1) { GE += phase.getComponents()[i].getx() * Math .log(((ComponentGENRTLmodifiedHV) componentArray[i]).getGamma(phase, numberOfComponents, - temperature, pressure, phasetype, alpha, Dij, DijT, intparam, mixRule)); + temperature, pressure, phasetype.getValue(), alpha, Dij, DijT, intparam, mixRule)); } } return (R * phase.getTemperature() * GE) * phase.getNumberOfMolesInPhase(); diff --git a/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedWS.java b/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedWS.java index 6d00c6b526..12bb3af2d8 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedWS.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedWS.java @@ -92,18 +92,18 @@ public void addComponent(String name, double moles, double molesInPhase, int com /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType phasetype) { double GE = 0; for (int i = 0; i < numberOfComponents; i++) { if (type == 0) { GE += phase.getComponents()[i].getx() * Math .log(((ComponentGEInterface) componentArray[i]).getGamma(phase, numberOfComponents, - temperature, pressure, phasetype, alpha, Dij, intparam, mixRule)); + temperature, pressure, phasetype.getValue(), alpha, Dij, intparam, mixRule)); } if (type == 1) { GE += phase.getComponents()[i].getx() * Math .log(((ComponentGENRTLmodifiedWS) componentArray[i]).getGamma(phase, numberOfComponents, - temperature, pressure, phasetype, alpha, Dij, DijT, intparam, mixRule)); + temperature, pressure, phasetype.getValue(), alpha, Dij, DijT, intparam, mixRule)); } } return R * temperature * GE * numberOfMolesInPhase; diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEUnifac.java b/src/main/java/neqsim/thermo/phase/PhaseGEUnifac.java index 71979db600..c535388b38 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEUnifac.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEUnifac.java @@ -181,17 +181,17 @@ public void checkGroups() { /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy() { - return getExcessGibbsEnergy(this, numberOfComponents, temperature, pressure, pt.getValue()); + return getExcessGibbsEnergy(this, numberOfComponents, temperature, pressure, pt); } /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType phasetype) { double GE = 0.0; for (int i = 0; i < numberOfComponents; i++) { GE += phase.getComponents()[i].getx() * Math.log(((ComponentGEUniquac) componentArray[i]) - .getGamma(phase, numberOfComponents, temperature, pressure, phasetype)); + .getGamma(phase, numberOfComponents, temperature, pressure, phasetype.getValue())); } return R * phase.getTemperature() * GE * phase.getNumberOfMolesInPhase(); } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEUnifacPSRK.java b/src/main/java/neqsim/thermo/phase/PhaseGEUnifacPSRK.java index e1d35d3cfd..7b440f0e35 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEUnifacPSRK.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEUnifacPSRK.java @@ -74,11 +74,11 @@ public void setMixingRule(int type) { /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType phasetype) { double GE = 0.0; for (int i = 0; i < numberOfComponents; i++) { GE += phase.getComponents()[i].getx() * Math.log(((ComponentGEUniquac) componentArray[i]) - .getGamma(phase, numberOfComponents, temperature, pressure, phasetype)); + .getGamma(phase, numberOfComponents, temperature, pressure, phasetype.getValue())); } return R * phase.getTemperature() * GE * phase.getNumberOfMolesInPhase(); // phase.getNumberOfMolesInPhase()* } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEUnifacUMRPRU.java b/src/main/java/neqsim/thermo/phase/PhaseGEUnifacUMRPRU.java index 354612814b..526f96d16a 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEUnifacUMRPRU.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEUnifacUMRPRU.java @@ -111,9 +111,9 @@ public void setMixingRule(int type) { /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType phaseType) { double GE = 0.0; - calcCommontemp(phase, numberOfComponents, temperature, pressure, phasetype); + calcCommontemp(phase, numberOfComponents, temperature, pressure, phaseType.getValue()); // ((ComponentGEUnifacUMRPRU) phase.getComponents()[0]).commonInit(phase, numberOfComponents, // temperature, pressure, phasetype); @@ -123,7 +123,7 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, } for (int i = 0; i < numberOfComponents; i++) { GE += phase.getComponents()[i].getx() * Math.log(((ComponentGEUniquac) componentArray[i]) - .getGamma(phase, numberOfComponents, temperature, pressure, phasetype)); + .getGamma(phase, numberOfComponents, temperature, pressure, phaseType.getValue())); } return R * phase.getTemperature() * GE * phase.getNumberOfMolesInPhase(); } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEUniquac.java b/src/main/java/neqsim/thermo/phase/PhaseGEUniquac.java index 14b31c614e..095f43dbb5 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEUniquac.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEUniquac.java @@ -89,12 +89,12 @@ public double getExcessGibbsEnergy() { /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType phasetype) { GE = 0; for (int i = 0; i < numberOfComponents; i++) { GE += phase.getComponents()[i].getx() * Math.log(((ComponentGEInterface) componentArray[i]).getGamma(phase, numberOfComponents, - temperature, pressure, phasetype, alpha, Dij, intparam, mixRule)); + temperature, pressure, phasetype.getValue(), alpha, Dij, intparam, mixRule)); } return R * temperature * numberOfMolesInPhase * GE; diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEUniquacmodifiedHV.java b/src/main/java/neqsim/thermo/phase/PhaseGEUniquacmodifiedHV.java index 89a8834938..3cf72d9d91 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEUniquacmodifiedHV.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEUniquacmodifiedHV.java @@ -38,7 +38,7 @@ public void addComponent(String name, double moles, double molesInPhase, int com /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType phasetype) { double GE = 0; /* diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEWilson.java b/src/main/java/neqsim/thermo/phase/PhaseGEWilson.java index 5e1062036e..642e8b872d 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEWilson.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEWilson.java @@ -80,7 +80,7 @@ public double getExcessGibbsEnergy() { /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType phasetype) { GE = 0; for (int i = 0; i < numberOfComponents; i++) { GE += phase.getComponents()[i].getx() diff --git a/src/main/java/neqsim/thermo/phase/PhaseInterface.java b/src/main/java/neqsim/thermo/phase/PhaseInterface.java index ed8ef08a5f..0d137feb5a 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseInterface.java +++ b/src/main/java/neqsim/thermo/phase/PhaseInterface.java @@ -245,24 +245,6 @@ public default void init(double totalNumberOfMoles, int numberOfComponents, int public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType pt, double beta); - /** - *

- * init. - *

- * - * @param totalNumberOfMoles Total number of moles in system. - * @param numberOfComponents Number of components in system. - * @param type a int. Use 0 to init, and 1 to reset. - * @param ptNumber Phase type index. - * @param beta Mole fraction of this phase in system. - * @deprecated Replace with init-function using PhaseType input. - */ - @Deprecated - public default void init(double totalNumberOfMoles, int numberOfComponents, int type, - int ptNumber, double beta) { - init(totalNumberOfMoles, numberOfComponents, type, PhaseType.byValue(ptNumber), beta); - } - /** *

* initPhysicalProperties. diff --git a/src/main/java/neqsim/thermo/phase/PhaseSrkCPA.java b/src/main/java/neqsim/thermo/phase/PhaseSrkCPA.java index 694187913f..5bf676152f 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseSrkCPA.java +++ b/src/main/java/neqsim/thermo/phase/PhaseSrkCPA.java @@ -1450,10 +1450,10 @@ public void setTotalNumberOfAccociationSites(int totalNumberOfAccociationSites) * @param totalNumberOfMoles a double * @param numberOfComponents a int * @param type a int - * @param phase a int + * @param phaseType a int * @param beta a double */ - public void initOld2(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + public void initOld2(double totalNumberOfMoles, int numberOfComponents, int type, int phaseType, double beta) { // type = 0 start init, type = 1 gi nye betingelser if (type == 0) { @@ -1531,11 +1531,11 @@ public void initOld2(double totalNumberOfMoles, int numberOfComponents, int type cpamix = cpaSelect.getMixingRule(1, this); } - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, type, PhaseType.byValue(phaseType), beta); if (type > 0 && isConstantPhaseVolume()) { calcDelta(); solveX(); - super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, 1, PhaseType.byValue(phaseType), beta); gcpa = calc_g(); // lngcpa = Math.log(gcpa); setGcpav(calc_lngV()); From 62da63b475c51f62d58ec499f6b638c3b2e8f6e5 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, 23 Feb 2024 12:26:15 +0100 Subject: [PATCH 2/2] doc: javadoc fix --- src/main/java/neqsim/thermo/phase/PhaseGE.java | 2 +- src/main/java/neqsim/thermo/util/readwrite/TablePrinter.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/neqsim/thermo/phase/PhaseGE.java b/src/main/java/neqsim/thermo/phase/PhaseGE.java index ddb59ee4d6..73e6068ac6 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGE.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGE.java @@ -51,7 +51,7 @@ public PhaseGE() { * @param totalNumberOfMoles a double * @param beta a double * @param numberOfComponents a int - * @param PhaseType a int + * @param type a PhaseType enum * @param phase a int */ public void init(double temperature, double pressure, double totalNumberOfMoles, double beta, diff --git a/src/main/java/neqsim/thermo/util/readwrite/TablePrinter.java b/src/main/java/neqsim/thermo/util/readwrite/TablePrinter.java index 9c7f0f0b45..7934716b32 100644 --- a/src/main/java/neqsim/thermo/util/readwrite/TablePrinter.java +++ b/src/main/java/neqsim/thermo/util/readwrite/TablePrinter.java @@ -99,6 +99,7 @@ public static void printTable(double[][] table) { * Returns a 2D string table in a formatted and visually appealing way. * * @param doubleArray The 2D double table to be printed. + * @return 2d string table */ public static String[][] convertDoubleToString(double[][] doubleArray) { // Initialize the 2D String array with the same dimensions as the double array