Skip to content

Commit

Permalink
chore: reorder order
Browse files Browse the repository at this point in the history
  • Loading branch information
asmfstatoil committed Jan 9, 2025
1 parent f3d0b30 commit a579f01
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 127 deletions.
30 changes: 15 additions & 15 deletions src/main/java/neqsim/thermo/Fluid.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,6 @@ public neqsim.thermo.system.SystemInterface getFluid() {
return fluid;
}

/**
*
*/
private void setThermoModel() {
if (thermoModel.equals("srk")) {
fluid = new neqsim.thermo.system.SystemSrkEos();
} else if (thermoModel.equals("pr")) {
fluid = new neqsim.thermo.system.SystemPrEos();
} else if (thermoModel.equals("cpa")) {
fluid = new neqsim.thermo.system.SystemSrkCPAstatoil();
} else {
fluid = new neqsim.thermo.system.SystemSrkEos();
}
}

/**
* <p>
* create2.
Expand Down Expand Up @@ -344,6 +329,21 @@ public String getThermoModel() {
return thermoModel;
}

/**
* Init fluid object?.
*/
private void setThermoModel() {
if (thermoModel.equals("srk")) {
fluid = new neqsim.thermo.system.SystemSrkEos();
} else if (thermoModel.equals("pr")) {
fluid = new neqsim.thermo.system.SystemPrEos();
} else if (thermoModel.equals("cpa")) {
fluid = new neqsim.thermo.system.SystemSrkCPAstatoil();
} else {
fluid = new neqsim.thermo.system.SystemSrkEos();
}
}

/**
* <p>
* Setter for the field <code>thermoModel</code>.
Expand Down
85 changes: 43 additions & 42 deletions src/main/java/neqsim/thermo/component/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -821,48 +821,6 @@ public double getNormalLiquidDensity(String unit) {
return refDensity * conversionFactor;
}

/** {@inheritDoc} */
@Override
public double getMolarMass(String unit) {
double refMolarMass = getMolarMass();
double conversionFactor = 1.0;
switch (unit) {
case "kg/mol":
conversionFactor = 1.0;
break;
case "gr/mol":
conversionFactor = 1000.0;
break;
case "lbm/lbmol":
conversionFactor = 1000.0;
break;
default:
throw new RuntimeException("unit not supported " + unit);
}
return refMolarMass * conversionFactor;
}

/** {@inheritDoc} */
@Override
public void setMolarMass(double value, String unit) {
double refMolarMass = value;
double conversionFactor = 1.0;
switch (unit) {
case "kg/mol":
conversionFactor = 1.0;
break;
case "gr/mol":
conversionFactor = 1000.0;
break;
case "lbm/lbmol":
conversionFactor = 1000.0;
break;
default:
throw new RuntimeException("unit not supported " + unit);
}
molarMass = refMolarMass * 1.0 / conversionFactor;
}

