From 082a8b86b79fe7facd40922a3e74a18cdb92ab86 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?=
<34712686+asmfstatoil@users.noreply.github.com>
Date: Thu, 9 Jan 2025 11:54:56 +0100
Subject: [PATCH] refact: rename MixingRule -> EosMixingRuleType
---
...MixingRule.java => EosMixingRuleType.java} | 35 ++++++++++---------
.../neqsim/thermo/system/SystemInterface.java | 6 ++--
.../thermo/system/SystemThermoTest.java | 13 ++++---
3 files changed, 27 insertions(+), 27 deletions(-)
rename src/main/java/neqsim/thermo/mixingrule/{MixingRule.java => EosMixingRuleType.java} (63%)
diff --git a/src/main/java/neqsim/thermo/mixingrule/MixingRule.java b/src/main/java/neqsim/thermo/mixingrule/EosMixingRuleType.java
similarity index 63%
rename from src/main/java/neqsim/thermo/mixingrule/MixingRule.java
rename to src/main/java/neqsim/thermo/mixingrule/EosMixingRuleType.java
index 02e9b5f58..2dca6514e 100644
--- a/src/main/java/neqsim/thermo/mixingrule/MixingRule.java
+++ b/src/main/java/neqsim/thermo/mixingrule/EosMixingRuleType.java
@@ -3,7 +3,8 @@
import neqsim.util.exception.InvalidInputException;
/**
- * Types of MixingRule, relating to different kind of mixing rules. Available types are:
+ * Types of EosMixingRule, relating to different kind of mixing rules relevant for EOS type phases.
+ * Available types are:
*
* - NO - 1 - classic mixing rule with all kij set to zero
* - CLASSIC - 2 - classic mixing rule with kij from NeqSim database
@@ -19,7 +20,7 @@
*
* @author ASMF
*/
-public enum MixingRule {
+public enum EosMixingRuleType {
NO(1), CLASSIC(2), HV(4), WS(5), CPA_MIX(7), CLASSIC_T(8), CLASSIC_T_CPA(9), CLASSIC_TX_CPA(10);
/** Holder for old style integer pt. */
@@ -28,14 +29,14 @@ public enum MixingRule {
// We know we'll never mutate this, so we can keep
// a local copy for fast lookup in forName
- private static final MixingRule[] copyOfValues = values();
+ private static final EosMixingRuleType[] copyOfValues = values();
/**
- * Constructor for MixingRule enum.
+ * Constructor for EosMixingRuleType enum.
*
* @param value Numeric value index for mixing rule
*/
- private MixingRule(int value) {
+ private EosMixingRuleType(int value) {
this.value = value;
}
@@ -50,34 +51,34 @@ public int getValue() {
}
/**
- * Get MixingRule by name.
+ * Get EosMixingRuleType by name.
*
- * @param name Name to get MixingRule for.
- * @return MixingRule object
+ * @param name Name to get EosMixingRuleType for.
+ * @return EosMixingRuleType object
*/
- public static MixingRule byName(String name) {
- for (MixingRule mr : copyOfValues) {
+ public static EosMixingRuleType byName(String name) {
+ for (EosMixingRuleType mr : copyOfValues) {
if (mr.name().equals(name.toUpperCase())) {
return mr;
}
}
throw new RuntimeException(
- new InvalidInputException("MixingRule", "byName", "name", "is not valid."));
+ new InvalidInputException("EosMixingRuleType", "byName", "name", "is not valid."));
}
/**
- * Get MixingRule by value.
+ * Get EosMixingRuleTypes by value.
*
- * @param value Value to get MixingRule for.
- * @return MixingRule object
+ * @param value Value to get EosMixingRuleTypes for.
+ * @return EosMixingRuleTypes object
*/
- public static MixingRule byValue(int value) {
- for (MixingRule mr : copyOfValues) {
+ public static EosMixingRuleType byValue(int value) {
+ for (EosMixingRuleType mr : copyOfValues) {
if (mr.getValue() == (value)) {
return mr;
}
}
throw new RuntimeException(
- new InvalidInputException("MixingRule", "byValue", "value", "is not valid."));
+ new InvalidInputException("EosMixingRuleType", "byValue", "value", "is not valid."));
}
}
diff --git a/src/main/java/neqsim/thermo/system/SystemInterface.java b/src/main/java/neqsim/thermo/system/SystemInterface.java
index 5a9c40363..a5a728e08 100644
--- a/src/main/java/neqsim/thermo/system/SystemInterface.java
+++ b/src/main/java/neqsim/thermo/system/SystemInterface.java
@@ -7,7 +7,7 @@
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.characterization.WaxModelInterface;
import neqsim.thermo.component.ComponentInterface;
-import neqsim.thermo.mixingrule.MixingRule;
+import neqsim.thermo.mixingrule.EosMixingRuleType;
import neqsim.thermo.phase.PhaseInterface;
import neqsim.thermo.phase.PhaseType;
import neqsim.util.ExcludeFromJacocoGeneratedReport;
@@ -2263,9 +2263,9 @@ public void setImplementedTemperatureDeriativesofFugacity(
/**
* method to set mixing rule used for the fluid.
*
- * @param mr MixingRule enum
+ * @param mr EosMixingRuleTypes enum
*/
- public default void setMixingRule(MixingRule mr) {
+ public default void setMixingRule(EosMixingRuleType mr) {
setMixingRule(mr.getValue());
}
diff --git a/src/test/java/neqsim/thermo/system/SystemThermoTest.java b/src/test/java/neqsim/thermo/system/SystemThermoTest.java
index 6c350cbdd..bdc06ab4d 100644
--- a/src/test/java/neqsim/thermo/system/SystemThermoTest.java
+++ b/src/test/java/neqsim/thermo/system/SystemThermoTest.java
@@ -6,7 +6,7 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import neqsim.thermo.ThermodynamicConstantsInterface;
-import neqsim.thermo.mixingrule.MixingRule;
+import neqsim.thermo.mixingrule.EosMixingRuleType;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermodynamicoperations.ThermodynamicOperations;
@@ -37,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");
@@ -148,18 +147,18 @@ void TESTsetForceSinglePhase() {
@Test
void TestMixingRuleTypes() {
- MixingRule[] mrNum = MixingRule.values();
- for (MixingRule mixingRule : mrNum) {
+ EosMixingRuleType[] mrNum = EosMixingRuleType.values();
+ for (EosMixingRuleType mixingRule : mrNum) {
testSystem.setMixingRule(mixingRule.getValue());
assertEquals(mixingRule.getValue(), testSystem.getMixingRule());
}
- for (MixingRule mixingRule : mrNum) {
+ for (EosMixingRuleType mixingRule : mrNum) {
testSystem.setMixingRule(mixingRule);
assertEquals(mixingRule.getValue(), testSystem.getMixingRule());
}
- for (MixingRule mixingRule : mrNum) {
+ for (EosMixingRuleType mixingRule : mrNum) {
testSystem.setMixingRule(mixingRule.name());
assertEquals(mixingRule.getValue(), testSystem.getMixingRule());
}