Skip to content

wellcast.dca

dca

Arps decline curve analysis.

Time is measured in days from the start of the fitted decline, rates in volume per day (for example bbl/d) and cumulative volumes in the same volume unit. The nominal decline rate di is expressed per year, as is customary in reserves reporting.

The three Arps (1945) models are

\[ q(t) = \begin{cases} q_i e^{-D_i t} & b = 0 \ \text{(exponential)} \\ q_i (1 + b D_i t)^{-1/b} & 0 < b < 1 \ \text{(hyperbolic)} \\ q_i / (1 + D_i t) & b = 1 \ \text{(harmonic)} \end{cases} \]

Arps, J. J. (1945), "Analysis of decline curves", Transactions of the AIME 160(1), 228-247, SPE-945228-G.

Probabilistic bands follow the petroleum reserves convention (SPE-PRMS): P90 is the low estimate (exceeded with 90 percent probability), P50 the best estimate and P10 the high estimate.

DeclineModel

DeclineModel(model: Literal['auto', 'exponential', 'hyperbolic', 'harmonic'] = 'auto', *, b_bounds: tuple[float, float] = (0.01, 2.0), from_peak: bool = True, loss: str = 'soft_l1')

Fit, forecast and evaluate an Arps decline.

Parameters:

Name Type Description Default
model ('auto', 'exponential', 'hyperbolic', 'harmonic')

Model to fit. "auto" fits all three and keeps the lowest AIC. Default "auto".

"auto"
b_bounds tuple of float

Bounds on the hyperbolic exponent. Default (0.01, 2.0); values above 1 occur during transient (unconventional) flow.

(0.01, 2.0)
from_peak bool

Start the fit at the peak of the 7-sample rolling median rate, so the ramp-up period is ignored. Default True.

True
loss str

Loss passed to scipy.optimize.least_squares. The default "soft_l1" (scale 0.1 in log-rate, about 10 percent) limits the influence of rate spikes; use "linear" for ordinary least squares.

'soft_l1'

Attributes:

Name Type Description
model_ str

Selected model name.

qi_, di_, b_ float

Fitted initial rate (volume/day), nominal decline (1/year) and exponent.

aic_ dict of str to float

AIC of every candidate model.

start_ Timestamp or None

Date of t = 0 when fitted on a date-indexed Series.

t_offset_ float

Time of the decline start (t = 0) on the input time axis, days. Non-zero when from_peak skipped a ramp-up period.

t_last_ float

Time of the last observation used in the fit, days after decline start.

n_obs_ int

Number of observations used.

Notes

Zero, negative and missing rates (shut-ins and gaps) are excluded before fitting. Fitting minimizes residuals of \(\ln q\), which treats rate errors as multiplicative.

Examples:

>>> import numpy as np
>>> from wellcast.dca import DeclineModel, arps_rate
>>> t = np.arange(0.0, 1000.0, 10.0)
>>> q = arps_rate(t, 1500.0, 0.8, 0.5)
>>> m = DeclineModel("hyperbolic").fit(q, time=t)
>>> round(m.qi_, 1), round(m.di_, 3), round(m.b_, 3)
(1500.0, 0.8, 0.5)
>>> round(m.eur(econ_limit=50.0) / 1e6, 4)
1.1196

from_params classmethod

from_params(qi: float, di: float, b: float, *, start: Timestamp | str | None = None) -> DeclineModel

Create a fitted model from known parameters.

Parameters:

Name Type Description Default
qi float

Initial rate, volume/day.

required
di float

Initial nominal decline, 1/year.

required
b float

Arps exponent.

required
start Timestamp or str

Date of t = 0, enabling date-based prediction.

None

Returns:

Type Description
DeclineModel

A model that can predict and compute EUR but has no bootstrap samples.

Examples:

>>> m = DeclineModel.from_params(1000.0, 0.5, 0.0)
>>> m.model_
'exponential'

fit

fit(rates: Series | ArrayLike, time: ArrayLike | None = None) -> DeclineModel

Fit the decline model.

Parameters:

Name Type Description Default
rates Series or array_like

Rates in volume/day. A Series with a DatetimeIndex defines the time axis itself; otherwise time (days) is used, or the sample number when time is omitted.

required
time array_like

Observation times in days, for array input.

None

Returns:

Type Description
DeclineModel

The fitted model (self).

Raises:

Type Description
FitError

If fewer than 4 positive observations remain or every candidate fit fails.

DataValidationError

If inputs are inconsistent.

