microbenthos.runners package¶
Submodules¶
microbenthos.runners.simulate module¶
-
class
microbenthos.runners.simulate.
SimulationRunner
(output_dir=None, resume=False, confirm=False, overwrite=False, model=None, simulation=None, progress=False, progress_tag='evolution', plot=False, video=False, frames=False, budget=False, exporters=None, show_eqns=False)[source]¶ Bases:
object
Class that handles the pipeline of creating and running simulations of models, and generating outputs from it.
This class will:
check that the model & simulation setup are complete
check the output path
create a log file
export the model definition
export the run setup
setup the exporters
run the simulation evolution
clean up
-
property
model
¶ The model to run with the
simulation
. Typically an instance ofMicroBenthosModel
.
-
add_exporter
(exptype, name=None, **kwargs)[source]¶ Add an exporter to the simulation run
- Parameters
- Returns
The name of the exporter created
-
_create_output_dir
()[source]¶ Create the output directory
- Raises
OSError – if
output_dir
is a file and not a dir
-
run
()[source]¶ Run the simulation with the stored model and simulation setup.
This performs a sequence of operations:
shows equations if
show_eqns
is setAnnounces simulation settings in output
Runs
check_simulation()
creates output directory
sets up the logfile
saves definitions to yaml outputs of simulation & model
saves the runtime info (library, exporter versions etc)
prepares the simulation
activates the exporter context (see
exporters_activated()
)iterates over the
simulation.evolution()
and passes returned state to the exportersafter that tears down the logfile
- Raises
RuntimeError – if no simulation exists