Skip to content

Commit

Permalink
refact: reorder code in PhaseEos init, remove logging
Browse files Browse the repository at this point in the history
  • Loading branch information
asmfstatoil committed Oct 24, 2024
1 parent 75f177a commit 5b0852c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
20 changes: 6 additions & 14 deletions src/main/java/neqsim/thermo/phase/PhaseEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,15 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int initType
}

if (initType != 0) {
try {
if (calcMolarVolume) {
if (calcMolarVolume) {
try {
molarVolume = molarVolume(pressure, temperature,
getA() / numberOfMolesInPhase / numberOfMolesInPhase, getB() / numberOfMolesInPhase,
pt);
} catch (Exception ex) {
// reraise IsNaNException and TooManyIterationsException as RuntimeException
throw new RuntimeException(ex);
}
} catch (Exception ex) {
logger.warn("Failed to solve for molarVolume within the iteration limit.");
logger.error(ex.getMessage());
throw new RuntimeException(ex);
// logger.error("too many iterations in volume calc!", ex);
// logger.info("moles " + numberOfMolesInPhase);
// logger.info("molarVolume " + getMolarVolume());
// logger.info("setting molar volume to ideal gas molar volume.............");
// setMolarVolume((R * temperature) / pressure);
// System.exit(0);
}

Z = pressure * getMolarVolume() / (R * temperature);
Expand All @@ -135,8 +128,7 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int initType
double sumAqueous = 0.0;
for (int i = 0; i < numberOfComponents; i++) {
if ((getComponent(i).isHydrocarbon() || getComponent(i).isInert()
|| getComponent(i).isIsTBPfraction())
&& !getComponent(i).getName().equals("water")
|| getComponent(i).isIsTBPfraction()) && !getComponent(i).getName().equals("water")
&& !getComponent(i).getName().equals("water_PC")) {
sumHydrocarbons += getComponent(i).getx();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ public void TPVflash(double volumeSpec, String unit) {
*/
public void TPflash() {
double flowRate = system.getTotalNumberOfMoles();
double minimumFlowRate = 1e-50;
if (flowRate < 1e-5) {
system.setTotalNumberOfMoles(1.0);
system.init(1);
Expand All @@ -162,7 +161,9 @@ public void TPflash() {
} else {
run();
}

if (flowRate < 1e-5) {
final double minimumFlowRate = 1e-50;
if (flowRate < minimumFlowRate) {
system.setTotalNumberOfMoles(minimumFlowRate);
} else {
Expand Down Expand Up @@ -1023,6 +1024,7 @@ public double[] calcImobilePhaseHydrateTemperature(double[] temperature, double[
systemTemp = system.clone();

for (int i = 0; i < temperature.length; i++) {
// todo: this function does not actually set hydTemps which is the returned variable
/*
* opsTemp = new ThermodynamicOperations(systemTemp);
* systemTemp.setTemperature(temperature[i]); systemTemp.setPressure(pressure[i]);
Expand Down

0 comments on commit 5b0852c

Please sign in to comment.