predict

predict(t: ArrayLike | DatetimeIndex) -> FloatOrArray

Predict rates.

Parameters:

Name Type Description Default
t array_like or DatetimeIndex

Days since the start of decline, or dates (when fitted on a date-indexed Series).

required

Returns:

Type Description
float or ndarray

Rate, volume/day.

Raises:

Type Description
FitError

If the model is not fitted.

cumulative

cumulative(t: ArrayLike | DatetimeIndex) -> FloatOrArray

Cumulative production from the start of decline.

Parameters:

Name Type Description Default
t array_like or DatetimeIndex

Days since the start of decline, or dates.

required

Returns:

Type Description
float or ndarray

Cumulative volume.

Raises:

Type Description
FitError

If the model is not fitted.

time_to_limit

time_to_limit(econ_limit: float) -> float

Days from the start of decline until the rate reaches econ_limit.

Parameters:

Name Type Description Default
econ_limit float

Economic limit rate, volume/day.

required

Returns:

Type Description
float

Time in days.

Raises:

Type Description
FitError

If the model is not fitted.

eur

eur(econ_limit: float, *, max_years: float | None = None) -> float

Estimated ultimate recovery from the start of decline.

Parameters:

Name Type Description Default
econ_limit float

Economic limit rate, volume/day.

required
max_years float

Cap on the producing life after the start of decline, years.

None

Returns:

Type Description
float

Cumulative volume from t = 0 to the economic limit. Production before the decline start (the ramp-up removed by from_peak) is not included.

Raises:

Type Description
FitError

If the model is not fitted.

DataValidationError

If econ_limit is not positive.

remaining

remaining(econ_limit: float, *, max_years: float | None = None) -> float

Remaining reserves after the last observation.

Parameters:

Name Type Description Default
econ_limit float

Economic limit rate, volume/day.

required
max_years float

Cap on the producing life after the start of decline, years.

None

Returns:

Type Description
float

eur(econ_limit) - cumulative(t_last_), never negative.

forecast

forecast(days: int, *, econ_limit: float | None = None) -> pd.DataFrame

Daily forecast after the last observation.

Parameters:

Name Type Description Default
days int

Number of days to forecast.

required
econ_limit float

Stop the forecast when the rate falls below this value.

None

Returns:

Type Description
DataFrame

Columns t (days since decline start), rate and cumulative; indexed by date when the start date is known.

Raises:

Type Description
FitError

If the model is not fitted.

bootstrap

bootstrap(n_samples: int = 200, *, seed: int | None = 0) -> DeclineModel

Estimate parameter uncertainty by residual bootstrap.

Log-rate residuals of the fit are resampled with replacement, added to the fitted curve and the selected model is refitted n_samples times.

Parameters:

Name Type Description Default
n_samples int

Number of bootstrap replicates. Default 200.

200
seed int or None

Random seed. Default 0.

0

Returns:

Type Description
DeclineModel

self, with samples stored for predict_interval and eur_quantiles.

Raises:

Type Description
FitError

If the model was not fitted on data.

predict_interval

predict_interval(t: ArrayLike | DatetimeIndex) -> pd.DataFrame

P90, P50 and P10 rate bands from the bootstrap samples.

Parameters:

Name Type Description Default
t array_like or DatetimeIndex

Days since decline start, or dates.

required

Returns:

Type Description
DataFrame

Columns p90 (low), p50 and p10 (high), one row per time.

Raises:

Type Description
FitError

If bootstrap has not been called.

eur_quantiles

eur_quantiles(econ_limit: float, *, max_years: float | None = None) -> pd.Series

P90, P50 and P10 EUR from the bootstrap samples.

Parameters:

Name Type Description Default
econ_limit float

Economic limit rate, volume/day.

required
max_years float

Cap on the producing life after decline start, years.

None

Returns:

Type Description
Series

Index p90, p50, p10 (ascending volumes).

Raises:

Type Description
FitError

If bootstrap has not been called.

summary

summary(econ_limit: float | None = None) -> pd.Series

Fitted parameters and diagnostics.

Parameters:

Name Type Description Default
econ_limit float

When given, eur and remaining are included.

None

Returns:

Type Description
Series

model, qi, di (nominal, 1/yr), de (effective annual decline, fraction), b, start, n_obs, residual_std (log-rate) and aic, plus eur and remaining when requested.

Raises:

Type Description
FitError

If the model is not fitted.

plot

plot(rates: Series | None = None, *, forecast_days: int = 3650, econ_limit: float | None = None, title: str | None = None) -> Any

