# Python Series – Basic plotting and curve fitting

//Python Series – Basic plotting and curve fitting

# Basic Gas MBE with Python

## One of the main approaches in estimating reserves as we produce hydrocarbons is to use the Material Balance Equation. The material balance equation (MBE) is simply a method to track the volumetric balance into, out, and stored (select cases) in the reservoir. The general MBE relates the initial pressure/ volume of hydrocarbons in the reservoir to total production volumes and current pressure conditions. There are several types of MBE depending on the types of fluid(s) in the reservoir (i.e., dry gas, wet gas, gas condensate, volatile oil, black oil) and the primary driving mechanism(s) (i.e., solution gas drive, gascap drive, natural water drive, compaction drive) for hydrocarbon production (Dake, 2010). Two of the main MBEs are designed for gas reservoirs (i.e., dry gas, wet gas, gas condensate) and oil reservoirs (i.e., volatile oil, black oil). The MBE for gas reservoir with no significant water influx nor other additional driving mechanisms (i.e., water drive), also known as volumetric depletion reservoir, can simply be defined as follows (Dake, 2010) ## Or in terms of PVT (Pressure, Volume, and Temperature), relations can be written as # Plotting Gas MBE

## The first step to creating the plot in Figure 1 is to initialize the library. Two of the libraries we will need are NumPy and matplotlib.pyplot and are written into the editor window on lines 12 and 13, as shown in Figure 2. For convenience, we rename the NumPy library as np and the matplotlib.pyplot library as plt. Figure 2 – Spyder interface

## The next step we need to do is to load the data we need. I simply copied the data from SPE 10125 to a notepad. The information that we will need for this analysis is the p/z and pressure history data. Following is the script to load the data. Figure 3 – Loading data stored in a text file named SPE_10125_MBE_Gas into Python

# GIIP Approximation

## In this case, we can select to analyze the abnormal pressure segment up to index 8 or dataset 8 (or 7 in Python, see line 31 in Figure 6). We then define the associated Gp and p/z data using the np.array package listed on lines 32-33 (Figure 6). Using the polyfit package (line 34), we can get the trendline information for our data by specifying the following command np.polyfit(x-data, y-data, degree of fitting polynomial). Since we are looking to get a linear trend, we use a degree of a fitting polynomial of 1. The polyfit function’s output is the coefficients of a linear line equation, as shown in Equation 3. Equation 3 is obtained after rearranging Equation 2 with b being the intercept related to our initial pressure/ compressibility factor ratio, m is the slope related to how we will predict our apparent GIP, x is the cumulative production data, and y is the p/z ratio history. We can then replot the data using the linear coefficients obtained through polyfit. The first coefficient relates to the slope and can be called using poly_1, and the second coefficient relates to the intercept. We can then use this information to define new ydata, as shown in lines 38 and 43. Plotting can then be performed similarly to describe previously, but this time we will plot a line, so we are using plt.plot instead (lines 39 and 44). The plot of the apparent pressure prediction is labeled as “Apparent” in Figure 1. Finally, we can determine the apparent GIP, G, utilizing the definition of the b-intercept and m-slope (which includes G) and determined as shown in line 47 (i.e., dividing the intercept-b by the slope-m). ## Next week, we will look into some more advanced analysis on plotting a dimensionless constant rate solution of an infinite acting reservoir. Until then, stay well everyone!

Disclaimer: The Well Log is a non-profit publication aimed “purely” to educate students at Texas A&M University and beyond on information pertinent to the petroleum engineering industry. All articles are written by student volunteers based on information obtained through online sources and SPE publications. If you are the owner of any materials we cited and would like us to remove it from our publications, please contact The Well Log Editors at thewelllog@gmail.com

Sources:

Dake, L. P. The Practice of Reservoir Engineering. Rev. Ed. L.P. Dake. Rev. ed., Elsevier, 2001.

Dr. Blasingame’s PETE 324 Lecture Notes

Ramagost, B. P., & Farshad, F. F. (1981, January 1). P/Z Abnormally Pressured Gas Reservoirs. Society of Petroleum Engineers. doi:10.2118/10125-MS

Duggan, J. O. (1972, February 1). The Anderson “L” -An Abnormally Pressured Gas Reservoir in South Texas. Society of Petroleum Engineers. doi:10.2118/2938-PA

2020-10-26T23:48:50+00:00

#### Welcome Ags!

Welcome to the 2020-2021 academic year. Have a blast!