Orrery
A GPU-accelerated N-body gravitational simulator
Loading...
Searching...
No Matches
runge_kutta4.hpp File Reference

Classical fourth-order Runge-Kutta, included as the counterexample. More...

Go to the source code of this file.

Classes

class  orrery::integrators::RungeKutta4
 The classical fourth-order Runge-Kutta method. More...

Detailed Description

Classical fourth-order Runge-Kutta, included as the counterexample.

RK4 is the integrator most people reach for first, and on this problem it is the wrong choice. It is not symplectic and it is not time-reversible, so the energy error of a long integration grows without bound instead of oscillating inside an envelope, and it does so while costing four force evaluations per step against velocity Verlet's one. The validation suite integrates the same eccentric orbit with all three methods and shows exactly that: the symplectic schemes stay inside a band for the whole run while RK4 drifts steadily out of it. ADR-0011 is the argument and that test is the evidence.

It is not here only to lose. A non-symplectic method of known order is a genuinely useful reference. Its error over a short interval is a clean power of the timestep, uncontaminated by the bounded oscillation that makes a symplectic method's error awkward to measure, so it is the easiest of the three to check a convergence order against, and it is the natural thing to compare a new solver against when the question is accuracy over one orbit rather than stability over a million.

The step advances the first-order system

dx/dt = v,   dv/dt = a(x)

through the usual four stages. The stage positions are not states of the system, which is why AccelerationField takes spans rather than a particle store, and the stage derivatives have to be accumulated somewhere, which is why this is the one integrator here that owns memory.