Skip to content

Commit

Permalink
feat: use defined constant values (#825)
Browse files Browse the repository at this point in the history
* refact: use defined constant values for atmospheric pressure 
* refact: use defined constant value for R
style / docfix
---------

Co-authored-by: Even Solbraa <41290109+EvenSol@users.noreply.github.com>
  • Loading branch information
asmfstatoil and EvenSol authored Nov 13, 2023
1 parent 0c9f2bc commit 94f14e4
Show file tree
Hide file tree
Showing 95 changed files with 873 additions and 769 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.ThermodynamicConstantsInterface;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;

Expand Down Expand Up @@ -152,7 +153,8 @@ public void runCalc() {
gasVolume[i] = getThermoSystem().getPhase(0).getNumberOfMolesInPhase()
* getThermoSystem().getPhase(0).getMolarMass() / density[i]; // getThermoSystem().getPhase(0).getVolume();
gasStandardVolume[i] = getThermoSystem().getPhase(0).getVolume()
* getThermoSystem().getPhase(0).getPressure() / 1.01325
* getThermoSystem().getPhase(0).getPressure()
/ ThermodynamicConstantsInterface.referencePressure
/ getThermoSystem().getPhase(0).getZ() * 288.15 / getThermoSystem().getTemperature();
Bg[i] = gasVolume[i] * 1e5 / gasStandardVolume[i];
Zgas[i] = getThermoSystem().getPhase(0).getZ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;

Expand Down Expand Up @@ -125,7 +126,8 @@ public void runCalc() {
}
}
gasStandardVolume[i] = getThermoSystem().getPhase(0).getVolume()
* getThermoSystem().getPhase(0).getPressure() / 1.01325
* getThermoSystem().getPhase(0).getPressure()
/ ThermodynamicConstantsInterface.referencePressure
/ getThermoSystem().getPhase(0).getZ() * 288.15 / getThermoSystem().getTemperature();
totalGasStandardVolume += getGasStandardVolume()[i];
// if (totalVolume[i] > saturationVolume) {
Expand Down Expand Up @@ -168,7 +170,7 @@ public void runCalc() {
}
}
}
getThermoSystem().setPressure(1.01325);
getThermoSystem().setPressure(ThermodynamicConstantsInterface.referencePressure);
getThermoSystem().setTemperature(288.15);
try {
thermoOps.TPflash();
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/neqsim/PVTsimulation/simulation/GOR.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package neqsim.PVTsimulation.simulation;

import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;
Expand Down Expand Up @@ -70,14 +71,15 @@ public void runCalc() {
}
if (getThermoSystem().getNumberOfPhases() > 1
&& getThermoSystem().getPhase(0).getType() == PhaseType.GAS) {
getThermoSystem().getPhase(0).setPressure(1.01325);
getThermoSystem().getPhase(0)
.setPressure(ThermodynamicConstantsInterface.referencePressure);
getThermoSystem().getPhase(0).setTemperature(288.15);
getThermoSystem().init(1);
Sm3gas[i] = getThermoSystem().getPhase(0).getVolume();
// setThermoSystem(getThermoSystem().phaseToSystem(1));
}
}
getThermoSystem().setPressure(1.01325);
getThermoSystem().setPressure(ThermodynamicConstantsInterface.referencePressure);
getThermoSystem().setTemperature(288.15);
thermoOps.TPflash();
oilVolumeStdCond = getThermoSystem().getPhase("oil").getVolume();
Expand Down Expand Up @@ -130,7 +132,8 @@ public static void main(String[] args) {

GOR sepSim = new GOR(tempSystem);
double[] temps = {313.15, 313.15, 313.15, 313.15, 313.15, 313.15, 313.15};
double[] pres = {500, 400, 200, 100, 50.0, 5.0, 1.01325};
double[] pres =
{500, 400, 200, 100, 50.0, 5.0, ThermodynamicConstantsInterface.referencePressure};
sepSim.setTemperaturesAndPressures(temps, pres);
sepSim.runCalc();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,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.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;
Expand Down Expand Up @@ -70,14 +71,15 @@ public void runCalc() {
}
if (getThermoSystem().getNumberOfPhases() > 1
&& getThermoSystem().getPhase(0).getType() == PhaseType.GAS) {
getThermoSystem().getPhase(0).setPressure(1.01325);
getThermoSystem().getPhase(0)
.setPressure(ThermodynamicConstantsInterface.referencePressure);
getThermoSystem().getPhase(0).setTemperature(288.15);
getThermoSystem().init(1);
Sm3gas[i] = getThermoSystem().getPhase(0).getVolume();
setThermoSystem(getThermoSystem().phaseToSystem(1));
}
}
getThermoSystem().setPressure(1.01325);
getThermoSystem().setPressure(ThermodynamicConstantsInterface.referencePressure);
getThermoSystem().setTemperature(288.15);
thermoOps.TPflash();
oilVolumeStdCond = getThermoSystem().getPhase("oil").getVolume();
Expand Down Expand Up @@ -130,7 +132,8 @@ public static void main(String[] args) {

SeparatorTest sepSim = new SeparatorTest(tempSystem);
double[] temps = {313.15, 313.15, 313.15, 313.15, 313.15, 313.15, 313.15};
double[] pres = {500, 400, 200, 100, 50.0, 5.0, 1.01325};
double[] pres =
{500, 400, 200, 100, 50.0, 5.0, ThermodynamicConstantsInterface.referencePressure};
sepSim.setSeparatorConditions(temps, pres);
sepSim.runCalc();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;
import neqsim.thermodynamicOperations.ThermodynamicOperations;
Expand Down Expand Up @@ -38,7 +39,7 @@ public SlimTubeSim(SystemInterface tempSystem, SystemInterface injectionGas) {
public void run() {
slimTubeNodeSystem = new SystemInterface[numberOfSlimTubeNodes + 1];

getThermoSystem().setPressure(1.01325);
getThermoSystem().setPressure(ThermodynamicConstantsInterface.referencePressure);
getThermoSystem().setTemperature(288.15);
thermoOps.TPflash();

Expand Down Expand Up @@ -162,7 +163,8 @@ public void run() {
* slimTubeNodeSystem[numberOfSlimTubeNodes].getNumberOfMoles());
*/
slimTubeNodeSystem[numberOfSlimTubeNodes].setTemperature(288.15);
slimTubeNodeSystem[numberOfSlimTubeNodes].setPressure(1.01325);
slimTubeNodeSystem[numberOfSlimTubeNodes]
.setPressure(ThermodynamicConstantsInterface.referencePressure);
slimOps1.TPflash();

/*
Expand All @@ -183,7 +185,8 @@ public void run() {
}

slimTubeNodeSystem[numberOfSlimTubeNodes].setTemperature(288.15);
slimTubeNodeSystem[numberOfSlimTubeNodes].setPressure(1.01325);
slimTubeNodeSystem[numberOfSlimTubeNodes]
.setPressure(ThermodynamicConstantsInterface.referencePressure);
slimOps1.TPflash();

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package neqsim.chemicalReactions.chemicalEquilibriaum;

import Jama.Matrix;
import neqsim.thermo.ThermodynamicConstantsInterface;

/**
* <p>
Expand All @@ -14,7 +15,7 @@ public class ChemEq implements java.io.Serializable {
private static final long serialVersionUID = 1000;
int NSPEC = 10;
int NELE = 3;
double R = 8.3143;
double R = ThermodynamicConstantsInterface.R;
double G_min = 0;
double T = 3500;
double P = 51;
Expand Down
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 Jama.Matrix;
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.component.ComponentInterface;
import neqsim.thermo.system.SystemInterface;

Expand All @@ -24,7 +25,7 @@ public class ChemicalEquilibrium implements java.io.Serializable {
double d_n_t = 0;
int NSPEC = 2;
int NELE = 2;
double R = 8.314;
double R = ThermodynamicConstantsInterface.R;
Matrix x_solve;
double y_solve;
double n_t = 0.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundarySystem.FluidBoundarySystem;
import neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhasePipeFlowNode.StratifiedFlowNode;
import neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData;
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.system.SystemFurstElectrolyteEos;
import neqsim.thermo.system.SystemInterface;

Expand Down Expand Up @@ -58,7 +59,7 @@ public void createSystem() {
* @param args an array of {@link java.lang.String} objects
*/
public static void main(String[] args) {
SystemInterface testSystem = new SystemFurstElectrolyteEos(275.3, 1.01325);
SystemInterface testSystem = new SystemFurstElectrolyteEos(275.3, ThermodynamicConstantsInterface.referencePressure);
PipeData pipe1 = new PipeData(10.0, 0.025);

testSystem.addComponent("methane", 0.061152181, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundarySystem.FluidBoundarySystem;
import neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhasePipeFlowNode.StratifiedFlowNode;
import neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData;
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.system.SystemFurstElectrolyteEos;
import neqsim.thermo.system.SystemInterface;

Expand Down Expand Up @@ -65,7 +66,8 @@ public void createSystem() {
* @param args an array of {@link java.lang.String} objects
*/
public static void main(String[] args) {
SystemInterface testSystem = new SystemFurstElectrolyteEos(275.3, 1.01325);
SystemInterface testSystem =
new SystemFurstElectrolyteEos(275.3, ThermodynamicConstantsInterface.referencePressure);
PipeData pipe1 = new PipeData(10.0, 0.025);

testSystem.addComponent("methane", 0.061152181, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public FlowNodeInterface getNextNode() {
@SuppressWarnings("unused")
public static void main(String[] args) {
SystemInterface testSystem = new SystemSrkEos(273.15 + 40.0, 10.0);
// SystemInterface testSystem = new SystemSrkCPAstatoil(275.3, 1.01325);
// SystemInterface testSystem = new SystemSrkCPAstatoil(275.3,
// ThermodynamicConstantsInterface.referencePressure);
ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
PipeData pipe1 = new PipeData(0.203, 0.00025);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ public FlowNodeInterface getNextNode() {
@SuppressWarnings("unused")
public static void mainOld(String[] args) {
SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 11.0, 60.0);
// SystemInterface testSystem = new SystemSrkCPAstatoil(275.3, 1.01325);
// SystemInterface testSystem = new SystemSrkCPAstatoil(275.3,
// ThermodynamicConstantsInterface.referencePressure);
ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
PipeData pipe1 = new PipeData(0.203, 0.00025);

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.ThermodynamicConstantsInterface;
import neqsim.thermo.system.SystemFurstElectrolyteEos;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;
Expand Down Expand Up @@ -129,15 +130,16 @@ public FlowNodeInterface getNextNode() {
public static void main(String[] args) {
/*
* System.out.println("Starter....."); SystemSrkEos testSystem = new SystemSrkEos(275.3,
* 1.01325); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); PipeData
* pipe1 = new PipeData(10.0, 0.025);
* ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations testOps = new
* ThermodynamicOperations(testSystem); PipeData pipe1 = new PipeData(10.0, 0.025);
*
* testSystem.addComponent("methane", 0.011152181, 0); testSystem.addComponent("ethane",
* 0.00011152181, 0); testSystem.addComponent("water", 0.00462204876, 1);
* testSystem.addComponent("methane", 0.061152181, 0); testSystem.addComponent("water",
* 0.00862204876, 1);
*/
SystemInterface testSystem = new SystemFurstElectrolyteEos(275.3, 1.01325);
SystemInterface testSystem =
new SystemFurstElectrolyteEos(275.3, ThermodynamicConstantsInterface.referencePressure);
ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
PipeData pipe1 = new PipeData(10.0, 0.025);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ public void setDt(double dt) {
*/
@SuppressWarnings("unused")
public static void main(String[] args) {
// SystemInterface testSystem = new SystemFurstElectrolyteEos(275.3, 1.01325);
// SystemInterface testSystem = new SystemFurstElectrolyteEos(275.3,
// ThermodynamicConstantsInterface.referencePressure);
// SystemInterface testSystem = new SystemSrkEos(313.3, 70.01325);
SystemInterface testSystem = new SystemSrkCPAstatoil(313.3, 70.01325);
ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import neqsim.standards.gasQuality.Standard_ISO6578;
import neqsim.standards.gasQuality.Standard_ISO6976;
import neqsim.standards.gasQuality.Standard_ISO6976_2016;
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

Expand Down Expand Up @@ -407,7 +408,8 @@ public static void main(String[] args) {
// thermo.system.SystemInterface testSystem = new
// thermo.system.SystemGERG2004Eos(273.15 - 161.4, 1.0);
neqsim.thermo.system.SystemInterface testSystem =
new neqsim.thermo.system.SystemSrkEos(273.15 - 161.4, 1.013);
new neqsim.thermo.system.SystemSrkEos(273.15 - 161.4,
ThermodynamicConstantsInterface.referencePressure);
/*
* testSystem.addComponent("nitrogen", 0.0136); testSystem.addComponent("methane", 0.9186);
* testSystem.addComponent("ethane", 0.0526); testSystem.addComponent("propane", 0.0115);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package neqsim.physicalProperties.physicalPropertyMethods.commonPhasePhysicalProperties.conductivity;

import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;

Expand All @@ -15,7 +16,8 @@ public class PFCTConductivityMethodMod86 extends Conductivity {
private static final long serialVersionUID = 1000;

/** Constant <code>referenceSystem</code>. */
public static SystemInterface referenceSystem = new SystemSrkEos(273.0, 1.01325);
public static SystemInterface referenceSystem =
new SystemSrkEos(273.0, ThermodynamicConstantsInterface.referencePressure);
double[] GVcoef = {-2.147621e5, 2.190461e5, -8.618097e4, 1.496099e4, -4.730660e2, -2.331178e2,
3.778439e1, -2.320481, 5.311764e-2};
double condRefA = -0.25276292;
Expand Down Expand Up @@ -167,7 +169,8 @@ public double calcConductivity() {
T0 = 273.15;
}

double nstarRef = getRefComponentViscosity(T0, 1.01325);
double nstarRef =
getRefComponentViscosity(T0, ThermodynamicConstantsInterface.referencePressure);
double CpID = referenceSystem.getLowestGibbsEnergyPhase().getComponent(0).getCp0(T0);
double Ffunc = 1.0 + 0.053432 * redDens - 0.030182 * redDens * redDens
- 0.029725 * redDens * redDens * redDens;
Expand Down Expand Up @@ -261,7 +264,8 @@ public double getRefComponentViscosity(double temp, double pres) {
4.2903609488e-2, 1.4529023444e2, 6.1276818706e3};
// double viscRefK[] = {-9.74602, 18.0834, -4126.66, 44.6055, 0.9676544, 81.8134, 15649.9};

double molDens = 101325.0 / 8.315 / phase.getPhase().getTemperature() / 1.0e3;
double molDens = ThermodynamicConstantsInterface.atm / ThermodynamicConstantsInterface.R
/ phase.getPhase().getTemperature() / 1.0e3;
double critMolDens = 10.15;
double redMolDens = (molDens - critMolDens) / critMolDens;
double viscRefO = GVcoef[0] * Math.pow(temp, -1.0) + GVcoef[1] * Math.pow(temp, -2.0 / 3.0)
Expand Down Expand Up @@ -319,7 +323,8 @@ public double calcMixLPViscosity() {
* 1.304e-4 * (Math.pow(Mwtemp / Mmtemp, 2.303) - Math.pow(Mmtemp, 2.303))) * 1e3;
* //phase.getPhase().getMolarMass();
*/
double redDens = 101325 / 8.315 / phase.getPhase().getTemperature() / 1.0e3 / 10.15;
double redDens = 101325 / ThermodynamicConstantsInterface.R / phase.getPhase().getTemperature()
/ 1.0e3 / 10.15;
double alfa0 = 0.0;
double alfaMix = 0.0;
double[] alphai = new double[phase.getPhase().getNumberOfComponents()];
Expand All @@ -339,8 +344,8 @@ public double calcMixLPViscosity() {

double T0 = phase.getPhase().getTemperature()
* referenceSystem.getPhase(0).getComponent(0).getTC() / TCmix * alfaMix / alfa0;
double P0 =
1.01325 * referenceSystem.getPhase(0).getComponent(0).getPC() / PCmix * alfaMix / alfa0;
double P0 = ThermodynamicConstantsInterface.referencePressure
* referenceSystem.getPhase(0).getComponent(0).getPC() / PCmix * alfaMix / alfa0;

double refVisosity = getRefComponentViscosity(T0, P0);
double viscosity = refVisosity * Math.pow(TCmix / Tc0, -1.0 / 6.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package neqsim.physicalProperties.physicalPropertyMethods.commonPhasePhysicalProperties.viscosity;

import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;

Expand All @@ -21,7 +22,8 @@ public class PFCTViscosityMethod extends Viscosity {
private static final long serialVersionUID = 1000;

int phaseTypeNumb = 1;
SystemInterface referenceSystem = new SystemSrkEos(273.0, 1.01325);
SystemInterface referenceSystem =
new SystemSrkEos(273.0, ThermodynamicConstantsInterface.referencePressure);
double[] GVcoef = {-2.090975e5, 2.647269e5, -1.472818e5, 4.716740e4, -9.491872e3, 1.219979e3,
-9.627993e1, 4.274152, -8.141531e-2};
double visRefA = 1.696985927;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package neqsim.physicalProperties.physicalPropertyMethods.commonPhasePhysicalProperties.viscosity;

import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;

Expand All @@ -14,8 +15,10 @@
public class PFCTViscosityMethodHeavyOil extends Viscosity {
private static final long serialVersionUID = 1000;

// SystemInterface referenceSystem = new SystemBWRSEos(273.15, 1.01325);
SystemInterface referenceSystem = new SystemSrkEos(273.0, 1.01325);
// SystemInterface referenceSystem = new SystemBWRSEos(273.15,
// ThermodynamicConstantsInterface.referencePressure);
SystemInterface referenceSystem =
new SystemSrkEos(273.0, ThermodynamicConstantsInterface.referencePressure);
int phaseTypeNumb = 1;
double[] GVcoef = {-2.090975e5, 2.647269e5, -1.472818e5, 4.716740e4, -9.491872e3, 1.219979e3,
-9.627993e1, 4.274152, -8.141531e-2};
Expand Down
Loading

0 comments on commit 94f14e4

Please sign in to comment.