From 0622462f221c83e54246f0899f01dc066896d646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= <34712686+asmfstatoil@users.noreply.github.com> Date: Sat, 11 Jan 2025 08:50:29 +0100 Subject: [PATCH] ref + docfix --- .../NonEquilibriumFluidBoundary.java | 3 -- .../equipment/ProcessEquipmentInterface.java | 10 +++--- .../neqsim/process/equipment/tank/Tank.java | 33 +++++++++++++++---- .../neqsim/thermo/component/Component.java | 5 +-- .../java/neqsim/thermo/phase/PhaseEos.java | 3 +- .../neqsim/thermo/phase/PhaseInterface.java | 23 +++++++------ .../neqsim/thermo/system/SystemInterface.java | 12 ++++--- .../util/readwrite/EclipseFluidReadWrite.java | 3 -- .../ThermodynamicOperations.java | 3 +- .../process/measurementdevice/nmVOCTest.java | 2 +- .../processmodel/LargeCombinedModelsTest.java | 2 +- .../SalesGasAndStableOilTest.java | 5 ++- 12 files changed, 60 insertions(+), 44 deletions(-) diff --git a/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/heatmasstransfercalc/nonequilibriumfluidboundary/NonEquilibriumFluidBoundary.java b/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/heatmasstransfercalc/nonequilibriumfluidboundary/NonEquilibriumFluidBoundary.java index 1b2c764b93..acfbfabdd5 100644 --- a/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/heatmasstransfercalc/nonequilibriumfluidboundary/NonEquilibriumFluidBoundary.java +++ b/src/main/java/neqsim/fluidmechanics/flownode/fluidboundary/heatmasstransfercalc/nonequilibriumfluidboundary/NonEquilibriumFluidBoundary.java @@ -628,8 +628,5 @@ public void solve() { } while (Math.abs((oldHeatFlux - heatFlux) / heatFlux) > 1e-6 && heatTransferCalc && iterInner < 50); init(); - // System.out.println("iterInner " +iterInner + " temp gas " + - // interphaseSystem.getTemperature(0)+ " temp liq " + - // interphaseSystem.getTemperature(1)); } } diff --git a/src/main/java/neqsim/process/equipment/ProcessEquipmentInterface.java b/src/main/java/neqsim/process/equipment/ProcessEquipmentInterface.java index ee6b796da8..e72c55f64e 100644 --- a/src/main/java/neqsim/process/equipment/ProcessEquipmentInterface.java +++ b/src/main/java/neqsim/process/equipment/ProcessEquipmentInterface.java @@ -89,8 +89,7 @@ public default boolean needRecalculation() { * setController. *

