Skip to content

Commit 011d2b2

Browse files
authored
added tempsat (#357)
1 parent e5ddfa6 commit 011d2b2

File tree

7 files changed

+827
-629
lines changed

7 files changed

+827
-629
lines changed

src/main/java/neqsim/PVTsimulation/simulation/BasePVTsimulation.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class BasePVTsimulation implements SimulationInterface {
2020
public double[] pressures = {381.5, 338.9, 290.6, 242.3, 194.1, 145.8, 145.8, 97.5, 49.3};
2121
public double temperature = 289.0;
2222
double[][] experimentalData = null;
23-
double saturationVolume = 0, saturationPressure = 0;
23+
double saturationVolume = 0, saturationPressure = 0, saturationTemperature;
2424
double Zsaturation = 0;
2525
public LevenbergMarquardt optimizer = new LevenbergMarquardt();
2626

@@ -165,4 +165,11 @@ public LevenbergMarquardt getOptimizer() {
165165
public double getZsaturation() {
166166
return Zsaturation;
167167
}
168+
169+
/**
170+
* @return the saturationTemperature
171+
*/
172+
public double getSaturationTemperature() {
173+
return saturationTemperature;
174+
}
168175
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
package neqsim.PVTsimulation.simulation;
2+
3+
import neqsim.thermo.system.SystemInterface;
4+
import neqsim.thermo.system.SystemSrkEos;
5+
6+
/**
7+
* <p>
8+
* SaturationPressure class.
9+
* </p>
10+
*
11+
* @author esol
12+
* @version $Id: $Id
13+
*/
14+
public class SaturationTemperature extends BasePVTsimulation {
15+
/**
16+
* <p>
17+
* Constructor for SaturationPressure.
18+
* </p>
19+
*
20+
* @param tempSystem a {@link neqsim.thermo.system.SystemInterface} object
21+
*/
22+
public SaturationTemperature(SystemInterface tempSystem) {
23+
super(tempSystem);
24+
}
25+
26+
/**
27+
* <p>
28+
* calcSaturationPressure.
29+
* </p>
30+
*
31+
* @return a double
32+
*/
33+
public double calcSaturationTemperature() {
34+
getThermoSystem().isImplementedCompositionDeriativesofFugacity(false);
35+
do {
36+
getThermoSystem().setTemperature(getThermoSystem().getTemperature() - 10.0);
37+
thermoOps.TPflash();
38+
} while (getThermoSystem().getNumberOfPhases() == 1
39+
&& getThermoSystem().getTemperature() > 30.0);
40+
do {
41+
getThermoSystem().setTemperature(getThermoSystem().getTemperature() + 10.0);
42+
thermoOps.TPflash();
43+
} while (getThermoSystem().getNumberOfPhases() > 1
44+
&& getThermoSystem().getTemperature() < 1200.0);
45+
double minTemp = getThermoSystem().getTemperature() - 10.0;
46+
double maxTemp = getThermoSystem().getTemperature();
47+
int iteration = 0;
48+
do {
49+
iteration++;
50+
getThermoSystem().setTemperature((minTemp + maxTemp) / 2.0);
51+
thermoOps.TPflash();
52+
if (getThermoSystem().getNumberOfPhases() > 1) {
53+
minTemp = getThermoSystem().getTemperature();
54+
} else {
55+
maxTemp = getThermoSystem().getTemperature();
56+
}
57+
} while (Math.abs(maxTemp - minTemp) > 1e-5 && iteration < 500);
58+
getThermoSystem().setTemperature(maxTemp);
59+
thermoOps.TPflash();
60+
return getThermoSystem().getTemperature();
61+
}
62+
63+
/** {@inheritDoc} */
64+
@Override
65+
public void run() {
66+
super.run();
67+
saturationTemperature = calcSaturationTemperature();
68+
}
69+
70+
/**
71+
* <p>
72+
* main.
73+
* </p>
74+
*
75+
* @param args an array of {@link java.lang.String} objects
76+
*/
77+
public static void main(String[] args) {
78+
SystemInterface tempSystem = new SystemSrkEos(273.15 + 20, 60.0);
79+
tempSystem.addComponent("nitrogen", 0.34);
80+
tempSystem.addComponent("CO2", 3.59);
81+
tempSystem.addComponent("methane", 67.42);
82+
tempSystem.addComponent("ethane", 9.02);
83+
tempSystem.addComponent("propane", 4.31);
84+
tempSystem.addComponent("i-butane", 0.93);
85+
tempSystem.addComponent("n-butane", 1.71);
86+
tempSystem.addComponent("i-pentane", 0.74);
87+
tempSystem.addComponent("n-pentane", 0.85);
88+
tempSystem.addComponent("n-hexane", 0.38);
89+
tempSystem.addTBPfraction("C7", 0.5, 109.00 / 1000.0, 0.6912);
90+
tempSystem.addTBPfraction("C8", 0.69, 120.20 / 1000.0, 0.7255);
91+
tempSystem.addTBPfraction("C9", 0.14, 129.5 / 1000.0, 0.7454);
92+
tempSystem.addTBPfraction("C10", 0.08, 135.3 / 1000.0, 0.7864);
93+
//tempSystem.createDatabase(true);
94+
tempSystem.setMixingRule(2);// "HV", "UNIFAC_UMRPRU");
95+
tempSystem.init(0);
96+
tempSystem.init(1);
97+
// tempSystem.saveFluid(928);
98+
99+
SimulationInterface satPresSim = new SaturationTemperature(tempSystem);
100+
satPresSim.run();
101+
satPresSim.getThermoSystem().display();
102+
/*
103+
* double saturationPressure = 350.0; double saturationTemperature = 273.15 + 80;
104+
*
105+
* TuningInterface tuning = new TuneToSaturation(satPresSim);
106+
* tuning.setSaturationConditions(saturationTemperature, saturationPressure); tuning.run();
107+
* tuning.getSimulation().getThermoSystem().display();
108+
*/
109+
}
110+
}

0 commit comments

Comments
 (0)