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

initiated work on HC-water phase envelope #531

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import neqsim.thermodynamicOperations.phaseEnvelopeOps.multicomponentEnvelopeOps.CricondenThermFlash;
import neqsim.thermodynamicOperations.phaseEnvelopeOps.multicomponentEnvelopeOps.HPTphaseEnvelope;
import neqsim.thermodynamicOperations.phaseEnvelopeOps.multicomponentEnvelopeOps.pTphaseEnvelope;
import neqsim.thermodynamicOperations.phaseEnvelopeOps.multicomponentEnvelopeOps.pTphaseEnvelopeHCwater;
import neqsim.thermodynamicOperations.phaseEnvelopeOps.reactiveCurves.pLoadingCurve2;
import neqsim.thermodynamicOperations.propertyGenerator.OLGApropertyTableGeneratorWaterStudents;
import neqsim.thermodynamicOperations.propertyGenerator.OLGApropertyTableGeneratorWaterStudentsPH;
Expand Down Expand Up @@ -1610,6 +1611,18 @@ public void calcPTphaseEnvelopeNew() {
getOperation().run();
}

/**
* <p>
* calcPTphaseEnvelopeHCwater.
* </p>
*/
public void calcPTphaseEnvelopeHCwater() {
operation = new pTphaseEnvelopeHCwater(system, fileName, (1.0 - 1e-10), 1.0, false);
// thisThread = new Thread(operation);
// thisThread.start();
getOperation().run();
}

/**
* <p>
* OLGApropTable.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
/*
* pTphaseEnvelopeHCwater.java
*
* Created on 14. oktober 2000, 21:59 Updated on May 2019, by Nefeli
*/

package neqsim.thermodynamicOperations.phaseEnvelopeOps.multicomponentEnvelopeOps;

import java.util.ArrayList;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