* - * @param controller a {@link neqsim.process.controllerdevice.ControllerDeviceInterface} - * object + * @param controller a {@link neqsim.process.controllerdevice.ControllerDeviceInterface} object */ public void setController(ControllerDeviceInterface controller); @@ -166,8 +165,7 @@ public default SystemInterface getFluid() { * runConditionAnalysis. *

* - * @param refExchanger a - * {@link neqsim.process.equipment.ProcessEquipmentInterface} object + * @param refExchanger a {@link neqsim.process.equipment.ProcessEquipmentInterface} object */ public void runConditionAnalysis(ProcessEquipmentInterface refExchanger); @@ -216,10 +214,10 @@ public default SystemInterface getFluid() { /** *

- * toJson. + * Serializes the Process Equipment along with its state to a JSON string. *

* - * @return a String + * @return json string. */ public String toJson(); diff --git a/src/main/java/neqsim/process/equipment/tank/Tank.java b/src/main/java/neqsim/process/equipment/tank/Tank.java index ae6012ba03..a0b76e7c9f 100644 --- a/src/main/java/neqsim/process/equipment/tank/Tank.java +++ b/src/main/java/neqsim/process/equipment/tank/Tank.java @@ -1,6 +1,8 @@ package neqsim.process.equipment.tank; import java.util.UUID; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import neqsim.process.equipment.ProcessEquipmentBaseClass; import neqsim.process.equipment.mixer.Mixer; import neqsim.process.equipment.stream.Stream; @@ -20,6 +22,8 @@ public class Tank extends ProcessEquipmentBaseClass { /** Serialization version UID. */ private static final long serialVersionUID = 1000; + /** Logger object for class. */ + static Logger logger = LogManager.getLogger(Tank.class); SystemInterface thermoSystem; SystemInterface gasSystem; @@ -148,14 +152,29 @@ public StreamInterface getLiquid() { return getLiquidOutStream(); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * + *

+ * Calculates the following properties: + *

+ *

+ */ @Override public void run(UUID id) { inletStreamMixer.run(id); SystemInterface thermoSystem2 = inletStreamMixer.getOutletStream().getThermoSystem().clone(); ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem2); ops.VUflash(thermoSystem2.getVolume(), thermoSystem2.getInternalEnergy()); - System.out.println("Volume " + thermoSystem2.getVolume() + " internalEnergy " + logger.info("Volume " + thermoSystem2.getVolume() + " internalEnergy " + thermoSystem2.getInternalEnergy()); steelWallTemperature = thermoSystem2.getTemperature(); if (thermoSystem2.hasPhaseType("gas")) { @@ -172,7 +191,7 @@ public void run(UUID id) { thermoSystem = thermoSystem2.clone(); thermoSystem.setTotalNumberOfMoles(1.0e-10); thermoSystem.init(1); - System.out.println("number of phases " + thermoSystem.getNumberOfPhases()); + logger.info("number of phases " + thermoSystem.getNumberOfPhases()); for (int j = 0; j < thermoSystem.getNumberOfPhases(); j++) { double relFact = gasVolume / (thermoSystem.getPhase(j).getVolume() * 1.0e-5); if (j == 1) { @@ -191,10 +210,10 @@ public void run(UUID id) { thermoSystem.setBeta(1.0 - 1e-10); } thermoSystem.init(3); - System.out.println("moles in separator " + thermoSystem.getNumberOfMoles()); + logger.info("moles in separator " + thermoSystem.getNumberOfMoles()); double volume1 = thermoSystem.getVolume(); - System.out.println("volume1 bef " + volume1); - System.out.println("beta " + thermoSystem.getBeta()); + logger.info("volume1 bef " + volume1); + logger.info("beta " + thermoSystem.getBeta()); if (thermoSystem2.getNumberOfPhases() == 2) { liquidLevel = thermoSystem.getPhase(1).getVolume() * 1e-5 / (liquidVolume + gasVolume); @@ -205,7 +224,7 @@ public void run(UUID id) { getLiquidLevel() * 3.14 / 4.0 * separatorDiameter * separatorDiameter * separatorLength; gasVolume = (1.0 - getLiquidLevel()) * 3.14 / 4.0 * separatorDiameter * separatorDiameter * separatorLength; - System.out.println("moles out" + liquidOutStream.getThermoSystem().getTotalNumberOfMoles()); + logger.info("moles out" + liquidOutStream.getThermoSystem().getTotalNumberOfMoles()); setCalculationIdentifier(id); } diff --git a/src/main/java/neqsim/thermo/component/Component.java b/src/main/java/neqsim/thermo/component/Component.java index baa5c92a34..f57d7aaff7 100644 --- a/src/main/java/neqsim/thermo/component/Component.java +++ b/src/main/java/neqsim/thermo/component/Component.java @@ -50,10 +50,11 @@ public abstract class Component implements ComponentInterface { /** Mole fraction of Component in Phase. */ protected double x = 0; /** - * Number of moles of Component in System. numberOfMoles = totalNumberOfMoles * z. + * Number of moles of Component in System. Ideally + * numberOfMoles = totalNumberOfMoles * z. */ protected double numberOfMoles = 0.0; - /** Number of moles of Component in Phase. totalNumberOfMoles * x * beta. */ + /** Number of moles of Component in Phase. Ideally totalNumberOfMoles * x * beta. */ protected double numberOfMolesInPhase = 0.0; protected double K; diff --git a/src/main/java/neqsim/thermo/phase/PhaseEos.java b/src/main/java/neqsim/thermo/phase/PhaseEos.java index 3bfac0e232..eb4a8598e7 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseEos.java +++ b/src/main/java/neqsim/thermo/phase/PhaseEos.java @@ -36,7 +36,7 @@ public abstract class PhaseEos extends Phase implements PhaseEosInterface { public double delta1 = 0; public double delta2 = 0; - protected EosMixingRules mixSelect = null; + protected EosMixingRules mixSelect = new EosMixingRules(); protected EosMixingRulesInterface mixRule = null; double uEOS = 0; double wEOS = 0; @@ -63,7 +63,6 @@ public PhaseEos clone() { *

*/ public PhaseEos() { - mixSelect = new EosMixingRules(); componentArray = new ComponentEosInterface[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS]; mixRule = mixSelect.getMixingRule(1); // solver = new newtonRhapson(); diff --git a/src/main/java/neqsim/thermo/phase/PhaseInterface.java b/src/main/java/neqsim/thermo/phase/PhaseInterface.java index 9372762d79..0f7423039c 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseInterface.java +++ b/src/main/java/neqsim/thermo/phase/PhaseInterface.java @@ -39,10 +39,10 @@ public interface PhaseInterface extends ThermodynamicConstantsInterface, Cloneab /** *

- * setMoleFractions. + * Set x and normalize for all Components in phase. *

* - * @param x an array of type double + * @param x Mole fractions of component in a phase. */ public void setMoleFractions(double[] x); @@ -690,8 +690,11 @@ public default void initPhysicalProperties(String name) { public double getpH(); /** + * Normalize property x. + * *

- * normalize. + * Property x is the mole fraction of a component in a specific phase. Normalizing, + * means that the sum of x for all Components in a phase equal 1.0. *

*/ public void normalize(); @@ -1280,10 +1283,10 @@ public default void setMixingRule(int mr) { /** *

- * getNumberOfMolesInPhase. + * Get the number of moles the phase contains. *

* - * @return a double + * @return The number of moles in the phase. */ public double getNumberOfMolesInPhase(); @@ -1723,7 +1726,7 @@ public default void setMixingRule(int mr) { /** *

- * dFdT. + * Calculate derivative of F per Temperature, i.e., dF/dT. *

* * @return a double @@ -1732,7 +1735,7 @@ public default void setMixingRule(int mr) { /** *

- * dFdV. + * Calculate derivative of F per Volume, i.e., dF/dV. *

* * @return a double @@ -1741,7 +1744,7 @@ public default void setMixingRule(int mr) { /** *

- * dFdTdV. + * Calculate derivative of F per Temperature and Volume, i.e., dF/dT * 1/dV. *

* * @return a double @@ -1818,8 +1821,8 @@ public default void setMixingRule(int mr) { public double getLogInfiniteDiluteFugacity(int k); /** - * Get mixing rule - * + * Get mixing rule. + * * @return a MixingRulesInterface */ public MixingRulesInterface getMixingRule(); diff --git a/src/main/java/neqsim/thermo/system/SystemInterface.java b/src/main/java/neqsim/thermo/system/SystemInterface.java index 78d378f352..e98bd59e7a 100644 --- a/src/main/java/neqsim/thermo/system/SystemInterface.java +++ b/src/main/java/neqsim/thermo/system/SystemInterface.java @@ -1472,7 +1472,7 @@ public default int getPhaseNumberOfPhase(String phaseTypeName) { /** *

- * Getter for property TC. + * Get critical temperature. *

* * @return Critical temperature @@ -1488,13 +1488,14 @@ public default int getPhaseNumberOfPhase(String phaseTypeName) { /** *

- * method to return temperature. + * method to return temperature from a specific phase. *

* * @param phaseNumber phase to get temperature of * @return temperature in unit Kelvin */ - public double getTemperature(int phaseNumber); + public double getTemperature(int phaseNumber); // TODO: is it possible for the phases to have + // different temperatures? /** * method to return temperature in a specified unit. @@ -2123,9 +2124,10 @@ public default void prettyPrint() { public void setAttractiveTerm(int i); /** + * Setter for property beta. *

- * Setter for property beta. NB! Sets beta = b for first phase and 1-b for second - * phase, not for multiphase systems. + * NB! Sets beta = b for first (heaviest) phase and 1-b for second (lightest) phase, not for + * multiphase systems. *

* * @param b Beta value to set. diff --git a/src/main/java/neqsim/thermo/util/readwrite/EclipseFluidReadWrite.java b/src/main/java/neqsim/thermo/util/readwrite/EclipseFluidReadWrite.java index 6a7f92e9d1..02f1ca38fe 100644 --- a/src/main/java/neqsim/thermo/util/readwrite/EclipseFluidReadWrite.java +++ b/src/main/java/neqsim/thermo/util/readwrite/EclipseFluidReadWrite.java @@ -371,7 +371,6 @@ public static SystemInterface read(String inputFile) { } } - // System.out.println(st); fluid.setMixingRule(2); fluid.useVolumeCorrection(true); fluid.init(0); @@ -385,8 +384,6 @@ public static SystemInterface read(String inputFile) { } } } - - // fluid.display(); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } diff --git a/src/main/java/neqsim/thermodynamicoperations/ThermodynamicOperations.java b/src/main/java/neqsim/thermodynamicoperations/ThermodynamicOperations.java index 19e4236a35..0be7e34f84 100644 --- a/src/main/java/neqsim/thermodynamicoperations/ThermodynamicOperations.java +++ b/src/main/java/neqsim/thermodynamicoperations/ThermodynamicOperations.java @@ -140,7 +140,7 @@ public void TPSolidflash() { } /** - * Method to perform a flash at given temperature, pressure and specified volume The number of + * Method to perform a flash at given temperature, pressure and specified volume. The number of * moles in the system are changed to match the specified volume. * * @param volumeSpec is the specified volume @@ -1380,6 +1380,7 @@ public void constantPhaseFractionTemperatureFlash(double fraction) throws IsNaNE fraction = 1.0 - 1.0e-10; } ConstantDutyFlashInterface operation = new ConstantDutyTemperatureFlash(system); + // TODO: bug, sum of beta will not equal 1 system.setBeta(1, fraction); system.setBeta(0, fraction); operation.run(); diff --git a/src/test/java/neqsim/process/measurementdevice/nmVOCTest.java b/src/test/java/neqsim/process/measurementdevice/nmVOCTest.java index 8b46c202bf..12c33edb00 100644 --- a/src/test/java/neqsim/process/measurementdevice/nmVOCTest.java +++ b/src/test/java/neqsim/process/measurementdevice/nmVOCTest.java @@ -121,7 +121,7 @@ public void testGetTotalFlowRate() { } @Test - public void nmVOCFlowRateTest() { + public void testnmVOCFlowRate() { process1.run(); Assertions.assertEquals(vocanalyser1.getMeasuredValue(), 10555.540704); Assertions.assertEquals(vocanalyser1.getMeasuredValue("tonnes/year"), 10555.540704); diff --git a/src/test/java/neqsim/process/processmodel/LargeCombinedModelsTest.java b/src/test/java/neqsim/process/processmodel/LargeCombinedModelsTest.java index e2664e1c3e..a120fb4170 100644 --- a/src/test/java/neqsim/process/processmodel/LargeCombinedModelsTest.java +++ b/src/test/java/neqsim/process/processmodel/LargeCombinedModelsTest.java @@ -538,7 +538,7 @@ public ProcessSystem createExpanderProcessModel(Separator dewPointScrubber2, } @Test - public void tesExpanderProcess() { + public void testExpanderProcess() { // wellFluid.setMultiPhaseCheck(true); ProcessSystem wellprocess = getWellStreamAndManifoldModel(wellFluid); wellprocess.run(); diff --git a/src/test/java/neqsim/process/processmodel/SalesGasAndStableOilTest.java b/src/test/java/neqsim/process/processmodel/SalesGasAndStableOilTest.java index 5f1afb3b6b..4519a8a050 100644 --- a/src/test/java/neqsim/process/processmodel/SalesGasAndStableOilTest.java +++ b/src/test/java/neqsim/process/processmodel/SalesGasAndStableOilTest.java @@ -2,6 +2,7 @@ import java.io.File; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import neqsim.process.equipment.compressor.Compressor; import neqsim.process.equipment.expander.Expander; @@ -20,13 +21,11 @@ public class SalesGasAndStableOilTest extends neqsim.NeqSimTest { File file = new File("src/test/java/neqsim/process/processmodel"); String fileFluid1 = file.getAbsolutePath() + "/feedfluid.e300"; + @Disabled("No assertions") @Test public void testProcess() { SystemInterface wellFluid = neqsim.thermo.util.readwrite.EclipseFluidReadWrite.read(fileFluid1); // wellFluid.setMultiPhaseCheck(true); - - neqsim.process.equipment.stream.Stream wellStream = - new neqsim.process.equipment.stream.Stream("HP well stream", wellFluid); SystemInterface LPwellFLuid = wellFluid.clone(); Stream wellStreamHP = new neqsim.process.equipment.stream.Stream("HP well stream", wellFluid);