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: Phase classes clean up #941

Merged
merged 2 commits into from
Mar 7, 2024
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: 2 additions & 1 deletion src/main/java/neqsim/thermo/phase/Phase.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ public double getMixGibbsEnergy() {
for (int i = 0; i < numberOfComponents; i++) {
gmix += getComponent(i).getx() * Math.log(getComponent(i).getx());
}
return getExcessGibbsEnergy() + R * temperature * gmix * numberOfMolesInPhase;
// todo: is this correct?
return R * temperature * numberOfMolesInPhase * getExcessGibbsEnergy() * gmix;
}

/** {@inheritDoc} */
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/phase/PhaseDesmukhMather.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents,
GE += phase.getComponents()[i].getx() * Math.log(((ComponentDesmukhMather) componentArray[i])
.getGamma(phase, numberOfComponents, temperature, pressure, pt));
}
// System.out.println("ge " + GE);
return R * temperature * numberOfMolesInPhase * GE; // phase.getNumberOfMolesInPhase()*
return R * temperature * numberOfMolesInPhase * GE;
}

/** {@inheritDoc} */
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/neqsim/thermo/phase/PhaseDuanSun.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents,
.getGammaPitzer(phase, numberOfComponents, temperature, pressure, pt, salinity));
}

return R * temperature * numberOfMolesInPhase * GE; // phase.getNumberOfMolesInPhase()*
return R * temperature * numberOfMolesInPhase * GE;
}

/** {@inheritDoc} */
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/neqsim/thermo/phase/PhaseGENRTL.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents,
temperature, pressure, pt, alpha, Dij, intparam, mixRule));
}

return R * temperature * numberOfMolesInPhase * GE; // phase.getNumberOfMolesInPhase()*
return R * temperature * numberOfMolesInPhase * GE;
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents,
temperature, pressure, pt, alpha, Dij, DijT, intparam, mixRule));
}
}
return (R * phase.getTemperature() * GE) * phase.getNumberOfMolesInPhase();
return R * phase.getTemperature() * phase.getNumberOfMolesInPhase() * GE;
}

/** {@inheritDoc} */
Expand All @@ -149,7 +149,7 @@ public double getGibbsEnergy() {
val +=
getComponent(i).getNumberOfMolesInPhase() * (getComponent(i).getLogFugacityCoefficient()); // +Math.log(getComponent(i).getx()*getComponent(i).getAntoineVaporPressure(temperature)));
}
return R * temperature * ((val) + Math.log(pressure) * numberOfMolesInPhase);
return R * temperature * numberOfMolesInPhase * (val + Math.log(pressure));
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,19 @@ public void addComponent(String name, double moles, double molesInPhase, int com
@Override
public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents,
double temperature, double pressure, PhaseType pt) {
// TODO: why is GE a local variable?
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, pt, alpha, Dij, intparam, mixRule));
}
if (type == 1) {
} else if (type == 1) {
GE += phase.getComponents()[i].getx() * Math
.log(((ComponentGENRTLmodifiedWS) componentArray[i]).getGamma(phase, numberOfComponents,
temperature, pressure, pt, alpha, Dij, DijT, intparam, mixRule));
}
}
return R * temperature * GE * numberOfMolesInPhase;
return R * temperature * numberOfMolesInPhase * GE;
}
}
4 changes: 2 additions & 2 deletions src/main/java/neqsim/thermo/phase/PhaseGEUnifac.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents,
GE += phase.getComponents()[i].getx() * Math.log(((ComponentGEUniquac) componentArray[i])
.getGamma(phase, numberOfComponents, temperature, pressure, pt));
}
return R * phase.getTemperature() * GE * phase.getNumberOfMolesInPhase();
return R * phase.getTemperature() * phase.getNumberOfMolesInPhase() * GE;
}

/** {@inheritDoc} */
Expand All @@ -204,7 +204,7 @@ public double getGibbsEnergy() {
val +=
getComponent(i).getNumberOfMolesInPhase() * (getComponent(i).getLogFugacityCoefficient());
}
return R * temperature * ((val) + Math.log(pressure) * numberOfMolesInPhase);
return R * temperature * numberOfMolesInPhase * (val + Math.log(pressure));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/neqsim/thermo/phase/PhaseGEUnifacPSRK.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents,
GE += phase.getComponents()[i].getx() * Math.log(((ComponentGEUniquac) componentArray[i])
.getGamma(phase, numberOfComponents, temperature, pressure, pt));
}
return R * phase.getTemperature() * GE * phase.getNumberOfMolesInPhase(); // phase.getNumberOfMolesInPhase()*
return R * phase.getTemperature() * phase.getNumberOfMolesInPhase() * GE;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents,
GE += phase.getComponents()[i].getx() * Math.log(((ComponentGEUniquac) componentArray[i])
.getGamma(phase, numberOfComponents, temperature, pressure, pt));
}
return R * phase.getTemperature() * GE * phase.getNumberOfMolesInPhase();
return R * phase.getTemperature() * phase.getNumberOfMolesInPhase() * GE;
}

