From e5766379f1df6093f4990f21af5d93cd53627761 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, 24 Oct 2024 21:22:02 +0200 Subject: [PATCH 1/3] feat: introduce enum type PhysicalPropertyModel --- .../twophasepipeflownode/AnnularFlow.java | 2 +- .../TwoPhasePackedBedFlowNode.java | 3 +- .../TwoPhasePipeFlowSystemReac.java | 3 +- .../PhysicalPropertyHandler.java | 27 +++--- .../PhysicalPropertyModel.java | 71 +++++++++++++++ src/main/java/neqsim/thermo/phase/Phase.java | 78 +++++++++------- .../neqsim/thermo/phase/PhaseInterface.java | 91 +++++++++++-------- .../neqsim/thermo/system/SystemInterface.java | 18 +++- .../neqsim/thermo/system/SystemThermo.java | 8 -- .../util/examples/TPflashTest.java | 4 +- .../util/examples/TestCondensate.java | 3 +- .../util/example/simpleGasScrubber.java | 1 - .../util/example/ReactiveDesmukhMather.java | 2 +- .../util/example/ReactiveKentEisenberg.java | 2 +- 14 files changed, 207 insertions(+), 106 deletions(-) create mode 100644 src/main/java/neqsim/physicalproperties/physicalpropertysystem/PhysicalPropertyModel.java diff --git a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/AnnularFlow.java b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/AnnularFlow.java index 96463403e6..76efa73c7d 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/AnnularFlow.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasepipeflownode/AnnularFlow.java @@ -167,7 +167,7 @@ public static void main(String[] args) { // testSystem.chemicalReactionInit(); testSystem.createDatabase(true); testSystem.setMixingRule(10); - // testSystem.setPhysicalPropertyModel(3); + // testSystem.setPhysicalPropertyModel(PhysicalPropertyModel.AMINE); // testSystem.setNumericDerivatives(true); testSystem.initPhysicalProperties(); testSystem.getPhase(0).setTemperature(273.15 + 85); diff --git a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasereactorflownode/TwoPhasePackedBedFlowNode.java b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasereactorflownode/TwoPhasePackedBedFlowNode.java index 1f54a3f186..b021619985 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasereactorflownode/TwoPhasePackedBedFlowNode.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/twophasenode/twophasereactorflownode/TwoPhasePackedBedFlowNode.java @@ -5,6 +5,7 @@ import neqsim.fluidmechanics.flownode.twophasenode.TwoPhaseFlowNode; import neqsim.fluidmechanics.geometrydefinitions.GeometryDefinitionInterface; import neqsim.fluidmechanics.geometrydefinitions.reactor.ReactorData; +import neqsim.physicalproperties.physicalpropertysystem.PhysicalPropertyModel; import neqsim.thermo.system.SystemFurstElectrolyteEos; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicoperations.ThermodynamicOperations; @@ -232,7 +233,7 @@ public static void main(String[] args) { testSystem.setMixingRule(4); testOps.TPflash(); testSystem.addComponent("CO2", 2000.11152181, "Nlitre/min", 0); - testSystem.setPhysicalPropertyModel(3); + testSystem.setPhysicalPropertyModel(PhysicalPropertyModel.AMINE); testSystem.init_x_y(); testSystem.getPhases()[1].setTemperature(313.0); testSystem.getPhases()[0].setTemperature(325.0); diff --git a/src/main/java/neqsim/fluidmechanics/flowsystem/twophaseflowsystem/twophasepipeflowsystem/TwoPhasePipeFlowSystemReac.java b/src/main/java/neqsim/fluidmechanics/flowsystem/twophaseflowsystem/twophasepipeflowsystem/TwoPhasePipeFlowSystemReac.java index 492c721ce1..a0d5e97371 100644 --- a/src/main/java/neqsim/fluidmechanics/flowsystem/twophaseflowsystem/twophasepipeflowsystem/TwoPhasePipeFlowSystemReac.java +++ b/src/main/java/neqsim/fluidmechanics/flowsystem/twophaseflowsystem/twophasepipeflowsystem/TwoPhasePipeFlowSystemReac.java @@ -1,5 +1,6 @@ package neqsim.fluidmechanics.flowsystem.twophaseflowsystem.twophasepipeflowsystem; +import neqsim.physicalproperties.physicalpropertysystem.PhysicalPropertyModel; import neqsim.thermo.system.SystemFurstElectrolyteEos; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicoperations.ThermodynamicOperations; @@ -42,7 +43,7 @@ public static void main(String[] args) { testSystem.chemicalReactionInit(); testSystem.createDatabase(true); testSystem.setMixingRule(4); - testSystem.setPhysicalPropertyModel(3); + testSystem.setPhysicalPropertyModel(PhysicalPropertyModel.AMINE); // testOps.TPflash(); // testSystem.display(); diff --git a/src/main/java/neqsim/physicalproperties/PhysicalPropertyHandler.java b/src/main/java/neqsim/physicalproperties/PhysicalPropertyHandler.java index 3b4e07afb1..68964c2282 100644 --- a/src/main/java/neqsim/physicalproperties/PhysicalPropertyHandler.java +++ b/src/main/java/neqsim/physicalproperties/PhysicalPropertyHandler.java @@ -3,6 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.physicalproperties.physicalpropertysystem.PhysicalProperties; +import neqsim.physicalproperties.physicalpropertysystem.PhysicalPropertyModel; import neqsim.physicalproperties.physicalpropertysystem.commonphasephysicalproperties.DefaultPhysicalProperties; import neqsim.physicalproperties.physicalpropertysystem.gasphysicalproperties.GasPhysicalProperties; import neqsim.physicalproperties.physicalpropertysystem.liquidphysicalproperties.AminePhysicalProperties; @@ -15,7 +16,7 @@ /** *

- * PhysicalPropertyHandler class. + * PhysicalPropertyHandler class. Group together the physical property functions (density for *

* * @author ESOL @@ -44,36 +45,36 @@ public PhysicalPropertyHandler() {} *

* * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param type 0 Orginal/default 1 Water 2 Glycol 3 Amine 4 CO2Water 6 Basic + * @param ppm PhysicalPropertyModel enum object */ - public void setPhysicalProperties(PhaseInterface phase, int type) { - switch (type) { - case 0: // Default + public void setPhysicalProperties(PhaseInterface phase, PhysicalPropertyModel ppm) { + switch (ppm) { + case DEFAULT: // Default gasPhysicalProperties = new GasPhysicalProperties(phase, 0, 0); oilPhysicalProperties = new LiquidPhysicalProperties(phase, 0, 0); aqueousPhysicalProperties = new WaterPhysicalProperties(phase, 0, 0); break; - case 1: // Water + case WATER: // Water gasPhysicalProperties = new GasPhysicalProperties(phase, 0, 0); oilPhysicalProperties = new LiquidPhysicalProperties(phase, 0, 0); aqueousPhysicalProperties = new WaterPhysicalProperties(phase, 0, 0); break; - case 2: // Glycol + case GLYCOL: // Glycol gasPhysicalProperties = new GasPhysicalProperties(phase, 0, 0); oilPhysicalProperties = new LiquidPhysicalProperties(phase, 0, 0); aqueousPhysicalProperties = new GlycolPhysicalProperties(phase, 0, 0); break; - case 3: // Amine + case AMINE: // Amine gasPhysicalProperties = new GasPhysicalProperties(phase, 0, 0); oilPhysicalProperties = new LiquidPhysicalProperties(phase, 0, 0); aqueousPhysicalProperties = new AminePhysicalProperties(phase, 0, 0); break; - case 4: // CO2water + case CO2WATER: gasPhysicalProperties = new GasPhysicalProperties(phase, 0, 0); oilPhysicalProperties = new LiquidPhysicalProperties(phase, 0, 0); aqueousPhysicalProperties = new CO2waterPhysicalProperties(phase, 0, 0); break; - case 6: // Basic? + case BASIC: gasPhysicalProperties = new DefaultPhysicalProperties(phase, 0, 0); oilPhysicalProperties = new DefaultPhysicalProperties(phase, 0, 0); aqueousPhysicalProperties = new DefaultPhysicalProperties(phase, 0, 0); @@ -81,7 +82,7 @@ public void setPhysicalProperties(PhaseInterface phase, int type) { default: logger .error("error selecting physical properties model.\n Continue using default model..."); - setPhysicalProperties(phase, 0); + setPhysicalProperties(phase, PhysicalPropertyModel.DEFAULT); break; } solidPhysicalProperties = new SolidPhysicalProperties(phase); @@ -94,13 +95,13 @@ public void setPhysicalProperties(PhaseInterface phase, int type) { /** *

- * getPhysicalProperty. + * Get PhysicalProperty *

* * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @return a {@link neqsim.physicalproperties.physicalpropertysystem.PhysicalProperties} object */ - public PhysicalProperties getPhysicalProperty(PhaseInterface phase) { + public PhysicalProperties getPhysicalProperties(PhaseInterface phase) { switch (phase.getType()) { case GAS: return gasPhysicalProperties; diff --git a/src/main/java/neqsim/physicalproperties/physicalpropertysystem/PhysicalPropertyModel.java b/src/main/java/neqsim/physicalproperties/physicalpropertysystem/PhysicalPropertyModel.java new file mode 100644 index 0000000000..17cc2b3e3a --- /dev/null +++ b/src/main/java/neqsim/physicalproperties/physicalpropertysystem/PhysicalPropertyModel.java @@ -0,0 +1,71 @@ +package neqsim.physicalproperties.physicalpropertysystem; + +import neqsim.util.exception.InvalidInputException; + +/** + * Types of PhysicalPropertyModel. This is used when initializing PhysicalPropertyhandler. + * + * @author ASMF + */ +public enum PhysicalPropertyModel { + DEFAULT(0), WATER(1), GLYCOL(2), AMINE(3), CO2WATER(4), BASIC(6); + + /** Holder for old style integer pt. */ + private final int value; + /** Holder for old style string physical property description. */ + + // We know we'll never mutate this, so we can keep + // a local copy for fast lookup in forName + private static final PhysicalPropertyModel[] copyOfValues = values(); + + /** + * Constructor for PhysicalPropertyModel enum. + * + * @param value Numeric value index for phase type + */ + private PhysicalPropertyModel(int value) { + this.value = value; + } + + /** + * Getter for property value. + * + * @return Numeric index of phase type + */ + @Deprecated + public int getValue() { + return this.value; + } + + /** + * Get PhysicalPropertyType by name. + * + * @param name Name to get PhysicalPropertyType for. + * @return PhysicalPropertyType object + */ + public static PhysicalPropertyModel byName(String name) { + for (PhysicalPropertyModel pt : copyOfValues) { + if (pt.name().equals(name.toUpperCase())) { + return pt; + } + } + throw new RuntimeException( + new InvalidInputException("PhysicalPropertyModel", "byName", "name", "is not valid.")); + } + + /** + * Get PhysicalPropertyModel by value. + * + * @param value Value to get PhysicalPropertyModel for. + * @return PhysicalPropertyModel object + */ + public static PhysicalPropertyModel byValue(int value) { + for (PhysicalPropertyModel pt : copyOfValues) { + if (pt.getValue() == (value)) { + return pt; + } + } + throw new RuntimeException( + new InvalidInputException("PhysicalPropertyModel", "byValue", "value", "is not valid.")); + } +} diff --git a/src/main/java/neqsim/thermo/phase/Phase.java b/src/main/java/neqsim/thermo/phase/Phase.java index 248097821c..17b67d48a3 100644 --- a/src/main/java/neqsim/thermo/phase/Phase.java +++ b/src/main/java/neqsim/thermo/phase/Phase.java @@ -12,6 +12,7 @@ import neqsim.physicalproperties.PhysicalPropertyHandler; import neqsim.physicalproperties.PhysicalPropertyType; import neqsim.physicalproperties.physicalpropertysystem.PhysicalProperties; +import neqsim.physicalproperties.physicalpropertysystem.PhysicalPropertyModel; import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.ThermodynamicModelSettings; import neqsim.thermo.component.ComponentInterface; @@ -19,7 +20,19 @@ import neqsim.util.exception.InvalidInputException; /** - * Phase class. + * Abstract Phase class. All Phase classes shall subclass this class. + * + *

+ * From wiki: A phase is a region of a space (a thermodynamic system), in neqsim named a + * SystemInterface, throughout which all physical properties of a material are essentially uniform. + * A SystemInterface can contain a single or multiple PhaseInterface objects. + * + * See PhaseType for the types of Phases that NeqSim is aware of. See also StateOfMatter. + * + * In NeqSim, there are multiple Phase classes, each representing a specific set of Equations Of + * State. Phases have corresponding Component classes and System classes to ensure same EoS is used + * throughout. + *

* * @author Even Solbraa */ @@ -37,10 +50,10 @@ public abstract class Phase implements PhaseInterface { private boolean constantPhaseVolume = false; - public int physicalPropertyType = 0; + private PhysicalPropertyModel ppm = PhysicalPropertyModel.DEFAULT; + public neqsim.physicalproperties.PhysicalPropertyHandler physicalPropertyHandler = null; protected boolean useVolumeCorrection = true; - public neqsim.physicalproperties.PhysicalPropertyHandler physicalPropertyHandler = null; protected double molarVolume = 1.0; protected double phaseVolume = 1.0; @@ -64,7 +77,11 @@ public abstract class Phase implements PhaseInterface { private int initType = 0; int mixingRuleNumber = 0; + + /** Temperature of phase. */ double temperature = 0; + + /** Pressure of phase. */ double pressure = 0; protected PhaseInterface[] refPhase = null; @@ -429,10 +446,8 @@ public void setTemperature(double temp) { public PhysicalProperties getPhysicalProperties() { if (physicalPropertyHandler == null) { initPhysicalProperties(); - return physicalPropertyHandler.getPhysicalProperty(this); - } else { - return physicalPropertyHandler.getPhysicalProperty(this); } + return physicalPropertyHandler.getPhysicalProperties(this); } /** {@inheritDoc} */ @@ -459,20 +474,25 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int initType /** {@inheritDoc} */ @Override - public void setPhysicalProperties() { - // System.out.println("Physical properties: Default model"); - setPhysicalProperties(physicalPropertyType); - // physicalProperty = new - // physicalproperties.physicalPropertySystem.commonPhasePhysicalProperties.DefaultPhysicalProperties(this,0,0); + public void setPpm(PhysicalPropertyModel ppm) { + this.ppm = ppm; + } + + /** {@inheritDoc} */ + @Override + public PhysicalPropertyModel getPhysicalPropertyModel() { + // todo: still inconsistent + return this.ppm; } /** {@inheritDoc} */ @Override - public void setPhysicalProperties(int type) { + public void setPhysicalPropertyModel(PhysicalPropertyModel ppm) { + setPpm(ppm); if (physicalPropertyHandler == null) { physicalPropertyHandler = new PhysicalPropertyHandler(); } - physicalPropertyHandler.setPhysicalProperties(this, type); + physicalPropertyHandler.setPhysicalProperties(this, ppm); } /** {@inheritDoc} */ @@ -488,8 +508,8 @@ public void initPhysicalProperties() { physicalPropertyHandler = new PhysicalPropertyHandler(); } - if (physicalPropertyHandler.getPhysicalProperty(this) == null) { - setPhysicalProperties(physicalPropertyType); + if (physicalPropertyHandler.getPhysicalProperties(this) == null) { + setPhysicalPropertyModel(ppm); } getPhysicalProperties().init(this); } @@ -500,19 +520,19 @@ public void initPhysicalProperties(PhysicalPropertyType ppt) { if (physicalPropertyHandler == null) { physicalPropertyHandler = new PhysicalPropertyHandler(); } - if (physicalPropertyHandler.getPhysicalProperty(this) == null) { - setPhysicalProperties(physicalPropertyType); + + if (physicalPropertyHandler.getPhysicalProperties(this) == null) { + setPhysicalPropertyModel(ppm); } getPhysicalProperties().setPhase(this); - - // if (physicalProperty == null || phaseTypeAtLastPhysPropUpdate != phaseType || - // !phaseTypeNameAtLastPhysPropUpdate.equals(phaseTypeName)) { - // this.setPhysicalProperties(); - // } - // physicalProperty.init(this, type); getPhysicalProperties().init(this, ppt); } + /** {@inheritDoc} */ + public void setPhysicalProperties(PhysicalPropertyModel ppm) { + physicalPropertyHandler.setPhysicalProperties(this, ppm); + } + /** {@inheritDoc} */ @Override public double geta(PhaseInterface phase, double temperature, double pressure, int numbcomp) { @@ -1911,18 +1931,6 @@ public void setRefPhase(neqsim.thermo.phase.PhaseInterface[] refPhase) { this.refPhase = refPhase; } - /** {@inheritDoc} */ - @Override - public final int getPhysicalPropertyType() { - return physicalPropertyType; - } - - /** {@inheritDoc} */ - @Override - public void setPhysicalPropertyType(int physicalPropertyType) { - this.physicalPropertyType = physicalPropertyType; - } - /** {@inheritDoc} */ @Override public void setParams(PhaseInterface phase, double[][] alpha, double[][] Dij, double[][] DijT, diff --git a/src/main/java/neqsim/thermo/phase/PhaseInterface.java b/src/main/java/neqsim/thermo/phase/PhaseInterface.java index fbb50d2d06..3bb13d39ad 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseInterface.java +++ b/src/main/java/neqsim/thermo/phase/PhaseInterface.java @@ -8,6 +8,7 @@ import neqsim.physicalproperties.PhysicalPropertyType; import neqsim.physicalproperties.physicalpropertysystem.PhysicalProperties; +import neqsim.physicalproperties.physicalpropertysystem.PhysicalPropertyModel; import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.component.ComponentInterface; import neqsim.thermo.system.SystemInterface; @@ -99,13 +100,6 @@ public interface PhaseInterface extends ThermodynamicConstantsInterface, Cloneab */ public double[] getMolarComposition(); - /** - *

- * resetPhysicalProperties. - *

- */ - public void resetPhysicalProperties(); - /** * method to return phase volume note: without Peneloux volume correction. * @@ -789,19 +783,65 @@ public default void addMolesChemReac(int component, double dn) { /** *

- * setPhysicalProperties. + * getPhysicalProperties. + *

+ * + * @return a {@link neqsim.physicalproperties.physicalpropertysystem.PhysicalProperties} object + */ + public PhysicalProperties getPhysicalProperties(); + + /** + *

+ * resetPhysicalProperties. + *

+ */ + public void resetPhysicalProperties(); + + /** + *

+ * Specify the type of the physical properties. + *

+ */ + public default void setPhysicalProperties() { + setPhysicalProperties(getPhysicalPropertyModel()); + } + + /** + *

+ * Specify the type of the physical properties. + *

+ * + * @param ppm PhysicalPropertyModel enum object + */ + public void setPhysicalProperties(PhysicalPropertyModel ppm); + + /** + *

+ * Getter for property ppm. + *

+ * + * @return a {@link neqsim.physicalproperties.physicalpropertysystem.PhysicalPropertyModel} object + */ + public PhysicalPropertyModel getPhysicalPropertyModel(); + + /** + *

+ * Setter for property ppm. *

+ * + * @param ppm PhysicalPropertyModel enum object */ - public void setPhysicalProperties(); + public void setPpm(PhysicalPropertyModel ppm); /** *

- * specify the type model for the physical properties you want to use. + * setPhysicalPropertyModel. *

* - * @param type 0 Orginal/default 1 Water 2 Glycol 3 Amine 4 CO2Water 6 Basic + * @param ppm a {@link neqsim.physicalproperties.physicalpropertysystem.PhysicalPropertyModel} + * object */ - public void setPhysicalProperties(int type); + public void setPhysicalPropertyModel(PhysicalPropertyModel ppm); /** *

@@ -837,15 +877,6 @@ public default void addMolesChemReac(int component, double dn) { */ public void setTemperature(double temperature); - /** - *

- * getPhysicalProperties. - *

- * - * @return a {@link neqsim.physicalproperties.physicalpropertysystem.PhysicalProperties} object - */ - public PhysicalProperties getPhysicalProperties(); - /** *

* molarVolume. @@ -1829,24 +1860,6 @@ public default void addMolesChemReac(int component, double dn) { */ public void setRefPhase(neqsim.thermo.phase.PhaseInterface[] refPhase); - /** - *

- * Getter for property physicalPropertyType. - *

- * - * @return a int - */ - public int getPhysicalPropertyType(); - - /** - *

- * Setter for property physicalPropertyType. - *

- * - * @param physicalPropertyType a int - */ - public void setPhysicalPropertyType(int physicalPropertyType); - /** *

* setParams. diff --git a/src/main/java/neqsim/thermo/system/SystemInterface.java b/src/main/java/neqsim/thermo/system/SystemInterface.java index 4cc8025a58..e7f6c6bc34 100644 --- a/src/main/java/neqsim/thermo/system/SystemInterface.java +++ b/src/main/java/neqsim/thermo/system/SystemInterface.java @@ -3,6 +3,7 @@ import neqsim.chemicalreactions.ChemicalReactionOperations; import neqsim.physicalproperties.PhysicalPropertyType; import neqsim.physicalproperties.interfaceproperties.InterphasePropertiesInterface; +import neqsim.physicalproperties.physicalpropertysystem.PhysicalPropertyModel; import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.characterization.WaxModelInterface; import neqsim.thermo.component.ComponentInterface; @@ -2448,9 +2449,22 @@ public void setImplementedTemperatureDeriativesofFugacity( /** * Set the physical property model type for each phase of the System. * - * @param type 0 Orginal/default 1 Water 2 Glycol 3 Amine 4 CO2Water 6 Basic + * @param ppm PhysicalPropertyModel enum object */ - public void setPhysicalPropertyModel(int type); + public default void setPhysicalPropertyModel(PhysicalPropertyModel ppm) { + for (int i = 0; i < getNumberOfPhases(); i++) { + getPhase(i).setPhysicalPropertyModel(ppm); + } + } + + /** + * Set the physical property model type for each phase of the System. + * + * @param type 0 Default, 1 Water, 2 Glycol, 3 Amine, 4 CO2Water, 6 Basic + */ + public default void setPhysicalPropertyModel(int type) { + setPhysicalPropertyModel(PhysicalPropertyModel.byValue(type)); + } /** * method to set the pressure of a fluid (same pressure for all phases). diff --git a/src/main/java/neqsim/thermo/system/SystemThermo.java b/src/main/java/neqsim/thermo/system/SystemThermo.java index 8322f9057f..7125e89dc0 100644 --- a/src/main/java/neqsim/thermo/system/SystemThermo.java +++ b/src/main/java/neqsim/thermo/system/SystemThermo.java @@ -4786,14 +4786,6 @@ public void setPhaseType(int phaseToChange, PhaseType pt) { } } - /** {@inheritDoc} */ - @Override - public void setPhysicalPropertyModel(int type) { - for (int i = 0; i < numberOfPhases; i++) { - getPhase(i).setPhysicalProperties(type); - } - } - /** {@inheritDoc} */ @Override public final void setPressure(double newPressure) { diff --git a/src/test/java/neqsim/physicalproperties/util/examples/TPflashTest.java b/src/test/java/neqsim/physicalproperties/util/examples/TPflashTest.java index 24a7fcf316..ab2dfaaddc 100644 --- a/src/test/java/neqsim/physicalproperties/util/examples/TPflashTest.java +++ b/src/test/java/neqsim/physicalproperties/util/examples/TPflashTest.java @@ -67,7 +67,7 @@ public static void main(String args[]) { testSystem.createDatabase(true); testSystem.setMixingRule(10); // testSystem.setMultiPhaseCheck(true); - // testSystem.setPhysicalPropertyModel(6); + // testSystem.setPhysicalPropertyModel(PhysicalPropertyType.BASIC); // testSystem.initPhysicalProperties(); // testSystem.getInterphaseProperties().setInterfacialTensionModel(3); // testSystem.useVolumeCorrection(true); @@ -93,7 +93,7 @@ public static void main(String args[]) { // double a = // testSystem.getPhase("oil").getPhysicalProperties().getDiffusionCoefficient(0, // 1); - // testSystem.setPhysicalPropertyModel(6); + // testSystem.setPhysicalPropertyModel(PhysicalPropertyType.BASIC); // testSystem.getPhase(0).initPhysicalProperties("viscosity"); double visc = testSystem.getPhase(1).getPhysicalProperties().getViscosityModel().calcViscosity(); diff --git a/src/test/java/neqsim/physicalproperties/util/examples/TestCondensate.java b/src/test/java/neqsim/physicalproperties/util/examples/TestCondensate.java index 8da23620e7..3cdc83c80b 100644 --- a/src/test/java/neqsim/physicalproperties/util/examples/TestCondensate.java +++ b/src/test/java/neqsim/physicalproperties/util/examples/TestCondensate.java @@ -2,6 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.physicalproperties.physicalpropertysystem.PhysicalPropertyModel; import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemPrEos; @@ -57,7 +58,7 @@ public static void main(String args[]) { testSystem.setMixingRule("classic"); testSystem.init(0); testSystem.init(1); - testSystem.setPhysicalPropertyModel(6); + testSystem.setPhysicalPropertyModel(PhysicalPropertyModel.BASIC); try { testOps.TPflash(); } catch (Exception ex) { diff --git a/src/test/java/neqsim/processsimulation/util/example/simpleGasScrubber.java b/src/test/java/neqsim/processsimulation/util/example/simpleGasScrubber.java index 47b84be2ad..2ce0e1663c 100644 --- a/src/test/java/neqsim/processsimulation/util/example/simpleGasScrubber.java +++ b/src/test/java/neqsim/processsimulation/util/example/simpleGasScrubber.java @@ -19,7 +19,6 @@ public class simpleGasScrubber { * * @param args an array of {@link java.lang.String} objects */ - @SuppressWarnings("unused") public static void main(String args[]) { neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 20.00); diff --git a/src/test/java/neqsim/thermo/util/example/ReactiveDesmukhMather.java b/src/test/java/neqsim/thermo/util/example/ReactiveDesmukhMather.java index 33cbaea315..f2e12e3a30 100644 --- a/src/test/java/neqsim/thermo/util/example/ReactiveDesmukhMather.java +++ b/src/test/java/neqsim/thermo/util/example/ReactiveDesmukhMather.java @@ -31,7 +31,7 @@ public static void main(String args[]) { testSystem.chemicalReactionInit(); testSystem.setMixingRule(2); testSystem.createDatabase(true); - // testSystem.setPhysicalPropertyModel(3); + // testSystem.setPhysicalPropertyModel(PhysicalPropertyModel.AMINE); ThermodynamicOperations ops = new ThermodynamicOperations(testSystem); diff --git a/src/test/java/neqsim/thermo/util/example/ReactiveKentEisenberg.java b/src/test/java/neqsim/thermo/util/example/ReactiveKentEisenberg.java index 78e6ab9f50..7d1e34c6d6 100644 --- a/src/test/java/neqsim/thermo/util/example/ReactiveKentEisenberg.java +++ b/src/test/java/neqsim/thermo/util/example/ReactiveKentEisenberg.java @@ -38,7 +38,7 @@ public static void main(String args[]) { testSystem.chemicalReactionInit(); testSystem.createDatabase(true); testSystem.setMixingRule(4); - // testSystem.setPhysicalPropertyModel(3); + // testSystem.setPhysicalPropertyModel(PhysicalPropertyModel.AMINE); ThermodynamicOperations ops = new ThermodynamicOperations(testSystem); From 7834de49cd99479cdf7174d1fa3d5c6819d8ac16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= <34712686+asmfstatoil@users.noreply.github.com> Date: Fri, 25 Oct 2024 09:51:46 +0200 Subject: [PATCH 2/3] doc: fix warning --- .../java/neqsim/physicalproperties/PhysicalPropertyType.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/neqsim/physicalproperties/PhysicalPropertyType.java b/src/main/java/neqsim/physicalproperties/PhysicalPropertyType.java index 9116ad4384..1a58a8aa15 100644 --- a/src/main/java/neqsim/physicalproperties/PhysicalPropertyType.java +++ b/src/main/java/neqsim/physicalproperties/PhysicalPropertyType.java @@ -10,9 +10,8 @@ public enum PhysicalPropertyType { MASS_DENSITY, DYNAMIC_VISCOSITY, THERMAL_CONDUCTIVITY; - // We know we'll never mutate this, so we can keep - // a local copy for fast lookup in byName - /** Constant copyOfValues */ + // We know we'll never mutate this, so we can keep a local copy for fast lookup in byName + /** Constant copyOfValues. */ private static final PhysicalPropertyType[] copyOfValues = values(); /** From d1396f73d653ef253c8f2a32ca781240ddf70a85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= <34712686+asmfstatoil@users.noreply.github.com> Date: Mon, 28 Oct 2024 13:21:23 +0100 Subject: [PATCH 3/3] test: add test --- src/main/java/neqsim/thermo/phase/Phase.java | 2 +- .../PhysicalPropertyModelTest.java | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/test/java/neqsim/physicalproperties/physicalpropertysystem/PhysicalPropertyModelTest.java diff --git a/src/main/java/neqsim/thermo/phase/Phase.java b/src/main/java/neqsim/thermo/phase/Phase.java index 17b67d48a3..301cf8e103 100644 --- a/src/main/java/neqsim/thermo/phase/Phase.java +++ b/src/main/java/neqsim/thermo/phase/Phase.java @@ -51,7 +51,7 @@ public abstract class Phase implements PhaseInterface { private boolean constantPhaseVolume = false; private PhysicalPropertyModel ppm = PhysicalPropertyModel.DEFAULT; - public neqsim.physicalproperties.PhysicalPropertyHandler physicalPropertyHandler = null; + public PhysicalPropertyHandler physicalPropertyHandler = null; protected boolean useVolumeCorrection = true; protected double molarVolume = 1.0; diff --git a/src/test/java/neqsim/physicalproperties/physicalpropertysystem/PhysicalPropertyModelTest.java b/src/test/java/neqsim/physicalproperties/physicalpropertysystem/PhysicalPropertyModelTest.java new file mode 100644 index 0000000000..012ef78e13 --- /dev/null +++ b/src/test/java/neqsim/physicalproperties/physicalpropertysystem/PhysicalPropertyModelTest.java @@ -0,0 +1,27 @@ +package neqsim.physicalproperties.physicalpropertysystem; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; + +public class PhysicalPropertyModelTest { + @Test + void testByName() { + assertEquals(PhysicalPropertyModel.AMINE, PhysicalPropertyModel.byName("amine")); + assertEquals(PhysicalPropertyModel.BASIC, PhysicalPropertyModel.byName("basic")); + assertEquals(PhysicalPropertyModel.CO2WATER, PhysicalPropertyModel.byName("co2water")); + assertEquals(PhysicalPropertyModel.DEFAULT, PhysicalPropertyModel.byName("default")); + assertEquals(PhysicalPropertyModel.GLYCOL, PhysicalPropertyModel.byName("glycol")); + assertEquals(PhysicalPropertyModel.WATER, PhysicalPropertyModel.byName("water")); + } + + + @Test + void testByValue() { + assertEquals(PhysicalPropertyModel.AMINE, PhysicalPropertyModel.byValue(3)); + assertEquals(PhysicalPropertyModel.BASIC, PhysicalPropertyModel.byValue(6)); + assertEquals(PhysicalPropertyModel.CO2WATER, PhysicalPropertyModel.byValue(4)); + assertEquals(PhysicalPropertyModel.DEFAULT, PhysicalPropertyModel.byValue(0)); + assertEquals(PhysicalPropertyModel.GLYCOL, PhysicalPropertyModel.byValue(2)); + assertEquals(PhysicalPropertyModel.WATER, PhysicalPropertyModel.byValue(1)); + } +}