diff --git a/src/main/java/neqsim/thermo/system/SystemThermo.java b/src/main/java/neqsim/thermo/system/SystemThermo.java index b1f17f325f..e0c6be2caa 100644 --- a/src/main/java/neqsim/thermo/system/SystemThermo.java +++ b/src/main/java/neqsim/thermo/system/SystemThermo.java @@ -236,18 +236,13 @@ public SystemInterface addFluid(SystemInterface addSystem) { if (index != -1) { addComponent(index, addSystem.getPhase(0).getComponent(i).getNumberOfmoles()); + } else 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 { - /* - * if(addSystem.getPhase(0).getComponent(i).isIsTBPfraction()) { - * addTBPfraction(addSystem.getPhase(0).getComponent(i).getComponentName(), - * addSystem.getPhase(0).getComponent(i).getNumberOfmoles(), - * addSystem.getPhase(0).getComponent(i).getMolarMass(), - * addSystem.getPhase(0).getComponent(i).getNormalLiquidDensity()); - * changeComponentName(addSystem.getPhase(0).getComponent(i).getComponentName()+ "_PC", - * addSystem.getPhase(0).getComponent(i).getComponentName().replaceFirst("_PC", "")); } - * addComponent(addSystem.getPhase(0).getComponent(i).getComponentName(), - * addSystem.getPhase(0).getComponent(i).getNumberOfmoles()); - */ addComponent(addSystem.getComponent(i)); } } diff --git a/src/test/java/neqsim/thermo/system/SystemThermoTest.java b/src/test/java/neqsim/thermo/system/SystemThermoTest.java index e22e64c454..09e2721b45 100644 --- a/src/test/java/neqsim/thermo/system/SystemThermoTest.java +++ b/src/test/java/neqsim/thermo/system/SystemThermoTest.java @@ -38,4 +38,40 @@ public void testTPflash2() { testSystem.setPressure(110000.0, "Pa"); assertEquals(1.1, testSystem.getPressure()); } + + /** + *
+ * testAddFluids + *
+ */ + @Test + @DisplayName("test addFluids with pseudo component") + public void testAddFluids() { + + neqsim.thermo.system.SystemPrEos fluid1 = new neqsim.thermo.system.SystemPrEos(298.0, 10.0); + fluid1.addComponent("methane", 1.0); + fluid1.addTBPfraction("C7", 1.0, 0.09, 0.81); + + neqsim.thermo.system.SystemPrEos fluid2 = new neqsim.thermo.system.SystemPrEos(298.0, 10.0); + fluid2.addComponent("methane", 1.0); + fluid2.addTBPfraction("C7", 1.0, 0.09, 0.81); + + fluid1.addFluid(fluid2); + + assertEquals(2.0, fluid1.getComponent(0).getNumberOfmoles()); + assertEquals(2.0, fluid1.getComponent(1).getNumberOfmoles()); + + assertEquals(2.0, fluid1.getComponent("methane").getNumberOfmoles()); + assertEquals(2.0, fluid1.getComponent("C7_PC").getNumberOfmoles()); + + neqsim.thermo.system.SystemPrEos fluid3 = new neqsim.thermo.system.SystemPrEos(298.0, 10.0); + fluid3.addComponent("nitrogen", 1.0); + fluid3.addTBPfraction("C8", 1.0, 0.092, 0.82); + + fluid1.addFluid(fluid3); + + assertEquals(2.0, fluid1.getComponent("methane").getNumberOfmoles()); + assertEquals(1.0, fluid1.getComponent("nitrogen").getNumberOfmoles()); + assertEquals(1.0, fluid1.getComponent("C8_PC").getNumberOfmoles()); + } }