From 691a712b39a984d40caa80df9418401a11c360f8 Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Sun, 21 May 2023 07:32:32 +0200 Subject: [PATCH] rebase on master (#693) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 684 addfluid is not adding pc if not existing (#685) * added test for addFLuids * updated test * updated test with new pseudo component * solution for bug * refact: simplified if-else nesting --------- Co-authored-by: Åsmund Våge Fannemel <34712686+asmfstatoil@users.noreply.github.com> * dont do log of zeros (#688) * AddfluidHighTemp (#689) * added test for addFLuids * updated test * updated test with new pseudo component * solution for bug * add test TPflas high * added gitlense extension * update * update * update test --------- Co-authored-by: Åsmund Våge Fannemel <34712686+asmfstatoil@users.noreply.github.com> --- .devcontainer/devcontainer.json | 3 +- .../neqsim/thermo/system/SystemThermo.java | 10 ++- .../flashOps/TPFlashTestHighTemp.java | 74 +++++++++++++++++++ 3 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestHighTemp.java diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a02edb9b51..48630efb30 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -45,7 +45,8 @@ "ms-vscode.test-adapter-converter", "shengchen.vscode-checkstyle", "mechatroner.rainbow-csv", - "redhat.vscode-xml" + "redhat.vscode-xml", + "eamodio.gitlens" ] diff --git a/src/main/java/neqsim/thermo/system/SystemThermo.java b/src/main/java/neqsim/thermo/system/SystemThermo.java index e0c6be2caa..d72a756184 100644 --- a/src/main/java/neqsim/thermo/system/SystemThermo.java +++ b/src/main/java/neqsim/thermo/system/SystemThermo.java @@ -243,7 +243,15 @@ public SystemInterface addFluid(SystemInterface addSystem) { addSystem.getPhase(0).getComponent(i).getMolarMass(), addSystem.getPhase(0).getComponent(i).getNormalLiquidDensity()); } else { - addComponent(addSystem.getComponent(i)); + if (addSystem.getPhase(0).getComponent(i).isIsTBPfraction()) { + addTBPfraction( + addSystem.getPhase(0).getComponent(i).getComponentName().replaceFirst("_PC", ""), + addSystem.getPhase(0).getComponent(i).getNumberOfmoles(), + addSystem.getPhase(0).getComponent(i).getMolarMass(), + addSystem.getPhase(0).getComponent(i).getNormalLiquidDensity()); + } else { + addComponent(addSystem.getComponent(i)); + } } } if (addedNewComponent) { diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestHighTemp.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestHighTemp.java new file mode 100644 index 0000000000..7f9e672c62 --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestHighTemp.java @@ -0,0 +1,74 @@ +package neqsim.thermodynamicOperations.flashOps; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +/** + * @author ESOL + * + */ +class TPFlashTestHighTemp { + + static neqsim.thermo.system.SystemInterface testSystem = null; + static ThermodynamicOperations testOps = null; + + /** + * @throws java.lang.Exception + */ + @BeforeEach + void setUp() throws Exception { + testSystem = new neqsim.thermo.system.SystemSrkEos(243.15, 300.0); + testSystem.addComponent("nitrogen", 1.64e-3); + testSystem.addComponent("CO2", 1.64e-3); + testSystem.addComponent("H2S", 1.64e-3); + testSystem.addComponent("methane", 90.0); + testSystem.addComponent("ethane", 2.0); + testSystem.addComponent("propane", 1.0); + testSystem.addComponent("i-butane", 1.0); + testSystem.addComponent("n-butane", 1.0); + testSystem.addComponent("i-pentane", 1.0); + testSystem.addComponent("n-pentane", 1.0); + testSystem.addComponent("n-hexane", 1.0); + testSystem.addComponent("n-heptane", 1.0); + testSystem.addComponent("n-octane", 1.0); + testSystem.addComponent("n-nonane", 1.0); + testSystem.addComponent("nC10", 1.0); + testSystem.addComponent("nC11", 1.0); + testSystem.addComponent("nC12", 1.0); + testSystem.addComponent("nC13", 1.0); + testSystem.addComponent("nC14", 1.0); + testSystem.addComponent("nC15", 1.0); + testSystem.addComponent("nC16", 1.0); + testSystem.addComponent("nC17", 1.0); + testSystem.addComponent("nC18", 1.0); + testSystem.addComponent("nC19", 1.0); + + + testSystem.setMixingRule("classic"); + + testSystem.setMolarComposition(new double[] {1.63e-3, 3.23e-3, 0, 3e-1, 4.6e-2, 1.4e-2, 2.2e-2, + 3.9e-3, 8.8e-3, 2.6e-3, 3.2e-2, 1.2e-1, 1.5e-1, 9.8e-2, 7.6e-2, 4.1e-2, 2.5e-2, 1.6e-2, + 1e-2, 5.6e-3, 2.7e-3, 1.3e-3, 8.7e-4, 3.8e-4}); + // testSystem.setMultiPhaseCheck(true); + } + + @Test + void testRun() { + testSystem.setPressure(88, "bara"); + /* + * for (int i = 0; i < 400; i++) { testSystem.setTemperature(0.0 + i * 1, "C"); testOps = new + * ThermodynamicOperations(testSystem); testOps.TPflash(); testSystem.initProperties(); + * System.out.print(testSystem.getPhaseFraction("gas", "mole") + " numerofphases " + + * testSystem.getNumberOfPhases() + " temp " + testSystem.getTemperature("C") + " hasoil " + + * testSystem.hasPhaseType("oil") + " gibbs energy " + testSystem.getGibbsEnergy() + + * " gibbs energy " + " density " + testSystem.getDensity("kg/m3") + " \n"); } + */ + testSystem.setTemperature(268.0, "C"); + testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + assertEquals(0.006832557441121211, testSystem.getPhaseFraction("gas", "mole"), 0.0001); + } +} +