Integrators
Three fixed-step schemes, chosen at construction:
from cosmic_warp.core.pipeline import SpacecraftSimulator
sim = SpacecraftSimulator(num_envs=4, integrator="symplectic", dt=1.0)
sim.reset()
sim.simulate(num_steps=600)
integrator |
Order | Force evaluations per step | Use for |
|---|---|---|---|
"rk4" (default) |
4 | 4 | most work: the most accurate per step |
"symplectic" |
2 | 2 | long orbit propagation: bounded energy error instead of drift |
"euler" |
1 | 1 | debugging, very small steps |
Cost scales roughly with force evaluations (Benchmarks); each order is checked by a convergence test.
Choosing the step
There is no adaptive step and no stability guard. Pick dt for the fastest
dynamics in the scenario — the orbit, a spin, a wheel's friction time
constant, a burn — then halve it and compare the quantity you care about.
Where the order drops
| Situation | Effect |
|---|---|
| A reaction wheel saturates inside a step | every scheme drops to second order around it (events are not located) |
| Propellant runs out inside a step | delta-v exact; an O(dt²) position error, once per burnout (burnout) |
Thrust or drag with "symplectic" |
no longer symplectic (it is for the orbit at constant mass under gravity and J2); drag enters to first order |
| Thrust within any step | thrust, torque and mass flow are evaluated once per step; only their rotation follows the attitude |
Derivations: Numerical integration. Comparisons
on orbits: integrator comparison,
energy conservation. YAML:
simulation.integrator.
API: Integrator and the factory ·
Euler ·
RK4 ·
Symplectic