Plot observed rates, the fitted curve and bootstrap bands.

Parameters:

Name Type Description Default
rates Series

Observed rates to overlay (date-indexed if the model is).

None
forecast_days int

Forecast horizon after the last observation. Default 3650.

3650
econ_limit float

Stop the forecast at this rate and draw the limit.

None
title str

Figure title.

None

Returns:

Type Description
Figure

Interactive figure with a logarithmic rate axis.

Raises:

Type Description
MissingDependencyError

If plotly is not installed.

arps_rate

arps_rate(t: ArrayLike, qi: float, di: float, b: float) -> FloatOrArray

Arps decline rate.

Parameters:

Name Type Description Default
t array_like

Time since the start of decline, days.

required
qi float

Initial rate at t = 0, volume/day.

required
di float

Initial nominal decline rate, 1/year.

required
b float

Arps exponent: 0 exponential, 1 harmonic, otherwise hyperbolic.

required

Returns:

Type Description
float or ndarray

Rate, volume/day.

Notes

See the module docstring for the equations; \(D_i\) is converted to 1/day as di / 365.25.

Examples:

>>> round(arps_rate(365.25, 1000.0, 0.5, 0.0), 2)
606.53
>>> round(arps_rate(365.25, 1000.0, 0.5, 1.0), 2)
666.67

arps_cumulative

arps_cumulative(t: ArrayLike, qi: float, di: float, b: float) -> FloatOrArray

Cumulative production of an Arps decline from t = 0.

Parameters:

Name Type Description Default
t array_like

Time since the start of decline, days.

required
qi float

Initial rate, volume/day.

required
di float

Initial nominal decline rate, 1/year.

required
b float

Arps exponent.

required

Returns:

Type Description
float or ndarray

Cumulative volume.

Notes

With \(D = D_i / 365.25\) (1/day):

\[ N_p(t) = \begin{cases} \frac{q_i}{D}\left(1 - e^{-Dt}\right) & b = 0 \\ \frac{q_i}{(1-b) D}\left[1 - (1 + bDt)^{(b-1)/b}\right] & b \ne 0, 1 \\ \frac{q_i}{D}\ln(1 + Dt) & b = 1 \end{cases} \]

Examples:

>>> round(arps_cumulative(365.25, 1000.0, 0.5, 0.0), 0)
287429.0

arps_time_to_rate

arps_time_to_rate(q: ArrayLike, qi: float, di: float, b: float) -> FloatOrArray

Time at which an Arps decline reaches rate q.

Parameters:

Name Type Description Default
q array_like

Target rate, volume/day.

required
qi float

Initial rate, volume/day.

required
di float

Initial nominal decline rate, 1/year.

required
b float

Arps exponent.

required

Returns:

Type Description
float or ndarray

Time in days (0 when q >= qi).

Notes

\(t = \ln(q_i/q)/D\) for \(b = 0\), otherwise \(t = [(q_i/q)^b - 1]/(bD)\).

Examples:

>>> round(arps_time_to_rate(500.0, 1000.0, 0.5, 1.0), 2)
730.5

fit_many

fit_many(df: DataFrame, by: str = 'well', rate_column: str = 'oil_rate', *, model: Literal['auto', 'exponential', 'hyperbolic', 'harmonic'] = 'auto', econ_limit: float | None = None, **kwargs: Any) -> pd.DataFrame

Fit a decline model to every well.

Wells that cannot be fitted are reported with status set to the error message instead of aborting the batch.

Parameters:

Name Type Description Default
df DataFrame

Production table with a DatetimeIndex.

required
by str

Grouping column. Default "well".

'well'
rate_column str

Rate column to fit. Default "oil_rate".

'oil_rate'
model str

Passed to DeclineModel. Default "auto".

'auto'
econ_limit float

Economic limit for EUR and remaining reserves.

None
**kwargs Any

Other DeclineModel options.

{}

Returns:

Type Description
DataFrame

One row per well (index by) with the columns of DeclineModel.summary and status ("ok" or the error). Rebuild a model with DeclineModel.from_params.

Raises:

Type Description
DataValidationError

If by or rate_column is missing or the index is not a DatetimeIndex.

Examples:

>>> from wellcast.datasets import make_synthetic_field
>>> field = make_synthetic_field(n_wells=2, n_injectors=0)
>>> table = fit_many(field.production, econ_limit=20.0)
>>> table["status"].tolist()
['ok', 'ok']