/** {@inheritDoc} */
@Override
public double getViscosityCorrectionFactor() {
Expand Down Expand Up @@ -1028,6 +986,27 @@ public final double getMolarMass() {
return this.molarMass;
}

/** {@inheritDoc} */
@Override
public double getMolarMass(String unit) {
double refMolarMass = getMolarMass();
double conversionFactor = 1.0;
switch (unit) {
case "kg/mol":
conversionFactor = 1.0;
break;
case "gr/mol":
conversionFactor = 1000.0;
break;
case "lbm/lbmol":
conversionFactor = 1000.0;
break;
default:
throw new RuntimeException("unit not supported " + unit);
}
return refMolarMass * conversionFactor;
}

/** {@inheritDoc} */
@Override
public final double getNumberOfMolesInPhase() {
Expand Down Expand Up @@ -1883,6 +1862,28 @@ public void setMolarMass(double molarMass) {
this.molarMass = molarMass;
}

/** {@inheritDoc} */
@Override
public void setMolarMass(double value, String unit) {
double refMolarMass = value;
double conversionFactor = 1.0;
switch (unit) {
case "kg/mol":
conversionFactor = 1.0;
break;
case "gr/mol":
conversionFactor = 1000.0;
break;
case "lbm/lbmol":
conversionFactor = 1000.0;
break;
default:
throw new RuntimeException("unit not supported " + unit);
}
molarMass = refMolarMass * 1.0 / conversionFactor;
}


/** {@inheritDoc} */
@Override
public final boolean doSolidCheck() {
Expand Down
51 changes: 26 additions & 25 deletions src/main/java/neqsim/thermo/mixingrule/CPAMixingRules.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ public double calcDelta(int siteNumber1, int siteNumber2, int compnumb1, int com
* ((PhaseCPAInterface) phase).getGcpa();
}

@Override
public double calcDeltaNog(int siteNumber1, int siteNumber2, int compnumb1, int compnumb2,
PhaseInterface phase, double temperature, double pressure, int numbcomp) {

public double calcDelta(int compnumb1, int compnumb2, PhaseInterface phase, double temperature,
double pressure, int numbcomp) {
if (assosSchemeType[compnumb1][compnumb2] == 0) {
double temp2 = 0;
double temp1 = (Math.exp(
Expand All @@ -205,7 +205,8 @@ public double calcDeltaNog(int siteNumber1, int siteNumber2, int compnumb1, int
* (((ComponentEosInterface) phase.getComponent(compnumb1)).getb()
+ ((ComponentEosInterface) phase.getComponent(compnumb1)).getb())
/ 2.0 * getCrossAssociationVolume(compnumb1, compnumb1, phase, temperature, pressure,
numbcomp);
numbcomp)
* ((PhaseCPAInterface) phase).getGcpa();
if (compnumb1 == compnumb2) {
temp2 = temp1;
} else {
Expand All @@ -214,23 +215,25 @@ public double calcDeltaNog(int siteNumber1, int siteNumber2, int compnumb1, int
* (((ComponentEosInterface) phase.getComponent(compnumb2)).getb()
+ ((ComponentEosInterface) phase.getComponent(compnumb2)).getb())
/ 2.0 * getCrossAssociationVolume(compnumb2, compnumb2, phase, temperature, pressure,
numbcomp);
numbcomp)
* ((PhaseCPAInterface) phase).getGcpa();
}
return ((PhaseCPAInterface) phase).getCrossAssosiationScheme(compnumb1, compnumb2,
siteNumber1, siteNumber2) * Math.sqrt(temp1 * temp2);
return Math.sqrt(temp1 * temp2);
}
return ((PhaseCPAInterface) phase).getCrossAssosiationScheme(compnumb1, compnumb2,
siteNumber1, siteNumber2)
* (Math.exp(getCrossAssociationEnergy(compnumb1, compnumb2, phase, temperature, pressure,
numbcomp) / (R * phase.getTemperature())) - 1.0)
return (Math.exp(
getCrossAssociationEnergy(compnumb1, compnumb2, phase, temperature, pressure, numbcomp)
/ (R * phase.getTemperature()))
- 1.0)
* (((ComponentEosInterface) phase.getComponent(compnumb1)).getb()
+ ((ComponentEosInterface) phase.getComponent(compnumb2)).getb())
/ 2.0
* getCrossAssociationVolume(compnumb1, compnumb2, phase, temperature, pressure, numbcomp);
* getCrossAssociationVolume(compnumb1, compnumb2, phase, temperature, pressure, numbcomp)
* ((PhaseCPAInterface) phase).getGcpa();
}

public double calcDelta(int compnumb1, int compnumb2, PhaseInterface phase, double temperature,
double pressure, int numbcomp) {
@Override
public double calcDeltaNog(int siteNumber1, int siteNumber2, int compnumb1, int compnumb2,
PhaseInterface phase, double temperature, double pressure, int numbcomp) {
if (assosSchemeType[compnumb1][compnumb2] == 0) {
double temp2 = 0;
double temp1 = (Math.exp(
Expand All @@ -240,8 +243,7 @@ public double calcDelta(int compnumb1, int compnumb2, PhaseInterface phase, doub
* (((ComponentEosInterface) phase.getComponent(compnumb1)).getb()
+ ((ComponentEosInterface) phase.getComponent(compnumb1)).getb())
/ 2.0 * getCrossAssociationVolume(compnumb1, compnumb1, phase, temperature, pressure,
numbcomp)
* ((PhaseCPAInterface) phase).getGcpa();
numbcomp);
if (compnumb1 == compnumb2) {
temp2 = temp1;
} else {
Expand All @@ -250,20 +252,19 @@ public double calcDelta(int compnumb1, int compnumb2, PhaseInterface phase, doub
* (((ComponentEosInterface) phase.getComponent(compnumb2)).getb()
+ ((ComponentEosInterface) phase.getComponent(compnumb2)).getb())
/ 2.0 * getCrossAssociationVolume(compnumb2, compnumb2, phase, temperature, pressure,
numbcomp)
* ((PhaseCPAInterface) phase).getGcpa();
numbcomp);
}
return Math.sqrt(temp1 * temp2);
return ((PhaseCPAInterface) phase).getCrossAssosiationScheme(compnumb1, compnumb2,
siteNumber1, siteNumber2) * Math.sqrt(temp1 * temp2);
}
return (Math.exp(
getCrossAssociationEnergy(compnumb1, compnumb2, phase, temperature, pressure, numbcomp)
/ (R * phase.getTemperature()))
- 1.0)
return ((PhaseCPAInterface) phase).getCrossAssosiationScheme(compnumb1, compnumb2,
siteNumber1, siteNumber2)
* (Math.exp(getCrossAssociationEnergy(compnumb1, compnumb2, phase, temperature, pressure,
numbcomp) / (R * phase.getTemperature())) - 1.0)
* (((ComponentEosInterface) phase.getComponent(compnumb1)).getb()
+ ((ComponentEosInterface) phase.getComponent(compnumb2)).getb())
/ 2.0
* getCrossAssociationVolume(compnumb1, compnumb2, phase, temperature, pressure, numbcomp)
* ((PhaseCPAInterface) phase).getGcpa();
* getCrossAssociationVolume(compnumb1, compnumb2, phase, temperature, pressure, numbcomp);
}

@Override
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/neqsim/thermo/mixingrule/EosMixingRules.java
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,12 @@ public void calcWij(PhaseInterface phase) {
}
}

@Override
public double calcWij(int compNumbi, int compNumj, PhaseInterface phase, double temperature,
double pressure, int numbcomp) {
return -2.0 * getWij(compNumbi, compNumj, temperature); // iwij[0][compNumbi][compNumj];
}

@Override
public void setWijParameter(int i, int j, double value) {
// System.out.println("intparam: " + value);
Expand Down Expand Up @@ -2075,12 +2081,6 @@ public double calcWTT(PhaseInterface phase, double temperature, double pressure,
}
return -WTT;
}

@Override
public double calcWij(int compNumbi, int compNumj, PhaseInterface phase, double temperature,
double pressure, int numbcomp) {
return -2.0 * getWij(compNumbi, compNumj, temperature); // iwij[0][compNumbi][compNumj];
}
}

/**
Expand Down
78 changes: 39 additions & 39 deletions src/main/java/neqsim/thermo/system/SystemThermo.java
Original file line number Diff line number Diff line change
Expand Up @@ -3577,35 +3577,6 @@ public final void initTotalNumberOfMoles(double change) {
}
}

/** {@inheritDoc} */
@Override
public void setPhaseType(int phaseToChange, String phaseName) {
// System.out.println("new phase type: cha " + pt);
if (allowPhaseShift) {
phaseType[phaseIndex[phaseToChange]] = PhaseType.byName(phaseName);
}
}

/** {@inheritDoc} */
@Override
public void invertPhaseTypes() {
// Following code was from public void setPhaseType(int phaseToChange, String
// phaseTypeName) {
/*
* int newPhaseType = 0; if (phaseTypeName.equals("gas")) { newPhaseType = 1; } else if
* (StateOfMatter.isLiquid(PhaseType.byDesc(phaseTypeName))) { newPhaseType = 0; } else {
* newPhaseType = 0; }
*/

for (int i = 0; i < getMaxNumberOfPhases(); i++) {
if (phaseType[i] == PhaseType.byValue(0)) {
phaseType[i] = PhaseType.byValue(1);
} else {
phaseType[i] = PhaseType.byValue(0);
}
}
}

/** {@inheritDoc} */
@Override
public final boolean isChemicalSystem() {
Expand Down Expand Up @@ -4264,16 +4235,6 @@ public void setAllComponentsInPhase(int phaseNum) {
init(1);
}

/** {@inheritDoc} */
@Override
public void setAllPhaseType(PhaseType pt) {
if (allowPhaseShift) {
for (int i = 0; i < getMaxNumberOfPhases(); i++) {
setPhaseType(i, pt);
}
}
}

/** {@inheritDoc} */
@Override
public void setAttractiveTerm(int i) {
Expand Down Expand Up @@ -4782,6 +4743,45 @@ public void setPhaseType(int phaseToChange, PhaseType pt) {
}
}

/** {@inheritDoc} */
@Override
public void setPhaseType(int phaseToChange, String phaseName) {
// System.out.println("new phase type: cha " + pt);
if (allowPhaseShift) {
phaseType[phaseIndex[phaseToChange]] = PhaseType.byName(phaseName);
}
}

/** {@inheritDoc} */
@Override
public void setAllPhaseType(PhaseType pt) {
if (allowPhaseShift) {
for (int i = 0; i < getMaxNumberOfPhases(); i++) {
setPhaseType(i, pt);
}
}
}

/** {@inheritDoc} */
@Override
public void invertPhaseTypes() {
// Following code was from public void setPhaseType(int phaseToChange, String
// phaseTypeName) {
/*
* int newPhaseType = 0; if (phaseTypeName.equals("gas")) { newPhaseType = 1; } else if
* (StateOfMatter.isLiquid(PhaseType.byDesc(phaseTypeName))) { newPhaseType = 0; } else {
* newPhaseType = 0; }
*/

for (int i = 0; i < getMaxNumberOfPhases(); i++) {
if (phaseType[i] == PhaseType.byValue(0)) {
phaseType[i] = PhaseType.byValue(1);
} else {
phaseType[i] = PhaseType.byValue(0);
}
}
}

/** {@inheritDoc} */
@Override
public final void setPressure(double newPressure) {
Expand Down

0 comments on commit a579f01

Please sign in to comment.