Machine Learning for Sustained Casing Pressure Detection

machine learning classifier for sustained casing pressure diagnosis showing MAASP ceiling on wellbore casing strings

By Saad Iqbal

Every well integrity engineer has the same recurring Monday-morning ritual: walk the wellhead pressure log, scan the B-annulus and C-annulus gauges, and ask the question that decides whether this is a quiet week or a very long one. Is that pressure reading just thermal breathing — the annulus warming and cooling with production rate the way it always has — or is it the first sign of a sustained casing pressure problem that builds, cycle after bleed-down, until it forces a workover? Get the call wrong one way and you bleed down a perfectly healthy annulus on a nervous schedule for years. Get it wrong the other way and a slow leak behind pipe becomes next quarter’s integrity incident.

The frustrating part is that the raw signal — annulus pressure versus time — looks almost identical in both cases on any single reading. The difference only shows up in the shape of the trend: how fast the pressure recovers after a bleed-down, whether it plateaus at a stable value or keeps climbing, and how that behavior tracks against tubing pressure, flow rate, and ambient temperature. That is a pattern-recognition problem, not a single-threshold alarm, and it is exactly the kind of problem a trained classifier is good at and a fixed high-pressure alarm is bad at.

machine learning classifier for sustained casing pressure diagnosis showing MAASP ceiling on wellbore casing strings

Why a Single Pressure Threshold Gets This Wrong

API RP 90 defines sustained casing pressure as annulus pressure that rebuilds after being bled to zero, which already tells you the single reading is the wrong unit of analysis — it is the rebuild behavior across multiple bleed-down cycles that matters. A fixed alarm set at, say, 70 percent of Maximum Allowable Annular Surface Pressure (MAASP) will fire identically for a well whose B-annulus is breathing thermally with produced-fluid temperature and a well whose cemented annulus has a genuine micro-annulus leak feeding gas up from a shallower zone. One needs no action. The other needs a workover before it becomes a well control event.

The Calculation Underneath: MAASP and the Rebuild-Rate Signature

Start with the governing relationship a well integrity engineer checks against by hand. Maximum Allowable Annular Surface Pressure for a given casing string is approximately:

MAASP = (Burst Rating / Safety Factor) − (Internal Fluid Gradient × TVD)

where Burst Rating is the casing’s rated internal yield pressure in psi, Safety Factor is typically 1.1–1.25 per operator policy, Internal Fluid Gradient is the annulus fluid’s pressure gradient in psi/ft, and TVD is true vertical depth to the casing shoe or next weak point in ft.

Worked example: a 9⅝-in, 47 lb/ft N-80 production casing rated at 6,330 psi burst, run to 8,500 ft TVD, with an annulus fluid gradient of 0.433 psi/ft (fresh water-based packer fluid) and a safety factor of 1.25:

MAASP = (6,330 / 1.25) − (0.433 × 8,500) = 5,064 − 3,681 = 1,383 psi

That single number is the ceiling. The classification problem is what happens below it: after a bleed-down to zero, a thermally breathing annulus typically rebuilds to a stable plateau within hours and holds there as long as flowing conditions hold steady — a self-limiting curve. A genuine SCP source — cement channeling, a casing leak, or tubing-to-annulus communication — rebuilds roughly linearly with time and does not plateau at a value that scales sensibly with temperature change alone. The rebuild rate (psi/hr) and the shape of the curve (concave, linear, or asymptotic) are the features that separate the two, not the peak pressure itself.

MAASP maximum allowable annular surface pressure formula worked example for sustained casing pressure analysis

Teaching a Model the Shape, Not Just the Number

This is where a trend classifier earns its place next to the MAASP hand calculation rather than replacing it. Gather, for each annulus on each well: the pressure-versus-time series across several bleed-down and rebuild cycles, tubing pressure and flow rate over the same window (thermal breathing tracks production, a true leak mostly does not), ambient and flowing temperature, and — where available — historical workover findings on what each flagged annulus actually turned out to be (thermal, confirmed SCP, or inconclusive).

