Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Nov 7, 2023
1 parent a4609c3 commit c9c8ad9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/neqsim/thermo/phase/Phase.java
Original file line number Diff line number Diff line change
Expand Up @@ -587,15 +587,15 @@ public double getMolarVolume(String unit) {
double conversionFactor = 1.0;
switch (unit) {
case "m3/mol":
conversionFactor = 1.0 / 1.0e5;
conversionFactor = 1.0;
break;
case "litre/mol":
conversionFactor = 1.0 / 1.0e2;
conversionFactor = 1000.0;
break;
default:
throw new RuntimeException("unit not supported " + unit);
}
return molarVolume * conversionFactor;
return getMolarMass() / getDensity("kg/m3") * conversionFactor;
}

/** {@inheritDoc} */
Expand Down
25 changes: 25 additions & 0 deletions src/test/java/neqsim/thermo/system/SystemPrEosTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,31 @@ public static void setUp() {
testSystem.initProperties();
}

/**
* <p>
* testMolarVolume.
* </p>
*/
@Test
@DisplayName("test testMolarVolume calc whre unit as input")
public void testMolarVolume() {
neqsim.thermo.system.SystemInterface testSystem =
new neqsim.thermo.system.SystemPrEos(298.0, 10.0);
testSystem.addComponent("nitrogen", 0.01);
testSystem.addComponent("CO2", 0.01);
testSystem.addComponent("methane", 0.68);
testSystem.addComponent("ethane", 0.1);
testSystem.setMixingRule("classic");
testModel = new neqsim.thermo.ThermodynamicModelTest(testSystem);
ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
testOps.TPflash();
testSystem.initProperties();
assertEquals(testSystem.getMolarVolume("m3/mol"),
testSystem.getMolarMass("kg/mol") / testSystem.getDensity("kg/m3"));
}



/**
* <p>
* testTPflash2.
Expand Down

0 comments on commit c9c8ad9

Please sign in to comment.