Skip to content

Commit 96a62f0

Browse files
authored
added RVP and TVP methods (#992)
1 parent 87f5c4a commit 96a62f0

File tree

5 files changed

+105
-9
lines changed

5 files changed

+105
-9
lines changed

src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java

+24-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass;
1616
import neqsim.processSimulation.util.monitor.StreamResponse;
1717
import neqsim.standards.gasQuality.Standard_ISO6976;
18+
import neqsim.standards.oilQuality.Standard_ASTM_D6377;
1819
import neqsim.thermo.system.SystemInterface;
1920
import neqsim.thermodynamicOperations.ThermodynamicOperations;
2021

@@ -443,8 +444,6 @@ public String[][] getResultTable() {
443444
return getFluid().calcResultTable();
444445
}
445446

446-
447-
448447
/** {@inheritDoc} */
449448
@Override
450449
public void runTransient(double dt, UUID id) {
@@ -550,6 +549,29 @@ public double TVP(double temperature, String unit) {
550549
return localSyst.getPressure();
551550
}
552551

552+
/** {@inheritDoc} */
553+
@Override
554+
public double getTVP(double referenceTemperature, String unit, String returnUnit) {
555+
SystemInterface localSyst = getFluid().clone();
556+
localSyst.setTemperature(referenceTemperature, unit);
557+
ThermodynamicOperations ops = new ThermodynamicOperations(localSyst);
558+
try {
559+
ops.bubblePointPressureFlash(false);
560+
} catch (Exception ex) {
561+
}
562+
return localSyst.getPressure(returnUnit);
563+
}
564+
565+
/** {@inheritDoc} */
566+
@Override
567+
public double getRVP(double referenceTemperature, String unit, String returnUnit) {
568+
SystemInterface localSyst = getFluid().clone();
569+
Standard_ASTM_D6377 standard = new Standard_ASTM_D6377(localSyst);
570+
standard.setReferenceTemperature(referenceTemperature, unit);
571+
standard.calculate();
572+
return standard.getValue("RVP", returnUnit);
573+
}
574+
553575
/** {@inheritDoc} */
554576
@Override
555577
public String[][] reportResults() {

src/main/java/neqsim/processSimulation/processEquipment/stream/StreamInterface.java

+24
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,30 @@ public default double getFlowRate(String unit) {
129129
*/
130130
public double TVP(double temperature, String unit);
131131

132+
/**
133+
* <p>
134+
* TVP.
135+
* </p>
136+
*
137+
* @param referenceTemperature a double
138+
* @param unit a {@link java.lang.String} object
139+
* @param returnUnit a {@link java.lang.String} object
140+
* @return a double
141+
*/
142+
public double getTVP(double referenceTemperature, String unit, String returnUnit);
143+
144+
/**
145+
* <p>
146+
* TVP.
147+
* </p>
148+
*
149+
* @param referenceTemperature a double
150+
* @param unit a {@link java.lang.String} object
151+
* @param returnUnit a {@link java.lang.String} object
152+
* @return a double
153+
*/
154+
public double getRVP(double referenceTemperature, String unit, String returnUnit);
155+
132156
/**
133157
* <p>
134158
* setFluid.

src/main/java/neqsim/standards/Standard.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public abstract class Standard extends NamedBaseClass implements StandardInterfa
4141
/**
4242
* Constructor for Standard.
4343
*
44-
* @param name name of standard
44+
* @param name name of standard
4545
* @param description description
4646
*/
4747
public Standard(String name, String description) {
@@ -52,8 +52,8 @@ public Standard(String name, String description) {
5252
/**
5353
* Constructor for Standard.
5454
*
55-
* @param name name of standard
56-
* @param thermoSyst input fluid
55+
* @param name name of standard
56+
* @param thermoSyst input fluid
5757
* @param description description of standard
5858
*/
5959
public Standard(String name, String description, SystemInterface thermoSyst) {
@@ -161,7 +161,7 @@ public void display(String name) {
161161
Container dialogContentPane = dialog.getContentPane();
162162
dialogContentPane.setLayout(new BorderLayout());
163163

164-
String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"};
164+
String[] names = { "", "Phase 1", "Phase 2", "Phase 3", "Unit" };
165165
String[][] table = createTable(name);
166166
JTable Jtab = new JTable(table, names);
167167
JScrollPane scrollpane = new JScrollPane(Jtab);

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

+29-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public class Standard_ASTM_D6377 extends neqsim.standards.Standard {
2121

2222
String unit = "bara";
2323
double RVP = 1.0;
24+
double TVP = 1.0;
25+
double referenceTemperature = 37.8;
26+
String referenceTemperatureUnit = "C";
2427

2528
/**
2629
* <p>
@@ -36,7 +39,7 @@ public Standard_ASTM_D6377(SystemInterface thermoSystem) {
3639
/** {@inheritDoc} */
3740
@Override
3841
public void calculate() {
39-
this.thermoSystem.setTemperature(273.15 + 37.8);
42+
this.thermoSystem.setTemperature(referenceTemperature, "C");
4043
this.thermoSystem.setPressure(ThermodynamicConstantsInterface.referencePressure);
4144
this.thermoOps = new ThermodynamicOperations(thermoSystem);
4245
try {
@@ -45,7 +48,7 @@ public void calculate() {
4548
logger.error(ex.getMessage(), ex);
4649
}
4750

48-
// double TVP = this.thermoSystem.getPressure();
51+
TVP = this.thermoSystem.getPressure();
4952
double liquidVolume = thermoSystem.getVolume();
5053

5154
this.thermoSystem.setPressure(0.9);
@@ -73,7 +76,16 @@ public String getUnit(String returnParameter) {
7376
/** {@inheritDoc} */
7477
@Override
7578
public double getValue(String returnParameter, java.lang.String returnUnit) {
76-
return RVP;
79+
if (returnParameter == "RVP") {
80+
neqsim.util.unit.PressureUnit presConversion = new neqsim.util.unit.PressureUnit(RVP, "bara");
81+
return presConversion.getValue(returnUnit);
82+
}
83+
if (returnParameter == "TVP") {
84+
neqsim.util.unit.PressureUnit presConversion = new neqsim.util.unit.PressureUnit(TVP, "bara");
85+
return presConversion.getValue(returnUnit);
86+
} else {
87+
return RVP;
88+
}
7789
}
7890

7991
/** {@inheritDoc} */
@@ -82,6 +94,20 @@ public double getValue(String returnParameter) {
8294
return RVP;
8395
}
8496

97+
/**
98+
* <p>
99+
* setReferenceTemperature.
100+
* </p>
101+
*
102+
* @param refTemp a double
103+
* @param refTempUnit a {@link java.lang.String} object
104+
*/
105+
public void setReferenceTemperature(double refTemp, String refTempUnit) {
106+
neqsim.util.unit.TemperatureUnit tempConversion =
107+
new neqsim.util.unit.TemperatureUnit(refTemp, refTempUnit);
108+
referenceTemperature = tempConversion.getValue(refTemp, refTempUnit, "C");
109+
}
110+
85111
/**
86112
* <p>
87113
* main.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package neqsim.standards.oilQuality;
2+
3+
import org.junit.jupiter.api.Assertions;
4+
import org.junit.jupiter.api.Test;
5+
import neqsim.thermo.system.SystemInterface;
6+
import neqsim.thermo.system.SystemSrkEos;
7+
8+
public class Standard_ASTM_D6377Test {
9+
@Test
10+
void testCalculate() {
11+
SystemInterface testSystem = new SystemSrkEos(273.15 + 2.0, 1.0);
12+
testSystem.addComponent("methane", 0.0006538);
13+
testSystem.addComponent("ethane", 0.006538);
14+
testSystem.addComponent("propane", 0.006538);
15+
testSystem.addComponent("n-pentane", 0.545);
16+
testSystem.setMixingRule(2);
17+
testSystem.init(0);
18+
Standard_ASTM_D6377 standard = new Standard_ASTM_D6377(testSystem);
19+
standard.setReferenceTemperature(37.8, "C");
20+
standard.calculate();
21+
Assertions.assertEquals(0.7298246193, standard.getValue("RVP", "bara"), 1e-3);
22+
Assertions.assertEquals(1.8710732396722, standard.getValue("TVP", "bara"), 1e-3);
23+
}
24+
}

0 commit comments

Comments
 (0)