diff --git a/src/main/java/neqsim/thermo/phase/PhaseEos.java b/src/main/java/neqsim/thermo/phase/PhaseEos.java index 7859d62891..1e39b5ef27 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseEos.java +++ b/src/main/java/neqsim/thermo/phase/PhaseEos.java @@ -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); @@ -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 { diff --git a/src/main/java/neqsim/thermodynamicoperations/ThermodynamicOperations.java b/src/main/java/neqsim/thermodynamicoperations/ThermodynamicOperations.java index f332557380..dd1a9ea94f 100644 --- a/src/main/java/neqsim/thermodynamicoperations/ThermodynamicOperations.java +++ b/src/main/java/neqsim/thermodynamicoperations/ThermodynamicOperations.java @@ -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); @@ -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 { @@ -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]);