Add a producer to a loaded deck
"""Load a deck and add a producer: the well, its perforation and its control in one ``m.set``.
Every verb returns a checked model, and a well with no control is refused(``[well.control.missing]``), so the new well and the facts that make it a producer are settogether, each at its address. A summary request for the new well is added beside the deck'sown, which stay. The deck is written whole, the loaded schedule kept.
Flow keywords it exercises: the whole of SPE1, plus WELSPECS, COMPDAT and WCONPROD for the newwell and its WOPR/WBHP summary.
Run it with ``python examples/add_well.py [DECK]``. DECK defaults to SPE1 in the opm-testscorpus at ``opm-tests/`` (``git clone https://github.com/OPM/opm-tests``); it writes``out/add_well/``."""
import sys
import petroscript as ps
path = sys.argv[1] if len(sys.argv) > 1 else "opm-tests/spe1/SPE1CASE2.DATA"m = ps.load(path)start = m.start.isoformat()
m = m.set({ "wells/P2": ps.Well(name="P2", i=5, j=5), f"schedule/{start}/P2/perforation/1": ps.Perforate(well="P2", k=(3, 3), diameter=0.5), f"schedule/{start}/P2/control": ps.Produce(well="P2", oil_rate=2000.0, bhp_limit=1000.0), "summary/wells/P2": ["oil_production_rate", "bottom_hole_pressure"],})print("wells:", [well.name for well in m.wells])
deck = ps.compile(m)deck.write("out/add_well")
if ps.simulators(): run = deck.run(folder="out/add_well/run") oil = run.wells("oil_production_rate").filter(well="P2") print(f"P2 oil rate: {oil['value'][0]:.0f} -> {oil['value'][-1]:.0f} {oil['unit'][-1]}")else: print("no simulator found (set PETROSCRIPT_FLOW, or put flow on PATH); the deck is in " "out/add_well")PetroScript is licensed under the Apache License 2.0. © 2026 Blauweiss EDV LLC. PetroScript by Blauweiss AI.For AI agents: llms.txt