diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/Flash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/Flash.java index 820e0793f4..972d278683 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/Flash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/Flash.java @@ -282,8 +282,8 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, // check for trivial solution double diffx = 0.0; for (int i = 0; i < clonedSystem.getPhase(0).getNumberOfComponents(); i++) { - diffx += Math.abs(clonedSystem.getPhase(0).getComponent(i).getx() - - clonedSystem.getPhase(1).getComponent(i).getx()); + diffx += Math.abs(clonedSystem.getPhase(j).getComponent(i).getx() + - minimumGibbsEnergySystem.getPhase(0).getComponent(i).getx()); } if (diffx < 1e-10) { tm[0] = 0.0; @@ -310,6 +310,7 @@ public void stabilityAnalysis() throws neqsim.util.exception.IsNaNException, logger.info("error in stability anlysis"); system.init(0); } + if (Double.isNaN(tm[j])) { tm[j] = 0; } @@ -357,7 +358,7 @@ public boolean stabilityCheck() { } else { RachfordRice rachfordRice = new RachfordRice(); try { - system.setBeta(rachfordRice.calcBeta(system.getKvector(), system.getzvector())); + system.setBeta(rachfordRice.calcBeta(system.getKvector(), minimumGibbsEnergySystem.getzvector())); } catch (Exception ex) { if (!Double.isNaN(rachfordRice.getBeta()[0])) { system.setBeta(rachfordRice.getBeta()[0]); diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/RachfordRice.java b/src/main/java/neqsim/thermodynamicoperations/flashops/RachfordRice.java index bdda3b43dd..5eb9702400 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/RachfordRice.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/RachfordRice.java @@ -7,6 +7,7 @@ package neqsim.thermodynamicoperations.flashops; import java.io.Serializable; +import java.util.Arrays; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.thermo.component.ComponentInterface; @@ -195,6 +196,8 @@ public double calcBetaMichelsen2001(double[] K, double[] z) beta[1] = 1.0 - nybeta; if (iterations >= maxIterations) { + logger.debug("K " + Arrays.toString(K)); + logger.debug("z " + Arrays.toString(z)); throw new neqsim.util.exception.TooManyIterationsException(new RachfordRice(), "calcBetaMichelsen2001", maxIterations); } diff --git a/src/test/java/neqsim/process/processmodel/ProcessSystemRunTransientTest.java b/src/test/java/neqsim/process/processmodel/ProcessSystemRunTransientTest.java index 72223aa783..b6c4b935ea 100644 --- a/src/test/java/neqsim/process/processmodel/ProcessSystemRunTransientTest.java +++ b/src/test/java/neqsim/process/processmodel/ProcessSystemRunTransientTest.java @@ -48,7 +48,6 @@ private SystemInterface getTestSystem() { testSystem.addComponent("methane", 0.900); testSystem.addComponent("ethane", 0.100); testSystem.addComponent("n-heptane", 1.00); - testSystem.createDatabase(true); testSystem.setMixingRule(2); return testSystem; } diff --git a/src/test/java/neqsim/process/processmodel/ProcessSystemTest.java b/src/test/java/neqsim/process/processmodel/ProcessSystemTest.java index 44c1d50594..873b6a708a 100644 --- a/src/test/java/neqsim/process/processmodel/ProcessSystemTest.java +++ b/src/test/java/neqsim/process/processmodel/ProcessSystemTest.java @@ -580,7 +580,7 @@ public void runTEGProcessTest2() { * coolerhOTteg3.getOutletStream().getFlowRate("kg/hr")); System.out.println("leantoresirc " + * leanTEGtoabs.getFlowRate("kg/hr")); */ - assertEquals(1.6574913669263535E-5, dehydratedGas.getFluid().getComponent("water").getx(), + assertEquals(1.5449593316401103E-5, dehydratedGas.getFluid().getComponent("water").getx(), 1e-6); }