diff --git a/src/main/java/neqsim/thermo/system/SystemBWRSEos.java b/src/main/java/neqsim/thermo/system/SystemBWRSEos.java index d003204388..57ef9932c8 100644 --- a/src/main/java/neqsim/thermo/system/SystemBWRSEos.java +++ b/src/main/java/neqsim/thermo/system/SystemBWRSEos.java @@ -62,8 +62,7 @@ public SystemBWRSEos(double T, double P, boolean solidCheck) { this(T, P); modelName = "BWRS-EOS"; attractiveTermNumber = 0; - numberOfPhases = 5; - maxNumberOfPhases = 5; + setNumberOfPhases(5); solidPhaseCheck = solidCheck; for (int i = 0; i < numberOfPhases; i++) { diff --git a/src/main/java/neqsim/thermo/system/SystemCSPsrkEos.java b/src/main/java/neqsim/thermo/system/SystemCSPsrkEos.java index ee5a971aa9..0a82ee951a 100644 --- a/src/main/java/neqsim/thermo/system/SystemCSPsrkEos.java +++ b/src/main/java/neqsim/thermo/system/SystemCSPsrkEos.java @@ -60,8 +60,7 @@ public SystemCSPsrkEos(double T, double P, boolean solidCheck) { this(T, P); modelName = "CSPsrk-EOS"; attractiveTermNumber = 0; - numberOfPhases = 5; - maxNumberOfPhases = 5; + setNumberOfPhases(5); solidPhaseCheck = solidCheck; for (int i = 0; i < numberOfPhases; i++) { diff --git a/src/main/java/neqsim/thermo/system/SystemDesmukhMather.java b/src/main/java/neqsim/thermo/system/SystemDesmukhMather.java index 96cfb6a479..aead20c9b7 100644 --- a/src/main/java/neqsim/thermo/system/SystemDesmukhMather.java +++ b/src/main/java/neqsim/thermo/system/SystemDesmukhMather.java @@ -56,8 +56,7 @@ public SystemDesmukhMather(double T, double P) { public SystemDesmukhMather(double T, double P, boolean solidCheck) { this(T, P); attractiveTermNumber = 0; - numberOfPhases = 4; - maxNumberOfPhases = 4; + setNumberOfPhases(4); modelName = "Desmukh-Mather-model"; solidPhaseCheck = solidCheck; diff --git a/src/main/java/neqsim/thermo/system/SystemDuanSun.java b/src/main/java/neqsim/thermo/system/SystemDuanSun.java index 3376bd7aae..2274c25481 100644 --- a/src/main/java/neqsim/thermo/system/SystemDuanSun.java +++ b/src/main/java/neqsim/thermo/system/SystemDuanSun.java @@ -65,8 +65,7 @@ public SystemDuanSun(double T, double P) { public SystemDuanSun(double T, double P, boolean solidCheck) { this(T, P); attractiveTermNumber = 0; - numberOfPhases = 4; - maxNumberOfPhases = 4; + setNumberOfPhases(4); modelName = "Duan-Sun-model"; solidPhaseCheck = solidCheck; diff --git a/src/main/java/neqsim/thermo/system/SystemGERG2004Eos.java b/src/main/java/neqsim/thermo/system/SystemGERG2004Eos.java index 137a21e78f..2495f4a5f1 100644 --- a/src/main/java/neqsim/thermo/system/SystemGERG2004Eos.java +++ b/src/main/java/neqsim/thermo/system/SystemGERG2004Eos.java @@ -62,8 +62,7 @@ public SystemGERG2004Eos(double T, double P, boolean solidCheck) { this(T, P); modelName = "GERG2004-EOS"; - numberOfPhases = 5; - maxNumberOfPhases = 5; + setNumberOfPhases(5); solidPhaseCheck = solidCheck; for (int i = 0; i < numberOfPhases; i++) { phaseArray[i] = new PhaseGERG2004Eos(); diff --git a/src/main/java/neqsim/thermo/system/SystemGERGwaterEos.java b/src/main/java/neqsim/thermo/system/SystemGERGwaterEos.java index 819ba2bfb3..66e955fa75 100644 --- a/src/main/java/neqsim/thermo/system/SystemGERGwaterEos.java +++ b/src/main/java/neqsim/thermo/system/SystemGERGwaterEos.java @@ -60,8 +60,7 @@ public SystemGERGwaterEos(double T, double P, boolean solidCheck) { this(T, P); modelName = "GERG-water-EOS"; attractiveTermNumber = 10; - numberOfPhases = 5; - maxNumberOfPhases = 5; + setNumberOfPhases(5); solidPhaseCheck = solidCheck; for (int i = 0; i < numberOfPhases; i++) { diff --git a/src/main/java/neqsim/thermo/system/SystemGEWilson.java b/src/main/java/neqsim/thermo/system/SystemGEWilson.java index 9d5190ea9c..80438ae087 100644 --- a/src/main/java/neqsim/thermo/system/SystemGEWilson.java +++ b/src/main/java/neqsim/thermo/system/SystemGEWilson.java @@ -56,8 +56,7 @@ public SystemGEWilson(double T, double P) { public SystemGEWilson(double T, double P, boolean solidCheck) { this(T, P); attractiveTermNumber = 0; - numberOfPhases = 4; - maxNumberOfPhases = 4; + setNumberOfPhases(4); modelName = "UNIFAC-GE-model"; solidPhaseCheck = solidCheck; diff --git a/src/main/java/neqsim/thermo/system/SystemKentEisenberg.java b/src/main/java/neqsim/thermo/system/SystemKentEisenberg.java index fdf5ddd500..df7af04c72 100644 --- a/src/main/java/neqsim/thermo/system/SystemKentEisenberg.java +++ b/src/main/java/neqsim/thermo/system/SystemKentEisenberg.java @@ -56,8 +56,7 @@ public SystemKentEisenberg(double T, double P) { public SystemKentEisenberg(double T, double P, boolean solidCheck) { this(T, P); attractiveTermNumber = 0; - numberOfPhases = 4; - maxNumberOfPhases = 4; + setNumberOfPhases(4); modelName = "Kent Eisenberg-model"; solidPhaseCheck = solidCheck; diff --git a/src/main/java/neqsim/thermo/system/SystemNRTL.java b/src/main/java/neqsim/thermo/system/SystemNRTL.java index 1805b81b70..f9d6d67f86 100644 --- a/src/main/java/neqsim/thermo/system/SystemNRTL.java +++ b/src/main/java/neqsim/thermo/system/SystemNRTL.java @@ -56,8 +56,7 @@ public SystemNRTL(double T, double P) { public SystemNRTL(double T, double P, boolean solidCheck) { this(T, P); attractiveTermNumber = 0; - numberOfPhases = 4; - maxNumberOfPhases = 4; + setNumberOfPhases(4); modelName = "NRTL-GE-model"; solidPhaseCheck = solidCheck; diff --git a/src/main/java/neqsim/thermo/system/SystemPCSAFT.java b/src/main/java/neqsim/thermo/system/SystemPCSAFT.java index 29aa196b0e..2e97e076c2 100644 --- a/src/main/java/neqsim/thermo/system/SystemPCSAFT.java +++ b/src/main/java/neqsim/thermo/system/SystemPCSAFT.java @@ -67,8 +67,7 @@ public SystemPCSAFT(double T, double P, boolean solidCheck) { this(T, P); modelName = "PCSAFT-EOS"; attractiveTermNumber = 0; - numberOfPhases = 5; - maxNumberOfPhases = 5; + setNumberOfPhases(5); solidPhaseCheck = solidCheck; for (int i = 0; i < numberOfPhases; i++) { phaseArray[i] = new PhasePCSAFTRahmat(); diff --git a/src/main/java/neqsim/thermo/system/SystemPCSAFTa.java b/src/main/java/neqsim/thermo/system/SystemPCSAFTa.java index 24153bb0b0..f7fa775131 100644 --- a/src/main/java/neqsim/thermo/system/SystemPCSAFTa.java +++ b/src/main/java/neqsim/thermo/system/SystemPCSAFTa.java @@ -62,8 +62,7 @@ public SystemPCSAFTa(double T, double P, boolean solidCheck) { this(T, P); modelName = "PCSAFTa-EOS"; attractiveTermNumber = 0; - numberOfPhases = 5; - maxNumberOfPhases = 5; + setNumberOfPhases(5); solidPhaseCheck = solidCheck; for (int i = 0; i < numberOfPhases; i++) { phaseArray[i] = new PhasePCSAFTa(); diff --git a/src/main/java/neqsim/thermo/system/SystemPrDanesh.java b/src/main/java/neqsim/thermo/system/SystemPrDanesh.java index 18f8898875..bc44f6726e 100644 --- a/src/main/java/neqsim/thermo/system/SystemPrDanesh.java +++ b/src/main/java/neqsim/thermo/system/SystemPrDanesh.java @@ -60,8 +60,7 @@ public SystemPrDanesh(double T, double P, boolean solidCheck) { this(T, P); modelName = "PR-Danesh-EOS"; attractiveTermNumber = 9; - numberOfPhases = 5; - maxNumberOfPhases = 5; + setNumberOfPhases(5); solidPhaseCheck = solidCheck; for (int i = 0; i < numberOfPhases; i++) { diff --git a/src/main/java/neqsim/thermo/system/SystemPrEos.java b/src/main/java/neqsim/thermo/system/SystemPrEos.java index 8721e14a60..4a40b5627a 100644 --- a/src/main/java/neqsim/thermo/system/SystemPrEos.java +++ b/src/main/java/neqsim/thermo/system/SystemPrEos.java @@ -57,9 +57,8 @@ public SystemPrEos(double T, double P) { public SystemPrEos(double T, double P, boolean solidCheck) { this(T, P); attractiveTermNumber = 1; - numberOfPhases = 5; + setNumberOfPhases(5); modelName = "PR-EOS"; - maxNumberOfPhases = 5; solidPhaseCheck = solidCheck; for (int i = 0; i < numberOfPhases; i++) { diff --git a/src/main/java/neqsim/thermo/system/SystemPrEos1978.java b/src/main/java/neqsim/thermo/system/SystemPrEos1978.java index f69017ba2b..25d622b94a 100644 --- a/src/main/java/neqsim/thermo/system/SystemPrEos1978.java +++ b/src/main/java/neqsim/thermo/system/SystemPrEos1978.java @@ -56,9 +56,8 @@ public SystemPrEos1978(double T, double P) { public SystemPrEos1978(double T, double P, boolean solidCheck) { this(T, P); attractiveTermNumber = 13; - numberOfPhases = 5; + setNumberOfPhases(5); modelName = "PR1978-EOS"; - maxNumberOfPhases = 5; solidPhaseCheck = solidCheck; for (int i = 0; i < numberOfPhases; i++) { diff --git a/src/main/java/neqsim/thermo/system/SystemPrGassemEos.java b/src/main/java/neqsim/thermo/system/SystemPrGassemEos.java index 00586027fb..9b292d72f7 100644 --- a/src/main/java/neqsim/thermo/system/SystemPrGassemEos.java +++ b/src/main/java/neqsim/thermo/system/SystemPrGassemEos.java @@ -60,8 +60,7 @@ public SystemPrGassemEos(double T, double P, boolean solidCheck) { this(T, P); modelName = "PR-Gassem-EOS"; attractiveTermNumber = 8; - numberOfPhases = 5; - maxNumberOfPhases = 5; + setNumberOfPhases(5); solidPhaseCheck = solidCheck; for (int i = 0; i < numberOfPhases; i++) { diff --git a/src/main/java/neqsim/thermo/system/SystemRKEos.java b/src/main/java/neqsim/thermo/system/SystemRKEos.java index f49dc0f190..123e6d7eaf 100644 --- a/src/main/java/neqsim/thermo/system/SystemRKEos.java +++ b/src/main/java/neqsim/thermo/system/SystemRKEos.java @@ -53,9 +53,8 @@ public SystemRKEos(double T, double P) { public SystemRKEos(double T, double P, boolean solidCheck) { this(T, P); attractiveTermNumber = 5; - numberOfPhases = 4; + setNumberOfPhases(4); modelName = "RK-EOS"; - maxNumberOfPhases = 4; solidPhaseCheck = solidCheck; for (int i = 0; i < numberOfPhases; i++) { diff --git a/src/main/java/neqsim/thermo/system/SystemSrkEos.java b/src/main/java/neqsim/thermo/system/SystemSrkEos.java index 1dc59c7005..bd85091f56 100644 --- a/src/main/java/neqsim/thermo/system/SystemSrkEos.java +++ b/src/main/java/neqsim/thermo/system/SystemSrkEos.java @@ -58,8 +58,7 @@ public SystemSrkEos(double T, double P, boolean solidCheck) { this(T, P); modelName = "SRK-EOS"; attractiveTermNumber = 0; - numberOfPhases = 5; - maxNumberOfPhases = 5; + setNumberOfPhases(5); solidPhaseCheck = solidCheck; for (int i = 0; i < numberOfPhases; i++) { phaseArray[i] = new PhaseSrkEos(); diff --git a/src/main/java/neqsim/thermo/system/SystemSrkPenelouxEos.java b/src/main/java/neqsim/thermo/system/SystemSrkPenelouxEos.java index 65b748b94c..efaf18cf29 100644 --- a/src/main/java/neqsim/thermo/system/SystemSrkPenelouxEos.java +++ b/src/main/java/neqsim/thermo/system/SystemSrkPenelouxEos.java @@ -58,8 +58,7 @@ public SystemSrkPenelouxEos(double T, double P, boolean solidCheck) { this(T, P); modelName = "SRK-Peneloux-EOS"; attractiveTermNumber = 0; - numberOfPhases = 5; - maxNumberOfPhases = 5; + setNumberOfPhases(5); solidPhaseCheck = solidCheck; for (int i = 0; i < numberOfPhases; i++) { phaseArray[i] = new PhaseSrkPenelouxEos(); diff --git a/src/main/java/neqsim/thermo/system/SystemTSTEos.java b/src/main/java/neqsim/thermo/system/SystemTSTEos.java index 2df56f47d3..ad665d0063 100644 --- a/src/main/java/neqsim/thermo/system/SystemTSTEos.java +++ b/src/main/java/neqsim/thermo/system/SystemTSTEos.java @@ -62,9 +62,8 @@ public SystemTSTEos(double T, double P) { public SystemTSTEos(double T, double P, boolean solidCheck) { this(T, P); attractiveTermNumber = 14; - numberOfPhases = 5; + setNumberOfPhases(5); modelName = "TST-EOS"; - maxNumberOfPhases = 5; solidPhaseCheck = solidCheck; for (int i = 0; i < numberOfPhases; i++) { diff --git a/src/main/java/neqsim/thermo/system/SystemThermo.java b/src/main/java/neqsim/thermo/system/SystemThermo.java index b8528d365a..1eea9eb92a 100644 --- a/src/main/java/neqsim/thermo/system/SystemThermo.java +++ b/src/main/java/neqsim/thermo/system/SystemThermo.java @@ -167,7 +167,7 @@ public void clearAll() { phaseType[0] = 1; phaseType[1] = 0; numberOfComponents = 0; - numberOfPhases = 2; + setNumberOfPhases(2); phase = 2; onePhaseType = 1; beta[0] = 1.0; @@ -324,7 +324,7 @@ public void addSolidPhase() { } } ((PhaseSolid) phaseArray[3]).setSolidRefFluidPhase(phaseArray[0]); - // numberOfPhases = 4; + if (getMaxNumberOfPhases() < 4) { setMaxNumberOfPhases(4); } @@ -354,8 +354,7 @@ public void addHydratePhase2() { getPhase(0).getComponent(i).getNumberOfmoles(), i); } } - numberOfPhases = 4; - setMaxNumberOfPhases(4); + setNumberOfPhases(4); } /** {@inheritDoc} */ @@ -387,8 +386,7 @@ public void addSolidComplexPhase(String type) { } } ((PhaseSolid) phaseArray[5]).setSolidRefFluidPhase(phaseArray[0]); - numberOfPhases = 6; - setMaxNumberOfPhases(6); + setNumberOfPhases(6); } /** @@ -439,10 +437,7 @@ public void addHydratePhase() { } ((PhaseHydrate) phaseArray[4]).setSolidRefFluidPhase(phaseArray[0]); - numberOfPhases = 5; - if (getMaxNumberOfPhases() < 5) { - setMaxNumberOfPhases(5); - } + setNumberOfPhases(5); } /** {@inheritDoc} */ @@ -1722,7 +1717,7 @@ public void init(int type, int phase) { */ public void initAnalytic(int type) { if (type == 0) { - numberOfPhases = getMaxNumberOfPhases(); + setNumberOfPhases(getMaxNumberOfPhases()); for (int i = 0; i < numberOfPhases; i++) { phaseType[i] = 0; beta[i] = 1.0; @@ -1736,7 +1731,7 @@ public void initAnalytic(int type) { phaseType[phaseIndex[i]], beta[phaseIndex[i]]); } } - numberOfPhases = 2; + setNumberOfPhases(2); } if (type == 1) { @@ -2302,6 +2297,9 @@ public String[] getComponentNames() { @Override public void setNumberOfPhases(int number) { this.numberOfPhases = number; + if (getMaxNumberOfPhases() < numberOfPhases) { + setMaxNumberOfPhases(number); + } } /** {@inheritDoc} */ @@ -3513,7 +3511,7 @@ public void setSolidPhaseCheck(boolean solidPhaseCheck) { getPhase(3).getComponent(k).setSolidCheck(solidPhaseCheck); } } - numberOfPhases = oldphase; + setNumberOfPhases(oldphase); } /** {@inheritDoc} */ @@ -3535,7 +3533,7 @@ public void setSolidPhaseCheck(String solidComponent) { logger.error("error", e); } } - numberOfPhases = oldphase; + setNumberOfPhases(oldphase); } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/thermo/system/SystemUNIFAC.java b/src/main/java/neqsim/thermo/system/SystemUNIFAC.java index 9be3c33503..29f5a82ac3 100644 --- a/src/main/java/neqsim/thermo/system/SystemUNIFAC.java +++ b/src/main/java/neqsim/thermo/system/SystemUNIFAC.java @@ -57,8 +57,7 @@ public SystemUNIFAC(double T, double P) { public SystemUNIFAC(double T, double P, boolean solidCheck) { this(T, P); attractiveTermNumber = 0; - numberOfPhases = 4; - maxNumberOfPhases = 4; + setNumberOfPhases(4); modelName = "UNIFAC-GE-model"; solidPhaseCheck = solidCheck; diff --git a/src/main/java/neqsim/thermo/system/SystemUNIFACpsrk.java b/src/main/java/neqsim/thermo/system/SystemUNIFACpsrk.java index ad1e28583e..f39576eb98 100644 --- a/src/main/java/neqsim/thermo/system/SystemUNIFACpsrk.java +++ b/src/main/java/neqsim/thermo/system/SystemUNIFACpsrk.java @@ -56,8 +56,7 @@ public SystemUNIFACpsrk(double T, double P) { public SystemUNIFACpsrk(double T, double P, boolean solidCheck) { this(T, P); attractiveTermNumber = 0; - numberOfPhases = 4; - maxNumberOfPhases = 4; + setNumberOfPhases(4); modelName = "UNIFAC-GE-model"; solidPhaseCheck = solidCheck;