pogona.SimulationKernel

class pogona.SimulationKernel[source]

Bases: Component

The simulation kernel that is responsible for starting and coordinating how a simulation is run.

For configuration, kernel parameters are configured on the root level, along with the following ‘kernel components’:

Molecule_manager

Configuration of the MoleculeManager

Movement_predictor

Configuration of the MovementPredictor

Scene_manager

Configuration of the SceneManager

Sensor_manager

Configuration of the SensorManager

Mesh_manager

Configuration of the MeshManager

All other Component instances must be configured under the YAML key components.

Attributes

adaptive_time_corrections_limit

Maximum number of corrections within one sub time step.

adaptive_time_max_error_threshold

If, when using adaptive time stepping, the error exceeds this threshold, the time step will be multiplied with time_step_reduction_factor and the molecule positions will be recalculated for the current step.

adaptive_time_safety_factor

Safety factor for estimating the optimal next step size to keep the error below adaptive_time_max_error_threshold.

base_delta_time

Base time step for adaptive time stepping.

component_name

Unique name of this component, unless it is "Generic component".

interpolation_method

results_dir

Base directory for any result files (e.g., sensor logs).

seed

sim_time

sim_time_limit

use_adaptive_time_stepping

If True, use adaptive time stepping.

__init__()[source]

Methods

__init__()

attach_component(component)

destroy_molecule(molecule)

finalize(simulation_kernel)

get_base_delta_time()

get_components()

get_elapsed_base_time_steps()

get_elapsed_sub_time_steps()

get_integration_method()

get_interpolation_method()

get_mesh_manager()

get_molecule_manager()

get_movement_predictor()

get_random_number_generator()

get_scene_manager()

get_seed()

get_sensor_manager()

get_simulation_time()

initialize(simulation_kernel, init_stage)

Use InitStages to initialize this Component instance.

initialize_components()

Run through all initialization stages for all attached components, starting with this simulation kernel itself, then the kernel components, and then the remaining components.

notify_components_new_time_step()

Allow sensors and other components to process the new positions of molecules.

process_new_time_step(simulation_kernel, ...)

set_arguments(**kwargs)

Read arguments as key value pairs and set this component's member variables accordingly.

simulation_loop_adaptive_rkf()

Simulation loop with adaptive time stepping.

simulation_loop_legacy()

start([skip_initialization])

Start the simulation.

__init__()[source]
attach_component(component: Component)[source]
destroy_molecule(molecule)[source]
finalize(simulation_kernel: SimulationKernel)
get_base_delta_time() float[source]
get_components() Dict[str, Component][source]
get_elapsed_base_time_steps() int[source]
get_elapsed_sub_time_steps() int[source]
get_integration_method() Integration[source]
get_interpolation_method() Interpolation[source]
get_mesh_manager() MeshManager[source]
get_molecule_manager() MoleculeManager[source]
get_movement_predictor() MovementPredictor[source]
get_random_number_generator() RandomState[source]
get_scene_manager() SceneManager[source]
get_seed() Optional[int][source]
get_sensor_manager() SensorManager[source]
get_simulation_time() float[source]
initialize(simulation_kernel: SimulationKernel, init_stage: InitStages)[source]

Use InitStages to initialize this Component instance.

initialize_components()[source]

Run through all initialization stages for all attached components, starting with this simulation kernel itself, then the kernel components, and then the remaining components.

Will be called automatically by the start() method.

notify_components_new_time_step()[source]

Allow sensors and other components to process the new positions of molecules. If using adaptive time stepping, this is only called in base time steps!

process_new_time_step(simulation_kernel: SimulationKernel, notification_stage: NotificationStages)
set_arguments(**kwargs)[source]

Read arguments as key value pairs and set this component’s member variables accordingly. Validity of the argument values will be checked in initialize().

simulation_loop_adaptive_rkf()[source]

Simulation loop with adaptive time stepping.

Uses a constant base time step base_delta_time. Within each base time step, sub-step sizes are chosen on a per-particle basis to ensure that the error of the selected Runge-Kutta-Fehlberg method (RKF) will stay below the threshold adaptive_time_max_error_threshold.

Sensors are only notified in base time steps, for now.

simulation_loop_legacy()[source]
start(skip_initialization=False)[source]

Start the simulation.

Parameters

skip_initialization – Should only ever be True if you previously called initialize_components() yourself.

adaptive_time_corrections_limit = 100

Maximum number of corrections within one sub time step. Since we estimate the optimal sub step size, the number of corrections should usually be very low (< 10?).

adaptive_time_max_error_threshold = inf

If, when using adaptive time stepping, the error exceeds this threshold, the time step will be multiplied with time_step_reduction_factor and the molecule positions will be recalculated for the current step.

adaptive_time_safety_factor = 0.85

Safety factor for estimating the optimal next step size to keep the error below adaptive_time_max_error_threshold. We want to avoid picking a next step size that would cause us to just barely overshoot the error threshold in the next (sub-)step.

base_delta_time = 1.0

Base time step for adaptive time stepping. Delta times will never be larger than this value. All logging and sensor evaluations happen at this interval.

component_name = 'Generic component'

Unique name of this component, unless it is “Generic component”.

id

Unique integer component ID

interpolation_method = 'MODIFIED_SHEPARD'
results_dir = ''

Base directory for any result files (e.g., sensor logs).

seed = 1
sim_time = 0.0
sim_time_limit = 0.0
use_adaptive_time_stepping = False

If True, use adaptive time stepping. Requires an appropriate integration method in the MovementPredictor.