opengnc.simulation package
Submodules
opengnc.simulation.events module
- class opengnc.simulation.events.Event(t: float, callback: Callable[[...], Any], *args: Any, **kwargs: Any)[source]
Bases:
objectA single discrete event to be processed at a specific time.
- class opengnc.simulation.events.EventQueue[source]
Bases:
objectPriority queue managing discrete events in the simulation. Handles maneuver scheduling and mode transitions.
opengnc.simulation.logging module
- class opengnc.simulation.logging.SimulationLogger(filename: str)[source]
Bases:
objectSimulation replay and logging interface. Records state history and outputs to common formats like JSON, CSV. (HDF5 support optionally using h5py if installed).
- log(t: float, state: Any, measurements: Any = None, estimates: Any = None, commands: Any = None) None[source]
Record a simulation step.
- Parameters:
t (float) – Simulation time.
state (Any) – True state of the system (e.g. state vector).
measurements (Any, optional) – Sensor measurements at this time step.
estimates (Any, optional) – Filter estimates at this time step.
commands (Any, optional) – Control commands sent to actuators.
opengnc.simulation.monte_carlo module
- class opengnc.simulation.monte_carlo.MonteCarloSim(simulator_factory: Callable[[...], Any])[source]
Bases:
objectMonte Carlo Simulation Harness.
Facilitates large-scale robustness analysis by executing multiple simulation runs with stochastic variations.
- Parameters:
simulator_factory (Callable[..., MissionSimulator]) – Generator function to produce specialized simulator instances. Signature: (seed, **kwargs) -> MissionSimulator.
- get_analyzer() MonteCarloAnalyzer[source]
Produce a statistical analyzer for the current simulation results.
- Returns:
Instance of the analyzer initialized with current trial data.
- Return type:
- run_parallel(num_runs: int, processes: int | None = None, **kwargs: Any) list[Any][source]
Execute Monte Carlo iterations across multiple processor cores.
- Parameters:
num_runs (int) – Number of trials to execute.
processes (Optional[int]) – Number of parallel workers. Defaults to machine CPU count.
**kwargs – Parameters for simulation configuration.
- Returns:
Aggregated results.
- Return type:
List[Any]
- run_sequential(num_runs: int, **kwargs: Any) list[Any][source]
Execute Monte Carlo iterations in a single thread.
- Parameters:
num_runs (int) – Number of trials to execute.
**kwargs – Variable parameters passed to the simulator factory.
- Returns:
Aggregated results from all trials.
- Return type:
List[Any]
opengnc.simulation.monte_carlo_analyzer module
- class opengnc.simulation.monte_carlo_analyzer.MonteCarloAnalyzer(results: List[Dict[str, Any]])[source]
Bases:
objectStatistical analysis suite for Monte Carlo simulations.
Provides specialized tools for calculating performance margins, stability metrics, and covariance consistency proofs.
- check_covariance_consistency(error_key: str, cov_key: str) Dict[str, float][source]
Perform a consistency test (e.g., NIS or NEES).
Calculates the average quadratic form: e^T * P^-1 * e Should be close to the dimension of the state if P is consistent.
opengnc.simulation.multibody module
- class opengnc.simulation.multibody.ConstellationSimulator(num_satellites: int, propagator: Callable[[float, Any, float, Any], Any], sensor_model: Callable[[float, Any], Any] | None = None, estimator: Callable[[float, Any], Any] | None = None, controller: Callable[[float, Any], Any] | None = None, logger: SimulationLogger | None = None)[source]
Bases:
objectMulti-Agent / Constellation Simulator.
Manages simultaneous simulation of multiple spacecraft, enabling coordinated formation flying or large network analysis.
- Parameters:
num_satellites (int) – Total spacecraft count.
propagator (PropagatorFunc) – Joint or vectorized propagator function.
sensor_model (Optional[SensorFunc]) – Measurement model.
estimator (Optional[EstimatorFunc]) – Centralized or multi-state estimator.
controller (Optional[ControllerFunc]) – Coordinating control logic.
logger (Optional[SimulationLogger]) – Data recording utility.
opengnc.simulation.realtime module
- class opengnc.simulation.realtime.RealTimeSimulator(*args: Any, rtf: float = 1.0, **kwargs: Any)[source]
Bases:
MissionSimulatorReal-time simulation synchronizing simulation time to wall-clock time. Supports Hardware-In-the-Loop (HIL) or Software-In-the-Loop (SIL) testing.
opengnc.simulation.scenario module
Scenario Configuration Manager.
- class opengnc.simulation.scenario.ScenarioConfig(filename: str | Path)[source]
Bases:
objectScenario Configuration Manager.
Handles loading and parsing of reproducible mission configurations from external formatted files (JSON, YAML).
- Parameters:
filename (Union[str, Path]) – Path to the configuration file.
- get(key: str, default: Any = None) Any[source]
Retrieve a configuration value using dot-notation.
Example: config.get(‘spacecraft.mass’, 500.0) retrieves the ‘mass’ property from the ‘spacecraft’ object.
- Parameters:
key (str) – Dot-separated access path (e.g., ‘propulsion.tank_vol’).
default (Any, optional) – Fallback value if key is missing.
- Returns:
The requested parameter value.
- Return type:
Any
opengnc.simulation.simulator module
- class opengnc.simulation.simulator.MissionSimulator(propagator: Callable[[float, Any, float, Any], Any], sensor_model: Callable[[float, Any], Any] | None = None, estimator: Callable[[float, Any], Any] | None = None, controller: Callable[[float, Any], Any] | None = None, logger: SimulationLogger | None = None)[source]
Bases:
objectHigh-Fidelity Mission Simulator.
Loop Sequence: 1. Update Sense: $mathbf{y} = h(t, mathbf{x}) + mathbf{v}$ 2. Estimate: $hat{mathbf{x}} = f(t, mathbf{y})$ 3. Control: $mathbf{u} = g(t, hat{mathbf{x}})$ 4. Propagate: $dot{mathbf{x}} = f(t, mathbf{x}, mathbf{u})$
- Parameters:
propagator (PropagatorFunc) – Truth propagation: $(t, x, dt, u) to x_{new}$
sensor_model (Optional[SensorFunc]) – Measurement model: $(t, x) to y$
estimator (Optional[EstimatorFunc]) – State estimation: $(t, y) to hat{x}$
controller (Optional[ControllerFunc]) – Control law: $(t, hat{x}) to u$
logger (Optional[SimulationLogger]) – Telemetry recording.
- initialize(t0: float, initial_state: Any) None[source]
Set the simulation starting epoch and state.
- Parameters:
t0 (float) – Start time (s).
initial_state (Any) – Initial truth state vector or object.
- run(t_end: float, dt: float) Any[source]
Execute the simulation loop until the termination time.
- Parameters:
t_end (float) – Simulation stop time (s).
dt (float) – Fixed integration step (s).
- Returns:
Returns logger history if available, otherwise simulation end state.
- Return type:
Any
- schedule_event(t: float, callback: Callable[[...], Any], *args: Any, **kwargs: Any) None[source]
Register a discrete event for future execution.
- Parameters:
t (float) – Target execution time (s).
callback (Callable) – Function to execute at time $t$.
- step(dt: float) None[source]
Execute a single fixed-step simulation frame.
Sequence: 1. Process pending discrete events. 2. Generate synthetic measurements (Sense). 3. Solve for state estimate (Estimate). 4. Compute control effort (Control). 5. Log data series. 6. Advance physics (Propagate).
- Parameters:
dt (float) – Simulation time step (s).
Module contents
Simulation module for the opengnc.
This module provides the architecture for end-to-end mission simulation, including scenario configuration, discrete-event scheduling, simulation logging, Monte Carlo harness, and real-time/multi-body support.
- class opengnc.simulation.ConstellationSimulator(num_satellites: int, propagator: Callable[[float, Any, float, Any], Any], sensor_model: Callable[[float, Any], Any] | None = None, estimator: Callable[[float, Any], Any] | None = None, controller: Callable[[float, Any], Any] | None = None, logger: SimulationLogger | None = None)[source]
Bases:
objectMulti-Agent / Constellation Simulator.
Manages simultaneous simulation of multiple spacecraft, enabling coordinated formation flying or large network analysis.
- Parameters:
num_satellites (int) – Total spacecraft count.
propagator (PropagatorFunc) – Joint or vectorized propagator function.
sensor_model (Optional[SensorFunc]) – Measurement model.
estimator (Optional[EstimatorFunc]) – Centralized or multi-state estimator.
controller (Optional[ControllerFunc]) – Coordinating control logic.
logger (Optional[SimulationLogger]) – Data recording utility.
- class opengnc.simulation.Event(t: float, callback: Callable[[...], Any], *args: Any, **kwargs: Any)[source]
Bases:
objectA single discrete event to be processed at a specific time.
- class opengnc.simulation.EventQueue[source]
Bases:
objectPriority queue managing discrete events in the simulation. Handles maneuver scheduling and mode transitions.
- class opengnc.simulation.MissionSimulator(propagator: Callable[[float, Any, float, Any], Any], sensor_model: Callable[[float, Any], Any] | None = None, estimator: Callable[[float, Any], Any] | None = None, controller: Callable[[float, Any], Any] | None = None, logger: SimulationLogger | None = None)[source]
Bases:
objectHigh-Fidelity Mission Simulator.
Loop Sequence: 1. Update Sense: $mathbf{y} = h(t, mathbf{x}) + mathbf{v}$ 2. Estimate: $hat{mathbf{x}} = f(t, mathbf{y})$ 3. Control: $mathbf{u} = g(t, hat{mathbf{x}})$ 4. Propagate: $dot{mathbf{x}} = f(t, mathbf{x}, mathbf{u})$
- Parameters:
propagator (PropagatorFunc) – Truth propagation: $(t, x, dt, u) to x_{new}$
sensor_model (Optional[SensorFunc]) – Measurement model: $(t, x) to y$
estimator (Optional[EstimatorFunc]) – State estimation: $(t, y) to hat{x}$
controller (Optional[ControllerFunc]) – Control law: $(t, hat{x}) to u$
logger (Optional[SimulationLogger]) – Telemetry recording.
- initialize(t0: float, initial_state: Any) None[source]
Set the simulation starting epoch and state.
- Parameters:
t0 (float) – Start time (s).
initial_state (Any) – Initial truth state vector or object.
- run(t_end: float, dt: float) Any[source]
Execute the simulation loop until the termination time.
- Parameters:
t_end (float) – Simulation stop time (s).
dt (float) – Fixed integration step (s).
- Returns:
Returns logger history if available, otherwise simulation end state.
- Return type:
Any
- schedule_event(t: float, callback: Callable[[...], Any], *args: Any, **kwargs: Any) None[source]
Register a discrete event for future execution.
- Parameters:
t (float) – Target execution time (s).
callback (Callable) – Function to execute at time $t$.
- step(dt: float) None[source]
Execute a single fixed-step simulation frame.
Sequence: 1. Process pending discrete events. 2. Generate synthetic measurements (Sense). 3. Solve for state estimate (Estimate). 4. Compute control effort (Control). 5. Log data series. 6. Advance physics (Propagate).
- Parameters:
dt (float) – Simulation time step (s).
- class opengnc.simulation.MonteCarloSim(simulator_factory: Callable[[...], Any])[source]
Bases:
objectMonte Carlo Simulation Harness.
Facilitates large-scale robustness analysis by executing multiple simulation runs with stochastic variations.
- Parameters:
simulator_factory (Callable[..., MissionSimulator]) – Generator function to produce specialized simulator instances. Signature: (seed, **kwargs) -> MissionSimulator.
- get_analyzer() MonteCarloAnalyzer[source]
Produce a statistical analyzer for the current simulation results.
- Returns:
Instance of the analyzer initialized with current trial data.
- Return type:
- run_parallel(num_runs: int, processes: int | None = None, **kwargs: Any) list[Any][source]
Execute Monte Carlo iterations across multiple processor cores.
- Parameters:
num_runs (int) – Number of trials to execute.
processes (Optional[int]) – Number of parallel workers. Defaults to machine CPU count.
**kwargs – Parameters for simulation configuration.
- Returns:
Aggregated results.
- Return type:
List[Any]
- run_sequential(num_runs: int, **kwargs: Any) list[Any][source]
Execute Monte Carlo iterations in a single thread.
- Parameters:
num_runs (int) – Number of trials to execute.
**kwargs – Variable parameters passed to the simulator factory.
- Returns:
Aggregated results from all trials.
- Return type:
List[Any]
- class opengnc.simulation.RealTimeSimulator(*args: Any, rtf: float = 1.0, **kwargs: Any)[source]
Bases:
MissionSimulatorReal-time simulation synchronizing simulation time to wall-clock time. Supports Hardware-In-the-Loop (HIL) or Software-In-the-Loop (SIL) testing.
- class opengnc.simulation.ScenarioConfig(filename: str | Path)[source]
Bases:
objectScenario Configuration Manager.
Handles loading and parsing of reproducible mission configurations from external formatted files (JSON, YAML).
- Parameters:
filename (Union[str, Path]) – Path to the configuration file.
- get(key: str, default: Any = None) Any[source]
Retrieve a configuration value using dot-notation.
Example: config.get(‘spacecraft.mass’, 500.0) retrieves the ‘mass’ property from the ‘spacecraft’ object.
- Parameters:
key (str) – Dot-separated access path (e.g., ‘propulsion.tank_vol’).
default (Any, optional) – Fallback value if key is missing.
- Returns:
The requested parameter value.
- Return type:
Any
- class opengnc.simulation.SimulationLogger(filename: str)[source]
Bases:
objectSimulation replay and logging interface. Records state history and outputs to common formats like JSON, CSV. (HDF5 support optionally using h5py if installed).
- log(t: float, state: Any, measurements: Any = None, estimates: Any = None, commands: Any = None) None[source]
Record a simulation step.
- Parameters:
t (float) – Simulation time.
state (Any) – True state of the system (e.g. state vector).
measurements (Any, optional) – Sensor measurements at this time step.
estimates (Any, optional) – Filter estimates at this time step.
commands (Any, optional) – Control commands sent to actuators.