/**
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/neqsim/thermo/phase/PhasePCSAFT.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ public double calcmSAFT() {
*/
public double calcF1dispSumTerm() {
double temp1 = 0.0;

for (int i = 0; i < numberOfComponents; i++) {
for (int j = 0; j < numberOfComponents; j++) {
temp1 +=
Expand All @@ -358,7 +357,6 @@ public double calcF1dispSumTerm() {
*/
public double calcF2dispSumTerm() {
double temp1 = 0.0;

for (int i = 0; i < numberOfComponents; i++) {
for (int j = 0; j < numberOfComponents; j++) {
temp1 += getComponent(i).getNumberOfMolesInPhase()
Expand Down
47 changes: 4 additions & 43 deletions src/main/java/neqsim/thermo/phase/PhasePCSAFTRahmat.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
*/
public class PhasePCSAFTRahmat extends PhasePCSAFT {
private static final long serialVersionUID = 1000;
static Logger logger = LogManager.getLogger(PhasePCSAFTRahmat.class);

double nSAFT = 1.0;
double dnSAFTdV = 1.0;

double dnSAFTdVdV = 1.0;

double dnSAFTdVdVdV = 1.0;

double dmeanSAFT = 0.0;
Expand All @@ -34,33 +33,22 @@ public class PhasePCSAFTRahmat extends PhasePCSAFT {
double volumeSAFT = 1.0;
double daHCSAFTdN = 1.0;
double daHSSAFTdN = 1.0;

double dgHSSAFTdN = 1.0;

double daHSSAFTdNdN = 1.0;

double dgHSSAFTdNdN = 1.0;

double daHSSAFTdNdNdN = 1.0;

double dgHSSAFTdNdNdN = 1.0;

// by Rahmat
double dNSAFTdT = 1.0;
double dF1dispVolTermdT = 0.0;
double dF1dispI1dT = 1.0;

double dF2dispI2dT = 1.0;

double dF2dispZHCdT = 1.0;
double dF1dispSumTermdT = 1.0;

double dF2dispSumTermdT = 1.0;

int useHS = 1;

int useDISP1 = 1;

int useDISP2 = 1;

private double[][] aConstSAFT = {
Expand All @@ -78,65 +66,35 @@ public class PhasePCSAFTRahmat extends PhasePCSAFT {
{0.0976883116, -0.2557574982, -9.1558561530, 20.642075974, -38.804430052, 93.626774077,
-29.666905585}};
private double F1dispVolTerm = 1.0;

private double F1dispSumTerm = 1.0;

private double F1dispI1 = 1.0;

private double F2dispI2 = 1.0;

private double F2dispZHC = 1.0;

private double F2dispZHCdN = 1.0;

private double F2dispZHCdm = 1.0;

private double F2dispZHCdV = 1.0;

private double F2dispI2dVdV;

private double F2dispI2dVdVdV = 0.0;

private double F2dispZHCdVdV = 1.0;

private double F2dispZHCdVdVdV = 1.0;

private double F1dispI1dNdN = 1.0;

private double F1dispI1dNdNdN = 1.0;

private double F1dispVolTermdV = 1.0;

private double F1dispVolTermdVdV = 1.0;

private double F1dispI1dN = 1.0;

private double F1dispI1dm = 1.0;

private double F1dispI1dV = 1.0;

private double F2dispI2dV = 1.0;

private double F2dispI2dN = 1.0;

private double F2dispI2dm = 1.0;

private double F2dispSumTerm = 0.0;

private double F2dispZHCdNdN = 1.0;

private double F2dispZHCdNdNdN = 1.0;

private double F2dispI2dNdN = 1.0;

private double F2dispI2dNdNdN = 1.0;

private double F1dispI1dVdV = 1.0;

private double F1dispI1dVdVdV = 1.0;

private double F1dispVolTermdVdVdV = 1.0;
static Logger logger = LogManager.getLogger(PhasePCSAFTRahmat.class);

/**
* <p>
Expand Down Expand Up @@ -171,10 +129,13 @@ public void addComponent(String name, double moles, double molesInPhase, int com
@Override
public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt,
double beta) {
// missing?
// if (initType > 0) {
for (int i = 0; i < numberOfComponents; i++) {
componentArray[i].Finit(this, temperature, pressure, totalNumberOfMoles, beta,
numberOfComponents, initType);
}
// }
super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta);
}

Expand Down
Loading