diff --git a/src/main/java/neqsim/thermo/mixingrule/EosMixingRuleType.java b/src/main/java/neqsim/thermo/mixingrule/EosMixingRuleType.java new file mode 100644 index 000000000..2dca6514e --- /dev/null +++ b/src/main/java/neqsim/thermo/mixingrule/EosMixingRuleType.java @@ -0,0 +1,84 @@ +package neqsim.thermo.mixingrule; + +import neqsim.util.exception.InvalidInputException; + +/** + * Types of EosMixingRule, relating to different kind of mixing rules relevant for EOS type phases. + * Available types are: + *
* setForceSinglePhase - force the fluid to be single phase of type as spesified by phasetype - * input + * input. *
* * @param phasetype a {@link neqsim.thermo.phase.PhaseType} object diff --git a/src/main/java/neqsim/thermo/system/SystemThermo.java b/src/main/java/neqsim/thermo/system/SystemThermo.java index a4384c7e8..44b49dde6 100644 --- a/src/main/java/neqsim/thermo/system/SystemThermo.java +++ b/src/main/java/neqsim/thermo/system/SystemThermo.java @@ -4434,21 +4434,23 @@ public final void setMixingRule(int type) { @Override public void setMixingRule(String typename) { int var = 0; - if (typename.equals("no")) { + if (typename.equalsIgnoreCase("no")) { var = 1; - } else if (typename.equals("classic")) { + } else if (typename.equalsIgnoreCase("classic")) { var = 2; - } else if (typename.equals("HV")) { + } else if (typename.equalsIgnoreCase("HV")) { var = 4; - } else if (typename.equals("WS")) { + } else if (typename.equalsIgnoreCase("WS")) { var = 5; - } else if (typename.equals("CPA-Mix")) { + } else if (typename.equalsIgnoreCase("CPA-Mix") || typename.equalsIgnoreCase("CPA_Mix")) { var = 7; - } else if (typename.equals("classic-T")) { + } else if (typename.equalsIgnoreCase("classic-T") || typename.equalsIgnoreCase("classic_T")) { var = 8; - } else if (typename.equals("classic-T-cpa")) { + } else if (typename.equalsIgnoreCase("classic-T-cpa") + || typename.equalsIgnoreCase("classic_t_cpa")) { var = 9; - } else if (typename.equals("classic-Tx-cpa")) { + } else if (typename.equalsIgnoreCase("classic-Tx-cpa") + || typename.equalsIgnoreCase("classic_tx_cpa")) { var = 10; } else { var = 1; diff --git a/src/test/java/neqsim/thermo/system/SystemThermoTest.java b/src/test/java/neqsim/thermo/system/SystemThermoTest.java index 905fdd96e..bdc06ab4d 100644 --- a/src/test/java/neqsim/thermo/system/SystemThermoTest.java +++ b/src/test/java/neqsim/thermo/system/SystemThermoTest.java @@ -6,6 +6,7 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import neqsim.thermo.ThermodynamicConstantsInterface; +import neqsim.thermo.mixingrule.EosMixingRuleType; import neqsim.thermo.phase.PhaseType; import neqsim.thermodynamicoperations.ThermodynamicOperations; @@ -36,8 +37,7 @@ public static void setUp() { */ @Test public void testCp() { - neqsim.thermo.system.SystemPrEos testSystem = - new neqsim.thermo.system.SystemPrEos(273.15 + 40.0, 1.0); + neqsim.thermo.system.SystemPrEos testSystem = new neqsim.thermo.system.SystemPrEos(273.15 + 40.0, 1.0); testSystem.addComponent("methane", 10.01); testSystem.addTBPfraction("C20", 10.68, 0.3, 0.85); testSystem.setMixingRule("classic"); @@ -144,4 +144,23 @@ void TESTsetForceSinglePhase() { assertEquals(density, testSystem.getDensity("kg/m3"), 1e-4); } + + @Test + void TestMixingRuleTypes() { + EosMixingRuleType[] mrNum = EosMixingRuleType.values(); + for (EosMixingRuleType mixingRule : mrNum) { + testSystem.setMixingRule(mixingRule.getValue()); + assertEquals(mixingRule.getValue(), testSystem.getMixingRule()); + } + + for (EosMixingRuleType mixingRule : mrNum) { + testSystem.setMixingRule(mixingRule); + assertEquals(mixingRule.getValue(), testSystem.getMixingRule()); + } + + for (EosMixingRuleType mixingRule : mrNum) { + testSystem.setMixingRule(mixingRule.name()); + assertEquals(mixingRule.getValue(), testSystem.getMixingRule()); + } + } }