Precision of arkode( ) vs. ode( ) at astronomical orbit simulation

If I use ode() to simulate the two-body problem sun-earth (state vector of 12 barycentric coordinates), there is a large discrepancy between the numerical and the analytical solution: In a simulation time of 550 (analytically calculated) orbital periods, the Earth completes 551 orbits. The circular orbit shape is fine. I used ode( ) with the default solver and the default tolerances. By narrowing the tolerances, the result becomes not more accurate. Can another solver help here that improves the numerical precision?

Yes! Stéphane recommended arkode( ) which allowed much higher precision. I achieved very good fit with the analytical solution, using method=“ERK_8” and rtol=1.D-12.
No more extra orbits! Problem solved.

Thanks Jens, can you share the code ? In fact it could become a demo in the Simulation/Sundials category…

S.

With pleasure! This will take some time because the current form of the code is not well commented.

Jens

1 Like

Stéphane,
here is the code. Feel free to modify it for the use as a demo.
Jens

New users can not upload. Here comes the script directly.

Script removed here.

Hello Jens,

I have granted you the possibility to upload files, can you edit your above post (copy/paste won’t work well with formatted text, please remove it) and drag/drop the file ?

Thanks,

S.

Here is the script.

Two_Body_Problem.sce (6.5 KB)

Jens

1 Like