Exerciseschevron_rightChapter 5chevron_right5.1
fitness_center

Exercise 5.1

Decline Rate Comparison

Level 2
Chapter 5: Data Visualization & Plotting
descriptionProblem

Generate exponential-decline production for three wells with the same initial rate and different decline rates:

  • Gentle: Di=0.02/monthD_i = 0.02 / \text{month}
  • Moderate: Di=0.05/monthD_i = 0.05 / \text{month}
  • Aggressive: Di=0.10/monthD_i = 0.10 / \text{month}

All start at qi=1,000q_i = 1{,}000 bbl/day. Compute monthly rates over 36 months using q(t)=qieDitq(t) = q_i \cdot e^{-D_i \cdot t}.

Build:

  1. t: NumPy array 0, 1, ..., 36.
  2. q_gentle, q_moderate, q_aggressive: three NumPy arrays of rates.
  3. A figure with two side-by-side subplots built via

fig, axes = plt.subplots(1, 2, figsize=(14, 5)). The left axis axes[0] plots all three wells on a linear y-scale. The right axis axes[1] plots the same three wells on a semi-log y-scale (axes[1].set_yscale("log")).

  1. Both panels need axis labels, a title, and a legend.

> Think about it: why does the petroleum industry prefer the > semi-log view for decline analysis? What information becomes visible > on the log scale that the linear scale hides?

lightbulbHints (0/3)

Stuck? Reveal hints one at a time — they progress from nudge to near-solution.

codeYour solution
main.py
visibilityReveal reference solutionexpand_more

Try solving it yourself first — the hints walk you through it. The solution below is one valid approach; yours may differ and still be correct.

import numpy as np
import matplotlib.pyplot as plt

qi = 1000
t = np.arange(0, 37)

q_gentle     = qi * np.exp(-0.02 * t)
q_moderate   = qi * np.exp(-0.05 * t)
q_aggressive = qi * np.exp(-0.10 * t)

fig, axes = plt.subplots(1, 2, figsize=(14, 5))

for ax in axes:
    ax.plot(t, q_gentle,     label="Gentle (Di=0.02/mo)")
    ax.plot(t, q_moderate,   label="Moderate (Di=0.05/mo)")
    ax.plot(t, q_aggressive, label="Aggressive (Di=0.10/mo)")
    ax.set_xlabel("Month")
    ax.set_ylabel("Oil rate (bbl/day)")
    ax.legend()
    ax.grid(True, alpha=0.3)

axes[0].set_title("Linear scale")
axes[1].set_yscale("log")
axes[1].set_title("Semi-log scale")

fig.suptitle("Decline-rate comparison - linear vs semi-log", fontweight="bold")
plt.tight_layout()
plt.show()

lockCopying code is a Full Access feature.