From fd552f7e88b9d6ae0a215bd538f2c554da059d77 Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Sat, 25 Nov 2023 17:50:18 +0100 Subject: [PATCH] bug fix (#857) --- .../distillation/DistillationColumn.java | 10 +--------- .../ThermodynamicOperations.java | 9 +++------ .../thermodynamicOperations/flashOps/TPmultiflash.java | 5 ++++- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/main/java/neqsim/processSimulation/processEquipment/distillation/DistillationColumn.java b/src/main/java/neqsim/processSimulation/processEquipment/distillation/DistillationColumn.java index de397915c0..b82e038aa8 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/distillation/DistillationColumn.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/distillation/DistillationColumn.java @@ -370,14 +370,6 @@ public void run(UUID id) { trays.get(i + 1).getLiquidOutStream()); ((SimpleTray) trays.get(i)).run(id); } - // for (int i = 1; i <= numberOfTrays - 1; i++) { - // int replaceStream = trays.get(i).getNumberOfInputStreams() - 2; - // if (i == (numberOfTrays - 1)) { - // replaceStream = trays.get(i).getNumberOfInputStreams() - 1; - // } - // ((Mixer) trays.get(i)).replaceStream(replaceStream, trays.get(i - 1).getGasOutStream()); - // ((SimpleTray) trays.get(i)).run(id); - // } for (int i = 0; i < numberOfTrays; i++) { err += Math.abs( oldtemps[i] - ((MixerInterface) trays.get(i)).getThermoSystem().getTemperature()); @@ -385,7 +377,7 @@ public void run(UUID id) { logger.info("error iter " + err + " iteration " + iter); // System.out.println("error iter " + err + " iteration " + iter); // massBalanceCheck(); - } while (err > 1e-4 && err < errOld && iter < maxNumberOfIterations); // && + } while (err > 1e-4 && err < errOld && iter < maxNumberOfIterations); // && // !massBalanceCheck()); // massBalanceCheck(); // componentMassBalanceCheck("water"); diff --git a/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java b/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java index 891a95a37a..18c08aa989 100644 --- a/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java +++ b/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java @@ -3,14 +3,11 @@ import java.awt.BorderLayout; import java.awt.Container; import java.util.List; - import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.api.ioc.CalculationResult; import neqsim.thermo.component.ComponentHydrate; import neqsim.thermo.system.SystemInterface; @@ -146,7 +143,7 @@ public void TPVflash(double volumeSpec, String unit) { public void TPflash() { double flowRate = system.getTotalNumberOfMoles(); double minimumFlowRate = 1e-50; - if (flowRate < 1e-3) { + if (flowRate < 1e-5) { system.setTotalNumberOfMoles(1.0); system.init(1); } @@ -157,13 +154,13 @@ public void TPflash() { } else { run(); } - if (flowRate < 1e-3) { + if (flowRate < 1e-5) { if (flowRate < minimumFlowRate) { system.setTotalNumberOfMoles(minimumFlowRate); } else { system.setTotalNumberOfMoles(flowRate); } - system.init(2); + system.init(1); } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java index 51a09bd3fa..8290b78704 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java @@ -379,7 +379,6 @@ public void stabilityAnalysis() { if (iter <= 150 || !system.isImplementedCompositionDeriativesofFugacity()) { if (iter % 7 == 0 && useaccsubst) { double vec1 = 0.0; - double vec2 = 0.0; double prod1 = 0.0; double prod2 = 0.0; @@ -841,6 +840,10 @@ public void stabilityAnalysis2() { } } } while ((Math.abs(err) > 1e-9 || err > errOld) && iter < 200); + if (iter > 198) { + System.out.println("too many iterations....." + err); + new Exception("to many iterations "); + } // logger.info("err: " + err + " ITER " + iter); double xTrivialCheck0 = 0.0; double xTrivialCheck1 = 0.0;