-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add hc analyser * add HC analyser and test
- Loading branch information
Showing
2 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
126 changes: 126 additions & 0 deletions
126
src/main/java/neqsim/process/measurementdevice/HydrocarbonDewPointAnalyser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/test/java/neqsim/process/measurementdevice/HydrocarbonDewPointAnalyserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
|
||
} | ||
} |