ADR-011 โ OPM Flow Simulator Integration¶
Status¶
Proposed
Context¶
Ian contributed a standalone Docker setup for OPM Flow in the opmflow/ directory.
This provides working infrastructure for running the open-source reservoir simulator, including:
- Dockerfile based on Ubuntu 22.04 with OPM packages from the official PPA
- docker-compose configuration for local development
- Sample SPE1CASE1 test case with output artifacts
- Documentation for standalone usage
However, this implementation exists as an isolated component within the repository:
- No adapter interface: The setup lacks the contract defined in
docs/simulators/adapter_matrix.mdrequiringrun(case) -> {converged, errors, metrics?, artifacts?}. - Architectural disconnect: Code in
opmflow/has no connection tosrc/clarissa/simulators/. - Repository hygiene issues: Output files (
.EGRID,.INIT,.PRT) committed to repo; duplicate test data files exist.
Per ADR-001, simulators are "first-class learning substrates" requiring proper integration into CLARISSA's feedback loop. The current standalone structure prevents OPM Flow from participating in the learning and governance cycles.
Decision¶
Refactor the OPM Flow integration from a standalone directory into the CLARISSA simulator module structure:
src/clarissa/simulators/
โโโ __init__.py
โโโ base.py # SimulatorAdapter ABC (new)
โโโ mock.py # existing MockSimulator
โโโ opm/
โโโ __init__.py
โโโ adapter.py # OPMFlowAdapter implementing contract
โโโ Dockerfile # moved from opmflow/
โโโ docker-compose.yml # moved from opmflow/
โโโ entrypoint.sh # moved from opmflow/
tests/
โโโ contracts/
โ โโโ test_simulator_contract.py # extended for OPM
โโโ integration/
โโโ test_opm_flow.py # new integration tests
The opmflow/ directory will be removed after migration.
Output artifacts and duplicate data files will be excluded via .gitignore.
Rationale¶
-
Alignment with ADR-001: Simulators belong in the core module as learning substrates, not as isolated infrastructure artifacts.
-
Contract enforcement: The adapter pattern ensures OPM Flow returns standardized feedback (
converged,errors,metrics) for CLARISSA's learning loop. -
Co-location principle: Adapter code and its Docker infrastructure belong togetherโ changes to one often require changes to the other.
-
Extensibility: This pattern serves as a template for future simulator backends (MRST, commercial simulators via file-based interfaces).
-
Testability: Contract tests can verify OPM adapter behavior alongside MockSimulator, enabling CI validation without requiring full simulation runs.
Consequences¶
Positive¶
- OPM Flow becomes a first-class CLARISSA component participating in learning cycles.
- Clear contract enables CI integration and standardized feedback parsing.
- Pattern established for additional simulator backends.
- Ian's infrastructure work is preserved and properly integrated.
Negative¶
- Migration requires careful commit sequence to preserve git history attribution.
- Adapter implementation adds code surface that must be maintained.
- Docker build adds CI complexity (image caching, registry decisions).
Neutral / Open¶
- Docker image build/push strategy for CI to be determined separately.
- Decision on test data location (keep SPE1 in repo vs. download on demand) deferred.
- MPI parallelization support in adapter interface not yet specified.
Alternatives Considered¶
Option B: Separate infrastructure directory¶
infrastructure/docker/opm-flow/
src/clarissa/simulators/opm/adapter.py # references infrastructure/
Option C: Keep opmflow/ as-is, add adapter separately¶
Rejected: Perpetuates architectural debt; creates unclear ownership; likely leads to duplicate Docker configurations or drift between standalone and integrated versions.
Implementation Notes¶
- Use Conventional Commits:
refactor:for moves,feat:for adapter implementation - Update CHANGELOG.md under appropriate version section
- Extend
.gitignorefor OPM output artifacts (.PRT,.EGRID,.INIT,.DBG) - Consider preserving git history via
git mvwhere possible
Related ADRs¶
- ADR-001 โ Physics-Centric, Simulator-in-the-Loop Architecture
- ADR-003 โ CLARISSA-Native Simulation Kernel
- ADR-004 โ Dual-Simulator Strategy (Superseded)