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.
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
Two-barrier philosophy: primary + independent secondary envelope. Drives override caps in the integrity engine.
Well-barrier element framework and independent verification principle. Informs the BarrierElement taxonomy and verification-penalty model.
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
Pydantic v2 frozen model: barriers, casing, fluids, depth, location, dates.
5 components: primary barrier, secondary barrier, cement quality, mechanical integrity, plugging → 0–100 score with override caps.
7 factors: integrity (inverted), fluid hazard, proximity to receptors, reservoir pressure, well age, temperature, data uncertainty → 0–100 score + 5×5 risk matrix.
Gate-based CO₂ + geothermal screening (ISO 27914-inspired) → verdict: reuse / remediate / monitor / abandon.
Key Features
Every score carries a nested calculation_trace. JSON and Excel reports embed the complete derivation, suitable for publication appendices.
All weights and thresholds live in weights.yaml and thresholds.yaml. Tunable without code changes.
JSON (lean or traced), Excel (multi-sheet audit trail), PDF (ReportLab publication-quality), and interactive Streamlit dashboard.
Gate-based CO₂ storage suitability (ISO 27914-inspired) and geothermal suitability screening in one pipeline.
Pass an explicit as_of date for byte-for-byte reproducible output across runs, platforms, and Python versions.
FastAPI backend with /assess, /assess/batch, and /report/{json|excel|pdf} endpoints. Interactive OpenAPI docs at /docs.
Tech Stack
| Layer | Technologies |
|---|---|
| Core engines | Python 3.12+, Pydantic v2, PyYAML |
| Visualisations | Plotly |
| Reports | ReportLab (PDF), OpenPyXL (Excel) |
| API | FastAPI, Uvicorn |
| Dashboard | Streamlit |
| Quality | pytest, ruff, mypy --strict, GitHub Actions CI |
| License | MIT |
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.7Sample Outcomes
| Well | Integrity | Risk | Verdict | CO₂ | Geothermal |
|---|---|---|---|---|---|
| WELL-EXCELLENT | 91.3 / 100 | 18.7 / 100 | ✅ REUSE | Suitable | Suitable |
| WELL-REMEDIATE | 59.0 / 100 | 46.2 / 100 | 🔧 REMEDIATE | Conditional | Conditional |
| WELL-ABANDON | 15.8 / 100 | 82.4 / 100 | ⛔ ABANDON | Unsuitable | Unsuitable |
| WELL-DATAPOOR | 47.3 / 100 | 61.0 / 100 | 🔧 REMEDIATE | Unsuitable | Insufficient data |
View source code and documentation on GitHub
Cite this tool — CITATION.cff available in the repository.