Part III: Reservoir & Production Engineering

Chapter 15

Natural Gas Engineering with Python

schedule15 min readfitness_center10 exercises

Why This Chapter Exists

Natural gas accounts for roughly a quarter of global energy consumption, and that share is growing. Unlike oil, which is valued primarily as a liquid fuel, gas serves as feedstock for power generation, petrochemicals, fertiliser production, and increasingly as a transition fuel in decarbonisation strategies. The engineering challenges of gas are distinct from oil: gas is compressible, its properties change dramatically with pressure and temperature, and transporting it requires either pipelines under high pressure or liquefaction at -162°C.

Every calculation in gas engineering starts with one fundamental reality: gas does not behave like an ideal gas. The ideal gas law (PV=nRTPV = nRT) is a useful approximation at low pressures, but at the pressures found in reservoirs (3,000–15,000 psi) and pipelines (500–2,000 psi), real gas behaviour deviates significantly. The compressibility factor ZZ captures that deviation, and getting ZZ right is the foundation on which every other gas calculation rests.

This chapter builds the core gas engineering toolkit: gas property calculations, well deliverability analysis, and pipeline hydraulics. Each calculation is implemented from the underlying physics so you understand what the equations assume and when they break down.

infoWhat You Will Learn

  • Calculate gas properties: Z-factor, formation volume factor, compressibility, viscosity, and density
  • Implement the Standing-Katz correlation and the Dranchuk-Abou-Kassem (DAK) equation of state
  • Perform gas well deliverability analysis (AOF, IPR)
  • Size gas pipelines using the General Flow Equation and its simplified forms
  • Calculate compression requirements for gas gathering and transmission

Gas Properties

The Compressibility Factor (Z)

The real gas equation of state is:

PV=ZnRTPV = ZnRT

where ZZ is the compressibility factor — a dimensionless number that corrects the ideal gas law for the behaviour of real gas molecules. At standard conditions (14.7 psia, 60°F), Z1.0Z \approx 1.0. At reservoir conditions, ZZ can range from 0.3 to 1.2 depending on pressure, temperature, and gas composition.

ZZ is calculated using reduced properties --- the ratio of actual conditions to the gas's critical conditions:

Ppr=PPpcTpr=TTpcP_{pr} = \frac{P}{P_{pc}} \qquad T_{pr} = \frac{T}{T_{pc}}

where PpcP_{pc} and TpcT_{pc} are the pseudo-critical pressure and temperature of the gas mixture, estimated from gas specific gravity using the Sutton correlations:

Ppc=756.8131.0×γg3.6×γg2P_{pc} = 756.8 - 131.0 \times \gamma_g - 3.6 \times \gamma_g^2
Tpc=169.2+349.5×γg74.0×γg2T_{pc} = 169.2 + 349.5 \times \gamma_g - 74.0 \times \gamma_g^2
main.py

Dranchuk-Abou-Kassem (DAK) Z-Factor Correlation

The Standing-Katz chart is the industry-standard graphical method for determining ZZ from reduced properties. The DAK correlation is an eleven-coefficient equation that fits the Standing-Katz chart to within 1% accuracy for most conditions:

main.py

Gas Formation Volume Factor and Density

Once ZZ is known, the gas formation volume factor BgB_g (reservoir volume per standard volume) and gas density follow directly:

Bg=Psc×Z×TP×Tsc=0.02827×Z×TP(res bbl/scf)B_g = \frac{P_{sc} \times Z \times T}{P \times T_{sc}} = \frac{0.02827 \times Z \times T}{P} \quad \text{(res bbl/scf)}
ρg=P×MgZ×R×T=2.7×γg×PZ×T(lb/ft³)\rho_g = \frac{P \times M_g}{Z \times R \times T} = \frac{2.7 \times \gamma_g \times P}{Z \times T} \quad \text{(lb/ft³)}
main.py

Gas Well Deliverability

Gas well deliverability testing determines a well's ability to produce against a given back-pressure. The two standard test methods are the backpressure (flow-after-flow) test and the isochronal test.

The deliverability equation has two common forms:

Simplified (backpressure) equation:

qsc=C(Pe2Pwf2)nq_{sc} = C(P_e^2 - P_{wf}^2)^n

Forchheimer (quadratic) equation:

Pe2Pwf2=Aqsc+Bqsc2P_e^2 - P_{wf}^2 = Aq_{sc} + Bq_{sc}^2

where AA represents laminar (Darcy) flow resistance and BB represents turbulent (non-Darcy) flow resistance near the wellbore.

main.py

Gas Pipeline Hydraulics

The steady-state flow of gas through a horizontal pipeline is governed by the General Flow Equation:

qsc=77.54×TbPb×[(P12P22)×D5f×γg×Tavg×Zavg×L]0.5q_{sc} = 77.54 \times \frac{T_b}{P_b} \times \left[ \frac{(P_1^2 - P_2^2) \times D^5} {f \times \gamma_g \times T_{avg} \times Z_{avg} \times L} \right]^{0.5}

