Production and reservoir toolbox
The TheTechIdea.OilGas.Production package. Settings: toolboxes.production in the environment.
Decline curve analysis
DeclineCurve is Arps' (1945) empirical decline - q(t) = qi (1 + b Di t)^(-1/b), b = 0 the exponential case q(t) = qi e^(-Di t):
| b | Decline | Cumulative production |
|---|---|---|
| 0 | Exponential | (qi - q) / Di |
| 0 < b < 1 | Hyperbolic | qi / (Di (1 - b)) x (1 - (q/qi)^(1-b)) |
| 1 | Harmonic | qi / Di x ln(qi / q) |
Rate(t), Cumulative(t), TimeAtRate(q) and Eur(economicLimit) (estimated ultimate recovery - cumulative production to an economic
limit rate) use these closed forms directly; Forecast(economicLimit, step) gives a rate and cumulative series out to the limit.
Harmonic decline (b = 1) never reaches zero production in finite time, so a forecast or EUR needs a maxTime or a positive economic
limit - an infinite decline (no maxTime) is reported rather than looping forever.
DeclineFitter.Fit(observations) fits qi, Di and b to rate-time data: for a given b, q^(-b) (or ln q when b = 0) is exactly linear in
time, so qi and Di come from an exact linear regression; b itself is found by a golden-section search minimising the squared-log-rate
residual. FitFixedB(observations, b) fits with b held at a company- or analyst-chosen value (0 for exponential, 1 for harmonic).
The fit reports its R-squared and flags TransientFlowWarning when b exceeds production.maxPhysicalB (default 1.0): Arps (1945)
noted that b above this range describes transient flow, not depletion, and overestimates reserves.
Inflow performance and nodal analysis
Vogel.Rate(qomax, pr, pb, pwf) is Vogel's (1968) dimensionless inflow relationship for a fully saturated solution-gas-drive reservoir
(pb >= pr): qo = qomax [1 - 0.2(pwf/pr) - 0.8(pwf/pr)^2]. MaxRateFromTest(testRate, testPwf, pr) finds qomax from one stabilised flow
test, checked against a published worked example (qo = 305 STB/D at pwf = 2010 psia, pr = 2550 psia, gives qomax = 883 STB/D).
For an undersaturated reservoir (pb < pr), CompositeRate(qomax, j, pr, pb, pwf) uses the straight line q = j(pr - pwf) above the
bubble point with the field-measured productivity index j, and Vogel's curve below it, matched in value at pb;
MaxRateFromProductivityIndex(j, pr, pb) gives the qomax that makes the two meet there (Standing, 1970), reducing to his
zero-drawdown relation qomax = j pr / 1.8 when pb >= pr.
Vertical lift (VerticalLift) is the two-phase pressure-traverse method of Beggs and Brill (1973), A Study of Two-Phase Flow in
Inclined Pipes (SPE 4007): the flow-pattern boundaries (segregated, intermittent, distributed, transition), the horizontal liquid
holdup correlations and the two-phase friction factor are reproduced and checked against their published equations. Traverse marches
the pressure from a known point (the wellhead or separator) down to bottomhole in steps of production.liftStep.
The inclination correction. The liquid holdup of segregated and intermittent upward flow is corrected for the pipe's inclination: HL(theta) = psi HL(0), psi = 1 + C [sin(1.8 theta) - 0.333 sin^3(1.8 theta)], C = (1 - lambdaL) ln(d lambdaL^e N_LV^f Fr^g), never below zero, with the published coefficients (segregated d, e, f, g = 0.011, -3.768, 3.539, -1.614; intermittent 2.96, 0.305, -0.4473, 0.0978; distributed flow needs none). N_LV is the Duns and Ros liquid velocity number v_sL (rho_L / (g sigma))^(1/4) - dimensionless, so it is computed from SI quantities and there is no constant to look up (the 1.938 of the field-unit form is that expression after unit conversion). It is part of the published method, so production.inclinationCorrection is on by default; switch it off to see the horizontal holdup. It applies to upward flow only (downhill coefficients could not be matched unambiguously), and in the transition region psi is interpolated with the same weights as the horizontal holdups - an assumption of this implementation, chosen because it keeps the result continuous across the pattern boundaries.
NodalAnalysis.Solve finds where a well's inflow (IPR) curve meets its outflow (tubing intake) curve - the well's actual operating
rate and flowing bottomhole pressure.
Pressure-test interpretation (Horner analysis)
HornerAnalysis.Analyze(inputs, readings) is the Horner (1951) build-up method: plotting shut-in pressure against log10 of the Horner
time ratio (tp + dt) / dt gives a straight line, pws = p* - m log10((tp + dt)/dt), whose slope gives permeability and whose value at
Delta t = 1 hour gives the skin factor (field units):
- m = 162.6 q B mu / (k h), so k = 162.6 q B mu / (m h);
- s = 1.151 [(p1hr - pwf) / m - log10(k / (phi mu ct rw^2)) + 3.23];
- p* (the pressure at a Horner ratio of 1 - infinite shut-in time) is the straight line's extrapolated value, used as an estimate of initial or average reservoir pressure.
The caller selects the middle-time readings that lie on the straight line (wellbore-storage effects distort early points, boundary
effects distort late ones); Analyze fits exactly to whichever readings it is given and reports the fit's R-squared.
No reliably reproducible published worked example could be found (several textbook excerpts found online did not reproduce their own stated answers when recomputed from the printed numbers - likely OCR errors in the source). The method is instead validated by generating synthetic build-up data from the same equations with known permeability, skin and initial pressure, and confirming the analysis recovers them exactly - the same approach used for the decline-curve fitter (7.9).
BuildupInputs.ProducingTimeFromCumulative(Np, q) gives the pseudo-producing time tp = 24 Np / q when it is not recorded directly.
HornerAnalysis.ToCsv exports the plotted points.
Values that come from the environment
Nothing about your fluids, tubing or reservoir is assumed in the code. production.pipeRoughness (0.0006 in, a figure often used for new steel tubing - an assumption: set yours) is the
wall roughness behind the friction factor. A flow calculation or build-up analysis that is not given a fluid or reservoir property takes it from production.defaultFluid or
production.defaultReservoir - your field's typical values, none set by default. If neither supplies it the call stops with an error naming the value (OilFvf is required: set it on
FlowProperties or in production.defaultFluid): a silent default gives a plausible answer for a fluid nobody described. The densities of a flow calculation, and the rate, shut-in pressure and
producing time of a build-up, are always required. production.nodalScanSteps (20) is how many rates the nodal analysis scans for the operating point, and
production.declineSearchMaxB (2) the largest decline exponent the fit will try.