Skip to content

Commit

Permalink
refact: use const from modelsettings
Browse files Browse the repository at this point in the history
  • Loading branch information
asmfstatoil committed Feb 21, 2024
1 parent b3f1611 commit 9285c8c
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/*
* ThermodynamicConstantsInterface.java
*
* Created on 3. juni 2000, 19:07
*/

package neqsim.thermo;

/**
Expand All @@ -23,8 +17,6 @@ public interface ThermodynamicConstantsInterface extends java.io.Serializable {
double gravity = 9.80665;
/** Constant <code>avagadroNumber=6.023e23</code>. */
double avagadroNumber = 6.023e23;
/** Constant <code>MAX_NUMBER_OF_COMPONENTS=100</code>. */
static final int MAX_NUMBER_OF_COMPONENTS = 100;
/** Constant <code>referenceTemperature=273.15</code> [K]. */
double referenceTemperature = 273.15;
/** Constant <code>referencePressure=1.01325</code> [bar]. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ public interface ThermodynamicModelSettings extends java.io.Serializable {
/** Constant <code>phaseFractionMinimumLimit=1e-12</code>. */
double phaseFractionMinimumLimit = 1e-12;
/** Constant <code>MAX_NUMBER_OF_COMPONENTS=100</code>. */
static final int MAX_NUMBER_OF_COMPONENTS = 100;
int MAX_NUMBER_OF_COMPONENTS = 100;
}
3 changes: 2 additions & 1 deletion src/main/java/neqsim/thermo/atomElement/UNIFACgroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.ThermodynamicModelSettings;
import neqsim.thermo.component.ComponentGEUnifac;
import neqsim.thermo.phase.PhaseGEUnifac;