where:

  • qscq_{sc} = flow rate at standard conditions (scf/day)
  • TbT_b, PbP_b = base temperature (°R) and pressure (psia)
  • P1P_1, P2P_2 = inlet and outlet pressures (psia)
  • DD = pipe internal diameter (inches)
  • ff = Moody friction factor
  • γg\gamma_g = gas specific gravity
  • TavgT_{avg} = average temperature (°R)
  • ZavgZ_{avg} = average Z-factor
  • LL = pipeline length (miles)

Several simplified forms exist for practical use. The Weymouth equation assumes a specific friction factor relationship and is conservative (underpredicts capacity). The Panhandle A equation is commonly used for large-diameter, high-pressure transmission lines.

main.py

Gas Compression

When pipeline pressure drop exceeds the available upstream pressure, or when gathering low-pressure gas for transmission, compression is required. The key calculations are compression ratio, number of stages, power requirement, and discharge temperature.

main.py

Exercises

fitness_center
Exercise 15.1Practice

-- Z-Factor Sensitivity

Calculate and plot Z vs. pressure (100–10,000 psia) for gas gravities of 0.55, 0.65, 0.75, and 0.85 at 200°F. How does gas composition (heavier = high...

arrow_forward
codePythonSolve Nowarrow_forward
fitness_center
Exercise 15.2Practice

-- Gas Property Module

Build a gas_properties module with functions for Z, Bg, density, viscosity, and compressibility. Include a gas_property_table(P_range, T, gamma_g) fun...

arrow_forward
codePythonSolve Nowarrow_forward
fitness_center
Exercise 15.3Practice

-- Gas Material Balance

For a volumetric gas reservoir (no water influx), the P/Z plot is linear: P/Z = (Pi/Zi)(1 - Gp/G). Given initial pressure 4,500 psia, temperature 220°...

arrow_forward
codePythonSolve Nowarrow_forward
fitness_center
Exercise 15.4Practice

-- Gas Well Deliverability

A gas well was tested at four rates. Fit both the backpressure equation and the Forchheimer equation. Calculate AOF using both methods and compare. Wh...

arrow_forward
codePythonSolve Nowarrow_forward
fitness_center
Exercise 15.5Practice

-- Pipeline Pressure Profile

For a 100-mile, 24-inch pipeline operating at 1,200 psia inlet and 800 psia outlet, calculate and plot the pressure at every mile along the pipeline. ...

arrow_forward
codePythonSolve Nowarrow_forward
fitness_center
Exercise 15.6Practice

-- Looped Pipeline

An existing 20-inch pipeline can deliver 120 MMscf/d. Demand has increased to 180 MMscf/d. Calculate the diameter of a parallel (looped) line that, co...

arrow_forward
codePythonSolve Nowarrow_forward
fitness_center
Exercise 15.7Practice

-- Compression Staging

For a compression ratio of 20:1, compare the total horsepower required for 1, 2, 3, and 4 stages. Plot HP vs. number of stages. Why does adding stages...

arrow_forward
codePythonSolve Nowarrow_forward
fitness_center
Exercise 15.8Practice

-- Gas Gathering System

Design a gas gathering system for four wells producing 10, 15, 8, and 22 MMscf/d at wellhead pressures of 400, 350, 300, and 450 psia respectively. Al...

arrow_forward
codePythonSolve Nowarrow_forward
fitness_center
Exercise 15.9Practice

-- Gas Dehydration

Gas must be dehydrated before entering a pipeline to prevent hydrate formation and corrosion. Calculate the water content of a 0.65 gravity gas at 1,0...

arrow_forward
codePythonSolve Nowarrow_forward
fitness_center
Exercise 15.10Practice

-- Integrated Gas Field Development

A gas field has estimated reserves of 500 Bscf. Design a development plan that includes: well deliverability (number of wells needed for a plateau rat...

arrow_forward
codePythonSolve Nowarrow_forward

Summary

  • Gas does not behave ideally. The compressibility factor Z corrects the ideal gas law for real gas behaviour and is the foundation of every gas engineering calculation.
  • The DAK correlation provides an analytical method to calculate Z from reduced pressure and temperature, replacing graphical methods with code.
  • Gas properties — formation volume factor, density, viscosity, and compressibility — all depend on Z and change significantly with pressure and temperature.
  • Gas well deliverability is characterised by the backpressure equation (q=C(ΔP2)nq = C(\Delta P^2)^n) or the Forchheimer equation. The deliverability exponent nn indicates the degree of turbulence near the wellbore.
  • Pipeline capacity depends on the fifth power of diameter, making pipe sizing the single most important decision in gas transmission. The General Flow, Weymouth, and Panhandle equations provide different levels of conservatism.
  • Compression is required when natural pressure is insufficient. Staging reduces power requirements significantly for high compression ratios.
  • The tools built in this chapter — z_factor_DAK(), gas_properties(), pipeline_capacity(), compression_power() — form a complete gas engineering calculation library.