Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

7/29/23, 11:30 AM Chato Solutions: Decline curve fitting with python

Decline curve fitting with python


PYTHON RESERVOIR ENGINEERING

Fitting production data using hyperbolic model.

AUTHOR

Rigoberto Chandomi Vazquez

PUBLISHED CITATION

Feb. 5, 2022 Vazquez, 2022

Non linear regression is a tool to find parameter from decline curves models, In this example we show you
how use curve_fit() function from scipy package in python. First loading the data and plot to analize its
behavior

import pandas as pd

data = pd.read_csv('REH_18.csv')
data

DAYS RATE
0 1 2.30000
1 2 3.00000
2 3 3.20000
3 4 3.00000
4 5 3.20000
.. ... ...
475 476 0.76237
476 477 0.66001
477 478 0.23185
478 479 0.26329
479 480 0.50926

[480 rows x 2 columns]

import matplotlib.pyplot as plt

DAYS = data.iloc[:, 0].values


RATE = data.iloc[:, 1].values
https://www.chatosolutions.com/posts/2022-02-05-hyppy/ 1/4
7/29/23, 11:30 AM Chato Solutions: Decline curve fitting with python

plt.scatter(DAYS,RATE);
plt.xlabel('Days');
plt.ylabel('Qg');
plt.show();

Hyperbolic decline

qi
qt =
1/b
(1 + bDi t)

Fist, the equation to fit the data has to be defined as a python function. The parameter getting from fitting
are the equation coefficiente and the coefficiente with a confidence interval.

from scipy.optimize import curve_fit

def hyperbolic(t,qi,b,Di):
return qi/((1+b*Di*t)**(1/b))

coef, coef_ic = curve_fit(hyperbolic, DAYS, RATE);

C:/Python37/python.exe:2: RuntimeWarning: invalid value encountered in power

print(coef)

[5.22129555 0.50293836 0.01120251]

print(coef_ic)

https://www.chatosolutions.com/posts/2022-02-05-hyppy/ 2/4
7/29/23, 11:30 AM Chato Solutions: Decline curve fitting with python

[[1.63858719e-02 5.22214531e-03 9.03298155e-05]


[5.22214531e-03 4.35482279e-03 5.10036457e-05]
[9.03298155e-05 5.10036457e-05 7.27271243e-07]]

Now, the predicted prodcution rate can be calculate using fitting parameters

hyp_pred = hyperbolic(DAYS, coef[0], coef[1], coef[2])

plt.rcParams["figure.figsize"]=20,10;
plt.scatter(DAYS, RATE);
plt.plot(DAYS,hyp_pred, color = "red", linewidth = 4);
plt.xlabel("Days");
plt.ylabel("Qg");
plt.show("");

Buy me a coffee

 0 Comments Share:  

https://www.chatosolutions.com/posts/2022-02-05-hyppy/ 3/4
7/29/23, 11:30 AM Chato Solutions: Decline curve fitting with python

Citation
For attribution, please cite this work as

Vazquez (2022, Feb. 5). Chato Solutions: Decline curve fitting with python. Retrieved from
https://www.chatosolutions.com/posts/2022-02-05-hyppy/

BibTeX citation

@misc{vazquez2022decline,
author = {Vazquez, Rigoberto Chandomi},
title = {Chato Solutions: Decline curve fitting with python},
url = {https://www.chatosolutions.com/posts/2022-02-05-hyppy/},
year = {2022}
}

https://www.chatosolutions.com/posts/2022-02-05-hyppy/ 4/4

You might also like