Simulator¶
simulator
¶
Simulation orchestration for flepimop2.
Simulator(system, engine, backend, *, target=None, simulate_config=None, system_config=None, engine_config=None, backend_config=None, parameter_configs=None, axes=None)
¶
Build and run a single simulation from configuration models.
Attributes:
| Name | Type | Description |
|---|---|---|
system |
SystemABC
|
The built system instance. |
engine |
EngineABC
|
The built engine instance. |
backend |
BackendABC
|
The built backend instance. |
target |
str | None
|
Optional target simulate config to use. |
simulate_config |
SimulateSpecificationModel | None
|
The resolved simulation specification. |
system_config |
ModuleConfigurationValue | None
|
The resolved system configuration dict. |
engine_config |
ModuleConfigurationValue | None
|
The resolved engine configuration dict. |
backend_config |
ModuleConfigurationValue | None
|
The resolved backend configuration dict. |
Initialize the simulator with resolved components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemABC
|
The built system instance. |
required |
engine
|
EngineABC
|
The built engine instance. |
required |
backend
|
BackendABC
|
The built backend instance. |
required |
target
|
str | None
|
Optional target simulate config to use. |
None
|
simulate_config
|
SimulateSpecificationModel | None
|
The resolved simulation specification, if available. |
None
|
system_config
|
ModuleConfigurationValue | None
|
The resolved system configuration model, if available. |
None
|
engine_config
|
ModuleConfigurationValue | None
|
The resolved engine configuration model, if available. |
None
|
backend_config
|
ModuleConfigurationValue | None
|
The resolved backend configuration model, if available. |
None
|
parameter_configs
|
dict[IdentifierString, ModuleConfigurationValue] | None
|
The resolved parameter configuration values, if available. |
None
|
axes
|
AxisCollection | None
|
The resolved runtime axis collection for the simulation. |
None
|
Raises:
| Type | Description |
|---|---|
Flepimop2ValidationError
|
If the engine is incompatible with the system. |
Source code in src/flepimop2/simulator.py
from_configuration_model(config_model, target=None)
classmethod
¶
Build a simulator from a configuration model.
Returns:
| Type | Description |
|---|---|
Simulator
|
The constructed simulator instance. |
Source code in src/flepimop2/simulator.py
resolve_inputs()
¶
Resolve configured parameters into an initial state and stepper inputs.
Returns:
| Type | Description |
|---|---|
tuple[dict[IdentifierString, ParameterValue], dict[IdentifierString, ParameterValue]]
|
Structured initial-state entries and structured stepper parameters. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If a required parameter is missing from configuration. |
ValueError
|
If model state cannot be resolved for the system. |
Source code in src/flepimop2/simulator.py
run(initial_state=None, params=None, meta=None)
¶
Run the simulation and persist results via the backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
initial_state
|
dict[IdentifierString, ParameterValue] | None
|
Structured initial-state entries for the simulation. |
None
|
params
|
dict[IdentifierString, ParameterValue] | None
|
Structured stepper parameters for the simulation. |
None
|
meta
|
RunMeta | None
|
Metadata about the simulation run. |
None
|
Returns:
| Type | Description |
|---|---|
Float64NDArray
|
The simulation result array. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |