Skip to content

Commit

Permalink
update (#1176)
Browse files Browse the repository at this point in the history
* update

* updated test

* update

* update

* update

* update
  • Loading branch information
EvenSol authored Nov 12, 2024
1 parent c7d52cb commit 2c26392
Show file tree
Hide file tree
Showing 7 changed files with 432 additions and 205 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ public double solve(double xin) {
xNew2 = xNew;
}

if (xNew < 0) {
xNew = 0;
if (xNew < -0.99) {
xNew = -0.99;
// System.out.println("x++...........");
}
if (xNew > 1.5) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public void setm(double val) {
logger.info("does not solve for accentric when new m is set... in AccentricBase class");
}

/** {@inheritDoc} */
@Override
public double getm() {
return this.m;
}

/** {@inheritDoc} */
@Override
public AttractiveTermBaseClass clone() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,6 @@ public interface AttractiveTermInterface extends Cloneable, java.io.Serializable
* @return a {@link neqsim.thermo.component.attractiveeosterm.AttractiveTermInterface} object
*/
public AttractiveTermInterface clone();

public double getm();
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public void setm(double val) {
solve.setOrder(2);
double[] acentricConstants = {-0.176, 1.574, (0.48 - this.m)};
solve.setConstants(acentricConstants);
getComponent().setAcentricFactor(solve.solve(0.2));
// System.out.println("solve accen " + component.getAcentricFactor());
getComponent().setAcentricFactor(solve.solve(0.25));
System.out.println("solve accen " + getComponent().getAcentricFactor());
}

/** {@inheritDoc} */
Expand Down
402 changes: 202 additions & 200 deletions src/main/resources/data/COMP.csv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void testPedersenHeavyOilPlusModelCharacterization() {
ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem);
ops.TPflash();
// thermoSystem.prettyPrint();
assertEquals(0.767272255056255, thermoSystem.getBeta(), 1e-4);
assertEquals(0.779829948507504, thermoSystem.getBeta(), 1e-4);
}

@Test
Expand Down
217 changes: 217 additions & 0 deletions src/test/java/neqsim/thermo/system/AcidTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
package neqsim.thermo.system;

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import neqsim.thermo.component.ComponentSrkCPA;
import neqsim.thermo.phase.PhaseType;
import neqsim.thermodynamicoperations.ThermodynamicOperations;

public class AcidTest extends neqsim.NeqSimTest {

/**
* <p>
* testAcid.
* </p>
*/
@Test
@DisplayName("test equilibrium of formic acid")
public void testAcid() {
neqsim.thermo.system.SystemSrkCPAstatoil testSystem =
new neqsim.thermo.system.SystemSrkCPAstatoil(298.0, 10.0);
testSystem.addComponent("methane", 1.0, "kg/sec");
testSystem.addComponent("formic acid", 25.0, "kg/sec");
testSystem.addComponent("water", 100.0, "kg/sec");
testSystem.setMixingRule(10);
ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
testOps.TPflash();
testSystem.prettyPrint();
}

/**
* <p>
* testtestBubpAcid.
* </p>
*/
@Test
@DisplayName("test bublepoint of formic acid")
public void testtestBubpAcid() {
neqsim.thermo.system.SystemSrkCPAstatoil testSystem =
new neqsim.thermo.system.SystemSrkCPAstatoil(373.0, 1.3501325);
testSystem.addComponent("formic acid", 25.0, "kg/sec");
testSystem.setMixingRule(10);
ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
try {
testOps.bubblePointPressureFlash(false);
testSystem.initProperties();
} catch (Exception e) {
e.printStackTrace();
}

assertEquals(33.2215005, testSystem.getPressure(), 0.001);
assertEquals(928.60315, testSystem.getDensity("kg/m3"), 0.001);


double t = 373.0;
double vapp =
Math.exp(50.323 + -5378.2 / t + -4.2030 * Math.log(t) + 3.4697e-6 * Math.pow(t, 2)) / 1e5;

assertEquals(0.9857520491, vapp, 0.001);

double dens = 1.938 / (0.24225 * (1 + Math.pow(1 - t / 588, 0.24435)));// * 46.025;

// assertEquals(1002.54762, dens, 0.001);

String scheme =
testSystem.getPhase(PhaseType.AQUEOUS).getComponent("formic acid").getAssociationScheme();
double aCPA =
((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent("formic acid"))
.geta();
double bCPA =
((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent("formic acid"))
.getb();
double boundvol =
((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent("formic acid"))
.getAssociationVolume();
double assenergy =
((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent("formic acid"))
.getAssociationEnergy();
double m =
((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent("formic acid"))
.getAttractiveTerm().getm();
assertEquals("1A", scheme);
assertEquals(53663.0, aCPA);
assertEquals(3.0, bCPA);
assertEquals(0.0155, boundvol);
assertEquals(41917.0, assenergy);
assertEquals(0.3338, m);
testSystem.prettyPrint();
}


/**
* <p>
* testtestBubpAcid.
* </p>
*/
@Test
@DisplayName("test bublepoint of acetic acid")
public void testtestBubpAceticAcid() {
neqsim.thermo.system.SystemSrkCPAstatoil testSystem =
new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 117.9, 1.01325);
testSystem.addComponent("AceticAcid", 25.0, "kg/sec");
testSystem.setMixingRule(10);
ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
try {
testOps.bubblePointPressureFlash();
testSystem.initProperties();
} catch (Exception e) {
e.printStackTrace();
}

assertEquals(0.999088711628, testSystem.getPressure(), 0.001);
assertEquals(817.50556, testSystem.getDensity("kg/m3"), 0.001);


double t = 373.0;
double vapp =
Math.exp(50.323 + -5378.2 / t + -4.2030 * Math.log(t) + 3.4697e-6 * Math.pow(t, 2)) / 1e5;

assertEquals(0.9857520491, vapp, 0.001);

double dens = 1.938 / (0.24225 * (1 + Math.pow(1 - t / 588, 0.24435)));// * 46.025;

// assertEquals(1002.54762, dens, 0.001);

String scheme = testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0).getAssociationScheme();
double aCPA = ((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0)).geta();
double bCPA = ((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0)).getb();
double boundvol = ((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0))
.getAssociationVolume();
double assenergy = ((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0))
.getAssociationEnergy();
double m = ((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0))
.getAttractiveTerm().getm();
assertEquals("1A", scheme);
assertEquals(91195.7, aCPA);
assertEquals(4.6818, bCPA);
assertEquals(0.00452, boundvol);
assertEquals(40323.0, assenergy);
assertEquals(0.4644000000000, m, 0.0001);
testSystem.prettyPrint();
}

/**
* <p>
* testtestBubpAcid.
* </p>
*/
@Test
@DisplayName("test bublepoint of water")
public void testtestWater() {
neqsim.thermo.system.SystemSrkCPAstatoil testSystem =
new neqsim.thermo.system.SystemSrkCPAstatoil(398.0, 1.01325);
testSystem.addComponent("water", 25.0, "kg/sec");
testSystem.setMixingRule(10);
ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
try {
testOps.bubblePointTemperatureFlash();
} catch (Exception e) {
e.printStackTrace();
}

String scheme = testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0).getAssociationScheme();
double aCPA = ((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0)).geta();
double bCPA = ((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0)).getb();
double boundvol = ((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0))
.getAssociationVolume();
double assenergy = ((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0))
.getAssociationEnergy();
double m = ((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0))
.getAttractiveTerm().getm();
assertEquals("4C", scheme);
assertEquals(12277.0, aCPA);
assertEquals(1.4515, bCPA);
assertEquals(0.0692, boundvol);
assertEquals(16655.0, assenergy);
assertEquals(.6735900000000007, m, 0.00001);
testSystem.prettyPrint();
}

/**
* <p>
* testtestBubpAcid.
* </p>
*/
@Test
@DisplayName("test bublepoint of MEG")
public void testtestMEG() {
neqsim.thermo.system.SystemSrkCPAstatoil testSystem =
new neqsim.thermo.system.SystemSrkCPAstatoil(398.0, 1.01325);
testSystem.addComponent("MEG", 25.0, "kg/sec");
testSystem.setMixingRule(10);
ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
try {
testOps.bubblePointTemperatureFlash();
} catch (Exception e) {
e.printStackTrace();
}

String scheme = testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0).getAssociationScheme();
double aCPA = ((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0)).geta();
double bCPA = ((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0)).getb();
double boundvol = ((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0))
.getAssociationVolume();
double assenergy = ((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0))
.getAssociationEnergy();
double m = ((ComponentSrkCPA) testSystem.getPhase(PhaseType.AQUEOUS).getComponent(0))
.getAttractiveTerm().getm();
assertEquals("4C", scheme);
assertEquals(108190.0, aCPA);
assertEquals(5.14, bCPA);
assertEquals(0.0141, boundvol);
assertEquals(19752.0, assenergy);
assertEquals(0.6743999999999983, m);
testSystem.prettyPrint();
}
}

0 comments on commit 2c26392

Please sign in to comment.