Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug in PC calculation for oil components and all tests #1076

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public double calcSurfaceTension(int interface1, int interface2) {
*/
public int getComponentWithHighestBoilingpoint() {
int compNumb = 0;
double boilPoint = -273.15;
double boilPoint = 0;
for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) {
if (system.getPhase(0).getComponent(i).getNormalBoilingPoint() > boilPoint) {
compNumb = i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public void removeTBPfraction() {
ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) {
double boilpoint = system.getPhase(0).getComponent(i).getNormalBoilingPoint();
if (boilpoint >= 69.0) {
if (boilpoint >= 273.15 + 69.0) {
list.add(system.getPhase(0).getComponent(i).getName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public boolean groupTBPfractions() {

for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) {
// if (system.getPhase(0).getComponent(i).getComponentType().equals("HC")) {
double boilpoint = system.getPhase(0).getComponent(i).getNormalBoilingPoint();
double boilpoint = system.getPhase(0).getComponent(i).getNormalBoilingPoint("C");

if (boilpoint >= 331.0) {
numb = 13;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public double calcPC(double molarMass, double density) {
TBPfractionCoefs = TBPfractionCoefsHeavyOil;
}

return 0.01325 + Math.exp(TBPfractionCoefs[1][0]
return Math.exp(0.01325 + TBPfractionCoefs[1][0]
+ TBPfractionCoefs[1][1] * Math.pow(density, TBPfractionCoefs[1][4])
+ TBPfractionCoefs[1][2] / molarMass + TBPfractionCoefs[1][3] / Math.pow(molarMass, 2.0));
}
Expand All @@ -173,26 +173,12 @@ public double calcm(double molarMass, double density) {

@Override
public double calcTB(double molarMass, double density) {
if (molarMass < 90) {
return 273.15 + 84;
}
if (molarMass < 107) {
return 273.15 + 116.6;
}
if (molarMass < 121) {
return 273.15 + 142.2;
}
if (molarMass < 134) {
return 273.15 + 165.8;
}
if (molarMass < 147) {
return 273.15 + 187.2;
}
if (molarMass < 161) {
return 273.15 + 208.3;
if (molarMass < 540) {
return 2E-06 * Math.pow(molarMass, 3) - 0.0035 * Math.pow(molarMass, 2) + 2.4003 * molarMass
+ 171.74;
} else {
return 97.58 * Math.pow(molarMass, 0.3323) * Math.pow(density, 0.04609);
}

return 97.58 * Math.pow(molarMass, 0.3323) * Math.pow(density, 0.04609);
}

@Override
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/neqsim/thermo/component/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,18 +287,18 @@ public void createComponent(String name, double moles, double molesInPhase, int
AntoineC = Double.parseDouble(dataSet.getString("ANTOINEC")); // AX
AntoineD = Double.parseDouble(dataSet.getString("ANTOINED"));
AntoineE = Double.parseDouble(dataSet.getString("ANTOINEE"));

normalBoilingPoint = Double.parseDouble(dataSet.getString("normboil")) + 273.15;
if (AntoineA == 0) {
AntoineA = 1.0;
AntoineB = getNormalBoilingPoint();
AntoineB = getNormalBoilingPoint() - 273.15;
}

AntoineASolid = Double.parseDouble(dataSet.getString("ANTOINESolidA"));
AntoineBSolid = Double.parseDouble(dataSet.getString("ANTOINESolidB"));
AntoineCSolid = Double.parseDouble(dataSet.getString("ANTOINESolidC"));

debyeDipoleMoment = Double.parseDouble(dataSet.getString("dipolemoment"));
normalBoilingPoint = Double.parseDouble(dataSet.getString("normboil"));

standardDensity = Double.parseDouble(dataSet.getString("stddens"));
viscosityCorrectionFactor = Double.parseDouble(dataSet.getString("viscfact")); // BC
racketZ = Double.parseDouble(dataSet.getString("racketZ")); // BE
Expand Down Expand Up @@ -1663,6 +1663,14 @@ public double getNormalBoilingPoint() {
return normalBoilingPoint;
}

/** {@inheritDoc} */
@Override
public double getNormalBoilingPoint(String unit) {
neqsim.util.unit.TemperatureUnit tempConversion =
new neqsim.util.unit.TemperatureUnit(getNormalBoilingPoint(), "K");
return tempConversion.getValue(unit);
}

/** {@inheritDoc} */
@Override
public void setNormalBoilingPoint(double normalBoilingPoint) {
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/neqsim/thermo/component/ComponentInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -921,16 +921,27 @@ public void Finit(PhaseInterface phase, double temperature, double pressure,
* Getter for property NormalBoilingPoint.
* </p>
*
* @return The normal boiling point of the component
* @return The normal boiling point of the component with unit Kelvin
*/
public double getNormalBoilingPoint();

/**
* <p>
* Getter for property NormalBoilingPoint.
* </p>
*
* @param unit Unit of return pressure
*
* @return The normal boiling point of the component
*/
public double getNormalBoilingPoint(String unit);

/**
* <p>
* setNormalBoilingPoint.
* </p>
*
* @param normalBoilingPoint a double
* @param normalBoilingPoint a double with unit Kelvin
*/
public void setNormalBoilingPoint(double normalBoilingPoint);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/neqsim/thermo/phase/Phase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1967,7 +1967,7 @@ public double[] groupTBPfractions() {
double[] TPBfrac = new double[20];

for (int i = 0; i < getNumberOfComponents(); i++) {
double boilpoint = getComponent(i).getNormalBoilingPoint();
double boilpoint = getComponent(i).getNormalBoilingPoint("C");

if (boilpoint >= 331.0) {
TPBfrac[19] += getComponent(i).getx();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/neqsim/thermo/system/SystemThermo.java
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo
getPhase(i).getComponent(componentName).setMolarMass(molarMass);
getPhase(i).getComponent(componentName).setComponentType("TBPfraction");
getPhase(i).getComponent(componentName).setNormalLiquidDensity(density);
getPhase(i).getComponent(componentName).setNormalBoilingPoint(TB - 273.15);
getPhase(i).getComponent(componentName).setNormalBoilingPoint(TB);
getPhase(i).getComponent(componentName)
.setAcentricFactor(refSystem.getPhase(0).getComponent(0).getAcentricFactor());
getPhase(i).getComponent(componentName).setCriticalVolume(critVol);
Expand Down Expand Up @@ -1086,7 +1086,7 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo
getPhase(i).getComponent(componentName).setMolarMass(molarMass);
getPhase(i).getComponent(componentName).setComponentType("TBPfraction");
getPhase(i).getComponent(componentName).setNormalLiquidDensity(density);
getPhase(i).getComponent(componentName).setNormalBoilingPoint(TB - 273.15);
getPhase(i).getComponent(componentName).setNormalBoilingPoint(TB);
getPhase(i).getComponent(componentName)
.setAcentricFactor(refSystem.getPhase(0).getComponent(0).getAcentricFactor());
getPhase(i).getComponent(componentName).setCriticalVolume(critVol);
Expand Down Expand Up @@ -2552,7 +2552,7 @@ public double[] getNormalBoilingPointTemperatures() {
double[] bt = new double[numberOfComponents];

for (int compNumb = 0; compNumb < numberOfComponents; compNumb++) {
bt[compNumb] = getPhase(0).getComponent(compNumb).getNormalBoilingPoint() + 273.15;
bt[compNumb] = getPhase(0).getComponent(compNumb).getNormalBoilingPoint();
}
return bt;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ void testRunCalc() {
assertEquals(2.1873758493453708E-4, CMEsim.getIsoThermalCompressibility()[0], 0.00001);
assertEquals(0.956122065, CMEsim.getRelativeVolume()[0], 0.001);
assertEquals(0.994254912, CMEsim.getRelativeVolume()[6], 0.001);
assertEquals(1.3486190, CMEsim.getRelativeVolume()[12], 0.001);
assertEquals(2.1400177022, CMEsim.getYfactor()[12], 0.001);
assertEquals(1.3572659252241415, CMEsim.getRelativeVolume()[12], 0.001);
assertEquals(2.153242696868525
, CMEsim.getYfactor()[12], 0.001);

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ void testRunCalc() {
new double[] {400, 300.0, 200.0, 100.0});
double[][] expData = {{0.95, 0.99, 1.0, 1.1}};
CVDsim.setExperimentalData(expData);
assertEquals(2.2458466, CVDsim.getRelativeVolume()[4], 0.001);
assertEquals(2.198101313307043

, CVDsim.getRelativeVolume()[4], 0.001);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,29 @@ void testRunCalc() {
SimulationInterface satPresSim = new SaturationPressure(tempSystem);
satPresSim.setTemperature(97.5, "C");
satPresSim.run();
assertEquals(190.7882175445, satPresSim.getThermoSystem().getPressure(), 0.1);
assertEquals(193.24093437194824, satPresSim.getThermoSystem().getPressure(), 0.1);
// tempSystem.prettyPrint();

double[] pressures = new double[] { 351.4, 323.2, 301.5, 275.9, 250.1, 226.1, 205.9, 179.1,
154.6, 132.1, 109.0, 78.6, 53.6, 22.0, 1.0 };
double[] pressures = new double[] {351.4, 323.2, 301.5, 275.9, 250.1, 226.1, 205.9, 179.1,
154.6, 132.1, 109.0, 78.6, 53.6, 22.0, 1.0};
DifferentialLiberation differentialLiberation = new DifferentialLiberation(tempSystem);
differentialLiberation.setPressures(pressures);
differentialLiberation.setTemperature(97.5, "C");
differentialLiberation.runCalc();

assertEquals(1.689644811955, differentialLiberation.getBo()[0], 0.001);
assertEquals(212.366545704, differentialLiberation.getRs()[0], 0.001);
assertEquals(677.27184, differentialLiberation.getOilDensity()[0], 0.001);
assertEquals(212.71942595049242
, differentialLiberation.getRs()[0], 0.001);
assertEquals(677.5970918499921
, differentialLiberation.getOilDensity()[0], 0.001);
assertEquals(1.7616805, differentialLiberation.getBo()[pressures.length - 9], 0.001);
assertEquals(1.312174206633, differentialLiberation.getBo()[pressures.length - 2], 0.001);
assertEquals(55.1339349, differentialLiberation.getRs()[pressures.length - 2], 0.001);
assertEquals(1.3111545517, differentialLiberation.getBo()[pressures.length - 2], 0.001);
assertEquals(55.10252632079461
, differentialLiberation.getRs()[pressures.length - 2], 0.001);
assertEquals(0.0556167850, differentialLiberation.getBg()[pressures.length - 2], 0.001);
assertEquals(1.0533007759, differentialLiberation.getBo()[pressures.length - 1], 0.001);
assertEquals(0.0, differentialLiberation.getRs()[pressures.length - 1], 0.001);
assertEquals(805.00070, differentialLiberation.getOilDensity()[pressures.length - 1], 0.001);
assertEquals(805.6468027140055
, differentialLiberation.getOilDensity()[pressures.length - 1], 0.001);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void testCalcSaturationTemperature() {

SimulationInterface satPresSim = new SaturationTemperature(tempSystem);
satPresSim.run();
assertEquals(tempSystem.getTemperature(), 380.3071922, 0.1);
assertEquals(tempSystem.getTemperature(), 380.127567672, 0.1);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ void testRunCalc() {
sepSim.setSeparatorConditions(temps, pres);
sepSim.runCalc();

assertEquals(1.1245991497229437, sepSim.getBofactor()[4], 0.0001);
assertEquals(1.1224612120760051, sepSim.getBofactor()[4], 0.0001);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void testRun() {
oilSystem.addTBPfraction("C17", 0.17, 234.0 / 1000.0, 0.84);
oilSystem.addTBPfraction("C18", 0.13, 251.0 / 1000.0, 0.844);
oilSystem.addTBPfraction("C19", 0.13, 270.0 / 1000.0, 0.854);
oilSystem.addPlusFraction("C20", 10.62, 381.0 / 1000.0, 0.88);
oilSystem.addPlusFraction("C20", 20.62, 381.0 / 1000.0, 0.88);
oilSystem.getCharacterization().characterisePlusFraction();
oilSystem.setMixingRule(2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ void testRunCalc() {
sepSim.setExperimentalData(expData);
// sepSim.runTuning();
sepSim.runCalc();
assertEquals(4.420762033045493E-4, sepSim.getOilViscosity()[0], 0.000001);
assertEquals(4.443002015621749E-4, sepSim.getOilViscosity()[0], 0.000001);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ void testRunCalc() {
double[] pres = {5, 5, 5.0, 5.0, 5.0, 5.0, 5.0};
sepSim.setTemperaturesAndPressures(temps, pres);
sepSim.runCalc();
assertEquals(0.2661032806907, sepSim.getThermoSystem().getPhaseFraction("wax", "mass"), 0.001);
assertEquals(0.2683853533110433, sepSim.getThermoSystem().getPhaseFraction("wax", "mass"),
0.001);
}

@Test
Expand All @@ -50,6 +51,7 @@ void testRunCalc2() {
sepSim.setTemperaturesAndPressures(temps, pres);
sepSim.runCalc();
NeqSimDataBase.setCreateTemporaryTables(false);
assertEquals(0.24679416544, sepSim.getThermoSystem().getPhaseFraction("wax", "mass"), 0.001);
assertEquals(0.24895564649970403, sepSim.getThermoSystem().getPhaseFraction("wax", "mass"),
0.001);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ void testRun2() {
for (int i = 0; i < 10; i++) {
reservoirOps.runTransient(deltaTime);
}
Assertions.assertEquals(352.274030, reservoirOps.getReservoirFluid().getPressure("bara"), 0.1);
Assertions.assertEquals(355.19330033985693
, reservoirOps.getReservoirFluid().getPressure("bara"), 0.1);
Assertions.assertEquals(11.698, reservoirOps.getWaterProdution("Sm3/day"), 0.1);

reservoirOps.setLowPressureLimit(52.0e5, "Pa");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ public void testreservoirTPsim() {
operations.add(reservoirGasTPsim);
operations.add(MPFMgas);
operations.run();
assertEquals(8760.096083, MPFMgas.getMeasuredValue("GOR_std", ""), 1.0);
assertEquals(8834.875493073961, MPFMgas.getMeasuredValue("GOR_std", ""), 1.0);

reservoirGasTPsim.setPressure(150.0, "bara");
operations.run();
assertEquals(14880.1810, MPFMgas.getMeasuredValue("GOR_std", ""), 1.0);
assertEquals(14937.606339690177
, MPFMgas.getMeasuredValue("GOR_std", ""), 1.0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ public void testProcess() {

operations.run();

assertEquals(2053.120373716, resycleScrubberStream.getFlowRate("kg/hr"), 0.1);
assertEquals(2046.8012652616517
, resycleScrubberStream.getFlowRate("kg/hr"), 0.1);

neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator =
new neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void runProcess() throws InterruptedException {

operations.run();

assertEquals(17195.25050, seprator3rdStage.getGasOutStream().getFlowRate("kg/hr"), 1.1);
assertEquals(17105.52983567356, seprator3rdStage.getGasOutStream().getFlowRate("kg/hr"), 1.1);

assertEquals(seprator3rdStage.getGasOutStream().getFlowRate("kg/hr"),
coolerLP.getOutletStream().getFlowRate("kg/hr"), 1e-4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ void testCalculate2() {
standard.setMethodRVP("VPCR4");
standard.setReferenceTemperature(37.8, "C");
standard.calculate();
Assertions.assertEquals(3.604002003478, standard.getValue("RVP", "bara"), 1e-3);
Assertions.assertEquals(7.8448385024, standard.getValue("TVP", "bara"), 1e-3);
Assertions.assertEquals(3.6145219653041623, standard.getValue("RVP", "bara"), 1e-3);
Assertions.assertEquals(7.867696779327479, standard.getValue("TVP", "bara"), 1e-3);

standard.setMethodRVP("RVP_ASTM_D6377");
standard.setReferenceTemperature(37.8, "C");
standard.calculate();
Assertions.assertEquals(3.00573767, standard.getValue("RVP", "bara"), 1e-3);
Assertions.assertEquals(7.8448385024, standard.getValue("TVP", "bara"), 1e-3);
Assertions.assertEquals(3.014511319063671, standard.getValue("RVP", "bara"), 1e-3);
Assertions.assertEquals(7.867696779327479
, standard.getValue("TVP", "bara"), 1e-3);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ void testPedersenSRKModel() {
SystemInterface thermoSystem = new SystemSrkEos(298.0, 10.0);
thermoSystem.getCharacterization().setTBPModel("PedersenSRK");
thermoSystem.addTBPfraction("C7", 1.0, 110.0 / 1000.0, 0.73);
assertEquals(554.3185637098962, thermoSystem.getComponent(0).getTC(), 1e-3);
assertEquals(26.007549082822628, thermoSystem.getComponent(0).getPC(), 1e-3);
assertEquals(281.1685637, thermoSystem.getComponent(0).getTC() - 273.15, 1e-3);
assertEquals(26.341015469211726
, thermoSystem.getComponent(0).getPC(), 1e-3);
assertEquals(0.508241, thermoSystem.getComponent(0).getAcentricFactor(), 1e-3);
assertEquals(384.6714299777243, thermoSystem.getComponent(0).getCriticalVolume(), 1e-3);
assertEquals(426.46717439, thermoSystem.getComponent(0).getCriticalVolume(), 1e-3);
assertEquals(122.93500, thermoSystem.getComponent(0).getNormalBoilingPoint("C"), 1e-3);
}

@Test
Expand All @@ -46,10 +48,9 @@ void testPedersenPRModel() {
thermoSystem.getCharacterization().setTBPModel("PedersenPR");
thermoSystem.addTBPfraction("C7", 1.0, 110.0 / 1000.0, 0.73);
assertEquals(560.546, thermoSystem.getComponent(0).getTC(), 1e-3);
assertEquals(25.838137535018557, thermoSystem.getComponent(0).getPC(), 1e-3);
assertEquals(26.16934428134274, thermoSystem.getComponent(0).getPC(), 1e-3);
assertEquals(0.3838836222383, thermoSystem.getComponent(0).getAcentricFactor(), 1e-3);
assertEquals(405.0890245138075, thermoSystem.getComponent(0).getCriticalVolume(), 1e-3);
assertEquals(444.07282144, thermoSystem.getComponent(0).getCriticalVolume(), 1e-3);
assertEquals(122.93500, thermoSystem.getComponent(0).getNormalBoilingPoint("C"), 1e-3);
}


}
2 changes: 1 addition & 1 deletion src/test/java/neqsim/thermo/system/SystemThermoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void testCp() {
ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
testOps.TPflash();
testSystem.initProperties();
assertEquals(2.0188664689245, testSystem.getPhase(1).getCp("kJ/kgK"), 1e-6);
assertEquals(2.00406932521, testSystem.getPhase(1).getCp("kJ/kgK"), 1e-6);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ void testRun6() {
testOps = new ThermodynamicOperations(testSystem5);
testOps.TPflash();
testSystem5.initProperties();
assertEquals(0.27697023508525664, testSystem5.getBeta(), 1e-6);
assertEquals(0.2838675588923609
, testSystem5.getBeta(), 1e-6);
assertEquals(3, testSystem5.getNumberOfPhases());
}

Expand Down
Loading