From bbd31b2dd96f86d2cc68c747ecccb20953d6428d Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Thu, 9 Jan 2025 13:53:20 +0000 Subject: [PATCH] add HC analyser and test --- .../HydrocarbonDewPointAnalyser.java | 45 ++++++------------- .../HydrocarbonDewPointAnalyserTest.java | 22 +++++---- 2 files changed, 28 insertions(+), 39 deletions(-) diff --git a/src/main/java/neqsim/process/measurementdevice/HydrocarbonDewPointAnalyser.java b/src/main/java/neqsim/process/measurementdevice/HydrocarbonDewPointAnalyser.java index 845186c89..ce9cbf096 100644 --- a/src/main/java/neqsim/process/measurementdevice/HydrocarbonDewPointAnalyser.java +++ b/src/main/java/neqsim/process/measurementdevice/HydrocarbonDewPointAnalyser.java @@ -4,7 +4,6 @@ import org.apache.logging.log4j.Logger; import neqsim.process.equipment.stream.StreamInterface; import neqsim.thermo.system.SystemInterface; -import neqsim.thermo.util.empiric.BukacekWaterInGas; import neqsim.thermodynamicoperations.ThermodynamicOperations; import neqsim.util.ExcludeFromJacocoGeneratedReport; @@ -22,8 +21,8 @@ public class HydrocarbonDewPointAnalyser extends StreamMeasurementDeviceBaseClas /** Logger object for class. */ static Logger logger = LogManager.getLogger(WaterDewPointAnalyser.class); - private double referencePressure = 40.0; - private String method = "Bukacek"; + private double referencePressure = 50.0; + private String method = "EOS"; /** *
@@ -66,35 +65,19 @@ public void displayResult() { /** {@inheritDoc} */ @Override public double getMeasuredValue(String unit) { - if (method.equals("Bukacek")) { - SystemInterface tempFluid = stream.getThermoSystem().clone(); - tempFluid.setTemperature(BukacekWaterInGas - .waterDewPointTemperature(tempFluid.getComponent("water").getx(), referencePressure)); - return tempFluid.getTemperature(unit); - } else if (method.equals("multiphase")) { - SystemInterface tempFluid = stream.getThermoSystem().clone(); - tempFluid.setPressure(referencePressure); - tempFluid.setTemperature(0.1, "C"); - ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); - try { - thermoOps.waterDewPointTemperatureMultiphaseFlash(); - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); - } - return tempFluid.getTemperature(unit); - } else { - SystemInterface tempFluid = stream.getThermoSystem().clone(); - SystemInterface tempFluid2 = tempFluid.setModel("GERG-water-EOS"); - tempFluid2.setPressure(referencePressure); - tempFluid2.setTemperature(-17.0, "C"); - ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid2); - try { - thermoOps.waterDewPointTemperatureFlash(); - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); - } - return tempFluid2.getTemperature(unit); + SystemInterface tempFluid = stream.getThermoSystem().clone(); + if (tempFluid.hasComponent("water")) { + tempFluid.removeComponent("water"); } + tempFluid.setPressure(referencePressure); + tempFluid.setTemperature(-10.0, "C"); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); + try { + thermoOps.dewPointTemperatureFlash(false); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + return tempFluid.getTemperature(unit); } /** diff --git a/src/test/java/neqsim/process/measurementdevice/HydrocarbonDewPointAnalyserTest.java b/src/test/java/neqsim/process/measurementdevice/HydrocarbonDewPointAnalyserTest.java index 0682f7da1..9c75cf8d9 100644 --- a/src/test/java/neqsim/process/measurementdevice/HydrocarbonDewPointAnalyserTest.java +++ b/src/test/java/neqsim/process/measurementdevice/HydrocarbonDewPointAnalyserTest.java @@ -1,5 +1,6 @@ package neqsim.process.measurementdevice; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import neqsim.process.equipment.stream.Stream; import neqsim.process.processmodel.ProcessSystem; @@ -8,16 +9,17 @@ public class HydrocarbonDewPointAnalyserTest { @Test - void testGetMethod() { + void testHCdewPoint() { SystemInterface thermoSystem = new SystemSrkEos(298.0, 50.0); thermoSystem.addComponent("methane", 1.0); - thermoSystem.addComponent("ethane", 1.0); - thermoSystem.addComponent("propane", 1.0); - thermoSystem.addComponent("i-butane", 1.0); - thermoSystem.addComponent("n-butane", 1.0); - thermoSystem.addComponent("i-pentane", 1.0); - thermoSystem.addComponent("n-pentane", 1.0); - + thermoSystem.addComponent("ethane", .01); + thermoSystem.addComponent("propane", 0.001); + thermoSystem.addComponent("i-butane", 0.001); + thermoSystem.addComponent("n-butane", 0.001); + thermoSystem.addComponent("i-pentane", 0.001); + thermoSystem.addComponent("n-pentane", 0.0001); + thermoSystem.addComponent("water", 0.001); + thermoSystem.setMixingRule("classic"); Stream stream1 = new Stream("stream 1", thermoSystem); HydrocarbonDewPointAnalyser hc_analyser = new HydrocarbonDewPointAnalyser("hc analyser", stream1); @@ -26,6 +28,10 @@ void testGetMethod() { process1.add(hc_analyser); process1.run(); + hc_analyser.setReferencePressure(40.0); + hc_analyser.getMeasuredValue("C"); + Assertions.assertEquals(-14.0173918, hc_analyser.getMeasuredValue("C"), 1e-5); + } }