Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

684 addfluid is not adding pc if not existing #685

Merged
merged 5 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions src/main/java/neqsim/thermo/system/SystemThermo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
36 changes: 36 additions & 0 deletions src/test/java/neqsim/thermo/system/SystemThermoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,40 @@ public void testTPflash2() {
testSystem.setPressure(110000.0, "Pa");
assertEquals(1.1, testSystem.getPressure());
}

/**
* <p>
* testAddFluids
* </p>
*/
@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());
}
}