Skip to content

Commit

Permalink
refact: simplify srkeos subclass constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
asmfstatoil committed Mar 15, 2024
1 parent 6d92a4a commit f3cedc5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/main/java/neqsim/thermo/system/SystemCSPsrkEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public SystemCSPsrkEos(double T, double P) {
* @param checkForSolids Set true to do solid phase check and calculations
*/
public SystemCSPsrkEos(double T, double P, boolean checkForSolids) {
super(T, P);
this.solidPhaseCheck = checkForSolids;;
super(T, P, checkForSolids);
modelName = "CSPsrk-EOS";
attractiveTermNumber = 0;

// Recreates phases created in super constructor SystemSrkEos
for (int i = 0; i < numberOfPhases; i++) {
phaseArray[i] = new PhaseCSPsrkEos();
phaseArray[i].setTemperature(T);
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/neqsim/thermo/system/SystemPCSAFT.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ public SystemPCSAFT(double T, double P) {
* @param checkForSolids Set true to do solid phase check and calculations
*/
public SystemPCSAFT(double T, double P, boolean checkForSolids) {
super(T, P);
this.solidPhaseCheck = checkForSolids;;
super(T, P, checkForSolids);
modelName = "PCSAFT-EOS";
attractiveTermNumber = 0;

// Recreates phases created in super constructor SystemSrkEos
for (int i = 0; i < numberOfPhases; i++) {
phaseArray[i] = new PhasePCSAFTRahmat();
phaseArray[i].setTemperature(T);
Expand Down Expand Up @@ -86,11 +86,6 @@ public SystemPCSAFT clone() {
logger.error("Cloning failed.", ex);
}

// clonedSystem.phaseArray = (PhaseInterface[]) phaseArray.clone();
// for(int i = 0; i < numberOfPhases; i++) {
// clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone();
// }

return clonedSystem;
}

Expand Down
9 changes: 2 additions & 7 deletions src/main/java/neqsim/thermo/system/SystemPCSAFTa.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public SystemPCSAFTa(double T, double P) {
* @param checkForSolids Set true to do solid phase check and calculations
*/
public SystemPCSAFTa(double T, double P, boolean checkForSolids) {
super(T, P);
this.solidPhaseCheck = checkForSolids;;
super(T, P, checkForSolids);
modelName = "PCSAFTa-EOS";
attractiveTermNumber = 0;

// Recreates phases created in super constructor SystemSrkEos
for (int i = 0; i < numberOfPhases; i++) {
phaseArray[i] = new PhasePCSAFTa();
phaseArray[i].setTemperature(T);
Expand Down Expand Up @@ -82,11 +82,6 @@ public SystemPCSAFTa clone() {
logger.error("Cloning failed.", ex);
}

// clonedSystem.phaseArray = (PhaseInterface[]) phaseArray.clone();
// for(int i = 0; i < numberOfPhases; i++) {
// clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone();
// }

return clonedSystem;
}
}
11 changes: 4 additions & 7 deletions src/main/java/neqsim/thermo/system/SystemSrkCPA.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ public SystemSrkCPA(double T, double P) {
*
* @param T The temperature in unit Kelvin
* @param P The pressure in unit bara (absolute pressure)
* @param checkForSolids Set true to check for solid phase and do solid phase calculations.
* @param checkForSolids Set true to do solid phase check and calculations
*/
public SystemSrkCPA(double T, double P, boolean checkForSolids) {
super(T, P);
this.solidPhaseCheck = checkForSolids;;
super(T, P, checkForSolids);

// Recreates phases created in super constructor SystemSrkEos
for (int i = 0; i < numberOfPhases; i++) {
phaseArray[i] = new PhaseSrkCPA();
phaseArray[i].setTemperature(T);
Expand Down Expand Up @@ -79,10 +80,6 @@ public SystemSrkCPA clone() {
logger.error("Cloning failed.", ex);
}

// for(int i = 0; i < numberOfPhases; i++) {
// clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone();
// }

return clonedSystem;
}

Expand Down
8 changes: 2 additions & 6 deletions src/main/java/neqsim/thermo/system/SystemSrkPenelouxEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public SystemSrkPenelouxEos(double T, double P) {
* @param checkForSolids Set true to do solid phase check and calculations
*/
public SystemSrkPenelouxEos(double T, double P, boolean checkForSolids) {
super(T, P);
this.solidPhaseCheck = checkForSolids;;
super(T, P, checkForSolids);
modelName = "SRK-Peneloux-EOS";
getCharacterization().setTBPModel("PedersenSRK");
attractiveTermNumber = 0;

// Recreates phases created in super constructor SystemSrkEos
for (int i = 0; i < numberOfPhases; i++) {
phaseArray[i] = new PhaseSrkPenelouxEos();
phaseArray[i].setTemperature(T);
Expand Down Expand Up @@ -76,10 +76,6 @@ public SystemSrkPenelouxEos clone() {
logger.error("Cloning failed.", ex);
}

// clonedSystem.phaseArray = (PhaseInterface[]) phaseArray.clone();
// for(int i = 0; i < numberOfPhases; i++) {
// clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone();
// }
return clonedSystem;
}
}

0 comments on commit f3cedc5

Please sign in to comment.