Accuracy of the Grav-Sim Integrators

The graphs in this article were generated by simulating the same Grav-Sim 2-body model for 201 orbits and drawing every 20th orbit.

The following initial conditions were used an should lead to successive elliptical orbits of eccenticity 0.78:

2MassPos(x)Pos(y)Pos(z)Vel(x)Vel(y)Vel(z)
01.00.00.00.00.00.020.0
10.15.00.00.00.0-0.20.0

For each integrator, graphs are shown for levels 1, 2 and 3 for both Constant and Variable time-steps.

The settings for each integrator have been manually tuned to use as many steps per orbit as necessary to produce graphs that appear similar at level 1 (i.e. have approximately the same magnitude of accumulated errors after 201 orbits). This is necessarily subjective.

Each successive level uses a factor of square-root-of-2 times more steps than the previous level. Hence level 3 uses twice as many steps as level 1.

The accuracy at levels 2, 3 and beyond depends on the quality of the integrator itself - in particular the "order" - which dictates how quickly the errors reduce with increasing numbers of steps.


Forward Euler (1st Order)


LevelConstant Time-StepsVariable Time-Steps
1

500000 steps per orbit



144000 steps per orbit


2

707106 steps per orbit



203646 steps per orbit


3

1000000 steps per orbit



288000 steps per orbit




Forward Plus (1st Order)


LevelConstant Time-StepsVariable Time-Steps
1

250000 steps per orbit



72000 steps per orbit


2

353554 steps per orbit



101823 steps per orbit


3

1000000 steps per orbit



144000 steps per orbit




ProtoHermite (2nd Order)


LevelConstant Time-StepsVariable Time-Steps
1

900 steps per orbit



400 steps per orbit


2

1273 steps per orbit



566 steps per orbit


3

1800 steps per orbit



800 steps per orbit




RungeKutta2n (2nd Order)


LevelConstant Time-StepsVariable Time-Steps
1

8000 steps per orbit



1151 steps per orbit


2

11313 steps per orbit



1628 steps per orbit


3

16000 steps per orbit



2302 steps per orbit




RungeKutta2n_fsal (2nd Order)


LevelConstant Time-StepsVariable Time-Steps
1

2000 steps per orbit



287 steps per orbit


2

2828 steps per orbit



406 steps per orbit


3

4000 steps per orbit



574 steps per orbit




LeapFrog (2nd Order)


LevelConstant Time-StepsVariable Time-Steps
1

500 steps per orbit



143 steps per orbit


2

707 steps per orbit



202 steps per orbit


3

1000 steps per orbit



286 steps per orbit




RungeKutta3 (3rd Order)


LevelConstant Time-StepsVariable Time-Steps
1

1000 steps per orbit



333 steps per orbit


2

1414 steps per orbit



471 steps per orbit


3

2000 steps per orbit



666 steps per orbit




RungeKutta4 (4th Order)


LevelConstant Time-StepsVariable Time-Steps
1

666 steps per orbit



216 steps per orbit


2

942 steps per orbit



305 steps per orbit


3

1332 steps per orbit



432 steps per orbit




RungeKutta4n (4th Order)


LevelConstant Time-StepsVariable Time-Steps
1

666 steps per orbit



216 steps per orbit


2

942 steps per orbit



305 steps per orbit


3

1332 steps per orbit



432 steps per orbit




ChinChen (4th Order)


LevelConstant Time-StepsVariable Time-Steps
1

666 steps per orbit



216 steps per orbit


2

942 steps per orbit



305 steps per orbit


3

1332 steps per orbit



432 steps per orbit




ChinChenOptimised (4th Order)


LevelConstant Time-StepsVariable Time-Steps
1

666 steps per orbit



216 steps per orbit


2

942 steps per orbit



305 steps per orbit


3

1332 steps per orbit



432 steps per orbit




Hermite (4th Order)


LevelConstant Time-StepsVariable Time-Steps
1

250 steps per orbit



75 steps per orbit


2

353 steps per orbit



106 steps per orbit


3

500 steps per orbit



150 steps per orbit




Hermite6 (6th Order)


LevelConstant Time-StepsVariable Time-Steps
1

193 steps per orbit



58 steps per orbit


2

273 steps per orbit



82 steps per orbit


3

386 steps per orbit



116 steps per orbit




Hermite8 (8th Order)


LevelConstant Time-StepsVariable Time-Steps
1

148 steps per orbit



45 steps per orbit


2

209 steps per orbit



64 steps per orbit


3

296 steps per orbit



90 steps per orbit



Note that the number of steps taken is an approximate target and will vary a little in practice, due to:

  • The shape of the orbit (e.g. circular vs elongated)
  • The accumulation of errors

There are 2 tuning variables in the Grav-Sim source code that control the relationship between the number of steps per orbit and the collision timescale (which is the only statistic available at run time). The settings for these variables is also subjective. For reference, they appear in basic.h and were set to the following values when generating these graphs:

#define CONSTANT_TUNING_FACTOR 5.6

#define VARIABLE_TUNING_FACTOR 18.0