Check the correlations against the equation of state
A volatile oil from its composition: the Peng–Robinson phase envelope, critical point, cricondenbar and cricondentherm, the saturation pressure at reservoir temperature, and the vapour split off at 2,000 psia, with its Z from the equation of state against the Dranchuk–Abou-Kassem correlation on the same gravity.
- UC-MULTI-010
Engineering use case UC-MULTI-010 (Compositional PVT Analysis: EoS + PVT).
The equation of state is rigorous and slow, and needs a composition; the correlations are fast and need a gravity. The workflow uses the first to decide what the fluid is and to check the second. PhaseEnvelope traces the bubble and dew curves and finds the critical point (Heidemann–Khalil); Saturation.FindPressure gives the saturation pressure at reservoir temperature; a flash below it splits the free gas, whose molar mass gives the gravity a correlation takes.
What an engineer learns from it: the critical point is at about 442 °F and 2,940 psia, far to the right of the 220 °F reservoir, so the reservoir fluid is an oil, and the saturation point at 220 °F is a bubble point, 3,347 psia, on the envelope's bubble curve. The cricondenbar, about 3,430 psia, is the highest pressure at which two phases can exist: keep the reservoir above it and no gas forms at any temperature. At 2,000 psia 47 % of the moles are free gas of 0.77 gravity, and Dranchuk–Abou-Kassem on that gravity gives Z = 0.872 against the equation of state's 0.841, 3.7 % apart: close enough for a gas-side field calculation, and a measure of what the gravity alone leaves out (this gas carries CO₂ and heavy ends a gravity cannot describe). The liquid is where the equation of state earns its place, and where it needs tuning to a lab report first.
Units: K and Pa in the library, °F and psia in the result. The model is untuned Peng–Robinson without volume translation or binary interaction coefficients.
Source
using System;
using System.Linq;
using Team76.Engineering.Core.Measures;
using Team76.Engineering.PVT.Correlations;
using Team76.Engineering.Thermodynamics.Envelopes;
using Team76.Engineering.Thermodynamics.Envelopes.CriticalPoint;
using Team76.Engineering.Thermodynamics.Eos.Builders;
using Team76.Engineering.Thermodynamics.Experiments;
using Team76.Engineering.Thermodynamics.Flash;
using Team76.Engineering.Thermodynamics.Models;
public class S : ICalcScript
{
public ScriptResult Run(ICalcContext ctx)
{
const double Psi = 6894.757; // Pa per psi
static double DegF(double kelvin) => kelvin * 1.8 - 459.67;
// The volatile oil of the CCE and separator entries.
var plus = new Component[]
{
new("C7", 547.6, 3.124e6, 0.280, 0.0960), new("C8", 575.6, 2.889e6, 0.312, 0.1070), new("C9", 604.2, 2.641e6, 0.348, 0.1210),
new("C10", 626.7, 2.419e6, 0.385, 0.1340), new("C12", 668.3, 2.082e6, 0.492, 0.1610), new("C16", 741.7, 1.627e6, 0.638, 0.2220),
};
var components = ComponentDatabase.Get(["nitrogen", "CO2", "H2S", "methane", "ethane", "propane", "i-butane", "n-butane", "i-pentane", "n-pentane", "n-hexane"])
.Concat(plus).ToArray();
double[] z = [0.0021, 0.0187, 0.0004, 0.5800, 0.0750, 0.0430, 0.0090, 0.0210, 0.0090, 0.0130, 0.0150, 0.0400, 0.0400, 0.0300, 0.0250, 0.0480, 0.0308];
var eos = CubicEoSBuilder.PengRobinson(components);
var feed = Mixture.FromFractions(components, z);
var tres = (220 - 32) / 1.8 + 273.15;
// 1. EoS: the phase envelope, its critical point, and the saturation pressure at 220 °F.
var envelope = new PhaseEnvelope(eos, feed, new HeidemannKhalilCriticalPointSolver()) { Pmax = 60e6 }.Calculate();
var sat = new Saturation(eos, feed).FindPressure(tres);
// 2. EoS: a flash at 2,000 psia, below the saturation pressure, splits off the free gas.
var flash = new FlashCalculator(eos, feed).Calculate(new FlashSpec.TP(tres, 2000 * Psi));
var gasGravity = flash.Vapor.Mixture.MolecularWeight / 0.028966;
var zEos = flash.Vapor.Z;
// 3. Correlations: the same gas from its gravity alone (Sutton pseudo-criticals, Dranchuk-Abou-Kassem Z).
var zDak = GasZFactor.ByDranchukAbouKassem(GasSpecificGravity.From(gasGravity), Pressure.FromPsi(2000), Temperature.FromDegF(220)).Dmnl;
var bubble = envelope.BubbleT.Zip(envelope.BubbleP).ToList();
var dew = envelope.DewT.Zip(envelope.DewP).ToList(); // trace order: the dew curve doubles back in T
var allP = envelope.BubbleP.Concat(envelope.DewP).ToList();
return ctx.Result()
.Set("Critical temperature (°F)", Math.Round(DegF(envelope.CriticalT)))
.Set("Critical pressure (psia)", Math.Round(envelope.CriticalP / Psi))
.Set("Cricondenbar (psia)", Math.Round(envelope.CricondenbarP / Psi))
.Set("Cricondentherm (°F)", Math.Round(DegF(envelope.CricondenthermT)))
.Set("Highest envelope pressure (psia)", Math.Round(allP.Max() / Psi))
.Set("Envelope closed", envelope.IsEnvelopeClosed)
.Set("Saturation pressure at 220 °F (psia)", Math.Round(sat.P / Psi))
.Set("Saturation kind", sat.Kind.ToString())
.Set("Vapour at 2,000 psia (mol/mol)", Math.Round(flash.V, 4))
.Set("Free-gas gravity at 2,000 psia", Math.Round(gasGravity, 4))
.Set("Free-gas Z, Peng-Robinson", Math.Round(zEos, 4))
.Set("Free-gas Z, Dranchuk-Abou-Kassem", Math.Round(zDak, 4))
.Set("Z difference (%)", Math.Round((zDak - zEos) / zEos * 100, 2))
.Set("Phase envelope", new ScriptChart(
[
new ScriptSeries("Bubble", bubble.Select(p => Math.Round(DegF(p.First), 1)).ToArray(), bubble.Select(p => Math.Round(p.Second / Psi)).ToArray()),
new ScriptSeries("Dew", dew.Select(p => Math.Round(DegF(p.First), 1)).ToArray(), dew.Select(p => Math.Round(p.Second / Psi)).ToArray()),
],
title: "Volatile oil, Peng-Robinson", xLabel: "T (°F)", yLabel: "P (psia)"));
}
}