Skip to main content
Back to Projects
Open Source · Python · 2025

Legacy Well Risk Assessment (LWRA)

Traceable, deterministic integrity and reuse-potential screening for legacy oil & gas wells — targeting CO₂ geological storage and geothermal energy applications.

Python 3.12+FastAPIStreamlitPydantic v2PlotlyReportLabOpenPyXLMIT License

Overview

LWRA is an open-source Python library that evaluates the integrity and reuse potential of legacy oil and gas wells. Given a structured well description (barriers, casing, fluids, depth, location), it runs three deterministic engines — integrity, risk, and recommendation — and produces a fully traceable WellAssessment. Every score carries a calculation trace suitable for publication appendices and regulatory review. Methodology is inspired by API RP 90, NORSOK D-010, and ISO 27914 (non-compliant advisory tool).

Methodology & Standards

Reference
API RP 90

Two-barrier philosophy: primary + independent secondary envelope. Drives override caps in the integrity engine.

Reference
NORSOK D-010

Well-barrier element framework and independent verification principle. Informs the BarrierElement taxonomy and verification-penalty model.

Reference
ISO 27914

CO₂ containment and well-integrity criteria. Inspires the gate-based CO₂ storage suitability screening.

LWRA does not claim official compliance with any standard. Results are advisory and must be reviewed by a qualified well-integrity engineer before any operational decision.

Pipeline Architecture

WellData
Integrity Engine
Risk Engine
Recommendation Engine
Stage
WellData

Pydantic v2 frozen model: barriers, casing, fluids, depth, location, dates.

Stage
Integrity Engine

5 components: primary barrier, secondary barrier, cement quality, mechanical integrity, plugging → 0–100 score with override caps.

Stage
Risk Engine

7 factors: integrity (inverted), fluid hazard, proximity to receptors, reservoir pressure, well age, temperature, data uncertainty → 0–100 score + 5×5 risk matrix.

Stage
Recommendation Engine

Gate-based CO₂ + geothermal screening (ISO 27914-inspired) → verdict: reuse / remediate / monitor / abandon.

Key Features

Full Traceability

Every score carries a nested calculation_trace. JSON and Excel reports embed the complete derivation, suitable for publication appendices.

Externalised Configuration

All weights and thresholds live in weights.yaml and thresholds.yaml. Tunable without code changes.

Four Report Formats

JSON (lean or traced), Excel (multi-sheet audit trail), PDF (ReportLab publication-quality), and interactive Streamlit dashboard.

Dual Reuse Screening

Gate-based CO₂ storage suitability (ISO 27914-inspired) and geothermal suitability screening in one pipeline.

Deterministic & Reproducible

Pass an explicit as_of date for byte-for-byte reproducible output across runs, platforms, and Python versions.

REST API

FastAPI backend with /assess, /assess/batch, and /report/{json|excel|pdf} endpoints. Interactive OpenAPI docs at /docs.

Tech Stack

LayerTechnologies
Core enginesPython 3.12+, Pydantic v2, PyYAML
VisualisationsPlotly
ReportsReportLab (PDF), OpenPyXL (Excel)
APIFastAPI, Uvicorn
DashboardStreamlit
Qualitypytest, ruff, mypy --strict, GitHub Actions CI
LicenseMIT

Quick Start

from datetime import date
from lwra.sample_data import excellent_well
from lwra.services.pipeline import assess_well_traced

result = assess_well_traced(excellent_well(), as_of=date(2025, 1, 1))
print(result.verdict)                   # "reuse"
print(result.overall_integrity_score)   # 91.3
print(result.risk_score)                # 18.7

Sample Outcomes

WellIntegrityRiskVerdictCO₂Geothermal
WELL-EXCELLENT91.3 / 10018.7 / 100✅ REUSESuitableSuitable
WELL-REMEDIATE59.0 / 10046.2 / 100🔧 REMEDIATEConditionalConditional
WELL-ABANDON15.8 / 10082.4 / 100⛔ ABANDONUnsuitableUnsuitable
WELL-DATAPOOR47.3 / 10061.0 / 100🔧 REMEDIATEUnsuitableInsufficient data

View source code and documentation on GitHub

Cite this tool — CITATION.cff available in the repository.