Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added tempsat #357

Merged
merged 8 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class BasePVTsimulation implements SimulationInterface {
public double[] pressures = {381.5, 338.9, 290.6, 242.3, 194.1, 145.8, 145.8, 97.5, 49.3};
public double temperature = 289.0;
double[][] experimentalData = null;
double saturationVolume = 0, saturationPressure = 0;
double saturationVolume = 0, saturationPressure = 0, saturationTemperature;
double Zsaturation = 0;
public LevenbergMarquardt optimizer = new LevenbergMarquardt();

Expand Down Expand Up @@ -165,4 +165,11 @@ public LevenbergMarquardt getOptimizer() {
public double getZsaturation() {
return Zsaturation;
}

/**
* @return the saturationTemperature
*/
public double getSaturationTemperature() {
return saturationTemperature;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package neqsim.PVTsimulation.simulation;

import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;

/**
* <p>
* SaturationPressure class.
* </p>
*
* @author esol
* @version $Id: $Id
*/
public class SaturationTemperature extends BasePVTsimulation {
/**
* <p>
* Constructor for SaturationPressure.
* </p>
*
* @param tempSystem a {@link neqsim.thermo.system.SystemInterface} object
*/
public SaturationTemperature(SystemInterface tempSystem) {
super(tempSystem);
}

/**
* <p>
* calcSaturationPressure.
* </p>
*
* @return a double
*/
public double calcSaturationTemperature() {
getThermoSystem().isImplementedCompositionDeriativesofFugacity(false);
do {
getThermoSystem().setTemperature(getThermoSystem().getTemperature() - 10.0);
thermoOps.TPflash();
} while (getThermoSystem().getNumberOfPhases() == 1
&& getThermoSystem().getTemperature() > 30.0);
do {
getThermoSystem().setTemperature(getThermoSystem().getTemperature() + 10.0);
thermoOps.TPflash();
} while (getThermoSystem().getNumberOfPhases() > 1
&& getThermoSystem().getTemperature() < 1200.0);
double minTemp = getThermoSystem().getTemperature() - 10.0;
double maxTemp = getThermoSystem().getTemperature();
int iteration = 0;
do {
iteration++;
getThermoSystem().setTemperature((minTemp + maxTemp) / 2.0);
thermoOps.TPflash();
if (getThermoSystem().getNumberOfPhases() > 1) {
minTemp = getThermoSystem().getTemperature();
} else {
maxTemp = getThermoSystem().getTemperature();
}
} while (Math.abs(maxTemp - minTemp) > 1e-5 && iteration < 500);
getThermoSystem().setTemperature(maxTemp);
thermoOps.TPflash();
return getThermoSystem().getTemperature();
}

/** {@inheritDoc} */
@Override
public void run() {
super.run();
saturationTemperature = calcSaturationTemperature();
}

/**
* <p>
* main.
* </p>
*
* @param args an array of {@link java.lang.String} objects
*/
public static void main(String[] args) {
SystemInterface tempSystem = new SystemSrkEos(273.15 + 20, 60.0);
tempSystem.addComponent("nitrogen", 0.34);
tempSystem.addComponent("CO2", 3.59);
tempSystem.addComponent("methane", 67.42);
tempSystem.addComponent("ethane", 9.02);
tempSystem.addComponent("propane", 4.31);
tempSystem.addComponent("i-butane", 0.93);
tempSystem.addComponent("n-butane", 1.71);
tempSystem.addComponent("i-pentane", 0.74);
tempSystem.addComponent("n-pentane", 0.85);
tempSystem.addComponent("n-hexane", 0.38);
tempSystem.addTBPfraction("C7", 0.5, 109.00 / 1000.0, 0.6912);
tempSystem.addTBPfraction("C8", 0.69, 120.20 / 1000.0, 0.7255);
tempSystem.addTBPfraction("C9", 0.14, 129.5 / 1000.0, 0.7454);
tempSystem.addTBPfraction("C10", 0.08, 135.3 / 1000.0, 0.7864);
//tempSystem.createDatabase(true);
tempSystem.setMixingRule(2);// "HV", "UNIFAC_UMRPRU");
tempSystem.init(0);
tempSystem.init(1);
// tempSystem.saveFluid(928);

SimulationInterface satPresSim = new SaturationTemperature(tempSystem);
satPresSim.run();
satPresSim.getThermoSystem().display();
/*
* double saturationPressure = 350.0; double saturationTemperature = 273.15 + 80;
*
* TuningInterface tuning = new TuneToSaturation(satPresSim);
* tuning.setSaturationConditions(saturationTemperature, saturationPressure); tuning.run();
* tuning.getSimulation().getThermoSystem().display();
*/
}
}
Loading