All examples
Small scripts that each run end to end: build or load a model, check it, compile it, write the deck and, when a simulator is found, run it and read the results by name. Each covers a different part of PetroScript and of what OPM Flow does, and its docstring names the Flow keywords it exercises. Run one from the repository root:
python examples/waterflood.py # writes out/waterflood/, and runs it when Flow is foundEvery public name, one line each, is on the API map.
deck.run() finds OPM Flow through PETROSCRIPT_FLOW, then flow on PATH, and JutulDarcy
through PETROSCRIPT_JUTULDARCY; lift_neqsim.py needs a NeqSim runner, PETROSCRIPT_NEQSIM
(Install and engines). Without one, each script stops after writing its deck
and says so. The four scripts that load a deck take its path
as an argument and default to SPE1 in the opm-tests corpus at opm-tests/.
| Script | What it shows |
|---|---|
waterflood.py | A model from scratch: an oil-water waterflood, checked, compiled, run and read |
load_and_edit.py | Load SPE1, lower a well’s target from day 365 with ps.Adjust, and read m.diff |
water_cut_rule.py | A rule that fires during the run: shut a producer once its water cut passes 50% |
grid_edit.py | Cut the permeability tenfold in a box with m.apply, checked with m.array |
gas_water_check.py | A gas field over water where m.check() catches a unit slip, fixed at its address |
aquifer.py | A Fetkovich aquifer under an oil column, run with and without it |
lift_table.py | A producer on a hand-built lift table, held to a tubing-head pressure limit as it depletes |
lift_neqsim.py | A lift table NeqSim makes from the tubing and the oil’s components, then run in Flow |
add_well.py | Load SPE1 and add a producer: the well, its perforation and its control in one m.set |
group_tree.py | Two groups under the field, wells on group control, one field oil target |
two_targets.py | One model, two simulators: SPE1 compiled for OPM Flow and for JutulDarcy, both run, compared by name |
tests/test_examples.py runs every script in a fresh process: without Flow on every suite run,
and with Flow in the flow-marked rows. The worked cases the docs and the book cite as fixtures
live under tests/fixtures/examples/; they are test inputs, not examples to start from.
PetroScript is licensed under the Apache License 2.0. © 2026 Blauweiss EDV LLC. PetroScript by Blauweiss AI.For AI agents: llms.txt