Engineering Libraries · 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: fifteen calculation domains, from fluid properties to enhanced recovery.
// Outflow: Hagedorn & Brown up 8,000 ft of 2.992" tubing.
var well = 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)));
// Inflow meets outflow: bisect on bottom-hole pressure.
double lo = 0, hi = 3000, pwf = 0, q = 0;
for (int i = 0; i < 40; i++)
{
pwf = (lo + hi) / 2;
q = InflowPerformance.RateByGeneralizedVogel(1.5, 3000, pwf, 2200);
var need = well.InletPressure(Pressure.FromPsi(200),
FlowRate.FromBblPerD(q), FlowRate.FromMmscfPerD(q * 500e-6)).Psi;
(lo, hi) = need > pwf ? (pwf, hi) : (lo, pwf);
}- 15
- calculation domains, from fluid properties to enhanced recovery
- 478
- calculation classes a script can call
- 2,040
- public methods a script can call
What's inside
Fifteen 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.
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.
BubblePointPressureGasZFactorBlackOilFluidEquations of state
Cubic equations of state with characterisation, splitting, binary interaction, flash, phase envelopes and critical points. Simulates CCE, DLE and CVD, and regresses to lab data.
CubicEoSBuilderPhaseEnvelopeSpecial core analysis
Relative permeability and capillary pressure for water-oil, gas-oil, gas-water, three-phase and gas-condensate systems.
CoreyWaterOilRelPermStoneIIRelPermWells and flow
From the sandface to the separator.
Inflow performance
Steady-state, pseudosteady-state and transient inflow, for oil, gas and fractured wells.
InflowPerformanceTransientFlowMultiphase well flow
Pressure traverses through tubing with the standard multiphase flow models, holdup and friction.
FlowModelBuilderPipeArtificial lift
ESP design (pump, motor, cable, total dynamic head, viscosity correction), gas-lift valves and rod pumps.
SystemAnalysisPumpSurface facilities
Single- and multiphase chokes, single- and two-phase pipelines, flow-regime maps.
GilbertChokeBakerMapReservoir and production analysis
Reading what the reservoir is telling you.
Decline-curve analysis
Decline models with robust fitting, outlier down-weighting, segmentation and AIC/BIC model selection.
ArpsHyperbolicFitterAicSelectorPressure-transient analysis
Bourdet derivative, buildup analysis, boundaries, dual porosity, horizontal and fractured wells, radial composite.
BourdetDerivativeBuildupRate-transient analysis
Flowing material balance, rate-integral derivatives and gas pseudo-time.
FlowingMaterialBalanceMaterial balance
Havlena–Odeh, gas material balance, drive indices and aquifer models.
HavlenaOdehFetkovichAquiferUncertainty and recovery
Ranges, not single numbers, and what comes after primary.
Monte Carlo
A sampling engine with normal, lognormal, PERT, triangular and uniform distributions, correlated inputs and P10/P50/P90.
MonteCarloBuilderEnhanced oil recovery
Screening and predictive models for CO₂ (minimum miscibility pressure, Koval sweep, oil swelling), polymer, chemical and steam flooding.
MinimumMiscibilityPressureIn 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.
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.
// Fit five decline models to the same history.
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/dSTOIIP as a range, not a number
Volumetrics under uncertainty, with porosity and water saturation correlated, sampled 10,000 times.
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");
var s = run.GetStatistics("stoiip"); // s.P10, s.P50, s.P90Read a buildup
The Bourdet derivative for the diagnostic plot, then permeability from the Horner slope.
// Diagnostic plot: Bourdet derivative on Agarwal equivalent time.
var derivative = BourdetDerivative.CalculateBuildup(tp, dt, pws, smoothingL: 0.1);
// Flat derivative = radial flow, so read the Horner slope over the last log cycle.
var hr = Buildup.HornerTimeRatio(tp, dt);
int a = dt.Length - 11, b = dt.Length - 1;
double slope = (pws[b] - pws[a]) / (Math.Log10(hr[a]) - Math.Log10(hr[b]));
// q = 850 STB/d, B = 1.25 rb/STB, mu = 1.1 cP, h = 60 ft.
double k = Buildup.PermeabilityFromSlope(slope, 850, 1.25, 1.1, 60);Size an ESP against the well's inflow
Intake pressure, total dynamic head, stages and motor horsepower for a target rate.
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.MotorHorsepowerRequiredCO₂ MMP with an impure injectant
The pure-CO₂ minimum miscibility pressure, corrected for the nitrogen and methane in recycled gas.
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, then whatever is left over as water influx.
var (n, m) = HavlenaOdeh.EstimateNAndM(F, Eo, Eg);
// Whatever the oil and gas cap don't explain 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();These and more in the example gallery → scripts, dashboards, queries and simulation decks, each with its page.
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 has a page: what it computes, its parameters and their units.
See every class and method
The reference is generated from the same catalog as the Scripting API Explorer in the app.