Expand All @@ -27,7 +28,7 @@ public class UNIFACgroup implements ThermodynamicConstantsInterface, Comparable<
double QComp = 0.0;
double QMix = 0.0;
public double[] QMixdN = null; // , xMixdN = null;
double[] lnGammaMixdn = new double[MAX_NUMBER_OF_COMPONENTS];
double[] lnGammaMixdn = new double[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
double lnGammaComp = 0.0;
double lnGammaMix = 0.0;
double lnGammaCompdT = 0.0;
Expand Down
17 changes: 13 additions & 4 deletions src/main/java/neqsim/thermo/component/Component.java
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 neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.ThermodynamicModelSettings;
import neqsim.thermo.atomElement.Element;
import neqsim.thermo.component.attractiveEosTerm.AttractiveTermInterface;
import neqsim.thermo.phase.PhaseInterface;
Expand Down Expand Up @@ -123,10 +124,17 @@ public abstract class Component implements ComponentInterface {
protected double paulingAnionicDiameter = 0;

private int orginalNumberOfAssociationSites = 0;

/* Derivative of fugacity wrt temperature */
protected double dfugdt = 0.1;
/* Derivative of fugacity wrt pressure */
protected double dfugdp = 0.1;
protected double[] dfugdn = new double[MAX_NUMBER_OF_COMPONENTS];
public double[] dfugdx = new double[MAX_NUMBER_OF_COMPONENTS];
/* Derivative of fugacity wrt mole fraction (of each ) */
protected double[] dfugdn = new double[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
/* Derivative of fugacity wrt temperature */
public double[] dfugdx = new double[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];

// Parameters for Antoine equation
double AntoineA = 0;
double AntoineB = 0;
double AntoineC = 0;
Expand All @@ -141,14 +149,15 @@ public abstract class Component implements ComponentInterface {
private double[] CpSolid = new double[5];
private double[] CpLiquid = new double[5];
private double heatOfFusion = 0.0;


double triplePointDensity = 10.0;
double triplePointPressure = 0.0;

private double triplePointTemperature = 1000.0;
double meltingPointTemperature = 110.0;

private double idealGasEnthalpyOfFormation = 0.0;
double idealGasGibbsEnergyOfFormation = 0.0;

double idealGasAbsoluteEntropy = 0.0;

double Hsub = 0.0;
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/neqsim/thermo/component/ComponentEos.java
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.ThermodynamicModelSettings;
import neqsim.thermo.component.attractiveEosTerm.AtractiveTermMatCopPRUMRNew;
import neqsim.thermo.component.attractiveEosTerm.AttractiveTermCPAstatoil;
import neqsim.thermo.component.attractiveEosTerm.AttractiveTermGERG;
Expand Down Expand Up @@ -57,8 +58,8 @@ public abstract class ComponentEos extends Component implements ComponentEosInte

public double aDiffDiffT = 0;

public double[] Aij = new double[MAX_NUMBER_OF_COMPONENTS];
public double[] Bij = new double[MAX_NUMBER_OF_COMPONENTS];
public double[] Aij = new double[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
public double[] Bij = new double[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
protected double delta1 = 0;

protected double delta2 = 0;
Expand All @@ -75,8 +76,8 @@ public abstract class ComponentEos extends Component implements ComponentEosInte

protected double bDerTn = 0;

protected double[] dAdndn = new double[MAX_NUMBER_OF_COMPONENTS];
protected double[] dBdndn = new double[MAX_NUMBER_OF_COMPONENTS];
protected double[] dAdndn = new double[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
protected double[] dBdndn = new double[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
private AttractiveTermInterface attractiveParameter;
static Logger logger = LogManager.getLogger(ComponentEos.class);

Expand Down Expand Up @@ -340,7 +341,7 @@ public double fugcoef(PhaseInterface phase) {
double pressure = phase.getPressure();
double logFugacityCoefficient =
dFdN(phase, phase.getNumberOfComponents(), temperature, pressure)
- Math.log(pressure * phase.getMolarVolume() / (R * temperature));
- Math.log(pressure * phase.getMolarVolume() / (R * temperature));
fugacityCoefficient = Math.exp(logFugacityCoefficient);
return fugacityCoefficient;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/neqsim/thermo/component/ComponentHydrate.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public class ComponentHydrate extends Component {
// double[] dHfHydrate = {-292714.5, -292016.0};
double[] dGfHydrate = {-235557, -235614};
double[] dHfHydrate = {-291786, -292016};
double[] reffug =
new double[neqsim.thermo.ThermodynamicConstantsInterface.MAX_NUMBER_OF_COMPONENTS];
double[] reffug = new double[neqsim.thermo.ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
private double sphericalCoreRadiusHydrate = 0.0;
private double lennardJonesEnergyParameterHydrate = 0.0;
private double lennardJonesMolecularDiameterHydrate = 0.0;
Expand Down Expand Up @@ -225,8 +224,9 @@ public double getEmptyHydrateStructureVapourPressure(int type, double temperatur
if (type == -1) {
return getSolidVaporPressure(temperature);
} else {
return Math.exp(getEmptyHydrateVapourPressureConstant(type, 0)
+ getEmptyHydrateVapourPressureConstant(type, 1) / temperature)
return Math
.exp(getEmptyHydrateVapourPressureConstant(type, 0)
+ getEmptyHydrateVapourPressureConstant(type, 1) / temperature)
* ThermodynamicConstantsInterface.referencePressure;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/neqsim/thermo/component/ComponentPRvolcor.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package neqsim.thermo.component;

import neqsim.thermo.ThermodynamicModelSettings;
import neqsim.thermo.phase.PhaseInterface;
import neqsim.thermo.phase.PhasePrEosvolcor;

Expand All @@ -21,7 +22,7 @@ public class ComponentPRvolcor extends ComponentPR {
private static final long serialVersionUID = 1000;
private double c;
// private double calcc;
public double[] Cij = new double[MAX_NUMBER_OF_COMPONENTS];
public double[] Cij = new double[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
public double Ci = 0;

/**
Expand Down
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 @@ -11,6 +11,7 @@
import org.apache.logging.log4j.Logger;
import neqsim.physicalProperties.PhysicalPropertyHandler;
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.ThermodynamicModelSettings;
import neqsim.thermo.component.ComponentInterface;
import neqsim.thermo.system.SystemInterface;
import neqsim.util.exception.InvalidInputException;
Expand Down Expand Up @@ -70,7 +71,7 @@ public abstract class Phase implements PhaseInterface {
* </p>
*/
public Phase() {
componentArray = new ComponentInterface[MAX_NUMBER_OF_COMPONENTS];
componentArray = new ComponentInterface[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
}

/** {@inheritDoc} */
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/neqsim/thermo/phase/PhaseEos.java
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.ThermodynamicModelSettings;
import neqsim.thermo.component.ComponentEosInterface;
import neqsim.thermo.mixingRule.EosMixingRules;
import neqsim.thermo.mixingRule.EosMixingRulesInterface;
Expand Down Expand Up @@ -57,7 +58,7 @@ public PhaseEos clone() {
public PhaseEos() {
super();
mixSelect = new EosMixingRules();
componentArray = new ComponentEosInterface[MAX_NUMBER_OF_COMPONENTS];
componentArray = new ComponentEosInterface[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
mixRule = mixSelect.getMixingRule(1);
// solver = new newtonRhapson();
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/neqsim/thermo/phase/PhaseGE.java
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 neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.ThermodynamicModelSettings;
import neqsim.thermo.component.ComponentGEInterface;
import neqsim.thermo.mixingRule.EosMixingRules;
import neqsim.thermo.mixingRule.EosMixingRulesInterface;
Expand Down Expand Up @@ -36,7 +37,7 @@ public class PhaseGE extends Phase implements PhaseGEInterface {
public PhaseGE() {
super();
setType(PhaseType.LIQUID);
componentArray = new ComponentGEInterface[MAX_NUMBER_OF_COMPONENTS];
componentArray = new ComponentGEInterface[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
useVolumeCorrection = false;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/neqsim/thermo/phase/PhaseGEUnifac.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Arrays;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.thermo.ThermodynamicModelSettings;
import neqsim.thermo.atomElement.UNIFACgroup;
import neqsim.thermo.component.ComponentGEUnifac;
import neqsim.thermo.component.ComponentGEUniquac;
Expand Down Expand Up @@ -32,7 +33,7 @@ public class PhaseGEUnifac extends PhaseGEUniquac {
*/
public PhaseGEUnifac() {
super();
componentArray = new ComponentGEUnifac[MAX_NUMBER_OF_COMPONENTS];
componentArray = new ComponentGEUnifac[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/neqsim/thermo/phase/PhaseGEUnifacPSRK.java
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.ThermodynamicModelSettings;
import neqsim.thermo.component.ComponentGEUnifac;
import neqsim.thermo.component.ComponentGEUnifacPSRK;
import neqsim.thermo.component.ComponentGEUniquac;
Expand All @@ -25,7 +26,7 @@ public class PhaseGEUnifacPSRK extends PhaseGEUnifac {
*/
public PhaseGEUnifacPSRK() {
super();
componentArray = new ComponentGEUnifacPSRK[MAX_NUMBER_OF_COMPONENTS];
componentArray = new ComponentGEUnifacPSRK[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/neqsim/thermo/phase/PhaseGEUnifacUMRPRU.java
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.ThermodynamicModelSettings;
import neqsim.thermo.component.ComponentGEUnifac;
import neqsim.thermo.component.ComponentGEUnifacUMRPRU;
import neqsim.thermo.component.ComponentGEUniquac;
Expand Down Expand Up @@ -31,7 +32,8 @@ public class PhaseGEUnifacUMRPRU extends PhaseGEUnifac {
*/
public PhaseGEUnifacUMRPRU() {
super();
componentArray = new ComponentGEUnifacUMRPRU[MAX_NUMBER_OF_COMPONENTS];
componentArray =
new ComponentGEUnifacUMRPRU[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/neqsim/thermo/phase/PhaseGEUniquac.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package neqsim.thermo.phase;

import neqsim.thermo.ThermodynamicModelSettings;
import neqsim.thermo.component.ComponentGEInterface;
import neqsim.thermo.component.ComponentGEUniquac;

Expand Down Expand Up @@ -33,7 +34,7 @@ public class PhaseGEUniquac extends PhaseGE {
*/
public PhaseGEUniquac() {
super();
componentArray = new ComponentGEInterface[MAX_NUMBER_OF_COMPONENTS];
componentArray = new ComponentGEInterface[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/neqsim/thermo/phase/PhaseGEWilson.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package neqsim.thermo.phase;

import neqsim.thermo.ThermodynamicModelSettings;
import neqsim.thermo.component.ComponentGEWilson;

/**
Expand All @@ -22,7 +23,7 @@ public class PhaseGEWilson extends PhaseGE {
*/
public PhaseGEWilson() {
super();
componentArray = new ComponentGEWilson[MAX_NUMBER_OF_COMPONENTS];
componentArray = new ComponentGEWilson[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
}

/**
Expand Down

0 comments on commit 9285c8c

Please sign in to comment.