Skip to content

Commit a25cc6a

Browse files
authored
added more methods (#1053)
1 parent ad33f31 commit a25cc6a

File tree

2 files changed

+92
-22
lines changed

2 files changed

+92
-22
lines changed

src/main/java/neqsim/standards/oilQuality/Standard_ASTM_D6377.java

+85-22
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,49 @@ public class Standard_ASTM_D6377 extends neqsim.standards.Standard {
2424
double TVP = 1.0;
2525
double referenceTemperature = 37.8;
2626
String referenceTemperatureUnit = "C";
27+
String methodRVP = "VPCR4"; // RVP_ASTM_D6377 // RVP_ASTM_D323_73_79 //
28+
// RVP_ASTM_D323_82 // VPCR4_no_water // VPCR4
29+
30+
private double VPCR4_no_water = 0.0;
31+
private double VPCR4 = 0.0;
32+
private double RVP_ASTM_D6377 = 0.0;
33+
private double RVP_ASTM_D323_73_79 = 0.0;
34+
private double RVP_ASTM_D323_82 = 0.0;
35+
36+
/**
37+
* Gets the method used for measuring Reid Vapor Pressure (RVP).
38+
*
39+
* The method can be one of the following:
40+
* <ul>
41+
* <li>RVP_ASTM_D6377</li>
42+
* <li>RVP_ASTM_D323_73_79</li>
43+
* <li>RVP_ASTM_D323_82</li>
44+
* <li>VPCR4</li>
45+
* </ul>
46+
*
47+
* @return the method used for RVP measurement.
48+
*/
49+
public String getMethodRVP() {
50+
return methodRVP;
51+
}
52+
53+
/**
54+
* Sets the method used for measuring Reid Vapor Pressure (RVP).
55+
*
56+
* The method should be one of the following:
57+
* <ul>
58+
* <li>RVP_ASTM_D6377</li>
59+
* <li>RVP_ASTM_D323_73_79</li>
60+
* <li>RVP_ASTM_D323_82</li>
61+
* <li>VPCR4</li>
62+
* </ul>
63+
*
64+
* @param methodRVP the method to set for RVP measurement.
65+
*/
66+
public void setMethodRVP(String methodRVP) {
67+
this.methodRVP = methodRVP;
68+
}
69+
2770

2871
/**
2972
* <p>
@@ -59,31 +102,24 @@ public void calculate() {
59102
logger.error(ex.getMessage(), ex);
60103
}
61104

62-
RVP = this.thermoSystem.getPressure();
63-
}
105+
VPCR4 = this.thermoSystem.getPressure();
106+
RVP_ASTM_D6377 = 0.834 * VPCR4;
107+
RVP_ASTM_D323_82 = (0.752 * (100.0 * this.thermoSystem.getPressure()) + 6.07) / 100.0;
64108

65-
// old method for RVP
66-
public void calculate2() {
67-
this.thermoSystem.setTemperature(referenceTemperature, "C");
68-
this.thermoSystem.setPressure(ThermodynamicConstantsInterface.referencePressure);
69-
this.thermoOps = new ThermodynamicOperations(thermoSystem);
70-
try {
71-
this.thermoOps.bubblePointPressureFlash(false);
72-
} catch (Exception ex) {
73-
logger.error(ex.getMessage(), ex);
109+
SystemInterface fluid1 = this.thermoSystem.clone();
110+
if (fluid1.hasComponent("water")) {
111+
fluid1.removeComponent("water");
112+
fluid1.init(0);
74113
}
75-
76-
TVP = this.thermoSystem.getPressure();
77-
double liquidVolume = thermoSystem.getVolume();
78-
79-
this.thermoSystem.setPressure(TVP * 0.9);
80114
try {
81-
this.thermoOps.TVflash(liquidVolume * 4.0);
115+
// ASTM D323 -08 method is used for this property calculation. It is defined at the pressure
116+
// at 100°F (37.8°C) at which 80% of the stream by volume is vapor at 100°F. In
117+
this.thermoOps.TVfractionFlash(0.8);
82118
} catch (Exception ex) {
83119
logger.error(ex.getMessage(), ex);
84120
}
85-
86-
RVP = (0.752 * (100.0 * this.thermoSystem.getPressure()) + 6.07) / 100.0;
121+
VPCR4_no_water = this.thermoSystem.getPressure();
122+
RVP_ASTM_D323_73_79 = VPCR4_no_water;
87123
}
88124

89125
/** {@inheritDoc} */
@@ -102,11 +138,14 @@ public String getUnit(String returnParameter) {
102138
@Override
103139
public double getValue(String returnParameter, java.lang.String returnUnit) {
104140
if (returnParameter == "RVP") {
105-
neqsim.util.unit.PressureUnit presConversion = new neqsim.util.unit.PressureUnit(RVP, "bara");
141+
double RVPlocal = getValue("RVP");
142+
neqsim.util.unit.PressureUnit presConversion =
143+
new neqsim.util.unit.PressureUnit(RVPlocal, "bara");
106144
return presConversion.getValue(returnUnit);
107145
}
108146
if (returnParameter == "TVP") {
109-
neqsim.util.unit.PressureUnit presConversion = new neqsim.util.unit.PressureUnit(TVP, "bara");
147+
neqsim.util.unit.PressureUnit presConversion =
148+
new neqsim.util.unit.PressureUnit(getValue("TVP"), "bara");
110149
return presConversion.getValue(returnUnit);
111150
} else {
112151
return RVP;
@@ -116,7 +155,27 @@ public double getValue(String returnParameter, java.lang.String returnUnit) {
116155
/** {@inheritDoc} */
117156
@Override
118157
public double getValue(String returnParameter) {
119-
return RVP;
158+
if (returnParameter.equals("RVP")) {
159+
switch (methodRVP) {
160+
case "RVP_ASTM_D6377":
161+
return RVP_ASTM_D6377;
162+
case "RVP_ASTM_D323_73_79":
163+
return RVP_ASTM_D323_73_79;
164+
case "VPCR4":
165+
return VPCR4;
166+
case "RVP_ASTM_D323_82":
167+
return RVP_ASTM_D323_82;
168+
case "VPCR4_no_water":
169+
return VPCR4_no_water;
170+
default:
171+
return VPCR4;
172+
}
173+
} else if (returnParameter.equals("TVP")) {
174+
return TVP;
175+
} else {
176+
logger.error("returnParameter not supported.. " + returnParameter);
177+
return 0.0;
178+
}
120179
}
121180

122181
/**
@@ -146,10 +205,14 @@ public static void main(String args[]) {
146205
testSystem.addComponent("ethane", 0.006538);
147206
testSystem.addComponent("propane", 0.006538);
148207
testSystem.addComponent("n-pentane", 0.545);
208+
testSystem.addComponent("water", 0.00545);
149209
testSystem.setMixingRule(2);
150210
testSystem.init(0);
151211
Standard_ASTM_D6377 standard = new Standard_ASTM_D6377(testSystem);
152212
standard.calculate();
153213
System.out.println("RVP " + standard.getValue("RVP", "bara"));
214+
standard.setMethodRVP("RVP_ASTM_D323_73_79");
215+
standard.calculate();
216+
System.out.println("RVP_ASTM_D323_73_79 " + standard.getValue("RVP", "bara"));
154217
}
155218
}

src/test/java/neqsim/standards/oilQuality/Standard_ASTM_D6377Test.java

+7
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,16 @@ void testCalculate2() {
3636
testSystem.init(0);
3737
testSystem.setPressure(100.0);
3838
Standard_ASTM_D6377 standard = new Standard_ASTM_D6377(testSystem);
39+
standard.setMethodRVP("VPCR4");
3940
standard.setReferenceTemperature(37.8, "C");
4041
standard.calculate();
4142
Assertions.assertEquals(3.604002003478, standard.getValue("RVP", "bara"), 1e-3);
4243
Assertions.assertEquals(7.8448385024, standard.getValue("TVP", "bara"), 1e-3);
44+
45+
standard.setMethodRVP("RVP_ASTM_D6377");
46+
standard.setReferenceTemperature(37.8, "C");
47+
standard.calculate();
48+
Assertions.assertEquals(3.00573767, standard.getValue("RVP", "bara"), 1e-3);
49+
Assertions.assertEquals(7.8448385024, standard.getValue("TVP", "bara"), 1e-3);
4350
}
4451
}

0 commit comments

Comments
 (0)