simulation#
hydromodpy.simulation orchestrates one simulation from validated
configuration to ingested results. It splits planning (declarative
SimulationPlan of ProcessRun units) from execution
(SimulationRunner) and post-run extraction.
Sub-modules#
simulation/planning/–SimulationPlanner.build()resolves[[simulation.process]]declarations into an immutableSimulationPlancontaining oneProcessRunper(process_id, solver_name)pair. Backward-only dependency resolution throughprovider.required_bindings().simulation/execution/–SimulationRunner.execute(plan, ctx, callbacks)iterates the plan, ensures the matching process context is available, and delegates each run to the registered solver adapter.simulation/extraction/– post-run hook (post_run_results()) that ingests solver outputs into the catalog. Four steps:extract_run_outputs,derive_run_outputs,auto_export_results,cleanup_solver_outputs.simulation/adapters/– backend-agnostic helpers (transport adapters, display postprocess). Different fromsolver/<backend>/adapters/which are backend-specific.
Plan and run units#
@dataclass(frozen=True)
class SimulationPlan:
name: str
description: str
runs: tuple[ProcessRun, ...]
@dataclass(frozen=True)
class ProcessRun:
id: str # for example "flow_main::modflownwt"
process_id: str
process_type: str # "flow", "transport", ...
solver: str # "modflownwt", "modflow6", "boussinesq", ...
depends_on: tuple[str, ...] # other ProcessRun ids
A single TOML such as flow_main [modflownwt] + transport_main
[modpath, mt3dms] expands into three ordered runs with the
implicit depends_on set.
Extraction pipeline#
After each execute, post_run_results():
Calls registered base extractors (
extract_run_outputs) that convert solver files (HDS, CBC, etc.) into NumPy / Pandas payloads.Computes derived outputs (
derive_run_outputs).Triggers auto-export (
auto_export_results: Zarr fields, CSV tables, JSON manifests).Cleans up scratch files (
cleanup_solver_outputs).
Derivation helpers live under
simulation/extraction/derivation/: base.py (Protocol),
observation_ingest.py, catchment_aggregation.py,
derived.py. They register through the solver-output-adapter
registry so each backend can ship its own extractor.
Key public symbols#
hydromodpy.simulation.planning.planner.SimulationPlannerhydromodpy.simulation.planning.plan.{SimulationPlan, ProcessRun}hydromodpy.simulation.execution.runner.SimulationRunnerhydromodpy.simulation.extraction.post_run.post_run_resultshydromodpy.simulation.execution.trial.{prepare_trials, run_trial_light, promote_trial}(used by calibration).
Recommended reading path#
hydromodpy/simulation/README.mdhydromodpy/simulation/planning/planner.pyhydromodpy/simulation/planning/plan.pyhydromodpy/simulation/execution/runner.pyhydromodpy/simulation/extraction/post_run.pyhydromodpy/simulation/execution/trial.pyfor theprepare-once / evaluate-manyprimitive used by calibration.
Layer-matrix neighbours#
Allowed targets:
core,schema,physics,spatial,data,simulation.Allowed sources:
solver,calibration,config,workflow,projectandcli.
See also#
Comparison Workflow Architecture for the comparison launcher built on top of this stack.
TOML To Solver Walkthrough for the step-by-step config-to-solver path.
solver for the registry that the planner queries.
workflow for the pipeline steps that wrap
SimulationRunner.