diff --git a/src/main/java/neqsim/process/measurementdevice/HydrocarbonDewPointAnalyser.java b/src/main/java/neqsim/process/measurementdevice/HydrocarbonDewPointAnalyser.java new file mode 100644 index 000000000..ce9cbf096 --- /dev/null +++ b/src/main/java/neqsim/process/measurementdevice/HydrocarbonDewPointAnalyser.java @@ -0,0 +1,126 @@ +package neqsim.process.measurementdevice; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import neqsim.process.equipment.stream.StreamInterface; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermodynamicoperations.ThermodynamicOperations; +import neqsim.util.ExcludeFromJacocoGeneratedReport; + +/** + *

+ * WaterDewPointAnalyser class. + *

+ * + * @author ESOL + * @version $Id: $Id + */ +public class HydrocarbonDewPointAnalyser extends StreamMeasurementDeviceBaseClass { + /** Serialization version UID. */ + private static final long serialVersionUID = 1000; + /** Logger object for class. */ + static Logger logger = LogManager.getLogger(WaterDewPointAnalyser.class); + + private double referencePressure = 50.0; + private String method = "EOS"; + + /** + *

+ * Constructor for WaterDewPointAnalyser. + *

+ * + * @param stream a {@link neqsim.process.equipment.stream.StreamInterface} object + */ + public HydrocarbonDewPointAnalyser(StreamInterface stream) { + this("HydrocarbonDewPointAnalyser", stream); + } + + /** + *

+ * Constructor for WaterDewPointAnalyser. + *

+ * + * @param name Name of WaterDewPointAnalyser + * @param stream a {@link neqsim.process.equipment.stream.StreamInterface} object + */ + public HydrocarbonDewPointAnalyser(String name, StreamInterface stream) { + super(name, "K", stream); + setConditionAnalysisMaxDeviation(1.0); + } + + /** {@inheritDoc} */ + @Override + @ExcludeFromJacocoGeneratedReport + public void displayResult() { + try { + // System.out.println("total water production [kg/dag]" + + // stream.getThermoSystem().getPhase(0).getComponent("water").getNumberOfmoles() * + // stream.getThermoSystem().getPhase(0).getComponent("water").getMolarMass()*3600*24); + // System.out.println("water in phase 1 (ppm) " + + // stream.getThermoSystem().getPhase(0).getComponent("water").getx()*1e6); + } finally { + } + } + + /** {@inheritDoc} */ + @Override + public double getMeasuredValue(String 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); + } + + /** + *

+ * Getter for the field referencePressure. + *

+ * + * @return Reference pressure in bara + */ + public double getReferencePressure() { + return referencePressure; + } + + /** + *

+ * Setter for the field referencePressure. + *

+ * + * @param referencePressure Reference pressure to set in in bara + */ + public void setReferencePressure(double referencePressure) { + this.referencePressure = referencePressure; + } + + /** + *

+ * Getter for the field method. + *

+ * + * @return a {@link java.lang.String} object + */ + public String getMethod() { + return method; + } + + /** + *

+ * Setter for the field method. + *

+ * + * @param method a {@link java.lang.String} object + */ + public void setMethod(String method) { + this.method = method; + } +} diff --git a/src/test/java/neqsim/process/measurementdevice/HydrocarbonDewPointAnalyserTest.java b/src/test/java/neqsim/process/measurementdevice/HydrocarbonDewPointAnalyserTest.java new file mode 100644 index 000000000..9c75cf8d9 --- /dev/null +++ b/src/test/java/neqsim/process/measurementdevice/HydrocarbonDewPointAnalyserTest.java @@ -0,0 +1,37 @@ +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; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemSrkEos; + +public class HydrocarbonDewPointAnalyserTest { + @Test + void testHCdewPoint() { + SystemInterface thermoSystem = new SystemSrkEos(298.0, 50.0); + thermoSystem.addComponent("methane", 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); + ProcessSystem process1 = new ProcessSystem(); + process1.add(stream1); + 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); + + + } +}