Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refact: setNumberOfPhases also increases maxNumberOfPhases if needed #386

Merged
merged 1 commit into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/system/SystemBWRSEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/system/SystemCSPsrkEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/system/SystemDuanSun.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/system/SystemGERG2004Eos.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/system/SystemGEWilson.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/system/SystemNRTL.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/system/SystemPCSAFT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/system/SystemPCSAFTa.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/system/SystemPrDanesh.java
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/system/SystemPrEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/system/SystemPrEos1978.java
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/system/SystemPrGassemEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/system/SystemRKEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/system/SystemSrkEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/system/SystemTSTEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
26 changes: 12 additions & 14 deletions src/main/java/neqsim/thermo/system/SystemThermo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -324,7 +324,7 @@ public void addSolidPhase() {
}
}
((PhaseSolid) phaseArray[3]).setSolidRefFluidPhase(phaseArray[0]);
// numberOfPhases = 4;

if (getMaxNumberOfPhases() < 4) {
setMaxNumberOfPhases(4);
}
Expand Down Expand Up @@ -354,8 +354,7 @@ public void addHydratePhase2() {
getPhase(0).getComponent(i).getNumberOfmoles(), i);
}
}
numberOfPhases = 4;
setMaxNumberOfPhases(4);
setNumberOfPhases(4);
}

/** {@inheritDoc} */
Expand Down Expand Up @@ -387,8 +386,7 @@ public void addSolidComplexPhase(String type) {
}
}
((PhaseSolid) phaseArray[5]).setSolidRefFluidPhase(phaseArray[0]);
numberOfPhases = 6;
setMaxNumberOfPhases(6);
setNumberOfPhases(6);
}

/**
Expand Down Expand Up @@ -439,10 +437,7 @@ public void addHydratePhase() {
}
((PhaseHydrate) phaseArray[4]).setSolidRefFluidPhase(phaseArray[0]);

numberOfPhases = 5;
if (getMaxNumberOfPhases() < 5) {
setMaxNumberOfPhases(5);
}
setNumberOfPhases(5);
}

/** {@inheritDoc} */
Expand Down Expand Up @@ -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;
Expand All @@ -1736,7 +1731,7 @@ public void initAnalytic(int type) {
phaseType[phaseIndex[i]], beta[phaseIndex[i]]);
}
}
numberOfPhases = 2;
setNumberOfPhases(2);
}

if (type == 1) {
Expand Down Expand Up @@ -2302,6 +2297,9 @@ public String[] getComponentNames() {
@Override
public void setNumberOfPhases(int number) {
this.numberOfPhases = number;
if (getMaxNumberOfPhases() < numberOfPhases) {
setMaxNumberOfPhases(number);
}
}

/** {@inheritDoc} */
Expand Down Expand Up @@ -3513,7 +3511,7 @@ public void setSolidPhaseCheck(boolean solidPhaseCheck) {
getPhase(3).getComponent(k).setSolidCheck(solidPhaseCheck);
}
}
numberOfPhases = oldphase;
setNumberOfPhases(oldphase);
}

/** {@inheritDoc} */
Expand All @@ -3535,7 +3533,7 @@ public void setSolidPhaseCheck(String solidComponent) {
logger.error("error", e);
}
}
numberOfPhases = oldphase;
setNumberOfPhases(oldphase);
}

/** {@inheritDoc} */
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/system/SystemUNIFAC.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/system/SystemUNIFACpsrk.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down