From 7cb35f4fd8b94b831fe60d4b2c0aa47ea63a1c11 Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:18:28 +0000 Subject: [PATCH] update --- .../oilquality/Standard_ASTM_D6377.java | 8 +++--- .../ThermodynamicOperations.java | 6 ++++- .../flashops/TPmultiflash.java | 2 ++ .../flashops/TVfractionFlash.java | 27 +++++++++++++++---- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/main/java/neqsim/standards/oilquality/Standard_ASTM_D6377.java b/src/main/java/neqsim/standards/oilquality/Standard_ASTM_D6377.java index 58e48696de..6baacf2b6b 100644 --- a/src/main/java/neqsim/standards/oilquality/Standard_ASTM_D6377.java +++ b/src/main/java/neqsim/standards/oilquality/Standard_ASTM_D6377.java @@ -99,11 +99,12 @@ public void calculate() { this.thermoSystem.setPressure(TVP * 0.9); try { - // ASTM D323 -08 method is used for this property calculation. It is defined at the pressure + // ASTM D323 -08 method is used for this property calculation. It is defined at + // the pressure // at 100°F (37.8°C) at which 80% of the stream by volume is vapor at 100°F. In this.thermoOps.TVfractionFlash(0.8); } catch (Exception ex) { - logger.error(ex.getMessage(), ex); + logger.error("not able to find RVP...", ex); } VPCR4 = this.thermoSystem.getPressure(); @@ -116,7 +117,8 @@ public void calculate() { fluid1.init(0); } try { - // ASTM D323 -08 method is used for this property calculation. It is defined at the pressure + // ASTM D323 -08 method is used for this property calculation. It is defined at + // the pressure // at 100°F (37.8°C) at which 80% of the stream by volume is vapor at 100°F. In this.thermoOps.TVfractionFlash(0.8); } catch (Exception ex) { diff --git a/src/main/java/neqsim/thermodynamicoperations/ThermodynamicOperations.java b/src/main/java/neqsim/thermodynamicoperations/ThermodynamicOperations.java index 61ed084e1d..b2fae0fb63 100644 --- a/src/main/java/neqsim/thermodynamicoperations/ThermodynamicOperations.java +++ b/src/main/java/neqsim/thermodynamicoperations/ThermodynamicOperations.java @@ -601,7 +601,11 @@ public void TVflash(double Vspec) { */ public void TVfractionFlash(double Vspec) { operation = new neqsim.thermodynamicoperations.flashops.TVfractionFlash(system, Vspec); - getOperation().run(); + try { + getOperation().run(); + } catch (Exception e) { + throw e; + } } /** diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/TPmultiflash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/TPmultiflash.java index 4ed67c1c19..9962efaf0e 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/TPmultiflash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/TPmultiflash.java @@ -199,6 +199,8 @@ public double solveBeta() { try { ans = dQdBM.solve(dQM).transpose(); } catch (Exception ex) { + logger.error(ex.getMessage()); + break; } betaMatrix = betaMatrix.minus(ans.scale(iter / (iter + 3.0))); removePhase = false; diff --git a/src/main/java/neqsim/thermodynamicoperations/flashops/TVfractionFlash.java b/src/main/java/neqsim/thermodynamicoperations/flashops/TVfractionFlash.java index 8491b6ef03..cb85507806 100644 --- a/src/main/java/neqsim/thermodynamicoperations/flashops/TVfractionFlash.java +++ b/src/main/java/neqsim/thermodynamicoperations/flashops/TVfractionFlash.java @@ -6,6 +6,8 @@ package neqsim.thermodynamicoperations.flashops; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import neqsim.thermo.system.SystemInterface; /** @@ -18,6 +20,7 @@ */ public class TVfractionFlash extends Flash { private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(TVfractionFlash.class); double Vfractionspec = 0; Flash tpFlash; @@ -86,12 +89,23 @@ public double solveQ() { if (nyPres <= 0.0) { nyPres = oldPres * 0.9; } + if (Math.abs(nyPres - oldPres) >= 10.0) { + nyPres = oldPres + Math.signum(nyPres - oldPres) * 10.0; + } system.setPressure(nyPres); - tpFlash.run(); + if (system.getPressure() < 5000) { + tpFlash.run(); + } else { + logger.error("too high pressure in TVfractionFLash.....stopping"); + break; + } error = Math.abs(dqdv / Vfractionspec); - // System.out.println("error " + error + "iteration " + iterations + " dQdv " + calcdQdV() - // + " new pressure " + nyPres + " error " + Math.abs((nyPres - oldPres) / (nyPres)) + logger.debug("pressure " + nyPres + " iteration " + iterations); + // System.out.println("error " + error + "iteration " + iterations + " dQdv " + + // calcdQdV() + // + " new pressure " + nyPres + " error " + Math.abs((nyPres - oldPres) / + // (nyPres)) // + " numberofphases " + system.getNumberOfPhases()); } while ((error > 1e-6 && Math.abs(pressureStep) > 1e-6 && iterations < 200) || iterations < 6); return nyPres; @@ -109,8 +123,11 @@ public void run() { } // System.out.println("enthalpy: " + system.getEnthalpy()); - solveQ(); - + try { + solveQ(); + } catch (Exception e) { + throw e; + } // System.out.println("volume: " + system.getVolume()); // System.out.println("Temperature: " + system.getTemperature()); }