rk4
cosmic_warp.core.integrators.rk4
Runge-Kutta 4th order (RK4) integrator implementation.
RK4Integrator
Bases: Integrator
Classic 4th-order Runge-Kutta integrator (RK4).
Good balance of accuracy and computational cost. Uses 4 function evaluations per step.
The method computes
k1 = f(t, y) k2 = f(t + dt/2, y + dt/2 * k1) k3 = f(t + dt/2, y + dt/2 * k2) k4 = f(t + dt, y + dt * k3) y(t+dt) = y(t) + dt/6 * (k1 + 2k2 + 2k3 + k4)
Reaction wheel momenta h(t) follow a closed-form solution within the step, so each stage evaluates them at its own time (0, dt/2, dt). The RK stages advance the body-frame total angular momentum L + h, whose rate tau_ext - omega x (L + h) needs no wheel torque; L is recovered by subtracting h at the stage time. This keeps the wheel/body coupling fourth-order.