Skip to content

Commit

Permalink
Phase type enum (#661)
Browse files Browse the repository at this point in the history
* add PhaseType enum to replace phasetype int and phasetypename as string.
* refact: introduce use of PhaseType Enum and replace calls settin
* Some doc fixes as well. 

NB! The old methods are still available, but deprecated.
  • Loading branch information
asmfstatoil authored and EvenSol committed May 22, 2023
1 parent c60174b commit 6c90be4
Show file tree
Hide file tree
Showing 37 changed files with 343 additions and 161 deletions.
3 changes: 2 additions & 1 deletion src/main/java/neqsim/PVTsimulation/simulation/GOR.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package neqsim.PVTsimulation.simulation;

import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;

Expand Down Expand Up @@ -68,7 +69,7 @@ public void runCalc() {
m3oil[i] = getThermoSystem().getVolume();
}
if (getThermoSystem().getNumberOfPhases() > 1
&& getThermoSystem().getPhase(0).getPhaseTypeName().equals("gas")) {
&& getThermoSystem().getPhase(0).getType() == PhaseType.GAS) {
getThermoSystem().getPhase(0).setPressure(1.01325);
getThermoSystem().getPhase(0).setTemperature(288.15);
getThermoSystem().init(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;

Expand Down Expand Up @@ -68,7 +69,7 @@ public void runCalc() {
m3oil[i] = getThermoSystem().getVolume();
}
if (getThermoSystem().getNumberOfPhases() > 1
&& getThermoSystem().getPhase(0).getPhaseTypeName().equals("gas")) {
&& getThermoSystem().getPhase(0).getType() == PhaseType.GAS) {
getThermoSystem().getPhase(0).setPressure(1.01325);
getThermoSystem().getPhase(0).setTemperature(288.15);
getThermoSystem().init(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,19 @@ public void setPhysicalProperties(PhaseInterface phase, int type) {
* @return a {@link neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface}
* object
*/
public neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface getPhysicalProperty(
PhaseInterface phase) {
switch (phase.getPhaseTypeName()) {
case "gas":
public PhysicalPropertiesInterface getPhysicalProperty(PhaseInterface phase) {
switch (phase.getType()) {
case GAS:
return gasPhysicalProperties;
case "oil":
case OIL:
return oilPhysicalProperties;
case "aqueous":
case AQUEOUS:
return aqueousPhysicalProperties;
case "solid":
case SOLID:
return solidPhysicalProperties;
case "wax":
case WAX:
return solidPhysicalProperties;
case "hydrate":
case HYDRATE:
return solidPhysicalProperties;
default:
return gasPhysicalProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import neqsim.physicalProperties.interfaceProperties.surfaceTension.LGTSurfaceTension;
import neqsim.physicalProperties.interfaceProperties.surfaceTension.ParachorSurfaceTension;
import neqsim.physicalProperties.interfaceProperties.surfaceTension.SurfaceTensionInterface;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;

/**
Expand Down Expand Up @@ -132,11 +133,11 @@ public void calcAdsorption() {
/** {@inheritDoc} */
@Override
public double getSurfaceTension(int numb1, int numb2) {
if (system.getPhase(numb1).getPhaseTypeName().equals("gas")
&& system.getPhase(numb2).getPhaseTypeName().equals("oil")) {
if (system.getPhase(numb1).getType() == PhaseType.GAS
&& system.getPhase(numb2).getType() == PhaseType.OIL) {
return gasLiquidSurfaceTensionCalc.calcSurfaceTension(numb1, numb2);
} else if (system.getPhase(numb1).getPhaseTypeName().equals("gas")
&& system.getPhase(numb2).getPhaseTypeName().equals("aqueous")) {
} else if (system.getPhase(numb1).getType() == PhaseType.GAS
&& system.getPhase(numb2).getType() == PhaseType.AQUEOUS) {
return gasAqueousSurfaceTensionCalc.calcSurfaceTension(numb1, numb2);
} else {
return liquidLiquidSurfaceTensionCalc.calcSurfaceTension(numb1, numb2);
Expand All @@ -155,7 +156,7 @@ public double getSurfaceTension(int numb1, int numb2, String unit) {
/** {@inheritDoc} */
@Override
public SurfaceTensionInterface getSurfaceTensionModel(int i) {
if (system.getPhase(i).getPhaseTypeName().equals("gas")) {
if (system.getPhase(i).getType() == PhaseType.GAS) {
return gasLiquidSurfaceTensionCalc;
} else {
return gasLiquidSurfaceTensionCalc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ public FirozabadiRamleyInterfaceTension(SystemInterface system) {
/**
* {@inheritDoc}
*
* Calculates the pure component surfacetension using the Macleod/Sugden method
* <p>
* using the Macleod/Sugden method
* </p>
*/
@Override
public double calcPureComponentSurfaceTension(int componentNumber) {
return 1.0e-3 * Math.pow(system.getPhases()[0].getComponents()[componentNumber]
.getParachorParameter()
* 1.0e-6
* (system.getPhases()[1].getPhysicalProperties().getDensity()
/ system.getPhases()[1].getMolarMass()
return 1.0e-3 * Math
.pow(system.getPhases()[0].getComponents()[componentNumber].getParachorParameter() * 1.0e-6
* (system.getPhases()[1].getPhysicalProperties().getDensity()
/ system.getPhases()[1].getMolarMass()
* system.getPhases()[1].getComponents()[componentNumber].getx()
- system.getPhases()[0].getPhysicalProperties().getDensity()
/ system.getPhases()[0].getMolarMass()
Expand All @@ -54,7 +55,7 @@ public double calcPureComponentSurfaceTension(int componentNumber) {
* {@inheritDoc}
*
* <p>
* Calculates the surfacetension using the Firozabadi Ramley (1988) method for mixtures Units: N/m
* Using the Firozabadi Ramley (1988) method for mixtures Units: N/m
* </p>
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public void calcInfluenceParameters() {
/**
* {@inheritDoc}
*
* Calculates the surfacetension using the Gradient Theory for mixtures Units: N/m
* <p>
* Using the Gradient Theory for mixtures Units: N/m
* </p>
*/
@Override
public double calcSurfaceTension(int interface1, int interface2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public LGTSurfaceTension(SystemInterface system) {
/**
* {@inheritDoc}
*
* Calculates the surfacetension using the Gradient Theory for mixtures Units: N/m
* <p>
* Using the Gradient Theory for mixtures Units: N/m
* </p>
*/
@Override
public double calcSurfaceTension(int interface1, int interface2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public double calcPureComponentSurfaceTension(int componentNumber) {
* {@inheritDoc}
*
* <p>
* Calculates the surfacetension using the Macleod/Sugden method for mixtures Units: N/m
* Using the Macleod/Sugden method for mixtures Units: N/m
* </p>
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ public SurfaceTension(SystemInterface system) {

/**
* <p>
* calcPureComponentSurfaceTension.
* Calculates the pure component surfacetension.
* </p>
*
* @param componentNumber a int
* @return a double
* @param componentNumber Number of component in phase's componentarray.
* @return pure component surface tension.
*/
public double calcPureComponentSurfaceTension(int componentNumber) {
return 0.0;
}

/** {@inheritDoc} */
@Override
public double calcSurfaceTension(int int1, int int2) {
public double calcSurfaceTension(int interface1, int interface2) {
return 0.0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
public interface SurfaceTensionInterface {
/**
* <p>
* calcSurfaceTension.
* calcSurfaceTension. Calculates the surfacetension.
* </p>
*
* @param int1 a int
* @param int2 a int
* @return a double
* @param interface1 Phase index 1
* @param interface2 Phase index 2
* @return Surface tension in N/m
*/
public double calcSurfaceTension(int int1, int int2);
public double calcSurfaceTension(int interface1, int interface2);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.thermo.phase.PhaseType;

/**
* <p>
Expand Down Expand Up @@ -65,7 +66,7 @@ public Conductivity clone() {
@Override
public double calcConductivity() {
// using default value of parafin wax
if (solidPhase.getPhase().getPhaseTypeName().equals("wax")) {
if (solidPhase.getPhase().getType() == PhaseType.WAX) {
conductivity = 0.25;
} else {
conductivity = 2.18;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.apache.logging.log4j.Logger;
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

Expand Down Expand Up @@ -319,14 +320,14 @@ public void run(UUID id) {
testOps.PHflash(enthalpy, 0);

if (mixedStream.getThermoSystem().getNumberOfPhases() == 1) {
if (mixedStream.getThermoSystem().getPhase(0).getPhaseTypeName().equals("aqueous")) {
if (mixedStream.getThermoSystem().getPhase(0).getType() == PhaseType.AQUEOUS) {
SystemInterface tempSystem = mixedStream.getThermoSystem().clone();
gasOutStream.setEmptyThermoSystem(tempSystem);
gasOutStream.run(id);
solventOutStream.setThermoSystem(tempSystem);
solventOutStream.run(id);
}
if (mixedStream.getThermoSystem().getPhase(0).getPhaseTypeName().equals("gas")) {
if (mixedStream.getThermoSystem().getPhase(0).getType() == PhaseType.GAS) {
SystemInterface tempSystem = mixedStream.getThermoSystem().clone();
solventOutStream.setEmptyThermoSystem(tempSystem);
solventOutStream.run(id);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/neqsim/standards/Standard.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ public String[][] createTable(String name) {
nf.applyPattern("#.#####E0");
String[][] table = new String[thermoSystem.getPhases()[0].getNumberOfComponents() + 30][6];
// String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"};
table[0][0] = ""; // getPhases()[0].getPhaseTypeName(); //"";
table[0][0] = ""; // getPhases()[0].getType(); //"";

for (int i = 0; i < thermoSystem.getPhases()[0].getNumberOfComponents() + 30; i++) {
for (int j = 0; j < 6; j++) {
table[i][j] = "";
}
}
for (int i = 0; i < thermoSystem.getNumberOfPhases(); i++) {
table[0][i + 1] = thermoSystem.getPhase(i).getPhaseTypeName();
table[0][i + 1] = thermoSystem.getPhase(i).getType().toString();
}

StringBuffer buf = new StringBuffer();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/neqsim/standards/gasQuality/Draft_GERG2004.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ public String[][] createTable(String name) {
nf.applyPattern("#.#####E0");
String[][] table = new String[thermoSystem.getPhases()[0].getNumberOfComponents() + 30][6];
// String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"};
table[0][0] = ""; // getPhases()[0].getPhaseTypeName(); //"";
table[0][0] = ""; // getPhases()[0].getType(); //"";

for (int i = 0; i < thermoSystem.getPhases()[0].getNumberOfComponents() + 30; i++) {
for (int j = 0; j < 6; j++) {
table[i][j] = "";
}
}
for (int i = 0; i < thermoSystem.getNumberOfPhases(); i++) {
table[0][i + 1] = thermoSystem.getPhase(i).getPhaseTypeName();
table[0][i + 1] = thermoSystem.getPhase(i).getType().toString();
}

StringBuffer buf = new StringBuffer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,15 +420,15 @@ public String[][] createTable(String name) {
nf.applyPattern("#.#####E0");
String[][] table = new String[thermoSystem.getPhases()[0].getNumberOfComponents() + 30][6];
// String[] names = { "", "Phase 1", "Phase 2", "Phase 3", "Unit" };
table[0][0] = ""; // getPhases()[0].getPhaseTypeName(); //"";
table[0][0] = ""; // getPhases()[0].getType(); //"";

for (int i = 0; i < thermoSystem.getPhases()[0].getNumberOfComponents() + 30; i++) {
for (int j = 0; j < 6; j++) {
table[i][j] = "";
}
}
for (int i = 0; i < thermoSystem.getNumberOfPhases(); i++) {
table[0][i + 1] = thermoSystem.getPhase(i).getPhaseTypeName();
table[0][i + 1] = thermoSystem.getPhase(i).getType().toString();
}

StringBuffer buf = new StringBuffer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public double dFdN(PhaseInterface phase, int numberOfComponents, double temperat
FSR2 = dFSR2dN(phase, numberOfComponents, temperature, pressure);
FLR = dFLRdN(phase, numberOfComponents, temperature, pressure);
FBorn = dFBorndN(phase, numberOfComponents, temperature, pressure);
// System.out.println("phase " + phase.getPhaseType());
// System.out.println("phase " + phase.getType());
// System.out.println("name " + componentName);
// System.out.println("Fsup: " + super.dFdN(phase,
// numberOfComponents,temperature, pressure));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public double dFdN(PhaseInterface phase, int numberOfComponents, double temperat
FSR2 = dFSR2dN(phase, numberOfComponents, temperature, pressure);
FLR = dFLRdN(phase, numberOfComponents, temperature, pressure);
FBorn = dFBorndN(phase, numberOfComponents, temperature, pressure);
// System.out.println("phase " + phase.getPhaseType());
// System.out.println("phase " + phase.getType());
// System.out.println("name " + componentName);
// System.out.println("Fsup: " + super.dFdN(phase,
// numberOfComponents,temperature, pressure));
Expand Down
Loading

0 comments on commit 6c90be4

Please sign in to comment.