From each bleed-down-to-rebuild cycle, engineer a small set of features rather than feeding raw time series into the model: rebuild rate in the first hour, rebuild rate in hours 2–24, plateau pressure as a fraction of MAASP, correlation between rebuild rate and simultaneous production rate, and days since last bleed-down. A gradient-boosted classifier or even a well-tuned logistic regression on those engineered features — built in Python with pandas for the cycle-slicing and scikit-learn for the model — will separate thermal breathing from genuine SCP candidates with far less noise than a static threshold, because it is scoring the behavior instead of a snapshot.

A minimal, fully worked example in code:

import pandas as pd
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.model_selection import train_test_split

# df: one row per bleed-down cycle, engineered features + label
# label: 1 = confirmed SCP on workover, 0 = thermal / benign
features = [
    "rebuild_rate_1hr_psi", "rebuild_rate_24hr_psi",
    "plateau_pct_of_maasp", "corr_rate_vs_production",
    "days_since_last_bleed"
]
X_train, X_test, y_train, y_test = train_test_split(
    df[features], df["label"], test_size=0.25, random_state=42
)
model = GradientBoostingClassifier(n_estimators=200, max_depth=3)
model.fit(X_train, y_train)
print("Test accuracy:", model.score(X_test, y_test))

# Score a new bleed-down cycle
new_cycle = [[48.0, 210.0, 0.61, 0.08, 9]]
risk = model.predict_proba(new_cycle)[0][1]
print(f"SCP risk probability: {risk:.1%}")

Score every active annulus on every scheduled bleed-down, and route anything the model flags above a conservative probability threshold — say 30 percent — to engineering review rather than straight to a workover queue. The model narrows the pile that needs a human look; it does not sign off on a workover by itself.

gradient boosted classifier bleed down rebuild rate curve shape for sustained casing pressure risk classification

Wiring It Into the Daily Workflow

Most operators already have wellhead annulus and tubing pressure flowing into a historian or SCADA system. The missing piece is usually not data access — it is turning raw pressure-versus-time into the cycle-level features above on a schedule, automatically, instead of someone pulling a spreadsheet once a quarter. A no-code workflow tool like Make or n8n can watch for each bleed-down event, slice out the rebuild window, compute the engineered features, and push them through the scoring model on a schedule, landing the output — and the flagged wells — on a shared dashboard the integrity team actually opens every morning.

automated workflow diagram using Make.com and n8n to flag sustained casing pressure risk from SCADA data

Verifying the Call

Expected result: a ranked list of annuli by SCP risk probability, refreshed after every scheduled bleed-down. Verify it against the MAASP hand calculation above for any annulus the model flags — if the plateau pressure is already closing in on MAASP regardless of what the model says, that annulus gets engineering attention on the pressure number alone, model or no model. Sanity-check a known case: run the model against a well with a documented, confirmed thermal-breathing history and confirm it scores low; run it against a well that was eventually worked over for genuine SCP and confirm it would have scored high well before the workover was called.

Three pitfalls catch most first attempts. First, too few confirmed-outcome cycles to train on — most operators have far more “probably fine” annuli than confirmed SCP cases, so the model needs class weighting or it will default to predicting “fine” for everything. Second, treating all annuli the same when B-annulus and C-annulus failure modes differ enough that separate models, or at minimum a type feature, usually outperform one model for everything. Third, forgetting that a changed operating regime — a choke change, an artificial lift conversion, a new completion nearby — can shift what “normal thermal breathing” looks like, so the model needs periodic retraining against recent cycles, not a one-time fit.

None of this replaces the well integrity engineer’s judgment or the API RP 90 framework — it sharpens where that judgment gets spent. Once an annulus is flagged, the same discipline that applies to erosion monitoring and other predictive-maintenance workflows applies here: trust the model to triage, and trust the hand calculation and the workover history to confirm. For the cementing decisions that prevent many of these annuli from becoming a problem in the first place, it is worth also reading how AI-assisted cementing design tools are being used to get zonal isolation right the first time.

Saad Iqbal Avatar

About the author

Saad Iqbal

Petroleum Engineer · Well Intervention & Stimulation Specialist

Saad Iqbal is a petroleum engineer and well intervention and stimulation specialist with more than a decade of field experience in hydraulic fracturing, coiled tubing, CSG, tight sandstone and shale developments. He explores practical AI, automation and data-driven engineering for safer, smarter upstream operations.