![]() |
Shamrock 2025.10.0
Astrophysical Code
|
Public Member Functions | |
| __init__ (self, model) | |
| do_checkpoint (self, int icheckpoint, **kwargs) | |
| run_setup (self) | |
| restore_from_checkpoint (self, dict metadata) | |
| evolve_until (self, float next_time, int|None next_iter_count, float|None next_walltime) | |
| trigger_and_advance_callbacks (self) | |
| goto_run_next_callback (self) | |
| run (self) | |
| Public Member Functions inherited from shamrock.utils.SimulationRunner.SimulationMeta | |
| __new__ (mcls, name, bases, namespace) | |
Public Attributes | |
| model = model | |
| dump_helper = ShamrockDumpHandleHelper(self.model, self.dump_prefix, metadata=True) | |
Static Public Attributes | |
| float | t_end = None |
| str | dump_prefix = None |
| float | cur_t = 0.0 |
| int | cur_iter_count = 0 |
Protected Attributes | |
| list | _callbacks = [] |
| list | _callbacks_state = None |
| Protected Attributes inherited from shamrock.utils.SimulationRunner.SimulationMeta | |
| _declared_callbacks = callbacks | |
| _setup = setup_func | |
SimulationRunner is a base class to declare a simulation with setup & callbacks.
A derived class must define:
- t_end: float = <end time of the simulation>
- a setup (any function decorated with @simulation_setup)
And can define callbacks (any function decorated with @callback):
< call every tsim = i * time_step >
- @callback(tsim_interval=1.0)
def analysis(self, icallback):
rank_0_print("analysis")
< call at exact simulation times >
- @callback(at_tsim=[1.0, 5.0, 10.0])
def snapshot(self, icallback):
rank_0_print("snapshot")
< call when tsim = dt_stop, niter_max is reached or walltime_step is reached >
- @callback(tsim_interval=dt_stop, iter_count_interval=1000, walltime_interval=30*60)
def do_checkpoint(self, icheckpoint):
self.dump_helper.dump(icheckpoint)
Note that for the last one that this reset the counters until next callback.
The trigger conditions are inclusive and reset the counters for all triggers of that callback.
Definition at line 261 of file SimulationRunner.py.
| shamrock.utils.SimulationRunner.SimulationRunner.__init__ | ( | self, | |
| model ) |
Definition at line 299 of file SimulationRunner.py.
| shamrock.utils.SimulationRunner.SimulationRunner.do_checkpoint | ( | self, | |
| int | icheckpoint, | ||
| ** | kwargs ) |
Definition at line 332 of file SimulationRunner.py.
| shamrock.utils.SimulationRunner.SimulationRunner.evolve_until | ( | self, | |
| float | next_time, | ||
| int | None | next_iter_count, | ||
| float | None | next_walltime ) |
Definition at line 388 of file SimulationRunner.py.
| shamrock.utils.SimulationRunner.SimulationRunner.goto_run_next_callback | ( | self | ) |
Definition at line 432 of file SimulationRunner.py.
| shamrock.utils.SimulationRunner.SimulationRunner.restore_from_checkpoint | ( | self, | |
| dict | metadata ) |
Definition at line 366 of file SimulationRunner.py.
| shamrock.utils.SimulationRunner.SimulationRunner.run | ( | self | ) |
Definition at line 469 of file SimulationRunner.py.
| shamrock.utils.SimulationRunner.SimulationRunner.run_setup | ( | self | ) |
Definition at line 349 of file SimulationRunner.py.
| shamrock.utils.SimulationRunner.SimulationRunner.trigger_and_advance_callbacks | ( | self | ) |
Definition at line 413 of file SimulationRunner.py.
|
protected |
Definition at line 302 of file SimulationRunner.py.
|
protected |
Definition at line 316 of file SimulationRunner.py.
|
static |
Definition at line 294 of file SimulationRunner.py.
|
static |
Definition at line 293 of file SimulationRunner.py.
| shamrock.utils.SimulationRunner.SimulationRunner.dump_helper = ShamrockDumpHandleHelper(self.model, self.dump_prefix, metadata=True) |
Definition at line 319 of file SimulationRunner.py.
|
static |
Definition at line 291 of file SimulationRunner.py.
| shamrock.utils.SimulationRunner.SimulationRunner.model = model |
Definition at line 300 of file SimulationRunner.py.
|
static |
Definition at line 290 of file SimulationRunner.py.