Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
shamrock.utils.SimulationRunner.SimulationRunner Class Reference
Inheritance diagram for shamrock.utils.SimulationRunner.SimulationRunner:
Collaboration diagram for shamrock.utils.SimulationRunner.SimulationRunner:

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

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

shamrock.utils.SimulationRunner.SimulationRunner.__init__ ( self,
model )

Definition at line 299 of file SimulationRunner.py.

Member Function Documentation

◆ do_checkpoint()

shamrock.utils.SimulationRunner.SimulationRunner.do_checkpoint ( self,
int icheckpoint,
** kwargs )

Definition at line 332 of file SimulationRunner.py.

◆ evolve_until()

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.

◆ goto_run_next_callback()

shamrock.utils.SimulationRunner.SimulationRunner.goto_run_next_callback ( self)

Definition at line 432 of file SimulationRunner.py.

◆ restore_from_checkpoint()

shamrock.utils.SimulationRunner.SimulationRunner.restore_from_checkpoint ( self,
dict metadata )

Definition at line 366 of file SimulationRunner.py.

◆ run()

shamrock.utils.SimulationRunner.SimulationRunner.run ( self)

Definition at line 469 of file SimulationRunner.py.

◆ run_setup()

shamrock.utils.SimulationRunner.SimulationRunner.run_setup ( self)

Definition at line 349 of file SimulationRunner.py.

◆ trigger_and_advance_callbacks()

shamrock.utils.SimulationRunner.SimulationRunner.trigger_and_advance_callbacks ( self)

Definition at line 413 of file SimulationRunner.py.

Member Data Documentation

◆ _callbacks

shamrock.utils.SimulationRunner.SimulationRunner._callbacks = []
protected

Definition at line 302 of file SimulationRunner.py.

◆ _callbacks_state

list shamrock.utils.SimulationRunner.SimulationRunner._callbacks_state = None
protected

Definition at line 316 of file SimulationRunner.py.

◆ cur_iter_count

shamrock.utils.SimulationRunner.SimulationRunner.cur_iter_count = 0
static

Definition at line 294 of file SimulationRunner.py.

◆ cur_t

shamrock.utils.SimulationRunner.SimulationRunner.cur_t = 0.0
static

Definition at line 293 of file SimulationRunner.py.

◆ dump_helper

shamrock.utils.SimulationRunner.SimulationRunner.dump_helper = ShamrockDumpHandleHelper(self.model, self.dump_prefix, metadata=True)

Definition at line 319 of file SimulationRunner.py.

◆ dump_prefix

str shamrock.utils.SimulationRunner.SimulationRunner.dump_prefix = None
static

Definition at line 291 of file SimulationRunner.py.

◆ model

shamrock.utils.SimulationRunner.SimulationRunner.model = model

Definition at line 300 of file SimulationRunner.py.

◆ t_end

float shamrock.utils.SimulationRunner.SimulationRunner.t_end = None
static

Definition at line 290 of file SimulationRunner.py.


The documentation for this class was generated from the following file: