PE library · The engine behind every script

The textbook, as a library the agent can call.

When the agent runs a nodal analysis, fits a decline or sizes an ESP, it doesn't improvise the formula. It calls tested, documented methods from one library: 17 calculation domains, from fluid properties to enhanced recovery.

A script on the PE library: the bubble point of a black-oil fluid, and what it returned.
A script on the PE library: the bubble point of a black-oil fluid, and what it returned.
17
calculation domains, from fluid properties to enhanced recovery
587
calculation classes a script can call
2,607
public methods a script can call

What's inside

17 domains, grouped the way an engineer works

Each domain is its own library with its own namespace, so a script brings in what it needs and the API reference reads like a table of contents.

Fluids and rock

What's in the reservoir, and how it moves through the pores.

PVT

Black-oil PVT

Correlations for oil, gas, water and CO₂: bubble point, solution GOR, formation volume factor, Z-factor, viscosity. Consistency checks on PVT tables.

BubblePointPressureGasZFactorBlackOilFluid
Thermodynamics

Thermodynamics

Cubic and residual-Helmholtz equations of state, including GERG-2008, with characterisation, splitting, binary interaction, flash, phase envelopes and critical points. Simulates CCE, DLE and CVD, and regresses to lab data.

CubicEoSBuilderPhaseEnvelopeGerg2008
SCAL

Special core analysis

Relative permeability and capillary pressure for water-oil, gas-oil, gas-water, three-phase and gas-condensate systems.

CoreyWaterOilRelPermStoneIIRelPerm

Wells and flow

From the sandface to the separator.

IPR

Inflow performance

Steady-state, pseudosteady-state and transient inflow, for oil, gas and fractured wells.

InflowPerformanceTransientFlow
VFP

Multiphase well flow

Pressure traverses through tubing with the standard multiphase flow models, holdup and friction.

FlowModelBuilderPipe
Orchestration

Nodal analysis

The operating point where inflow meets lift: IPR curves against single- or multiphase tubing curves or printed tables, with or without a wellhead choke.

OperatingPointSolverChokedOperatingPointSolver
AL

Artificial lift

ESP design (pump, motor, cable, total dynamic head, viscosity correction), gas-lift valves and rod pumps.

SystemAnalysisPump
SF

Surface facilities

Single- and multiphase chokes, single- and two-phase pipelines, flow-regime maps.

GilbertChokeBakerMap
Process

Process flowsheets

Steady-state flowsheets of separators, compressors, pumps, valves and heat exchangers.

FlowsheetSeparator
FA

Flow assurance

Hydrate formation, erosional velocity and corrosion.

HydrateErosionCorrosion
Frac

Hydraulic fracturing

Fracture geometry, Carter leakoff and proppant.

PKNModelCarterLeakoff

Reservoir and production analysis

Reading what the reservoir is telling you.

DCA

Decline-curve analysis

Decline models with robust fitting, outlier down-weighting, segmentation and AIC/BIC model selection.

ArpsHyperbolicFitterAicSelector
PTA

Pressure-transient analysis

Bourdet derivative, buildup analysis, boundaries, dual porosity, horizontal and fractured wells, radial composite.

BourdetDerivativeBuildup
RTA

Rate-transient analysis

Flowing material balance, rate-integral derivatives and gas pseudo-time.

FlowingMaterialBalance
MBE

Material balance

Havlena–Odeh, gas material balance, drive indices and aquifer models.

HavlenaOdehFetkovichAquifer

Uncertainty and recovery

Ranges, not single numbers, and what comes after primary.

MC

Monte Carlo

A sampling engine with normal, lognormal, PERT, triangular and uniform distributions, correlated inputs and P10/P50/P90.

MonteCarloBuilder
EoR

Enhanced oil recovery

Screening and predictive models for CO₂ (minimum miscibility pressure, Koval sweep, oil swelling), polymer, chemical and steam flooding.

MinimumMiscibilityPressure

In practice

A day's work, in a dozen lines

The kind of script the agent writes for you. Each one is real calls into the library, short enough to read and check, and each one runs.

Find the well's operating point

Hagedorn & Brown outflow against generalized Vogel inflow, intersected by the operating-point solver: the bottom-hole pressure where what the reservoir gives meets what the tubing can lift.

nodal_analysis.scriptOrchestration
// Outflow: Hagedorn & Brown up 8,000 ft of 2.992" tubing, from 200 psia at the wellhead, at a GOR of 500 scf/STB.
var tubing = FlowModelBuilder.HagedornAndBrown(
    new Pipe(Length.FromFeet(8000), Angle.FromDegrees(90),
             Roughness.From(0.0006), Length.FromInches(2.992)),
    new TraverseFluidProvider(GasSpecificGravity.From(0.7),
        Density.FromLbPerFt3(53), Viscosity.FromCP(1.2),
        InterfacialTension.FromDynesPerCm(30), Temperature.FromDegF(180)));
var lift = new MultiPhaseLiftCurve(tubing, Pressure.FromPsi(200), SolutionRelation.FromScfPerStb(500));

// Inflow: generalized Vogel, PI 1.5 STB/(psi.d), 3,000 psia reservoir, 2,200 psia bubble point.
var inflow = InflowPerformanceCurve.GeneralizedVogel(1.5, Pressure.FromPsi(3000), Pressure.FromPsi(2200));

// Where they cross. OperatingPoint is the stable crossing, and null when there is none.
var nodal = OperatingPointSolver.Solve(inflow, lift);
var point = nodal.HasOperatingPoint ? nodal.OperatingPoint : null;

Pick the decline model, then book the EUR

Fit five models to the same history, let AIC choose, and run the winner to the economic limit.

dca_eur.scriptDCA
// Fit five decline models to the same history, each with the name it is reported under.
string[] names = ["Exponential", "Hyperbolic", "Modified hyperbolic", "Duong", "Stretched exponential"];
DeclineModelBase[] candidates =
[
    ArpsHyperbolicFitter.FitExponential(t, q),
    ArpsHyperbolicFitter.Fit(t, q),
    ModifiedHyperbolicFitter.Fit(t, q),
    DuongFitter.Fit(t, q),
    StretchedExponentialFitter.Fit(t, q),
];

// Let AIC pick, so extra parameters have to earn their place.
var best = AicSelector.Instance.SelectBest(candidates, t, q);
var eur = best.Model.UltimateByRateLimit(5);   // to 5 bbl/d
var picked = names[Array.IndexOf(candidates, best.Model)];

STOIIP as a range, not a number

Volumetrics under uncertainty, with porosity and water saturation correlated, sampled 10,000 times.

stoiip_mc.scriptMC
var run = new MonteCarloBuilder()
    .AddInput("area", new TriangularDistribution(800, 1200, 1900))
    .AddInput("h", new PertDistribution(40, 65, 110))
    .AddInput("phi", new PertDistribution(0.14, 0.21, 0.27))
    .AddInput("sw", new PertDistribution(0.18, 0.28, 0.45))
    .WithCorrelation("phi", "sw", -0.6)
    .WithIterations(10_000).WithSeed(76)
    .Run(x => 7758 * x[0] * x[1] * x[2] * (1 - x[3]) / 1.25, "stoiip");

// Percentiles of the outcome: s.P10 is the low case. Reserves reports name the same number P90.
var s = run.GetStatistics("stoiip");

Read a buildup

A diagnostic plot that shows wellbore storage, radial flow and a sealing fault, then permeability from the Horner slope where the derivative is flat.

buildup.scriptPTA
// Diagnostic plot: pressure change and its Bourdet derivative, on Agarwal equivalent time.
var derivative = BourdetDerivative.CalculateBuildup(tp, dt, pws, smoothingL: 0.1);

// The derivative is flat from about 3 to 8 hours: that is radial flow. Read the Horner slope there.
var hr = Buildup.HornerTimeRatio(tp, dt);
int a = Array.FindIndex(dt, x => x >= 3), b = Array.FindLastIndex(dt, x => x <= 8);
double slope = (pws[b] - pws[a]) / (Math.Log10(hr[a]) - Math.Log10(hr[b]));

double k = Buildup.PermeabilityFromSlope(slope, q, bo, mu, h);

Size an ESP against the well's inflow

Intake pressure, total dynamic head, stages and motor horsepower for a target rate.

esp_design.scriptAL.ESP
var esp = SystemAnalysis.DesignCheck(
    designRate: 2000,          // STB/d
    pumpTvd: 7500,             // ft
    wellheadPressure: 150,
    reservoirPressure: 3200,
    productivityIndex: 2.2,
    specificGravity: 0.88,
    headPerStage: 42,          // from the pump curve
    pumpEfficiency: 0.68,
    formationVolumeFactor: 1.2);

// esp.StagesRequired, esp.TotalDynamicHead,
// esp.PumpIntakePressure, esp.MotorHorsepowerRequired

CO₂ MMP with an impure injectant

The pure-CO₂ minimum miscibility pressure, corrected for the nitrogen and methane in recycled gas.

co2_mmp.scriptEoR.Co2
var pure = MinimumMiscibilityPressure.ByYelligMetcalfe(
    Temperature.FromDegF(165), Pressure.FromPsi(1850));

var recycled = MinimumMiscibilityPressure.CorrectByAlston1985(
    pure,
    moleFractionCo2: 0.88, moleFractionN2: 0.04,
    moleFractionC1: 0.08, moleFractionH2S: 0.00);

// Miscible only while the reservoir stays above recycled.Psi.

Oil in place, gas cap and aquifer

A Havlena–Odeh fit for oil in place and gas-cap size over the surveys before an aquifer arrives, then whatever is left over as water influx.

material_balance.scriptMBE
// Fit the surveys from before the aquifer arrives, so its water is not read as oil.
var (n, m) = HavlenaOdeh.EstimateNAndM(F[..3], Eo[..3], Eg[..3]);

// Whatever the oil and gas cap don't explain, at any survey, is water influx.
var et = Eo.Zip(Eg, (o, g) => o + m * g).ToArray();
var we = F.Zip(et, (f, e) => HavlenaOdeh.InferWaterInflux(f, n, e)).ToArray();

How it fits

One library, three ways in

The agent

Writes scripts that call it

The agent reads the same reference you do, then writes a short script against it.

Scripts and dashboards

Bring it in like any library

A using line in a script or a dashboard, and the whole surface is there.

You

Read what was called

Every method a script calls is documented in the app's Scripting API Explorer: what it computes, its parameters and their units.