Skip to content

Commit

Permalink
Refact process simulation (#503)
Browse files Browse the repository at this point in the history
* refact: autoformatting and fixing style warnings
  • Loading branch information
asmfstatoil authored Jul 24, 2022
1 parent 6a490cd commit 612d650
Show file tree
Hide file tree
Showing 27 changed files with 841 additions and 854 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

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 Down Expand Up @@ -110,96 +109,96 @@ public double getMeasuredValue() {
}

/** {@inheritDoc} */
@Override
public double getMeasuredValue(String measurement) {
if (measurement.equals("mass rate")) {
return stream.getThermoSystem().getFlowRate("kg/hr");
@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);
tempFluid.setPressure(pressure, unitP);
ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid);
try {
thermoOps.TPflash();
} catch (Exception ex) {
logger.error(ex.getStackTrace());
return Double.NaN;
}
// tempFluid.display();
if (!tempFluid.hasPhaseType("gas")) {
return Double.NaN;
}
if (!tempFluid.hasPhaseType("oil")) {
return Double.NaN;
}
tempFluid.initPhysicalProperties("density");
return tempFluid.getPhase("gas").getCorrectedVolume()
/ tempFluid.getPhase("oil").getCorrectedVolume();
}
if (measurement.equals("gasDensity") || measurement.equals("oilDensity")
|| measurement.equals("waterDensity")) {
SystemInterface tempFluid = stream.getThermoSystem().clone();
tempFluid.setTemperature(temperature, unitT);
tempFluid.setPressure(pressure, unitP);
ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid);
try {
thermoOps.TPflash();
} catch (Exception ex) {
logger.error(ex.getStackTrace());
return Double.NaN;
}
tempFluid.initPhysicalProperties();
if (measurement.equals("gasDensity")) {
if (!tempFluid.hasPhaseType("gas")) {
return 0.0;
} else {
return tempFluid.getPhase("gas").getDensity("kg/m3");
}

if(stream.getThermoSystem().getFlowRate("kg/hr")<1e-10) {
return Double.NaN;
}
if (measurement.equals("oilDensity")) {
if (!tempFluid.hasPhaseType("oil")) {
return 0.0;
} else {
return tempFluid.getPhase("oil").getDensity("kg/m3");
}

if (measurement.equals("GOR")) {
SystemInterface tempFluid = stream.getThermoSystem().clone();
tempFluid.setTemperature(temperature, unitT);
tempFluid.setPressure(pressure, unitP);
ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid);
try {
thermoOps.TPflash();
} catch (Exception e) {
logger.error(e.getStackTrace());
return Double.NaN;
}
// tempFluid.display();
if (!tempFluid.hasPhaseType("gas")) {
return Double.NaN;
}
if (!tempFluid.hasPhaseType("oil")) {
return Double.NaN;
}
tempFluid.initPhysicalProperties("density");
return tempFluid.getPhase("gas").getCorrectedVolume()
/ tempFluid.getPhase("oil").getCorrectedVolume();
}
if (measurement.equals("waterDensity")) {
if (!tempFluid.hasPhaseType("aqueous")) {
return 0.0;
} else {
return tempFluid.getPhase("aqueous").getDensity("kg/m3");
}
if (measurement.equals("gasDensity") || measurement.equals("oilDensity")
|| measurement.equals("waterDensity")) {
SystemInterface tempFluid = stream.getThermoSystem().clone();
tempFluid.setTemperature(temperature, unitT);
tempFluid.setPressure(pressure, unitP);
ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid);
try {
thermoOps.TPflash();
} catch (Exception e) {
logger.error(e.getStackTrace());
return Double.NaN;
}
tempFluid.initPhysicalProperties();
if (measurement.equals("gasDensity")) {
if (!tempFluid.hasPhaseType("gas")) {
return 0.0;
} else {
return tempFluid.getPhase("gas").getDensity("kg/m3");
}
}
if (measurement.equals("oilDensity")) {
if (!tempFluid.hasPhaseType("oil")) {
return 0.0;
} else {
return tempFluid.getPhase("oil").getDensity("kg/m3");
}
}
if (measurement.equals("waterDensity")) {
if (!tempFluid.hasPhaseType("aqueous")) {
return 0.0;
} else {
return tempFluid.getPhase("aqueous").getDensity("kg/m3");
}
}
return 0.0;
} else if (measurement.equals("GOR_std")) {
SystemInterface tempFluid = stream.getThermoSystem().clone();
tempFluid.setTemperature(15.0, "C");
tempFluid.setPressure(1.01325, "bara");
ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid);
try {
thermoOps.TPflash();
} catch (Exception e) {
logger.error(e.getStackTrace());
return Double.NaN;
}
if (!tempFluid.hasPhaseType("gas")) {
return Double.NaN;
}
if (!tempFluid.hasPhaseType("oil")) {
return Double.NaN;
}
tempFluid.initPhysicalProperties("density");
return tempFluid.getPhase("gas").getCorrectedVolume()
/ tempFluid.getPhase("oil").getCorrectedVolume();
} else
return 0.0;
}
}
return 0.0;
} else if (measurement.equals("GOR_std")) {
SystemInterface tempFluid = stream.getThermoSystem().clone();
tempFluid.setTemperature(15.0, "C");
tempFluid.setPressure(1.01325, "bara");
ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid);
try {
thermoOps.TPflash();
} catch (Exception ex) {
logger.error(ex.getStackTrace());
return Double.NaN;
}
if (!tempFluid.hasPhaseType("gas")) {
return Double.NaN;
}
if (!tempFluid.hasPhaseType("oil")) {
return Double.NaN;
}
tempFluid.initPhysicalProperties("density");
return tempFluid.getPhase("gas").getCorrectedVolume()
/ tempFluid.getPhase("oil").getCorrectedVolume();
} else
return 0.0;
}

/**
* <p>
Expand Down
Loading

0 comments on commit 612d650

Please sign in to comment.