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: remove deprecated phasetype methods #927

Merged
merged 4 commits into from
Feb 23, 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package neqsim.MathLib.nonLinearSolver;

import Jama.Matrix;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;

/**
Expand Down Expand Up @@ -358,8 +359,8 @@ public void calcInc2(int np) {
PC2 = Math.exp(u.get(numberOfComponents + 1, 0));
system.setTC((TC1 + TC2) * 0.5);
system.setPC((PC1 + PC2) * 0.5);
system.setPhaseType(0, 1);
system.setPhaseType(1, 0);
system.setPhaseType(0, PhaseType.byValue(1));
system.setPhaseType(1, PhaseType.byValue(0));
return;
} else if ((xlnkmax < avscp && testcrit != 1) && (np != ic03p && !etterCP)) {
// System.out.println("hei fra her");
Expand Down
26 changes: 0 additions & 26 deletions src/main/java/neqsim/thermo/phase/PhaseInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -1921,32 +1921,6 @@ public void setParams(PhaseInterface phase, double[][] alpha, double[][] Dij, do
*/
public void setType(PhaseType pt);

/**
* <p>
* Getter for property phasetype as int.
* </p>
*
* @return a int
* @deprecated Replace with {@link getType}
*/
@Deprecated
public default int getPhaseType() {
return getType().getValue();
}

/**
* <p>
* Setter for property phaseType.
* </p>
*
* @param phaseType Phasetype as int.
* @deprecated Replace with {@link setType}
*/
@Deprecated
public default void setPhaseType(int phaseType) {
setType(PhaseType.byValue(phaseType));
}

/**
* <p>
* Getter for property phaseTypeName.
Expand Down
34 changes: 0 additions & 34 deletions src/main/java/neqsim/thermo/system/SystemInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -1917,30 +1917,6 @@ public double calcBeta()
*/
public void chemicalReactionInit();

// public double getdfugdt(int i, int j);

/**
* Change the phase type of a given phase.
*
* @param phaseToChange the phase number of the phase to set phase type
* @param newPhaseType the phasetype number to set
* @deprecated Replaced by {@link setPhaseType}
*/
@Deprecated
public default void setPhaseType(int phaseToChange, int newPhaseType) {
setPhaseType(phaseToChange, PhaseType.byValue(newPhaseType));
}

/**
* Change the phase type of a given phase.
*
* @param phaseToChange the phase number of the phase to set phase type
* @param phaseTypeName the phase type name, see PhaseTypes
*/
public default void setPhaseType(int phaseToChange, String phaseTypeName) {
setPhaseType(phaseToChange, PhaseType.byDesc(phaseTypeName));
}

/**
* Change the phase type of a given phase.
*
Expand All @@ -1949,16 +1925,6 @@ public default void setPhaseType(int phaseToChange, String phaseTypeName) {
*/
public void setPhaseType(int phaseToChange, PhaseType pt);

/**
* Set phase type of all phases.
*
* @param phases Set to "all" to set all phases, else nothing happens.
* @param newPhaseType the phasetype number to set
* @deprecated Replaced by {@link setAllPhaseType}
*/
@Deprecated
public void setPhaseType(String phases, int newPhaseType);

/**
* Set phase type of all phases.
*
Expand Down
34 changes: 8 additions & 26 deletions src/main/java/neqsim/thermo/system/SystemThermo.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import neqsim.thermo.phase.PhaseSolidComplex;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.phase.PhaseWax;
import neqsim.thermo.phase.StateOfMatter;
import neqsim.util.database.NeqSimDataBase;
import neqsim.util.exception.InvalidInputException;

Expand Down Expand Up @@ -2967,31 +2966,6 @@ public void setPhaseType(int phaseToChange, PhaseType pt) {
}
}

/** {@inheritDoc} */
@Override
public void setPhaseType(int phaseToChange, String phaseTypeName) {
// System.out.println("new phase type: cha " + newPhaseType);
int newPhaseType = 0;
if (phaseTypeName.equals("gas")) {
newPhaseType = 1;
} else if (StateOfMatter.isLiquid(PhaseType.byDesc(phaseTypeName))) {
newPhaseType = 0;
} else {
newPhaseType = 0;
}

setPhaseType(phaseToChange, PhaseType.byValue(newPhaseType));
}