/**
* <p>
* pTphaseEnvelope class.
* </p>
*
* @author asmun
* @version $Id: $Id
*/
public class pTphaseEnvelopeHCwater extends pTphaseEnvelope {
private static final long serialVersionUID = 1000;
static Logger logger = LogManager.getLogger(pTphaseEnvelopeHCwater.class);
ThermodynamicOperations ops = null;

class PhaseEnevelopePoint {

double temperature;
double pressure;
String dewPointType;

public PhaseEnevelopePoint(SystemInterface fluid) {
this.temperature = fluid.getTemperature();
this.pressure = fluid.getPressure();

if (fluid.getNumberOfPhases() > 1 && fluid.getPhase(1).getPhaseTypeName().equals("aqueous")
&& fluid.getPhase(0).getPhaseTypeName().equals("gas")) {
this.dewPointType = "2 phase gas-aqueous dew point";
} else if (fluid.getNumberOfPhases() > 1
&& fluid.getPhase(1).getPhaseTypeName().equals("aqueous")
&& fluid.getPhase(0).getPhaseTypeName().equals("oil")) {
this.dewPointType = "2 phase oil-aqueous dew point";
} else if (fluid.getNumberOfPhases() > 1 && fluid.getPhase(1).getPhaseTypeName().equals("oil")
&& fluid.getPhase(0).getPhaseTypeName().equals("gas")) {
this.dewPointType = "2 phase gas-oil dew point";
}
}
}

ArrayList<PhaseEnevelopePoint> data = new ArrayList<PhaseEnevelopePoint>();

/**
* <p>
* Constructor for pTphaseEnvelopeHCwater.
* </p>
*/
public pTphaseEnvelopeHCwater() {}

/**
* <p>
* Constructor for pTphaseEnvelopeHCwater.
* </p>
* Method follow algorithm in : Lindeloff, N. and M.L. Michelsen, Phase envelope calculations for
* hydrocarbon-water mixtures. SPE Journal, 2003. 8(03): p. 298-303.
*
* @param system a {@link neqsim.thermo.system.SystemInterface} object
* @param name a {@link java.lang.String} object
* @param phaseFraction a double
* @param lowPres a double
* @param bubfirst a boolean
*/
public pTphaseEnvelopeHCwater(SystemInterface system, String name, double phaseFraction,
double lowPres, boolean bubfirst) {
super(system, name, phaseFraction, lowPres, bubfirst);
}

/** {@inheritDoc} */
@Override
public void run() {
// envelope contruction method comes here.....

/**
* Steps in algorithm (figure names references original paper of Lindeloff and Michelsen):
*
*
* Tracing the dewline segments that separate the single-phase region from the two-phase region
* (Lines I and II in Fig. 1).
*
* Determining the three-phase points on the dewline. These are the points where the overall
* composition is at equilibrium with two incipient phases.
*
* Tracing the phase boundaries that separate the two-phase region from the three-phase region
* (Lines III and IV in Fig. 1). These phase boundaries emerge from the three-phase points or
* exist as isolated lines.
*
*/


// Step 1.
// Tracing the dewline segments that separate the single-phase region from the
// two-phase region (Lines I and II in Fig. 1).
//
system.setTemperature(0.0, "C");
system.setPressure(lowPres, "atm");
// initializing fluid and calculaton K-values according to Wilson
system.init(0);

// Create a thermodynamic operation object for the fluid
ops = new ThermodynamicOperations(system);

// Initialize with threee steps along dew point line
startTraceDewPointLine();

double dewPointPressure = system.getPressure("bara");
// at the moment we use the HC phase envelope method in the super class
// super.run();
}

private void startTraceDewPointLine() {
double highDewPointTemperature = 0.0;
system.setPressure(lowPres);

try {
ops.dewPointTemperatureFlash(false);
} catch (Exception e) {
logger.error(e.toString());
}






for (int i = 0; i < 3; i++) {
// setting pressure to 1.0 atm
system.setPressure(lowPres + 1.0 * i, "atm");
// Calculate the dew point temprature of the fluid
try {
ops.dewPointTemperatureFlash(false);
} catch (Exception e) {
logger.error(e.toString());
}
if (checkForThreePhases()) {
break;
}
data.add(new PhaseEnevelopePoint(system));
}
}

private boolean checkForThreePhases() {
try {
ops.TPflash();
} catch (Exception e) {
logger.error(e.toString());
}
if (system.getNumberOfPhases() > 2) {
return true;
} else {
return false;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package neqsim.thermodynamicOperations.phaseEnvelopeOps.multicomponentEnvelopeOps;

import org.junit.jupiter.api.Test;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkCPAstatoil;
import neqsim.thermo.system.SystemSrkEos;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

/**
* Tests for phase envelop algorithm as presented in: Lindeloff, N. and M.L. Michelsen, Phase
* envelope calculations for hydrocarbon-water mixtures. SPE Journal, 2003. 8(03): p. 298-303.
*
**/
public class pTphaseEnvelopeHCwaterTest {
static SystemInterface thermoSystem = null;

/**
* In the currecnt test Fluid1 from the paper is tested.
**/
@Test
void testFluid1() {
thermoSystem = new SystemSrkEos(298.0, 10.0);
thermoSystem.addComponent("nitrogen", 0.34);
thermoSystem.addComponent("CO2", 0.84);
thermoSystem.addComponent("methane", 89.95);
thermoSystem.addComponent("ethane", 5.17);
thermoSystem.addComponent("propane", 2.04);
thermoSystem.addComponent("i-butane", 0.36);
thermoSystem.addComponent("n-butane", 0.55);
thermoSystem.addComponent("i-pentane", 0.14);
thermoSystem.addComponent("n-pentane", 0.10);
thermoSystem.addComponent("n-hexane", 0.01);
thermoSystem.addComponent("water", 500e-4);
thermoSystem.setMixingRule("classic");
thermoSystem.setMultiPhaseCheck(true);

ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem);
testOps.calcPTphaseEnvelopeHCwater();

}

/**
* In the currecnt test Fluid2 from the paper is tested.
**/
@Test
void testFluid2() {
thermoSystem = new SystemSrkCPAstatoil(298.0, 10.0);
thermoSystem.addComponent("CO2", 2.79);
thermoSystem.addComponent("methane", 71.51);
thermoSystem.addComponent("ethane", 5.77);
thermoSystem.addComponent("propane", 4.10);
thermoSystem.addComponent("i-butane", 1.32);
thermoSystem.addComponent("n-butane", 1.60);
thermoSystem.addComponent("i-pentane", 0.82);
thermoSystem.addComponent("n-pentane", 0.64);
thermoSystem.addComponent("n-hexane", 1.05);
thermoSystem.addTBPfraction("C7", 10.40, 191.0 / 1.0e3, 0.82);

thermoSystem.addComponent("water", 8.0);
thermoSystem.setMixingRule(10);
thermoSystem.setMultiPhaseCheck(true);

ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem);
testOps.calcPTphaseEnvelopeHCwater();

}
}