9. Using it as a library
For anything beyond "run once, get files" — batch runs, custom output processing, coupling with other tools — use the Python API directly instead of the CLI:
from vflood_rri.model import load_model
from vflood_rri.engine import run
model = load_model("RRI_Input.txt")
print(model.river.count, "river cells")
def on_output(snap):
print(snap.step, snap.hs.max())
final_state = run(model, on_output=on_output)load_model() does all the static setup (grid, indexing, channel geometry — no
physics yet); run() does the actual time-stepping and calls on_output/on_storage
callbacks whenever there's a new snapshot to hand off. See cli.py for a complete,
working example of wiring those callbacks up to real files.