Skip to content

Commit

Permalink
refact: get phase using phasetype, AQUEOUS
Browse files Browse the repository at this point in the history
  • Loading branch information
asmfstatoil committed Feb 27, 2024
1 parent a8904b1 commit 77b36e0
Show file tree
Hide file tree
Showing 30 changed files with 503 additions and 470 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import neqsim.statistics.parameterFitting.SampleSet;
import neqsim.statistics.parameterFitting.SampleValue;
import neqsim.statistics.parameterFitting.nonLinearParameterFitting.LevenbergMarquardt;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;

Expand Down Expand Up @@ -131,7 +132,7 @@ public void runCalc() {
}
if (getThermoSystem().hasPhaseType("aqueous")) {
aqueousDensity[i] =
getThermoSystem().getPhase("aqueous").getPhysicalProperties().getViscosity();
getThermoSystem().getPhase(PhaseType.AQUEOUS).getPhysicalProperties().getViscosity();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import neqsim.statistics.parameterFitting.SampleSet;
import neqsim.statistics.parameterFitting.SampleValue;
import neqsim.statistics.parameterFitting.nonLinearParameterFitting.LevenbergMarquardt;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;

Expand Down Expand Up @@ -129,7 +130,7 @@ public void runCalc() {
}
if (getThermoSystem().hasPhaseType("aqueous")) {
aqueousViscosity[i] =
getThermoSystem().getPhase("aqueous").getPhysicalProperties().getViscosity();
getThermoSystem().getPhase(PhaseType.AQUEOUS).getPhysicalProperties().getViscosity();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import neqsim.statistics.parameterFitting.SampleSet;
import neqsim.statistics.parameterFitting.SampleValue;
import neqsim.statistics.parameterFitting.nonLinearParameterFitting.LevenbergMarquardt;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;

Expand Down Expand Up @@ -141,7 +142,7 @@ public void runCalc() {
}
if (getThermoSystem().hasPhaseType("aqueous")) {
aqueousViscosity[i] =
getThermoSystem().getPhase("aqueous").getPhysicalProperties().getViscosity();
getThermoSystem().getPhase(PhaseType.AQUEOUS).getPhysicalProperties().getViscosity();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import neqsim.fluidMechanics.flowNode.twoPhaseNode.TwoPhaseFlowNode;
import neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface;
import neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

Expand Down Expand Up @@ -180,7 +181,7 @@ public static void main(String[] args) {
k++;
test.display("length " + length);
System.out.println("length " + length + " wt% MEG "
+ test.getBulkSystem().getPhase("aqueous").getWtFrac("MEG") * 100.0);
+ test.getBulkSystem().getPhase(PhaseType.AQUEOUS).getWtFrac("MEG") * 100.0);
// test.getBulkSystem().display("length " + length);
// test.getInterphaseSystem().display("length " + length);
// test.getFluidBoundary().display("length " + length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.apache.logging.log4j.Logger;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

Expand Down Expand Up @@ -192,7 +193,7 @@ public double getMeasuredValue(String measurement, String unit) {
return Double.NaN;
}
tempFluid.initPhysicalProperties("density");
return tempFluid.getPhase("aqueous").getFlowRate(unit);
return tempFluid.getPhase(PhaseType.AQUEOUS).getFlowRate(unit);
}
if (measurement.equals("gasDensity") || measurement.equals("oilDensity")
|| measurement.equals("waterDensity")) {
Expand Down Expand Up @@ -225,7 +226,7 @@ public double getMeasuredValue(String measurement, String unit) {
if (!tempFluid.hasPhaseType("aqueous")) {
return 0.0;
} else {
return tempFluid.getPhase("aqueous").getDensity("kg/m3");
return tempFluid.getPhase(PhaseType.AQUEOUS).getDensity("kg/m3");
}
}
return 0.0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package neqsim.processSimulation.measurementDevice;

import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

Expand Down Expand Up @@ -92,7 +93,7 @@ public double getMeasuredValue(String unit) {
}
thermoOps = new ThermodynamicOperations(reactiveThermoSystem);
thermoOps.TPflash();
return reactiveThermoSystem.getPhase("aqueous").getpH();
return reactiveThermoSystem.getPhase(PhaseType.AQUEOUS).getpH();
} else {
System.out.println("no aqueous phase for pH analyser");
return 7.0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package neqsim.processSimulation.measurementDevice.simpleFlowRegime;

import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

Expand Down Expand Up @@ -42,8 +43,8 @@ public class FluidSevereSlug {
}
if (fluid.hasPhaseType("aqueous")) {
phaseNumber = fluid.getPhaseNumberOfPhase("aqueous");
waterDensity = fluid.getPhase("aqueous").getDensity("kg/m3");
waterViscosity = fluid.getPhase("aqueous").getViscosity("kg/msec");
waterDensity = fluid.getPhase(PhaseType.AQUEOUS).getDensity("kg/m3");
waterViscosity = fluid.getPhase(PhaseType.AQUEOUS).getViscosity("kg/msec");
waterWtFraction = fluid.getWtFraction(phaseNumber) * 100;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;
import neqsim.util.unit.PressureUnit;
Expand Down Expand Up @@ -368,7 +369,8 @@ public void setReservoirFluid(SystemInterface thermoSystem, double gasVolume, do
public void run(UUID id) {
// System.out.println("gas volume " + thermoSystem.getPhase("gas").getVolume("m3"));
// System.out.println("oil volume " + thermoSystem.getPhase("oil").getVolume("m3"));
// System.out.println("water volume " + thermoSystem.getPhase("aqueous").getVolume("m3"));
// System.out.println("water volume " +
// thermoSystem.getPhase(PhaseType.AQUEOUS).getVolume("m3"));

for (int i = 0; i < gasProducer.size(); i++) {
gasProducer.get(i).getStream().run(id);
Expand Down Expand Up @@ -536,7 +538,7 @@ public void runTransient(double dt, UUID id) {
* thermoSystem.getPhase("gas").getVolume("m3")); if (thermoSystem.hasPhaseType("oil"))
* System.out.println("oil volume " + thermoSystem.getPhase("oil").getVolume("m3")); if
* (thermoSystem.hasPhaseType("aqueous")) System.out.println("water volume " +
* thermoSystem.getPhase("aqueous").getVolume("m3"));
* thermoSystem.getPhase(PhaseType.AQUEOUS).getVolume("m3"));
*/
// System.out.println("pressure " + thermoSystem.getPressure("bara"));

Expand All @@ -557,7 +559,7 @@ public void runTransient(double dt, UUID id) {
/*
* if(thermoSystem.hasPhaseType("aqueous")) { for (int k = 0; k < waterInjector.size(); k++) {
* waterInjector.get(k).getStream().getFluid()
* .setMolarComposition(thermoSystem.getPhase("aqueous").getMolarComposition());
* .setMolarComposition(thermoSystem.getPhase(PhaseType.AQUEOUS).getMolarComposition());
* waterInjector.get(k).getStream().run(); }
*/
for (int k = 0; k < waterInjector.size(); k++) {
Expand All @@ -577,7 +579,7 @@ public void runTransient(double dt, UUID id) {

// getReservoirFluid().getPhase("gas").getVolume("m3")/1.0e6 + " oil volume "+
// getReservoirFluid().getPhase("oil").getVolume("m3")/1.0e6 + " water volume "+
// getReservoirFluid().getPhase("aqueous").getVolume("m3")/1.0e6);
// getReservoirFluid().getPhase(PhaseType.AQUEOUS).getVolume("m3")/1.0e6);
// oilOutStream.getFluid().setMolarComposition(thermoSystem.getPhase("oil").getMolarComposition());
// oilOutStream.run(id);

Expand Down Expand Up @@ -680,7 +682,7 @@ public static void main(String[] args) {
for (int i = 0; i < 1; i++) {
reservoirOps.runTransient(60 * 60 * 24 * 15);
System.out.println("water volume"
+ reservoirOps.getReservoirFluid().getPhase("aqueous").getVolume("m3") / 1.0e6);
+ reservoirOps.getReservoirFluid().getPhase(PhaseType.AQUEOUS).getVolume("m3") / 1.0e6);
System.out
.println("oil production total" + reservoirOps.getOilProductionTotal("Sm3") + " Sm3");
System.out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;
import neqsim.util.NamedBaseClass;
Expand Down Expand Up @@ -140,7 +141,7 @@ public double getStdWaterProduction() {
ops.TPflash();
double volume = 0;
if (locStream.hasPhaseType("aqueous")) {
volume = locStream.getPhase("aqueous").getVolume("m3");
volume = locStream.getPhase(PhaseType.AQUEOUS).getVolume("m3");
}
return volume;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void run(UUID id) {
thermoSystem = inletStreamMixer.getOutletStream().getThermoSystem().clone();

// double oilInWaterIn = 0.0001; //
// thermoSystem.getPhase("aqueous").getOilMolarConcentration();
// thermoSystem.getPhase(PhaseType.AQUEOUS).getOilMolarConcentration();
// double oilInWaterOut = 0.0;
double inPressure = thermoSystem.getPressure("bara");
underflowPressure = inPressure / 2.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import neqsim.processSimulation.processEquipment.separator.sectionType.ValveSection;
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

Expand Down Expand Up @@ -370,7 +371,7 @@ public void runTransient(double dt, UUID id) {
volumeLoc += thermoSystem.getPhase("oil").getVolume("m3");
}
if (thermoSystem.hasPhaseType("aqueous")) {
volumeLoc += thermoSystem.getPhase("aqueous").getVolume("m3");
volumeLoc += thermoSystem.getPhase(PhaseType.AQUEOUS).getVolume("m3");
}
liquidLevel = volumeLoc / (liquidVolume + gasVolume);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import neqsim.processSimulation.processEquipment.util.Adjuster;
import neqsim.processSimulation.processEquipment.valve.ThrottlingValve;
import neqsim.processSimulation.processSystem.ProcessSystem;
import neqsim.thermo.phase.PhaseType;

/**
* <p>
Expand Down Expand Up @@ -112,7 +113,7 @@ public static void main(String[] args) {
reservoirOps.run();

System.out.println("water volume"
+ reservoirOps.getReservoirFluid().getPhase("aqueous").getVolume("m3") / 1.0e6);
+ reservoirOps.getReservoirFluid().getPhase(PhaseType.AQUEOUS).getVolume("m3") / 1.0e6);
System.out
.println("oil production total" + reservoirOps.getOilProductionTotal("Sm3") + " Sm3");
System.out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,61 +1,68 @@
package neqsim.processSimulation.util.monitor;

import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.thermo.phase.PhaseType;

/**
* <p>StreamResponse class.</p>
* <p>
* StreamResponse class.
* </p>
*
* @author asmund
* @version $Id: $Id
*/
public class StreamResponse {
public String name;
public Fluid fluid;
public Double temperature;
public Double pressure;
public Double volumeFlow;
public Double molarMass;
public Double massDensity;
public Double massflow;
public Double massflowGas;
public Double massflowOil;
public Double massflowAqueous;
public String name;
public Fluid fluid;
public Double temperature;
public Double pressure;
public Double volumeFlow;
public Double molarMass;
public Double massDensity;
public Double massflow;
public Double massflowGas;
public Double massflowOil;
public Double massflowAqueous;

/**
* <p>Constructor for StreamResponse.</p>
*
* @param inputStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object
*/
public StreamResponse(StreamInterface inputStream){
name = inputStream.getName();
fluid = new Fluid(inputStream.getFluid());
temperature = inputStream.getTemperature("C");
pressure = inputStream.getPressure("bara");
molarMass = inputStream.getFluid().getMolarMass();
massDensity = inputStream.getFluid().getDensity("kg/m3");
massflow = inputStream.getFluid().getFlowRate("kg/hr");
volumeFlow = inputStream.getFluid().getFlowRate("m3/hr");
/**
* <p>
* Constructor for StreamResponse.
* </p>
*
* @param inputStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface}
* object
*/
public StreamResponse(StreamInterface inputStream) {
name = inputStream.getName();
fluid = new Fluid(inputStream.getFluid());
temperature = inputStream.getTemperature("C");
pressure = inputStream.getPressure("bara");
molarMass = inputStream.getFluid().getMolarMass();
massDensity = inputStream.getFluid().getDensity("kg/m3");
massflow = inputStream.getFluid().getFlowRate("kg/hr");
volumeFlow = inputStream.getFluid().getFlowRate("m3/hr");

if (inputStream.getFluid().hasPhaseType("gas")) {
massflowGas = inputStream.getFluid().getPhase("gas").getFlowRate("kg/hr");
} else {
massflowGas = 0.0;
}
if (inputStream.getFluid().hasPhaseType("aqueous")) {
massflowAqueous = inputStream.getFluid().getPhase("aqueous").getFlowRate("kg/hr");
} else {
massflowAqueous = 0.0;
}
if (inputStream.getFluid().hasPhaseType("oil")) {
massflowOil = inputStream.getFluid().getPhase("oil").getFlowRate("kg/hr");
} else {
massflowOil = 0.0;
}
if (inputStream.getFluid().hasPhaseType("gas")) {
massflowGas = inputStream.getFluid().getPhase("gas").getFlowRate("kg/hr");
} else {
massflowGas = 0.0;
}

/**
* <p>print.</p>
*/
public void print(){
if (inputStream.getFluid().hasPhaseType("aqueous")) {
massflowAqueous = inputStream.getFluid().getPhase(PhaseType.AQUEOUS).getFlowRate("kg/hr");
} else {
massflowAqueous = 0.0;
}
if (inputStream.getFluid().hasPhaseType("oil")) {
massflowOil = inputStream.getFluid().getPhase("oil").getFlowRate("kg/hr");
} else {
massflowOil = 0.0;
}
}

/**
* <p>
* print.
* </p>
*/
public void print() {}
}
2 changes: 1 addition & 1 deletion src/main/java/neqsim/thermo/ThermodynamicModelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public boolean checkFugacityCoefficients() {
// logger.info("Total fug gas : " + temp1);
// logger.info("Total fug liq : " + temp2);
// logger.info("MOLAR VOLUME 1 " + system.getPhase("gas").getMolarVolume());
// logger.info("MOLAR VOLUME 2 " + system.getPhase("aqueous").getMolarVolume());
// logger.info("MOLAR VOLUME 2 " + system.getPhase(PhaseType.AQUEOUS).getMolarVolume());
// logger.info("number of phases " + system.getNumberOfPhases());
// logger.info("number of components " + system.getNumberOfComponents());
// temp1 -= system.getPhase(j).getGresTP() / (R * system.getTemperature());
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/neqsim/thermo/util/empiric/DuanSun.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemElectrolyteCPAstatoil;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;
Expand Down Expand Up @@ -683,6 +684,7 @@ public static void main(String[] args) {
.println("CO2 in liquid " + fluid1.getPhase(0).getComponent(0).getLogFugacityCoefficient());
System.out
.println("CO2 in liquid " + fluid1.getPhase(0).getComponent(0).getFugacityCoefficient());
System.out.println("CO2 in liquid " + fluid1.getPhase("aqueous").getComponent("CO2").getx());
System.out
.println("CO2 in liquid " + fluid1.getPhase(PhaseType.AQUEOUS).getComponent("CO2").getx());
}
}
Loading

0 comments on commit 77b36e0

Please sign in to comment.