Pick the separator pressure that leaves the most stock-tank oil
A two-stage separator test on a volatile oil: the first stage at 100 °F swept from 30 to 600 psia, the stock tank at 60 °F and 1 atm, with the GOR and Bo of each train and the first-stage pressure that maximises the stock-tank oil.
Engineering use case: Thermodynamics, Layer 2, Separator Test, with SeparatorTest.OptimizeFirstStagePressure.
A separator test flashes the reservoir fluid through the surface train: stage 1 at (T1, P1), its liquid into stage 2, and so on to the stock tank. A low first-stage pressure flashes the intermediates (C₃ to C₆) into the gas; a high one carries too much methane into the stock tank, where it flashes and strips them anyway. Between the two is a pressure that leaves the most liquid. The library's Bo is Ahmed's B_ofb: the feed at its bubble point and reservoir temperature, 220 °F here, over the stock-tank oil at 60 °F.
What an engineer learns from it: the stock-tank oil per mole of feed peaks at a first stage of 288 psia, an interior optimum: 0.265 mol/mol, against 0.225 at 30 psia and 0.261 at 600 psia. At the optimum the GOR is about 2,090 scf/STB and Bo 2.25 rb/STB, numbers that name a volatile oil; at 30 psia the same fluid reports 2,440 scf/STB and 2.49. Moving the first stage from 30 psia to the optimum makes 10.6 % more stock-tank oil from the same reservoir fluid, which is why separator pressure is a design decision and not a default. The identities hold: the stock-tank oil is (1 − V1)(1 − V2) and the total GOR is (1 − n_STO)/n_STO in moles.
Units: the library works in K, Pa and moles; the script converts the GOR with 379.49 scf/lb-mol and 0.158987 m³/STB. An untuned Peng–Robinson without volume translation makes the stock-tank liquid too light, so read the optimum pressure and the trend, and tune the model to a lab separator test before trusting the absolute Bo.
Source
using System;
using System.Linq;
using Team76.Engineering.Thermodynamics.Eos.Builders;
using Team76.Engineering.Thermodynamics.Experiments;
using Team76.Engineering.Thermodynamics.Models;
public class S : ICalcScript
{
public ScriptResult Run(ICalcContext ctx)
{
const double Psi = 6894.757; // Pa per psi
const double ScfPerMol = 379.49 / 453.59237; // ideal gas at 60 °F and 14.696 psia
const double M3PerStb = 0.158987;
// The volatile oil of the CCE entry: N2 to C6 from the database, C7+ as six pseudo-components.
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);
// A first stage at 100 °F, then the stock tank at 60 °F and 1 atm; the reservoir is at 220 °F.
var tres = (220 - 32) / 1.8 + 273.15;
var t100 = (100 - 32) / 1.8 + 273.15;
var sep = new SeparatorTest(eos, feed);
// Sweep the first-stage pressure, then let the library find the one that leaves the most stock-tank oil.
var sweep = new[] { 30.0, 60, 100, 200, 300, 400, 600 }
.Select(p => (Psia: p, Train: sep.Calculate([(t100, p * Psi), (SeparatorTest.StockTankReferenceTemperature, SeparatorTest.StockTankReferencePressure)], tres)))
.ToList();
var opt = sep.OptimizeFirstStagePressure([t100, SeparatorTest.StockTankReferenceTemperature], 30 * Psi, 600 * Psi, [SeparatorTest.StockTankReferencePressure]);
// Gas per stock-tank barrel: moles of gas per mole of feed, at 379.49 scf/lb-mol, over the stock-tank oil volume.
double Gor(SeparatorTestResult r) => (1 - r.StockTankOilMoles) * ScfPerMol / (r.StockTankOilVolume / M3PerStb);
var rows = sweep.Select(s => new object[]
{
s.Psia, Math.Round(s.Train.StockTankOilMoles, 5), Math.Round(Gor(s.Train)), Math.Round(s.Train.Bo, 3),
}).ToList();
// The optimum's own train, rerun with the reservoir temperature so it carries a Bo.
var best = sep.Calculate([(t100, opt.FirstStagePressure), (SeparatorTest.StockTankReferenceTemperature, SeparatorTest.StockTankReferencePressure)], tres);
var low = sweep[0].Train;
return ctx.Result()
.Set("Best first-stage pressure (psia)", Math.Round(opt.FirstStagePressure / Psi))
.Set("Optimum shape", opt.Shape.ToString())
.Set("Stock-tank oil at the optimum (mol/mol feed)", Math.Round(opt.Objective, 5))
.Set("Stock-tank oil at 30 psia (mol/mol feed)", Math.Round(opt.ObjectiveAtLowerBound, 5))
.Set("Stock-tank oil at 600 psia (mol/mol feed)", Math.Round(opt.ObjectiveAtUpperBound, 5))
.Set("GOR at the optimum (scf/STB)", Math.Round(Gor(best)))
.Set("Bo at the optimum (rb/STB)", Math.Round(best.Bo, 3))
.Set("Total GOR at the optimum (mol/mol)", Math.Round(best.TotalGOR, 4))
.Set("First-stage vapour at the optimum (mol/mol)", Math.Round(best.Stages[0].Equilibrium.V, 4))
.Set("Stock-tank vapour at the optimum (mol/mol)", Math.Round(best.Stages[1].Equilibrium.V, 4))
.Set("Extra oil over a 30 psia stage (%)", Math.Round((best.StockTankOilVolume / low.StockTankOilVolume - 1) * 100, 1))
.Set("Two-stage train", new ScriptTable(["First stage (psia)", "Stock-tank oil (mol/mol)", "GOR (scf/STB)", "Bo (rb/STB)"], rows))
.Set("Stock-tank oil", new ScriptChart(sweep.Select(s => s.Psia).ToArray(), sweep.Select(s => s.Train.StockTankOilMoles).ToArray(),
title: "Stock-tank oil against first-stage pressure", xLabel: "First stage (psia)", yLabel: "mol per mol of feed"));
}
}