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

Fix t vflashbug #460

Merged
merged 5 commits into from
Jul 7, 2022
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
@@ -1,5 +1,8 @@
package neqsim.processSimulation.measurementDevice;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.processSimulation.processEquipment.splitter.Splitter;
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.thermo.system.SystemInterface;
Expand All @@ -15,106 +18,108 @@
* @version $Id: $Id
*/
public class MultiPhaseMeter extends MeasurementDeviceBaseClass {
private static final long serialVersionUID = 1000;

protected StreamInterface stream = null;
double pressure = 10.0, temperature = 298.15;
String unitT, unitP;

public MultiPhaseMeter() {
name = "Multi Phase Meter";
}

/**
* <p>
* Constructor for MultiPhaseMeter.
* </p>
*
* @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface}
* object
*/
public MultiPhaseMeter(StreamInterface stream) {
this();
name = "Multi Phase Meter";
this.stream = stream;
}

/**
* <p>
* Constructor for MultiPhaseMeter.
* </p>
*
* @param name a {@link java.lang.String} object
* @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface}
* object
*/
public MultiPhaseMeter(String name, StreamInterface stream) {
this();
this.name = name;
this.stream = stream;
}

/**
* <p>
* Getter for the field <code>pressure</code>.
* </p>
*
* @return a double
*/
public double getPressure() {
return pressure;
}

/**
* <p>
* Setter for the field <code>pressure</code>.
* </p>
*
* @param pressure a double
* @param unitP a {@link java.lang.String} object
*/
public void setPressure(double pressure, String unitP) {
this.pressure = pressure;
this.unitP = unitP;
}

/**
* <p>
* getTemperature.
* </p>
*
* @return a double
*/
public double getTemperature() {
return temperature;
}

/**
* <p>
* Setter for the field <code>temperature</code>.
* </p>
*
* @param temperature a double
* @param unitT a {@link java.lang.String} object
*/
public void setTemperature(double temperature, String unitT) {
this.temperature = temperature;
this.unitT = unitT;
}

/** {@inheritDoc} */
@Override
public double getMeasuredValue() {
return stream.getThermoSystem().getFlowRate("kg/hr");
}

/** {@inheritDoc} */
private static final long serialVersionUID = 1000;
static Logger logger = LogManager.getLogger(MultiPhaseMeter.class);
protected StreamInterface stream = null;
double pressure = 10.0, temperature = 298.15;
String unitT, unitP;

public MultiPhaseMeter() {
name = "Multi Phase Meter";
}

/**
* <p>
* Constructor for MultiPhaseMeter.
* </p>
*
* @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object
*/
public MultiPhaseMeter(StreamInterface stream) {
this();
name = "Multi Phase Meter";
this.stream = stream;
}

/**
* <p>
* Constructor for MultiPhaseMeter.
* </p>
*
* @param name a {@link java.lang.String} object
* @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object
*/
public MultiPhaseMeter(String name, StreamInterface stream) {
this();
this.name = name;
this.stream = stream;
}

/**
* <p>
* Getter for the field <code>pressure</code>.
* </p>
*
* @return a double
*/
public double getPressure() {
return pressure;
}

/**
* <p>
* Setter for the field <code>pressure</code>.
* </p>
*
* @param pressure a double
* @param unitP a {@link java.lang.String} object
*/
public void setPressure(double pressure, String unitP) {
this.pressure = pressure;
this.unitP = unitP;
}

/**
* <p>
* getTemperature.
* </p>
*
* @return a double
*/
public double getTemperature() {
return temperature;
}

/**
* <p>
* Setter for the field <code>temperature</code>.
* </p>
*
* @param temperature a double
* @param unitT a {@link java.lang.String} object
*/
public void setTemperature(double temperature, String unitT) {
this.temperature = temperature;
this.unitT = unitT;
}

/** {@inheritDoc} */
@Override
public double getMeasuredValue() {
return stream.getThermoSystem().getFlowRate("kg/hr");
}

/** {@inheritDoc} */
@Override
public double getMeasuredValue(String measurement) {
if (measurement.equals("mass rate")) {
return stream.getThermoSystem().getFlowRate("kg/hr");
}


if(stream.getThermoSystem().getFlowRate("kg/hr")<1e-10) {
return Double.NaN;
}

if (measurement.equals("GOR")) {
SystemInterface tempFluid = stream.getThermoSystem().clone();
tempFluid.setTemperature(temperature, unitT);
Expand All @@ -123,11 +128,12 @@ public double getMeasuredValue(String measurement) {
try {
thermoOps.TPflash();
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getStackTrace());
return Double.NaN;
}
// tempFluid.display();
if (!tempFluid.hasPhaseType("gas")) {
return 0.0;
return Double.NaN;
}
if (!tempFluid.hasPhaseType("oil")) {
return Double.NaN;
Expand All @@ -145,7 +151,8 @@ public double getMeasuredValue(String measurement) {
try {
thermoOps.TPflash();
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getStackTrace());
return Double.NaN;
}
tempFluid.initPhysicalProperties();
if (measurement.equals("gasDensity")) {
Expand Down Expand Up @@ -178,11 +185,11 @@ public double getMeasuredValue(String measurement) {
try {
thermoOps.TPflash();
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getStackTrace());
return Double.NaN;
}
// tempFluid.display();
if (!tempFluid.hasPhaseType("gas")) {
return 0.0;
return Double.NaN;
}
if (!tempFluid.hasPhaseType("oil")) {
return Double.NaN;
Expand All @@ -194,44 +201,44 @@ public double getMeasuredValue(String measurement) {
return 0.0;
}

/**
* <p>
* main.
* </p>
*
* @param args an array of {@link java.lang.String} objects
*/
public static void main(String[] args) {
SystemInterface testFluid = new SystemSrkEos(338.15, 50.0);
testFluid.addComponent("nitrogen", 1.205);
testFluid.addComponent("CO2", 1.340);
testFluid.addComponent("methane", 87.974);
testFluid.addComponent("ethane", 5.258);
testFluid.addComponent("propane", 3.283);
testFluid.addComponent("i-butane", 0.082);
testFluid.addComponent("n-butane", 0.487);
testFluid.addComponent("i-pentane", 0.056);
testFluid.addComponent("n-pentane", 1.053);
testFluid.addComponent("nC10", 4.053);
testFluid.setMixingRule(2);
testFluid.setMultiPhaseCheck(true);

testFluid.setTemperature(24.0, "C");
testFluid.setPressure(48.0, "bara");
testFluid.setTotalFlowRate(4.5, "MSm3/day");

Stream stream_1 = new Stream("Stream1", testFluid);

MultiPhaseMeter multiPhaseMeter = new MultiPhaseMeter("test", stream_1);
multiPhaseMeter.setTemperature(90.0, "C");
multiPhaseMeter.setPressure(60.0, "bara");

neqsim.processSimulation.processSystem.ProcessSystem operations =
new neqsim.processSimulation.processSystem.ProcessSystem();
operations.add(stream_1);
operations.add(multiPhaseMeter);
operations.run();
System.out.println("GOR " + multiPhaseMeter.getMeasuredValue("GOR"));
System.out.println("GOR_std " + multiPhaseMeter.getMeasuredValue("GOR_std"));
}
/**
* <p>
* main.
* </p>
*
* @param args an array of {@link java.lang.String} objects
*/
public static void main(String[] args) {
SystemInterface testFluid = new SystemSrkEos(338.15, 50.0);
testFluid.addComponent("nitrogen", 1.205);
testFluid.addComponent("CO2", 1.340);
testFluid.addComponent("methane", 87.974);
testFluid.addComponent("ethane", 5.258);
testFluid.addComponent("propane", 3.283);
testFluid.addComponent("i-butane", 0.082);
testFluid.addComponent("n-butane", 0.487);
testFluid.addComponent("i-pentane", 0.056);
testFluid.addComponent("n-pentane", 1.053);
testFluid.addComponent("nC10", 4.053);
testFluid.setMixingRule(2);
testFluid.setMultiPhaseCheck(true);

testFluid.setTemperature(24.0, "C");
testFluid.setPressure(48.0, "bara");
testFluid.setTotalFlowRate(4.5, "MSm3/day");

Stream stream_1 = new Stream("Stream1", testFluid);

MultiPhaseMeter multiPhaseMeter = new MultiPhaseMeter("test", stream_1);
multiPhaseMeter.setTemperature(90.0, "C");
multiPhaseMeter.setPressure(60.0, "bara");

neqsim.processSimulation.processSystem.ProcessSystem operations =
new neqsim.processSimulation.processSystem.ProcessSystem();
operations.add(stream_1);
operations.add(multiPhaseMeter);
operations.run();
System.out.println("GOR " + multiPhaseMeter.getMeasuredValue("GOR"));
System.out.println("GOR_std " + multiPhaseMeter.getMeasuredValue("GOR_std"));
}
}
Loading