Skip to content

Commit

Permalink
refact: make PhaseGE abstract, throw exception for non implemented me…
Browse files Browse the repository at this point in the history
…thods
  • Loading branch information
asmfstatoil committed Feb 27, 2024
1 parent 4765491 commit ec8952b
Show file tree
Hide file tree
Showing 11 changed files with 191 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ public double getFickBinaryDiffusionCoefficient(int i, int j) {
/** {@inheritDoc} */
@Override
public double calcBinaryDiffusionCoefficient(int i, int j, int method) {
throw new UnsupportedOperationException("Not supported yet.");
throw new UnsupportedOperationException("Unimplemented method 'calcBinaryDiffusionCoefficient");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.UUID;
import neqsim.util.NamedBaseClass;
import neqsim.util.exception.InvalidInputException;

/**
* Base class for process simulation objects.
Expand All @@ -20,7 +21,9 @@ public abstract class SimulationBaseClass extends NamedBaseClass implements Simu
protected double time = 0;

/**
* <p>Constructor for SimulationBaseClass.</p>
* <p>
* Constructor for SimulationBaseClass.
* </p>
*
* @param name a {@link java.lang.String} object
*/
Expand Down Expand Up @@ -67,8 +70,8 @@ public void setTime(double value) {
/** {@inheritDoc} */
public void increaseTime(double dt) {
if (dt < 0) {
throw new UnsupportedOperationException(
"Input dt is negative - not allowed to go backwards in time.");
throw new RuntimeException(new InvalidInputException(this, "increaseTime", "dt",
"Negative values are not allowed. Not possible to go backwards in time."));
}
this.time = this.time + dt;
}
Expand Down
60 changes: 43 additions & 17 deletions src/main/java/neqsim/thermo/phase/PhaseDesmukhMather.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import org.apache.logging.log4j.Logger;
import neqsim.thermo.component.ComponentDesmukhMather;
import neqsim.thermo.component.ComponentGEInterface;
import neqsim.util.exception.IsNaNException;
import neqsim.util.exception.TooManyIterationsException;

/**
* <p>
Expand Down Expand Up @@ -95,6 +97,25 @@ && getComponents()[k].getComponentName().equals("MDEA")) {
}
}

/** {@inheritDoc} */
@Override
public void setAlpha(double[][] alpha) {
throw new UnsupportedOperationException("Unimplemented method 'setAlpha'");
}

/**
* <p>
* Getter for the field <code>aij</code>.
* </p>
*
* @param i a int
* @param j a int
* @return a double
*/
public double getAij(int i, int j) {
return aij[i][j];
}

/**
* <p>
* Setter for the field <code>aij</code>.
Expand All @@ -113,14 +134,26 @@ public void setAij(double[][] alpha) {
* Setter for the field <code>bij</code>.
* </p>
*
* @param Dij an array of {@link double} objects
* @param Bij an array of {@link double} objects
*/
public void setBij(double[][] Dij) {
for (int i = 0; i < Dij.length; i++) {
System.arraycopy(bij[i], 0, this.bij[i], 0, Dij[0].length);
public void setBij(double[][] Bij) {
for (int i = 0; i < Bij.length; i++) {
System.arraycopy(bij[i], 0, this.bij[i], 0, Bij[0].length);
}
}

/** {@inheritDoc} */
@Override
public void setDij(double[][] Dij) {
throw new UnsupportedOperationException("Unimplemented method 'setDij'");
}

/** {@inheritDoc} */
@Override
public void setDijT(double[][] DijT) {
throw new UnsupportedOperationException("Unimplemented method 'setDijT'");
}

/**
* <p>
* getBetaDesMatij.
Expand All @@ -134,19 +167,6 @@ public double getBetaDesMatij(int i, int j) {
return aij[i][j] + bij[i][j] * temperature;
}

/**
* <p>
* Getter for the field <code>aij</code>.
* </p>
*
* @param i a int
* @param j a int
* @return a double
*/
public double getAij(int i, int j) {
return aij[i][j];
}

/**
* <p>
* Getter for the field <code>bij</code>.
Expand Down Expand Up @@ -262,4 +282,10 @@ public double getSolventMolarMass() {
}
return molesMass / moles;
}

@Override
public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt)
throws IsNaNException, TooManyIterationsException {
throw new UnsupportedOperationException("Unimplemented method 'molarVolume'");
}
}
14 changes: 14 additions & 0 deletions src/main/java/neqsim/thermo/phase/PhaseDuanSun.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package neqsim.thermo.phase;

import neqsim.thermo.component.ComponentGeDuanSun;
import neqsim.util.exception.IsNaNException;
import neqsim.util.exception.TooManyIterationsException;

/**
* <p>
Expand Down Expand Up @@ -59,6 +61,12 @@ public void setDij(double[][] Dij) {
}
}

/** {@inheritDoc} */
@Override
public void setDijT(double[][] DijT) {
throw new UnsupportedOperationException("Unimplemented method 'setDijT'");
}

/** {@inheritDoc} */
@Override
public double getExcessGibbsEnergy() {
Expand Down Expand Up @@ -111,4 +119,10 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents,
public double getGibbsEnergy() {
return R * temperature * numberOfMolesInPhase * (GE + Math.log(pressure));
}

@Override
public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt)
throws IsNaNException, TooManyIterationsException {
throw new UnsupportedOperationException("Unimplemented method 'molarVolume'");
}
}
73 changes: 1 addition & 72 deletions src/main/java/neqsim/thermo/phase/PhaseGE.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* @author Even Solbraa
* @version $Id: $Id
*/
public class PhaseGE extends Phase implements PhaseGEInterface {
public abstract class PhaseGE extends Phase implements PhaseGEInterface {
private static final long serialVersionUID = 1000;
static Logger logger = LogManager.getLogger(PhaseGE.class);

Expand Down Expand Up @@ -133,84 +133,13 @@ public void resetMixingRule(int type) {
mixRuleEos = mixSelect.resetMixingRule(2, this);
}

/** {@inheritDoc} */
@Override
public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) {
return 1;
}

/**
* <p>
* molarVolumeAnalytic.
* </p>
*
* @param pressure a double
* @param temperature a double
* @param A a double
* @param B a double
* @param phase a int
* @return a double
*/
public double molarVolumeAnalytic(double pressure, double temperature, double A, double B,
int phase) {
return 1;
}

/** {@inheritDoc} */
@Override
public void addComponent(String name, double moles, double molesInPhase, int compNumber) {
super.addComponent(name, molesInPhase);
// TODO: compNumber not in use
}

/**
* <p>
* setAlpha.
* </p>
*
* @param alpha an array of {@link double} objects
*/
public void setAlpha(double[][] alpha) {}

/**
* <p>
* setDij.
* </p>
*
* @param Dij an array of {@link double} objects
*/
public void setDij(double[][] Dij) {}

/** {@inheritDoc} */
@Override
public double getExcessGibbsEnergy() {
logger.error("this getExcessGibbsEnergy should never be used.......");
return 0;
}

/** {@inheritDoc} */
@Override
public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents,
double temperature, double pressure, PhaseType pt) {
logger.error("this getExcessGibbsEnergy should never be used.......");
return 0;
}

/** {@inheritDoc} */
@Override
public double getGibbsEnergy() {
return 0;
}

/**
* <p>
* setDijT.
* </p>
*
* @param DijT an array of {@link double} objects
*/
public void setDijT(double[][] DijT) {}

/** {@inheritDoc} */
@Override
public double getActivityCoefficientSymetric(int k) {
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/neqsim/thermo/phase/PhaseGEInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,31 @@ public interface PhaseGEInterface {
*/
public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents,
double temperature, double pressure, PhaseType pt);

/**
* <p>
* setAlpha.
* </p>
*
* @param alpha an array of {@link double} objects
*/
public void setAlpha(double[][] alpha);

/**
* <p>
* setDij.
* </p>
*
* @param Dij an array of {@link double} objects
*/
public void setDij(double[][] Dij);

/**
* <p>
* setDijT.
* </p>
*
* @param DijT an array of {@link double} objects
*/
public void setDijT(double[][] DijT);
}
14 changes: 14 additions & 0 deletions src/main/java/neqsim/thermo/phase/PhaseGENRTL.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import neqsim.thermo.component.ComponentGEInterface;
import neqsim.thermo.component.ComponentGeNRTL;
import neqsim.util.exception.IsNaNException;
import neqsim.util.exception.TooManyIterationsException;

/**
* <p>
Expand Down Expand Up @@ -97,6 +99,12 @@ public void setDij(double[][] Dij) {
}
}

/** {@inheritDoc} */
@Override
public void setDijT(double[][] DijT) {
throw new UnsupportedOperationException("Unimplemented method 'setDijT'");
}

/** {@inheritDoc} */
@Override
public double getExcessGibbsEnergy() {
Expand Down Expand Up @@ -124,4 +132,10 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents,
public double getGibbsEnergy() {
return R * temperature * numberOfMolesInPhase * (GE + Math.log(pressure));
}

@Override
public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt)
throws IsNaNException, TooManyIterationsException {
throw new UnsupportedOperationException("Unimplemented method 'molarVolume'");
}
}
26 changes: 26 additions & 0 deletions src/main/java/neqsim/thermo/phase/PhaseGEUniquac.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import neqsim.thermo.ThermodynamicModelSettings;
import neqsim.thermo.component.ComponentGEInterface;
import neqsim.thermo.component.ComponentGEUniquac;
import neqsim.util.exception.IsNaNException;
import neqsim.util.exception.TooManyIterationsException;

/**
* <p>
Expand Down Expand Up @@ -65,6 +67,24 @@ public PhaseGEUniquac(PhaseInterface phase, double[][] alpha, double[][] Dij, St
}
}

/** {@inheritDoc} */
@Override
public void setAlpha(double[][] alpha) {
throw new UnsupportedOperationException("Unimplemented method 'setAlpha'");
}

/** {@inheritDoc} */
@Override
public void setDij(double[][] Dij) {
throw new UnsupportedOperationException("Unimplemented method 'setDij'");
}

/** {@inheritDoc} */
@Override
public void setDijT(double[][] DijT) {
throw new UnsupportedOperationException("Unimplemented method 'setDijT'");
}

/** {@inheritDoc} */
@Override
public void addComponent(String name, double moles, double molesInPhase, int compNumber) {
Expand Down Expand Up @@ -99,4 +119,10 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents,

return R * temperature * numberOfMolesInPhase * GE;
}

@Override
public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt)
throws IsNaNException, TooManyIterationsException {
throw new UnsupportedOperationException("Unimplemented method 'molarVolume'");
}
}
Loading

0 comments on commit ec8952b

Please sign in to comment.