QC a black-oil table before it reaches the simulator
Generate a Vasquez–Beggs black-oil table, run the Coats consistency inequalities over its saturated rows, then show the check catching one mistyped Rs.
- UC-PVT-011
- UC-PVT-003
Engineering use cases UC-PVT-011 (QC a Black-Oil PVT Table) and UC-PVT-003 (Build Black Oil PVT Table).
A saturated black-oil table is consistent only if, as the pressure falls, the gas that comes out of solution frees more reservoir volume than the oil shrinks: Bg dRs/dp > dBo/dp, with Bg in bbl/scf. Coats (2000) adds that Bg must fall with pressure and that Bo − Rs Bg and Bg − Rv Bo stay positive. A table that breaks one gives a negative total compressibility, and the simulator fails, or worse, runs, far from the cause. CoatsPvtConsistency.CheckSaturatedTable tests each interval with its chord slopes at both ends and names the inequality that fails.
What an engineer learns from it: the generated table, a 35 °API oil with 500 scf/STB at 180 °F, has its bubble point at 2,668 psia and passes on all four saturated intervals. Over 1,000 to 1,500 psia, for example, the liberated gas frees Bg ΔRs ≈ 0.19 rb/STB against a ΔBo of 0.046. Type 535 for the 355 scf/STB at 2,000 psia, two digits swapped, and the check fails on one interval, 2,000 to 2,500 psia, on the saturated-oil compressibility: Rs now falls as the pressure rises there. The table looks plausible by eye; the check finds the row.
Field units: psia, scf/STB, rb/STB, and Bg in rcf/scf in the table, divided by 5.6146 to bbl/scf for the check. Only the saturated rows go in: above the bubble point Rs is constant and the inequalities do not apply.
Source
using System;
using System.Linq;
using Team76.Engineering.Core.Measures;
using Team76.Engineering.PVT.Facades;
using Team76.Engineering.PVT.Quality;
public class S : ICalcScript
{
public ScriptResult Run(ICalcContext ctx)
{
// A Vasquez-Beggs table for a 35 °API oil with 500 scf/STB at 180 °F, then the Coats (2000) check on it.
var input = new BlackOilTableInput
{
ApiGravity = ApiGravity.From(35),
GasGravity = GasSpecificGravity.From(0.65),
Temperature = Temperature.FromDegF(180),
Rsb = SolutionRelation.FromScfPerStb(500),
DeadOilViscosity = Viscosity.FromCP(2.0),
Correlations = OilCorrelationOptions.VasquezBeggs,
};
var table = BlackOilTable.Generate(input, [500.0, 1000, 1500, 2000, 2500, 3000, 3500, 4000]);
var pb = table.BubblePoint.Psi;
// The saturated rows only, with Bg in bbl/scf so Bg·dRs/dp is in the units of dBo/dp.
var sat = table.Rows.Where(r => r.Pressure.Psi <= pb).ToList();
double[] p = sat.Select(r => r.Pressure.Psi).ToArray();
double[] bo = sat.Select(r => r.Bo.BblPerStb).ToArray();
double[] bg = sat.Select(r => r.Bg.RcfPerScf / 5.614583).ToArray();
double[] rs = sat.Select(r => r.Rs.ScfPerStb).ToArray();
var qc = CoatsPvtConsistency.CheckSaturatedTable(p, bo, bg, rs);
// The same table with one typing slip: Rs at 2,000 psia entered as 535 for 355.
var slipped = rs.ToArray();
var at = Array.FindIndex(p, x => Math.Abs(x - 2000) < 0.01);
slipped[at] = 535;
var qcSlipped = CoatsPvtConsistency.CheckSaturatedTable(p, bo, bg, slipped);
var rows = table.Rows.Select(r => new object[]
{
Math.Round(r.Pressure.Psi), Math.Round(r.Rs.ScfPerStb), Math.Round(r.Bo.BblPerStb, 4), Math.Round(r.Bg.RcfPerScf, 5), Math.Round(r.Viscosity.CP, 3),
}).ToList();
var failures = qcSlipped.Failures
.Select(f => new object[] { Math.Round(f.PressureFrom), Math.Round(f.PressureTo), string.Join(", ", f.Checks.Failures) })
.ToList();
return ctx.Result()
.Set("Pb (psia)", Math.Round(pb))
.Set("Saturated rows", sat.Count)
.Set("Table passes Coats", qc.All)
.Set("Slipped table passes Coats", qcSlipped.All)
.Set("Failing intervals", qcSlipped.Failures.Count)
.Set("Black-oil table", new ScriptTable(["P (psia)", "Rs (scf/STB)", "Bo (rb/STB)", "Bg (rcf/scf)", "μo (cP)"], rows))
.Set("Coats failures, slipped table", new ScriptTable(["From (psia)", "To (psia)", "Fails"], failures));
}
}