Skip to content

Commit

Permalink
Bug mpm returns incorrect value (#917)
Browse files Browse the repository at this point in the history
* bug: MPM returns incorrect value

* bug fix suggestion.

Bug had to do when we create a stream from another stream (as we do for stream2). Then we set temperature and pressure on it - but it does not set it on the correct stream

* added init properties

* bug fix

* update

* fix bug

* new fix

---------

Co-authored-by: Sviatoslav Eroshkin <[email protected]>
  • Loading branch information
EvenSol and Sviatose authored Feb 16, 2024
1 parent 449219b commit b3f1611
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
Loading

0 comments on commit b3f1611

Please sign in to comment.