Skip to content

Commit

Permalink
update RVP calc (#1048)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol authored Jul 18, 2024
1 parent 26972e2 commit 417fc8f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void calculate() {
TVP = this.thermoSystem.getPressure();
double liquidVolume = thermoSystem.getVolume();

this.thermoSystem.setPressure(0.9);
this.thermoSystem.setPressure(TVP * 0.9);
try {
this.thermoOps.TVflash(liquidVolume * 4.0);
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ public double solveQ() {
double oldPres = system.getPressure();
double nyPres = system.getPressure();
double iterations = 1;
double error = 100.0, errorOld = 1000.0;
do {
iterations++;
errorOld = error;
oldPres = nyPres;
system.init(3);
nyPres = oldPres - (iterations) / (iterations + 10.0) * calcdQdV() / calcdQdVV();
Expand All @@ -88,9 +90,11 @@ public double solveQ() {
}
system.setPressure(nyPres);
tpFlash.run();
// System.out.println(" dQdv " + calcdQdV() + " new pressure " + nyPres + " error " +
// Math.abs((nyPres-oldPres)/(nyPres)) + " numberofphases "+system.getNumberOfPhases());
} while (Math.abs((nyPres - oldPres) / (nyPres)) > 1e-9 && iterations < 1000 || iterations < 3);
// System.out.println(" dQdv " + calcdQdV() + " new pressure " + nyPres + " error "
// + Math.abs((nyPres - oldPres) / (nyPres)) + " numberofphases "
// + system.getNumberOfPhases());
error = Math.abs(calcdQdV());
} while (Math.abs(error) > 1e-9 && iterations < 200 && error < errorOld || iterations < 3);
return nyPres;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,34 @@ void testCalculate() {
SystemInterface testSystem = new SystemSrkEos(273.15 + 2.0, 1.0);
testSystem.addComponent("methane", 0.0006538);
testSystem.addComponent("ethane", 0.006538);
testSystem.addComponent("propane", 0.006538);
testSystem.addComponent("propane", 0.06538);
testSystem.addComponent("n-pentane", 0.1545);
testSystem.addComponent("nC10", 0.545);
testSystem.setMixingRule(2);
testSystem.init(0);
Standard_ASTM_D6377 standard = new Standard_ASTM_D6377(testSystem);
standard.setReferenceTemperature(37.8, "C");
standard.calculate();
Assertions.assertEquals(0.94552559993, standard.getValue("RVP", "bara"), 1e-3);
Assertions.assertEquals(1.666298367, standard.getValue("TVP", "bara"), 1e-3);
}

@Test
void testCalculate2() {
SystemInterface testSystem = new SystemSrkEos(273.15 + 2.0, 1.0);
testSystem.addComponent("methane", 0.026538);
testSystem.addComponent("ethane", 0.16538);
testSystem.addComponent("propane", 0.26538);
testSystem.addComponent("n-pentane", 0.545);
testSystem.addComponent("nC10", 0.545);
testSystem.addTBPfraction("C11", 0.545, 145.0 / 1000.0, 0.82);
testSystem.setMixingRule(2);
testSystem.init(0);
testSystem.setPressure(100.0);
Standard_ASTM_D6377 standard = new Standard_ASTM_D6377(testSystem);
standard.setReferenceTemperature(37.8, "C");
standard.calculate();
//Assertions.assertEquals(0.7298246193, standard.getValue("RVP", "bara"), 1e-3);
Assertions.assertEquals(1.8710732396722, standard.getValue("TVP", "bara"), 1e-3);
Assertions.assertEquals(3.017010, standard.getValue("RVP", "bara"), 1e-3);
Assertions.assertEquals(7.8448385024, standard.getValue("TVP", "bara"), 1e-3);
}
}

0 comments on commit 417fc8f

Please sign in to comment.