Skip to content

Commit

Permalink
Merge branch 'master' into refact_getPhase
Browse files Browse the repository at this point in the history
  • Loading branch information
asmfstatoil committed Feb 29, 2024
2 parents 2f27f1f + 388d877 commit ba49e1c
Show file tree
Hide file tree
Showing 37 changed files with 710 additions and 225 deletions.
6 changes: 3 additions & 3 deletions src/main/java/neqsim/thermo/component/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,12 @@ public void setProperties(ComponentInterface component) {
/** {@inheritDoc} */
@Override
public void init(double temperature, double pressure, double totalNumberOfMoles, double beta,
int type) {
int initType) {
if (totalNumberOfMoles == 0) {
throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, "init",
"totalNumberOfMoles", "must be larger than 0"));
}
if (type == 0) {
if (initType == 0) {
K = Math.exp(Math.log(criticalPressure / pressure)
+ 5.373 * (1.0 + srkacentricFactor) * (1.0 - criticalTemperature / temperature));
z = numberOfMoles / totalNumberOfMoles;
Expand All @@ -556,7 +556,7 @@ public Element getElements() {
/** {@inheritDoc} */
@Override
public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta,
int numberOfComponents, int type) {}
int numberOfComponents, int initType) {}

/** {@inheritDoc} */
@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/neqsim/thermo/component/ComponentBWRS.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public ComponentBWRS clone() {
/** {@inheritDoc} */
@Override
public void init(double temperature, double pressure, double totalNumberOfMoles, double beta,
int type) {
super.init(temperature, pressure, totalNumberOfMoles, beta, type);
int initType) {
super.init(temperature, pressure, totalNumberOfMoles, beta, initType);

BP[0] = R * temperature;
BP[1] = aBWRS[0] * temperature + aBWRS[1] * Math.sqrt(temperature) + aBWRS[2]
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/neqsim/thermo/component/ComponentCSPsrk.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ public ComponentCSPsrk clone() {
/** {@inheritDoc} */
@Override
public void init(double temperature, double pressure, double totalNumberOfMoles, double beta,
int type) {
super.init(temperature, pressure, totalNumberOfMoles, beta, type);
int initType) {
super.init(temperature, pressure, totalNumberOfMoles, beta, initType);
h_scale_mix_i = Bi / (refPhaseBWRS.getRefBWRSPhase().getB()
/ refPhaseBWRS.getRefBWRSPhase().getNumberOfMolesInPhase());

double termfi1 = Ai / refPhaseBWRS.getA();
double termfi2 = h_scale_mix_i / refPhaseBWRS.getH_scale_mix();
double termfi3 = ((ComponentEosInterface) refPhaseBWRS.getRefBWRSPhase().getComponent(0))
.getaDiffT()
double termfi3 =
((ComponentEosInterface) refPhaseBWRS.getRefBWRSPhase().getComponent(0)).getaDiffT()
/ ((ComponentEosInterface) refPhaseBWRS.getRefBWRSPhase().getComponent(0)).getaT()
* refPhaseBWRS.getRefBWRSPhase().getTemperature()
/ refPhaseBWRS.getNumberOfMolesInPhase();
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/neqsim/thermo/component/ComponentEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ public ComponentEos clone() {

/** {@inheritDoc} */
@Override
public void init(double temp, double pres, double totMoles, double beta, int type) {
super.init(temp, pres, totMoles, beta, type);
public void init(double temp, double pres, double totMoles, double beta, int initType) {
super.init(temp, pres, totMoles, beta, initType);
a = calca();
b = calcb();
reducedTemperature = reducedTemperature(temp);
reducedPressure = reducedPressure(pres);
aT = a * alpha(temp);
if (type >= 2) {
if (initType >= 2) {
aDiffT = diffaT(temp);
aDiffDiffT = diffdiffaT(temp);
}
Expand All @@ -145,10 +145,10 @@ public void init(double temp, double pres, double totMoles, double beta, int typ
/** {@inheritDoc} */
@Override
public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta,
int numberOfComponents, int type) {
int numberOfComponents, int initType) {
Bi = phase.calcBi(componentNumber, phase, temp, pres, numberOfComponents);
Ai = phase.calcAi(componentNumber, phase, temp, pres, numberOfComponents);
if (type >= 2) {
if (initType >= 2) {
AiT = phase.calcAiT(componentNumber, phase, temp, pres, numberOfComponents);
}
double totVol = phase.getMolarVolume() * phase.getNumberOfMolesInPhase();
Expand All @@ -157,7 +157,7 @@ public void Finit(PhaseInterface phase, double temp, double pres, double totMole
/ (-R * temp * phase.dFdVdV()
- phase.getNumberOfMolesInPhase() * R * temp / (totVol * totVol));

if (type >= 3) {
if (initType >= 3) {
for (int j = 0; j < numberOfComponents; j++) {
Aij[j] = phase.calcAij(componentNumber, j, phase, temp, pres, numberOfComponents);
Bij[j] = phase.calcBij(componentNumber, j, phase, temp, pres, numberOfComponents);
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/neqsim/thermo/component/ComponentInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -816,10 +816,11 @@ public default void addMolesChemReac(double dn) {
* @param pressure Pressure in unit ?. Used to calculate <code>K</code>.
* @param totalNumberOfMoles Total number of moles of component.
* @param beta Beta value, i.e.,
* @param type Init type. Calculate <code>K</code>, <code>z</code>, <code>x</code> if type == 0.
* @param initType Init type. Calculate <code>K</code>, <code>z</code>, <code>x</code> if type ==
* 0.
*/
public void init(double temperature, double pressure, double totalNumberOfMoles, double beta,
int type);
int initType);

/**
* <p>
Expand All @@ -832,10 +833,10 @@ public void init(double temperature, double pressure, double totalNumberOfMoles,
* @param totalNumberOfMoles a double
* @param beta a double
* @param numberOfComponents a int
* @param type a int
* @param initType a int
*/
public void Finit(PhaseInterface phase, double temperature, double pressure,
double totalNumberOfMoles, double beta, int numberOfComponents, int type);
double totalNumberOfMoles, double beta, int numberOfComponents, int initType);

/**
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ public ComponentModifiedFurstElectrolyteEos(String component_name, double moles,
if (ionicCharge != 0) {
setIsIon(true);
}
b = ionicCharge != 0 ? (neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[0]
* Math.pow(getIonicDiameter(), 3.0)
b = ionicCharge != 0
? (neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[0]
* Math.pow(getIonicDiameter(), 3.0)
+ neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[1]) * 1e5
: b;
a = ionicCharge != 0 ? 1.0e-35 : a;
Expand Down Expand Up @@ -118,8 +119,9 @@ public ComponentModifiedFurstElectrolyteEos(int number, double TC, double PC, do
* </p>
*/
public void initFurstParam() {
b = ionicCharge != 0 ? (neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[0]
* Math.pow(getIonicDiameter(), 3.0)
b = ionicCharge != 0
? (neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[0]
* Math.pow(getIonicDiameter(), 3.0)
+ neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[1]) * 1e5
: b;
lennardJonesMolecularDiameter =
Expand Down Expand Up @@ -163,7 +165,7 @@ public double calcb() {
/** {@inheritDoc} */
@Override
public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta,
int numberOfComponents, int type) {
int numberOfComponents, int initType) {
Wi = ((PhaseModifiedFurstElectrolyteEos) phase).calcWi(componentNumber, phase, temp, pres,
numberOfComponents);
WiT = ((PhaseModifiedFurstElectrolyteEos) phase).calcWiT(componentNumber, phase, temp, pres,
Expand Down Expand Up @@ -209,7 +211,7 @@ public void Finit(PhaseInterface phase, double temp, double pres, double totMole
if (getLennardJonesMolecularDiameter() > 0) {
XBorni = ionicCharge * ionicCharge / (getLennardJonesMolecularDiameter() * 1e-10);
}
super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, type);
super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, initType);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ public ComponentModifiedFurstElectrolyteEosMod2004(String component_name, double
if (ionicCharge != 0) {
setIsIon(true);
}
b = ionicCharge != 0 ? (neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[0]
* Math.pow(getIonicDiameter(), 3.0)
b = ionicCharge != 0
? (neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[0]
* Math.pow(getIonicDiameter(), 3.0)
+ neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[1]) * 1e5
: b;
a = ionicCharge != 0 ? 1.0e-35 : a;
Expand Down Expand Up @@ -118,8 +119,9 @@ public ComponentModifiedFurstElectrolyteEosMod2004(int number, double TC, double
* </p>
*/
public void initFurstParam() {
b = ionicCharge != 0 ? (neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[0]
* Math.pow(getIonicDiameter(), 3.0)
b = ionicCharge != 0
? (neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[0]
* Math.pow(getIonicDiameter(), 3.0)
+ neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[1]) * 1e5
: b;
lennardJonesMolecularDiameter =
Expand Down Expand Up @@ -155,7 +157,7 @@ public double calcb() {
/** {@inheritDoc} */
@Override
public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta,
int numberOfComponents, int type) {
int numberOfComponents, int initType) {
Wi = ((PhaseModifiedFurstElectrolyteEosMod2004) phase).calcWi(componentNumber, phase, temp,
pres, numberOfComponents);
WiT = ((PhaseModifiedFurstElectrolyteEosMod2004) phase).calcWiT(componentNumber, phase, temp,
Expand Down Expand Up @@ -183,7 +185,8 @@ public void Finit(PhaseInterface phase, double temp, double pres, double totMole
((PhaseModifiedFurstElectrolyteEosMod2004) phase).getDiElectricConstant(), 2.0)
* R * temp * temp)
* diElectricdn
+ 2.0 * electronCharge * electronCharge * avagadroNumber / (vacumPermittivity
+ 2.0 * electronCharge * electronCharge * avagadroNumber
/ (vacumPermittivity
* Math.pow(
((PhaseModifiedFurstElectrolyteEosMod2004) phase).getDiElectricConstant(), 3.0)
* R * temp)
Expand All @@ -194,15 +197,16 @@ public void Finit(PhaseInterface phase, double temp, double pres, double totMole
.pow(((PhaseModifiedFurstElectrolyteEosMod2004) phase).getDiElectricConstant(), 2.0) * R
* temp)
* diElectricdndV
+ 2.0 * electronCharge * electronCharge * avagadroNumber / (vacumPermittivity
+ 2.0 * electronCharge * electronCharge * avagadroNumber
/ (vacumPermittivity
* Math.pow(
((PhaseModifiedFurstElectrolyteEosMod2004) phase).getDiElectricConstant(), 3.0)
* R * temp)
* diElectricdn
* ((PhaseModifiedFurstElectrolyteEosMod2004) phase).getDiElectricConstantdV();
XLRi = calcXLRdN(phase, numberOfComponents, temp, pres);
XBorni = ionicCharge * ionicCharge / (getLennardJonesMolecularDiameter() * 1e-10);
super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, type);
super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, initType);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/neqsim/thermo/component/ComponentPCSAFT.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ public ComponentPCSAFT clone() {
/** {@inheritDoc} */
@Override
public void init(double temperature, double pressure, double totalNumberOfMoles, double beta,
int type) {
int initType) {
setdSAFTi(getSigmaSAFTi() * (1.0 - 0.12 * Math.exp(-3.0 * getEpsikSAFT() / temperature)));
super.init(temperature, pressure, totalNumberOfMoles, beta, type);
super.init(temperature, pressure, totalNumberOfMoles, beta, initType);
}

/** {@inheritDoc} */
@Override
public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta,
int numberOfComponents, int type) {
super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, type);
int numberOfComponents, int initType) {
super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, initType);
setDnSAFTdi(calcdnSAFTdi(phase, numberOfComponents, temp, pres));
setDghsSAFTdi(calcdghsSAFTdi(phase, numberOfComponents, temp, pres));
setDlogghsSAFTdi(1.0 / ((PhasePCSAFT) phase).getGhsSAFT() * getDghsSAFTdi());
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/neqsim/thermo/component/ComponentPRvolcor.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public ComponentPRvolcor(String component_name, double moles, double molesInPhas

/** {@inheritDoc} */
@Override
public void init(double temp, double pres, double totMoles, double beta, int type) {
super.init(temp, pres, totMoles, beta, type);
public void init(double temp, double pres, double totMoles, double beta, int initType) {
super.init(temp, pres, totMoles, beta, initType);
c = calcc();
}

Expand All @@ -123,14 +123,14 @@ public double getcT() {
/** {@inheritDoc} */
@Override
public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta,
int numberOfComponents, int type) {
super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, type);
int numberOfComponents, int initType) {
super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, initType);
Ci = ((PhasePrEosvolcor) phase).calcCi(componentNumber, phase, temp, pres, numberOfComponents);
if (type >= 2) {
if (initType >= 2) {
((PhasePrEosvolcor) phase).calcCiT(componentNumber, phase, temp, pres, numberOfComponents);
}

if (type >= 3) {
if (initType >= 3) {
for (int j = 0; j < numberOfComponents; j++) {
Cij[j] = ((PhasePrEosvolcor) phase).calcCij(componentNumber, j, phase, temp, pres,
numberOfComponents);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/neqsim/thermo/phase/Phase.java
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public void init() {

/** {@inheritDoc} */
@Override
public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType pt,
public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt,
double beta) {
if (totalNumberOfMoles <= 0) {
throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, "init",
Expand All @@ -416,10 +416,10 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph
setType(pt);
// setPhysicalProperties(physicalPropertyType);
}
this.setInitType(type);
this.setInitType(initType);
this.numberOfComponents = numberOfComponents;
for (int i = 0; i < numberOfComponents; i++) {
componentArray[i].init(temperature, pressure, totalNumberOfMoles, beta, type);
componentArray[i].init(temperature, pressure, totalNumberOfMoles, beta, initType);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/neqsim/thermo/phase/PhaseBWRSEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ public void addComponent(String name, double moles, double molesInPhase, int com

/** {@inheritDoc} */
@Override
public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType pt,
public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt,
double beta) {
double oldMolDens = 0;
if (type == 0) {
super.init(totalNumberOfMoles, numberOfComponents, type, pt, beta);
if (initType == 0) {
super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta);
super.init(totalNumberOfMoles, numberOfComponents, 3, pt, beta);
return;
}
do {
oldMolDens = getMolarDensity();
super.init(totalNumberOfMoles, numberOfComponents, type, pt, beta);
super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta);
} while (Math.abs((getMolarDensity() - oldMolDens) / oldMolDens) > 1e-10);
getF();
// calcPVT();
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/neqsim/thermo/phase/PhaseCSPsrkEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ public void addComponent(String name, double moles, double molesInPhase, int com

/** {@inheritDoc} */
@Override
public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType pt,
public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt,
double beta) {
double oldtemp = temperature;
if (type == 0) {
if (initType == 0) {
refBWRSPhase.init(1.0, 1, 0, pt, 1.0);
refBWRSPhase.init(1.0, 1, 3, pt, 1.0);
} else {
refBWRSPhase.init(1.0, 1, 3, pt, 1.0);
}
do {
super.init(totalNumberOfMoles, numberOfComponents, type, pt, beta);
super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta);
oldtemp = refBWRSPhase.getTemperature();
h_scale_mix = getNumberOfMolesInPhase() * getb() / brefBWRSPhase;
double term1 = getA() / ((ComponentEosInterface) refBWRSPhase.getComponent(0)).getaT();
Expand All @@ -84,7 +84,7 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph
refBWRSPhase.setMolarVolume(getTotalVolume() / h_scale_mix);
// refBWRSPhase.setPressure(refBWRSPhase.calcPressure());
refBWRSPhase.setPressure(pressure * h_scale_mix / f_scale_mix);
refBWRSPhase.init(1.0, 1, type, pt, 1.0);
refBWRSPhase.init(1.0, 1, initType, pt, 1.0);
} while (Math.abs((oldtemp - refBWRSPhase.getTemperature()) / oldtemp) > 1e-8);
}

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPA.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ public void setMixingRule(int type) {

/** {@inheritDoc} */
@Override
public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType pt,
public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt,
double beta) {
if (type == 0) {
if (initType == 0) {
setTotalNumberOfAccociationSites(0);
selfAccociationScheme = new int[numberOfComponents][0][0];
crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0];
Expand Down Expand Up @@ -182,8 +182,8 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph
cpamix = cpaSelect.getMixingRule(1, this);
}

super.init(totalNumberOfMoles, numberOfComponents, type, pt, beta);
if (type > 0 && isConstantPhaseVolume()) {
super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta);
if (initType > 0 && isConstantPhaseVolume()) {
volInit();
calcDelta();
solveX();
Expand All @@ -195,17 +195,17 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph
gcpavvv = calc_lngVVV();
}

if (type > 0) {
if (initType > 0) {
hcpatot = calc_hCPA();
}

if (type > 1) {
if (initType > 1) {
volInit();
initCPAMatrix(type);
initCPAMatrix(initType);
// hcpatotdT = calc_hCPAdT();
// super.init(totalNumberOfMoles, numberOfComponents, type, pt, beta);
}
super.init(totalNumberOfMoles, numberOfComponents, type, pt, beta);
super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta);
}

/**
Expand Down
Loading

0 comments on commit ba49e1c

Please sign in to comment.