Skip to content

Commit

Permalink
add hc analyser
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Jan 9, 2025
1 parent c25386a commit c9c23ec
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
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.thermo.util.empiric.BukacekWaterInGas;
import neqsim.thermodynamicoperations.ThermodynamicOperations;
import neqsim.util.ExcludeFromJacocoGeneratedReport;

/**
* <p>
* WaterDewPointAnalyser class.
* </p>
*
* @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 = 40.0;
private String method = "Bukacek";

/**
* <p>
* Constructor for WaterDewPointAnalyser.
* </p>
*
* @param stream a {@link neqsim.process.equipment.stream.StreamInterface} object
*/
public HydrocarbonDewPointAnalyser(StreamInterface stream) {
this("HydrocarbonDewPointAnalyser", stream);
}

/**
* <p>
* Constructor for WaterDewPointAnalyser.
* </p>
*
* @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) {
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);
}
}

/**
* <p>
* Getter for the field <code>referencePressure</code>.
* </p>
*
* @return Reference pressure in bara
*/
public double getReferencePressure() {
return referencePressure;
}

/**
* <p>
* Setter for the field <code>referencePressure</code>.
* </p>
*
* @param referencePressure Reference pressure to set in in bara
*/
public void setReferencePressure(double referencePressure) {
this.referencePressure = referencePressure;
}

/**
* <p>
* Getter for the field <code>method</code>.
* </p>
*
* @return a {@link java.lang.String} object
*/
public String getMethod() {
return method;
}

/**
* <p>
* Setter for the field <code>method</code>.
* </p>
*
* @param method a {@link java.lang.String} object
*/
public void setMethod(String method) {
this.method = method;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package neqsim.process.measurementdevice;

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 testGetMethod() {
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);

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();

}
}

0 comments on commit c9c23ec

Please sign in to comment.