Skip to content

Commit

Permalink
test: update tests to use EosMixingRule
Browse files Browse the repository at this point in the history
  • Loading branch information
asmfstatoil committed Jan 9, 2025
1 parent b1e76e4 commit c25386a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import neqsim.thermo.mixingrule.EosMixingRuleType;
import neqsim.thermodynamicoperations.ThermodynamicOperations;

/**
Expand All @@ -30,7 +31,7 @@ void setUp() {
testSystem.addComponent("ethane", 0.0);
testSystem.addComponent("n-pentane", 9E-1);
testSystem.addComponent("nC16", 1E-1);
testSystem.setMixingRule("classic");
testSystem.setMixingRule(EosMixingRuleType.CLASSIC);
testOps = new ThermodynamicOperations(testSystem);
testOps.TPflash();
testSystem.initProperties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import neqsim.thermo.mixingrule.EosMixingRuleType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkCPAstatoil;
import neqsim.thermodynamicoperations.ThermodynamicOperations;
Expand All @@ -22,7 +23,7 @@ void testRun() {
testSystem.addComponent("MEG", 0.000001);
testSystem.addComponent("water", 0.0010);
testSystem.createDatabase(true);
testSystem.setMixingRule(10);
testSystem.setMixingRule(EosMixingRuleType.byValue(10));

testSystem.init(0);
testSystem.setMultiPhaseCheck(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import neqsim.thermo.mixingrule.EosMixingRuleType;
import neqsim.thermodynamicoperations.ThermodynamicOperations;

public class PTPhaseEnvelopeTest {
Expand All @@ -25,22 +26,23 @@ void testDewP() {
testSystem.addComponent("nitrogen", 0.01);
testSystem.addComponent("CO2", 0.01);
testSystem.addComponent("methane", 0.98);
testSystem.setMixingRule("classic");
testSystem.setMixingRule(EosMixingRuleType.byName("classic"));

testOps = new ThermodynamicOperations(testSystem);
testOps.TPflash();
testSystem.initProperties();
testOps.calcPTphaseEnvelope();
double[] dewPointPressures = testOps.get("dewP");
double[] expectedDewPointPressures = new double[] { 1.1051709180756477, 1.2214027581601699, 1.3498588075760032,
1.4918246976412703, 1.6652911949458864, 1.8794891289619104, 2.1418131227502055,
2.4690864123141987, 2.881197018974799, 3.404779997613969, 4.075230307874481,
4.938583914869986, 6.051801019586486, 7.477304695462727, 9.260793952051571,
11.364101185282063, 13.480106047577934, 14.53423776629387, 13.607498029406681,
11.181207439509638, 9.189487040488075, 9.612827246459474, 10.706126846063928,
12.501491987760147, 15.075672692089958, 18.51283799420178, 23.330378296334104,
29.71319711031059, 37.25532259549197, 43.660805656603934, 45.75836660678656,
46.42490219574348, 46.83203503669948, 46.869568345957006, 46.903557772489435 };
double[] expectedDewPointPressures =
new double[] {1.1051709180756477, 1.2214027581601699, 1.3498588075760032,
1.4918246976412703, 1.6652911949458864, 1.8794891289619104, 2.1418131227502055,
2.4690864123141987, 2.881197018974799, 3.404779997613969, 4.075230307874481,
4.938583914869986, 6.051801019586486, 7.477304695462727, 9.260793952051571,
11.364101185282063, 13.480106047577934, 14.53423776629387, 13.607498029406681,
11.181207439509638, 9.189487040488075, 9.612827246459474, 10.706126846063928,
12.501491987760147, 15.075672692089958, 18.51283799420178, 23.330378296334104,
29.71319711031059, 37.25532259549197, 43.660805656603934, 45.75836660678656,
46.42490219574348, 46.83203503669948, 46.869568345957006, 46.903557772489435};
// System.out.println(Arrays.toString(dewPointPressures));
assertArrayEquals(expectedDewPointPressures, dewPointPressures, 10E-10);
}
Expand All @@ -58,7 +60,8 @@ void testFailingCaseWithWater() {
testOps.TPflash();
testSystem.initProperties();

Exception exception = assertThrows(ArrayIndexOutOfBoundsException.class, () -> testOps.calcPTphaseEnvelope());
Exception exception =
assertThrows(ArrayIndexOutOfBoundsException.class, () -> testOps.calcPTphaseEnvelope());
}

@Test
Expand Down Expand Up @@ -132,7 +135,8 @@ void testFailingCase1() {
void testFailingCase2() {
// testSystem.setTemperature(40, "C");
// testSystem.setPressure(50, "bara");
neqsim.thermo.system.SystemInterface fluid0_HC = new neqsim.thermo.system.SystemUMRPRUMCEos(298.0, 50.0);
neqsim.thermo.system.SystemInterface fluid0_HC =
new neqsim.thermo.system.SystemUMRPRUMCEos(298.0, 50.0);
fluid0_HC.addComponent("nitrogen", 2.5);
fluid0_HC.addComponent("CO2", 4.5);
fluid0_HC.addComponent("methane", 79.45);
Expand Down

0 comments on commit c25386a

Please sign in to comment.