From 4d29db5a6c41e595848c27bc9db7114bb26e3be1 Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:34:03 +0100 Subject: [PATCH] changed code when low molecular weights of plus fraction (#1214) --- .../thermo/characterization/Characterise.java | 6 ++- .../characterization/PlusFractionModel.java | 13 ++++- .../PlusFractionModelInterface.java | 6 ++- .../PlusFractionModelTest.java | 48 +++++++++++++++++++ 4 files changed, 67 insertions(+), 6 deletions(-) diff --git a/src/main/java/neqsim/thermo/characterization/Characterise.java b/src/main/java/neqsim/thermo/characterization/Characterise.java index f46f425a90..3c598c8686 100644 --- a/src/main/java/neqsim/thermo/characterization/Characterise.java +++ b/src/main/java/neqsim/thermo/characterization/Characterise.java @@ -159,8 +159,10 @@ public void characterisePlusFraction() { plusFractionModel = plusFractionModelSelector.getModel("Pedersen Heavy Oil"); logger.info("changing to " + plusFractionModel.getName()); } - plusFractionModel.characterizePlusFraction(TBPfractionModel); - lumpingModel.generateLumpedComposition(this); + boolean couldCharacerize = plusFractionModel.characterizePlusFraction(TBPfractionModel); + if (couldCharacerize) { + lumpingModel.generateLumpedComposition(this); + } } } diff --git a/src/main/java/neqsim/thermo/characterization/PlusFractionModel.java b/src/main/java/neqsim/thermo/characterization/PlusFractionModel.java index 46b9798ecf..e95773cc87 100644 --- a/src/main/java/neqsim/thermo/characterization/PlusFractionModel.java +++ b/src/main/java/neqsim/thermo/characterization/PlusFractionModel.java @@ -1,5 +1,7 @@ package neqsim.thermo.characterization; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import neqsim.thermo.system.SystemInterface; /** @@ -11,6 +13,7 @@ * @version $Id: $Id */ public class PlusFractionModel implements java.io.Serializable { + static Logger logger = LogManager.getLogger(PlusFractionModel.class); private static final long serialVersionUID = 1000; private String name = ""; private SystemInterface system = null; @@ -193,7 +196,7 @@ public boolean hasPlusFraction() { } @Override - public void characterizePlusFraction(TBPModelInterface TBPModel) { + public boolean characterizePlusFraction(TBPModelInterface TBPModel) { system.init(0); Integer firstPlusNumber = Integer.valueOf(0); if (system.getPhase(0).getComponent(plusComponentNumber).getComponentName().substring(3, 4) @@ -210,6 +213,10 @@ public void characterizePlusFraction(TBPModelInterface TBPModel) { numberOfPlusPseudocomponents = lastPlusFractionNumber - firstPlusFractionNumber + 1; + if (PVTsimMolarMass[firstPlusFractionNumber - 6] > MPlus * 1000) { + logger.error("Plus fraction molar mass too light "); + return false; + } // System.out.println("first plus fraction number " + firstPlusFractionNumber); coefs[0] = 0.1; coefs[1] = Math.log(zPlus) / getFirstPlusFractionNumber(); @@ -229,6 +236,7 @@ public void characterizePlusFraction(TBPModelInterface TBPModel) { dens[i] = getCoef(2) + getCoef(3) * Math.log(i); } // System.out.println("z,m,dens " + z[i] + " " + M[i] + " " + dens[i]); + return true; } @Override @@ -381,7 +389,7 @@ public void densityUOP() { } @Override - public void characterizePlusFraction(TBPModelInterface TBPModel) { + public boolean characterizePlusFraction(TBPModelInterface TBPModel) { system.init(0); double MWBU = Double.NaN; double MWBL = Double.NaN; @@ -427,6 +435,7 @@ public void characterizePlusFraction(TBPModelInterface TBPModel) { for (int i = firstPlusFractionNumber; i < lastPlusFractionNumber; i++) { zValues[i] *= zPlus / sumZ; } + return true; } public void setGammaParameters(double shape, double minMW) { diff --git a/src/main/java/neqsim/thermo/characterization/PlusFractionModelInterface.java b/src/main/java/neqsim/thermo/characterization/PlusFractionModelInterface.java index 1ff5ccbc19..1c9bfa9c0c 100644 --- a/src/main/java/neqsim/thermo/characterization/PlusFractionModelInterface.java +++ b/src/main/java/neqsim/thermo/characterization/PlusFractionModelInterface.java @@ -25,7 +25,7 @@ public interface PlusFractionModelInterface extends java.io.Serializable { * * @param model a {@link neqsim.thermo.characterization.TBPModelInterface} object */ - public void characterizePlusFraction(TBPModelInterface model); + public boolean characterizePlusFraction(TBPModelInterface model); /** *

@@ -73,7 +73,9 @@ public interface PlusFractionModelInterface extends java.io.Serializable { public int getLastPlusFractionNumber(); /** - *

setLastPlusFractionNumber.

+ *

+ * setLastPlusFractionNumber. + *

* * @param fract a int */ diff --git a/src/test/java/neqsim/thermo/characterization/PlusFractionModelTest.java b/src/test/java/neqsim/thermo/characterization/PlusFractionModelTest.java index 0e6f3b3959..59a97feaa5 100644 --- a/src/test/java/neqsim/thermo/characterization/PlusFractionModelTest.java +++ b/src/test/java/neqsim/thermo/characterization/PlusFractionModelTest.java @@ -144,4 +144,52 @@ void testGammaModelCharacterization() { .getGammaParameters()[1]; assertEquals(90.0, minMW, 1e-4); } + + @Test + void testC6C7PlusModel() { + SystemInterface thermoSystem = null; + thermoSystem = new SystemSrkEos(298.0, 10.0); + + thermoSystem.addComponent("CO2", 1.0); + thermoSystem.addComponent("methane", 51.0); + thermoSystem.addComponent("ethane", 1.0); + thermoSystem.addComponent("propane", 1.0); + + thermoSystem.getCharacterization().setTBPModel("PedersenSRK"); // this need to be set before + // adding oil components + + String[] componentNames = {"C7"}; + double[] molarComposition = {0.15}; + double[] molarMasses = {0.092}; + double[] reldens = {0.82}; + + thermoSystem.getCharacterization().setTBPModel("PedersenSRK"); // this need to be set before + + thermoSystem.addOilFractions(componentNames, molarComposition, molarMasses, reldens, true); + + // In this case the molar mass of the plus fraction is set to 0.092 kg/mol an is too low to + // distribute the component into heavier components + assertEquals(5, thermoSystem.getNumberOfComponents()); + + thermoSystem = new SystemSrkEos(298.0, 10.0); + + thermoSystem.addComponent("CO2", 1.0); + thermoSystem.addComponent("methane", 51.0); + thermoSystem.addComponent("ethane", 1.0); + thermoSystem.addComponent("propane", 1.0); + + thermoSystem.getCharacterization().setTBPModel("PedersenSRK"); // this need to be set before + // adding oil components + + molarMasses = new double[] {0.120}; + + thermoSystem.getCharacterization().setTBPModel("PedersenSRK"); // this need to be set before + + thermoSystem.addOilFractions(componentNames, molarComposition, molarMasses, reldens, true); + // In this case the molar mass of the plus fraction is high enogh and can be characterized into + // heavier components + + assertEquals(16, thermoSystem.getNumberOfComponents()); + + } }