Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add hc dew point analyser #1245

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;

/**
* <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 = 50.0;
private String method = "EOS";

/**
* <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) {
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);
}

/**
* <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,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);


}
}
Loading