/** {@inheritDoc} */
@Override
public void setPhaseType(String phases, int newPhaseType) {
// System.out.println("new phase type: cha " + newPhaseType);
if (phases.equals("all")) {
setAllPhaseType(PhaseType.byValue(newPhaseType));
}
}

/** {@inheritDoc} */
@Override
public void setAllPhaseType(PhaseType pt) {
Expand All @@ -3005,6 +2979,14 @@ public void setAllPhaseType(PhaseType 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ public void waterPrecipitationTemperature() throws Exception {
// system.getTemperature();
// }

// if(system.doHydrateCheck()){
// if(system.getHydrateCheck()){
// hydrateFormationTemperature(1);
// if(system.getTemperature()>lowTemperature) lowTemperature =
// system.getTemperature();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import Jama.Matrix;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.BaseOperation;

Expand Down Expand Up @@ -342,9 +343,9 @@ public boolean stabilityCheck() {
system.setNumberOfPhases(1);

if (lowestGibbsEnergyPhase == 0) {
system.setPhaseType(0, 1);
system.setPhaseType(0, PhaseType.byValue(1));
} else {
system.setPhaseType(0, 0);
system.setPhaseType(0, PhaseType.byValue(0));
}
system.init(1);
if (solidCheck && !system.doMultiPhaseCheck()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import Jama.Matrix;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;

/**
Expand Down Expand Up @@ -291,16 +292,16 @@ public void checkGibbs() {
double gibbs1 = 0;
double gibbs2 = 0;
for (int i = 0; i < system.getNumberOfPhases() - 1; i++) {
system.setPhaseType(i, 0);
system.setPhaseType(i, PhaseType.byValue(0));
system.init(1);
gibbs1 = system.getPhase(i).getGibbsEnergy();
system.setPhaseType(i, 1);
system.setPhaseType(i, PhaseType.byValue(1));
system.init(1);
gibbs2 = system.getPhase(i).getGibbsEnergy();
if (gibbs1 < gibbs2) {
system.setPhaseType(i, 0);
system.setPhaseType(i, PhaseType.byValue(0));
} else {
system.setPhaseType(i, 1);
system.setPhaseType(i, PhaseType.byValue(1));
}
system.init(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import Jama.Matrix;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

Expand Down Expand Up @@ -336,16 +337,16 @@ public void checkGibbs() {
double gibbs1 = 0;
double gibbs2 = 0;
for (int i = 0; i < system.getNumberOfPhases() - 1; i++) {
system.setPhaseType(i, 0);
system.setPhaseType(i, PhaseType.byValue(0));
system.init(1);
gibbs1 = system.getPhase(i).getGibbsEnergy();
system.setPhaseType(i, 1);
system.setPhaseType(i, PhaseType.byValue(1));
system.init(1);
gibbs2 = system.getPhase(i).getGibbsEnergy();
if (gibbs1 < gibbs2) {
system.setPhaseType(i, 0);
system.setPhaseType(i, PhaseType.byValue(0));
} else {
system.setPhaseType(i, 1);
system.setPhaseType(i, PhaseType.byValue(1));
}
system.init(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import Jama.Matrix;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

Expand Down Expand Up @@ -263,16 +264,16 @@ public void checkGibbs() {
double gibbs1 = 0;
double gibbs2 = 0;
for (int i = 0; i < system.getNumberOfPhases() - 1; i++) {
system.setPhaseType(i, 0);
system.setPhaseType(i, PhaseType.byValue(0));
system.init(1);
gibbs1 = system.getPhase(i).getGibbsEnergy();
system.setPhaseType(i, 1);
system.setPhaseType(i, PhaseType.byValue(1));
system.init(1);
gibbs2 = system.getPhase(i).getGibbsEnergy();
if (gibbs1 < gibbs2) {
system.setPhaseType(i, 0);
system.setPhaseType(i, PhaseType.byValue(0));
} else {
system.setPhaseType(i, 1);
system.setPhaseType(i, PhaseType.byValue(1));
}
system.init(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;
Expand Down Expand Up @@ -30,8 +29,7 @@ public class TPflash extends Flash {
* Constructor for TPflash.
* </p>
*/
public TPflash() {
}
public TPflash() {}

/**
* <p>
Expand Down Expand Up @@ -364,12 +362,12 @@ public void run() {

// Checks if gas or oil is the most stable phase
double gasgib = system.getPhase(0).getGibbsEnergy();
system.setPhaseType(0, 0);
system.setPhaseType(0, PhaseType.byValue(0));
system.init(1, 0);
double liqgib = system.getPhase(0).getGibbsEnergy();

if (gasgib * (1.0 - Math.signum(gasgib) * 1e-8) < liqgib) {
system.setPhaseType(0, 1);
system.setPhaseType(0, PhaseType.byValue(1));
}
system.init(1);

Expand Down Expand Up @@ -461,18 +459,18 @@ public void run() {
// Checks if gas or oil is the most stable phase
if (system.getPhase(0).getType() == PhaseType.GAS) {
gasgib = system.getPhase(0).getGibbsEnergy();
system.setPhaseType(0, 0);
system.setPhaseType(0, PhaseType.byValue(0));
system.init(1, 0);
liqgib = system.getPhase(0).getGibbsEnergy();
} else {
liqgib = system.getPhase(0).getGibbsEnergy();
system.setPhaseType(0, 1);
system.setPhaseType(0, PhaseType.byValue(1));
system.init(1, 0);
gasgib = system.getPhase(0).getGibbsEnergy();
}

if (gasgib * (1.0 - Math.signum(gasgib) * 1e-8) < liqgib) {
system.setPhaseType(0, 1);
system.setPhaseType(0, PhaseType.byValue(1));
}

system.init(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkSchwartzentruberEos;
import neqsim.thermodynamicOperations.ThermodynamicOperations;
Expand Down Expand Up @@ -83,7 +84,7 @@ public void run() {
SystemInterface testSystem2 = new SystemSrkSchwartzentruberEos(216, 1);
ThermodynamicOperations testOps2 = new ThermodynamicOperations(testSystem2);
testSystem2.addComponent(testSystem.getPhase(0).getComponent(k).getComponentName(), 1);
testSystem2.setPhaseType(0, 1);
testSystem2.setPhaseType(0, PhaseType.byValue(1));
noFreezeliq = true;
SolidFug = 0.0;
FluidFug = 0.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.apache.logging.log4j.Logger;
import neqsim.dataPresentation.JFreeChart.graph2b;
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkSchwartzentruberEos;
import neqsim.thermodynamicOperations.ThermodynamicOperations;
Expand Down Expand Up @@ -69,7 +70,7 @@ public FugTestConstP(SystemInterface system, double pres) {
public void initTestSystem2(int K) {
this.testSystem2 = new SystemSrkSchwartzentruberEos(temp, pres);
this.testSystem2.addComponent(compName, 1);
this.testSystem2.setPhaseType(0, 1);
this.testSystem2.setPhaseType(0, PhaseType.byValue(1));
this.testOps2 = new ThermodynamicOperations(testSystem2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.io.Writer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

Expand Down Expand Up @@ -161,8 +162,8 @@ public void run() {
}

if (!thermoSystem.hasPhaseType("gas")) {
// TODO: here is a bug, calling with input oil does nothing.
thermoSystem.setPhaseType("oil", 1);
thermoSystem.setPhaseType(thermoSystem.getPhaseNumberOfPhase(PhaseType.OIL),
PhaseType.byValue(1));
thermoSystem.init(3);
thermoSystem.initPhysicalProperties();

Expand All @@ -171,8 +172,8 @@ public void run() {
}

if (!thermoSystem.hasPhaseType("oil")) {
// TODO: here is a bug, calling with input gas does nothing.
thermoSystem.setPhaseType("gas", 1);
thermoSystem.setPhaseType(thermoSystem.getPhaseNumberOfPhase(PhaseType.GAS),
PhaseType.byValue(1));
thermoSystem.init(3);
thermoSystem.initPhysicalProperties();

Expand All @@ -181,7 +182,7 @@ public void run() {
}

if (!thermoSystem.hasPhaseType("aqueous")) {
thermoSystem.setPhaseType(1, 1);
thermoSystem.setPhaseType(1, PhaseType.byValue(1));
thermoSystem.init(3);
thermoSystem.initPhysicalProperties();

Expand Down
Loading
Loading