diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java b/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java index 262f89b610..7db456a340 100644 --- a/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java +++ b/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java @@ -19,8 +19,8 @@ public class MultiPhaseMeter extends StreamMeasurementDeviceBaseClass { private static final long serialVersionUID = 1000; static Logger logger = LogManager.getLogger(MultiPhaseMeter.class); - double pressure = 10.0; - double temperature = 298.15; + double pressure = 1.01325; + double temperature = 288.15; String unitT; String unitP; @@ -111,15 +111,15 @@ public double getMeasuredValue(String unit) { */ public double getMeasuredValue(String measurement, String unit) { if (measurement.equals("mass rate")) { - return stream.getThermoSystem().getFlowRate(unit); + return stream.getFlowRate(unit); } - if (stream.getThermoSystem().getFlowRate("kg/hr") < 1e-10) { + if (stream.getFlowRate("kg/hr") < 1e-10) { return Double.NaN; } if (measurement.equals("GOR")) { - SystemInterface tempFluid = stream.getThermoSystem().clone(); + SystemInterface tempFluid = stream.getFluid().clone(); tempFluid.setTemperature(temperature, unitT); tempFluid.setPressure(pressure, unitP); ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); @@ -231,6 +231,7 @@ public double getMeasuredValue(String measurement, String unit) { return 0.0; } else if (measurement.equals("GOR_std")) { SystemInterface tempFluid = stream.getThermoSystem().clone(); + tempFluid.setTemperature(15.0, "C"); tempFluid.setPressure(ThermodynamicConstantsInterface.referencePressure, "bara"); ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); @@ -247,6 +248,22 @@ public double getMeasuredValue(String measurement, String unit) { return Double.NaN; } tempFluid.initPhysicalProperties("density"); + + double GOR_in_sm3_sm3 = tempFluid.getPhase("gas").getFlowRate("Sm3/hr") + / tempFluid.getPhase("oil").getFlowRate("m3/hr"); + double GOR_via_corrected_volume = tempFluid.getPhase("gas").getCorrectedVolume() + / tempFluid.getPhase("oil").getCorrectedVolume(); + + + System.out.println("Stream 2 (results inside MPM) " + " GOR sm3/sm3 " + GOR_in_sm3_sm3 + + " GOR Corrected by volume " + GOR_via_corrected_volume); + + System.out.println("Stream 2 (results inside MPM) getPhase(gas).getCorrectedVolume() " + + tempFluid.getPhase("gas").getCorrectedVolume()); + System.out.println("Stream 2 (results inside MPM) getPhase(oil).getCorrectedVolume() " + + tempFluid.getPhase("oil").getCorrectedVolume()); + + // GOR_via_corrected_volume and GOR_in_sm3_sm3 should not be so different ? return tempFluid.getPhase("gas").getCorrectedVolume() / tempFluid.getPhase("oil").getCorrectedVolume(); } else { diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java index 048449415f..e03b25f49a 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java @@ -54,9 +54,7 @@ public Stream() { * Constructor for Stream. *
* - * @param stream a - * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object + * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object */ @Deprecated public Stream(StreamInterface stream) { @@ -87,13 +85,12 @@ public Stream(String name) { /** * Constructor for Stream. * - * @param name name of stream + * @param name name of stream * @param stream input stream */ public Stream(String name, StreamInterface stream) { this(name); this.setStream(stream); - thermoSystem = stream.getThermoSystem(); numberOfStreams++; streamNumber = numberOfStreams; } @@ -103,7 +100,7 @@ public Stream(String name, StreamInterface stream) { * Constructor for Stream. * * - * @param name a {@link java.lang.String} object + * @param name a {@link java.lang.String} object * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object */ public Stream(String name, SystemInterface thermoSystem) { @@ -138,12 +135,12 @@ public void setGasQuality(double gasQuality) { /** {@inheritDoc} */ @Override public double getHydrateEquilibriumTemperature() { - if (!thermoSystem.getPhase(0).hasComponent("water")) { + if (!getFluid().getPhase(0).hasComponent("water")) { System.out.println("ny hydrate: no water in stream: " + name); return 0.0; } try { - SystemInterface copySystem = thermoSystem.clone(); + SystemInterface copySystem = getFluid().clone(); copySystem.setHydrateCheck(true); ThermodynamicOperations thermoOps = new ThermodynamicOperations(copySystem); thermoOps.hydrateFormationTemperature(); @@ -163,7 +160,7 @@ public double getHydrateEquilibriumTemperature() { * @return a double */ public double getSolidFormationTemperature(String solidName) { - SystemInterface copySystem = thermoSystem.clone(); + SystemInterface copySystem = getFluid().clone(); try { if (solidName.equals("hydrate")) { @@ -195,14 +192,18 @@ public Stream clone() { if (stream != null) { clonedSystem.setStream((Stream) stream.clone()); } - clonedSystem.thermoSystem = getThermoSystem().clone(); + if (thermoSystem != null) { + clonedSystem.thermoSystem = thermoSystem.clone(); + } + + return clonedSystem; } /** {@inheritDoc} */ @Override public double getTemperature() { - return thermoSystem.getTemperature(); + return getFluid().getTemperature(); } /** {@inheritDoc} */ @@ -214,7 +215,7 @@ public double getTemperature(String unit) { /** {@inheritDoc} */ @Override public double getPressure() { - return thermoSystem.getPressure(); + return getFluid().getPressure(); } /** {@inheritDoc} */ @@ -226,23 +227,27 @@ public double getPressure(String unit) { /** {@inheritDoc} */ @Override public double getMolarRate() { - return thermoSystem.getTotalNumberOfMoles(); + return getFluid().getTotalNumberOfMoles(); } /** {@inheritDoc} */ @Override public void setThermoSystem(SystemInterface thermoSystem) { - this.thermoSystem = thermoSystem; - // TODO: when is stream not null? if (stream != null) { stream.setThermoSystem(thermoSystem); + } else { + this.thermoSystem = thermoSystem; } } /** {@inheritDoc} */ @Override public void setFluid(SystemInterface fluid) { - this.setThermoSystem(fluid); + if (stream != null) { + stream.setFluid(fluid); + } else { + this.setThermoSystem(fluid); + } } /** {@inheritDoc} */ @@ -255,7 +260,8 @@ public void setThermoSystemFromPhase(SystemInterface thermoSystem, String phaseT } else if (thermoSystem.hasPhaseType("oil")) { this.thermoSystem = thermoSystem.phaseToSystem(thermoSystem.getPhaseNumberOfPhase("oil")); } else if (thermoSystem.hasPhaseType("aqueous")) { - this.thermoSystem = thermoSystem.phaseToSystem(thermoSystem.getPhaseNumberOfPhase("aqueous")); + this.thermoSystem = + thermoSystem.phaseToSystem(thermoSystem.getPhaseNumberOfPhase("aqueous")); } else { System.out.println("no phase of type " + phaseTypeName); System.out.println("...returning empty system "); @@ -282,13 +288,13 @@ public void setEmptyThermoSystem(SystemInterface thermoSystem) { /** {@inheritDoc} */ @Override public SystemInterface getThermoSystem() { - return this.thermoSystem; + return this.getFluid(); } /** {@inheritDoc} */ @Override public void setFlowRate(double flowrate, String unit) { - this.getFluid().setTotalFlowRate(flowrate, unit); + getFluid().setTotalFlowRate(flowrate, unit); } /** {@inheritDoc} */ @@ -307,12 +313,15 @@ public void setTemperature(double temperature, String unit) { @Override public void runTPflash() { if (stream != null) { - thermoSystem = this.stream.getThermoSystem().clone(); + thermoSystem = stream.getThermoSystem().clone(); } ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); thermoOps.TPflash(); thermoSystem.initProperties(); + if (stream != null) { + stream.setFluid(thermoSystem); + } } /** {@inheritDoc} */ @@ -336,12 +345,11 @@ public boolean needRecalculation() { @Override public void run(UUID id) { // System.out.println("start flashing stream... " + streamNumber); - if (stream != null) { - thermoSystem = this.stream.getThermoSystem().clone(); - } + thermoSystem = getFluid().clone(); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); - if (stream != null && getThermoSystem().getNumberOfComponents() == 1 + if (stream != null && thermoSystem.getNumberOfComponents() == 1 && getSpecification().equals("TP")) { setSpecification("PH"); } @@ -368,7 +376,8 @@ && getSpecification().equals("TP")) { double gasEnthalpy = thermoSystem.getPhase(0).getEnthalpy(); double liquidEnthalpy = thermoSystem.getPhase(1).getEnthalpy(); - double enthalpySpec = getGasQuality() * gasEnthalpy + (1.0 - getGasQuality()) * liquidEnthalpy; + double enthalpySpec = + getGasQuality() * gasEnthalpy + (1.0 - getGasQuality()) * liquidEnthalpy; thermoOps.PHflash(enthalpySpec); } catch (Exception ex) { logger.error(ex.getMessage(), ex); @@ -390,7 +399,7 @@ && getSpecification().equals("TP")) { } } else if (getSpecification().equals("PH")) { try { - thermoOps.PHflash(getThermoSystem().getEnthalpy(), 0); + thermoOps.PHflash(thermoSystem.getEnthalpy(), 0); } catch (Exception ex) { logger.error(ex.getMessage(), ex); thermoOps.TPflash(); @@ -401,10 +410,13 @@ && getSpecification().equals("TP")) { thermoSystem.initProperties(); - lastFlowRate = getFluid().getFlowRate("kg/hr"); - lastTemperature = getFluid().getTemperature(); - lastPressure = getFluid().getPressure(); + lastFlowRate = thermoSystem.getFlowRate("kg/hr"); + lastTemperature = thermoSystem.getTemperature(); + lastPressure = thermoSystem.getPressure(); + if (stream != null) { + stream.setFluid(thermoSystem); + } // System.out.println("number of phases: " + thermoSystem.getNumberOfPhases()); // System.out.println("beta: " + thermoSystem.getBeta()); setCalculationIdentifier(id); @@ -413,7 +425,7 @@ && getSpecification().equals("TP")) { /** {@inheritDoc} */ @Override public void displayResult() { - thermoSystem.display(name); + getFluid().display(name); } /** @@ -424,7 +436,7 @@ public void displayResult() { * @return an array of {@link java.lang.String} objects */ public String[][] getResultTable() { - return thermoSystem.getResultTable(); + return getFluid().getResultTable(); } /** {@inheritDoc} */ @@ -458,7 +470,7 @@ public void runController(double dt, UUID id) { /** {@inheritDoc} */ @Override public void flashStream() { - ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); + ThermodynamicOperations ops = new ThermodynamicOperations(getFluid()); ops.TPflash(); } @@ -468,7 +480,7 @@ public void flashStream() { * */ public void phaseEnvelope() { - SystemInterface localSyst = thermoSystem.clone(); + SystemInterface localSyst = getFluid().clone(); ThermodynamicOperations ops = new ThermodynamicOperations(localSyst); ops.setRunAsThread(true); ops.calcPTphaseEnvelope(true); @@ -480,7 +492,7 @@ public void phaseEnvelope() { /** {@inheritDoc} */ @Override public double CCB(String unit) { - SystemInterface localSyst = thermoSystem.clone(); + SystemInterface localSyst = getFluid().clone(); ThermodynamicOperations ops = new ThermodynamicOperations(localSyst); ops.setRunAsThread(true); ops.calcPTphaseEnvelope(true); @@ -501,7 +513,7 @@ public double CCB(String unit) { /** {@inheritDoc} */ @Override public double CCT(String unit) { - SystemInterface localSyst = thermoSystem.clone(); + SystemInterface localSyst = getFluid().clone(); ThermodynamicOperations ops = new ThermodynamicOperations(localSyst); ops.setRunAsThread(true); ops.calcPTphaseEnvelope(true); @@ -522,7 +534,7 @@ public double CCT(String unit) { /** {@inheritDoc} */ @Override public double TVP(double temperature, String unit) { - SystemInterface localSyst = thermoSystem.clone(); + SystemInterface localSyst = getFluid().clone(); localSyst.setTemperature(temperature, unit); ThermodynamicOperations ops = new ThermodynamicOperations(localSyst); try { @@ -535,7 +547,7 @@ public double TVP(double temperature, String unit) { /** {@inheritDoc} */ @Override public String[][] reportResults() { - return thermoSystem.getResultTable(); + return getFluid().getResultTable(); } /** @@ -544,9 +556,9 @@ public String[][] reportResults() { * * * @param propertyName a {@link java.lang.String} object - * @param unit a {@link java.lang.String} object - * @param phase a {@link java.lang.String} object - * @param component a {@link java.lang.String} object + * @param unit a {@link java.lang.String} object + * @param phase a {@link java.lang.String} object + * @param component a {@link java.lang.String} object * @return a {@link java.lang.Object} object */ public Object getProperty(String propertyName, String unit, String phase, String component) { @@ -560,7 +572,7 @@ public Object getProperty(String propertyName, String unit, String phase, String /** {@inheritDoc} */ @Override public double GCV() { - Standard_ISO6976 standard = new Standard_ISO6976(thermoSystem.clone(), 0, 15.55, "volume"); + Standard_ISO6976 standard = new Standard_ISO6976(getFluid().clone(), 0, 15.55, "volume"); standard.setReferenceState("real"); standard.calculate(); return standard.getValue("GCV") * 1.0e3; @@ -569,7 +581,7 @@ public double GCV() { /** {@inheritDoc} */ @Override public double LCV() { - Standard_ISO6976 standard = new Standard_ISO6976(thermoSystem.clone(), 0, 15.55, "volume"); + Standard_ISO6976 standard = new Standard_ISO6976(getFluid().clone(), 0, 15.55, "volume"); standard.setReferenceState("real"); standard.calculate(); return standard.getValue("InferiorCalorificValue") * 1.0e3; @@ -580,12 +592,20 @@ public double LCV() { * Setter for the fieldstream
.
*
*
- * @param stream a
- * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface}
- * object
+ * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object
*/
public void setStream(StreamInterface stream) {
this.stream = stream;
}
+ /** {@inheritDoc} */
+ @Override
+ public SystemInterface getFluid() {
+ if (stream != null) {
+ return stream.getFluid();
+ } else {
+ return thermoSystem;
+ }
+ }
+
}
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java b/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java
index a1e971a96d..7960f74268 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java
@@ -33,7 +33,9 @@ public class GORfitter extends TwoPortEquipment {
@Deprecated
/**
- * Constructor for GORfitter.
+ *+ * Constructor for GORfitter. + *
*/ public GORfitter() { super("GOR fitter"); @@ -64,7 +66,9 @@ public GORfitter(String name, StreamInterface stream) { } /** - *getGFV.
+ *+ * getGFV. + *
* * @return a double */ @@ -211,6 +215,7 @@ public void run(UUID id) { } catch (Exception ex) { logger.error(ex.getMessage(), ex); } + tempFluid.initProperties(); outStream.setThermoSystem(tempFluid); if (!tempFluid.hasPhaseType("gas")) { GVF = 0.0; @@ -262,7 +267,9 @@ public void setGVF(double gvf) { } /** - *Getter for the field referenceConditions
.
+ * Getter for the field referenceConditions
.
+ *
Setter for the field referenceConditions
.
+ * Setter for the field referenceConditions
.
+ *
isFitAsGVF.
+ *+ * isFitAsGVF. + *
* * @return the fitAsGVF */ @@ -289,7 +300,9 @@ public boolean isFitAsGVF() { } /** - *Setter for the field fitAsGVF
.
+ * Setter for the field fitAsGVF
.
+ *