Martomate logo

Solar system simulation

Simulation of a three star system

Here we see three stars affected by the gravity of the others. The system starts out in one configuration, with the green star orbiting the orange one, but after som time the green star transitions to orbiting the blue star instead. It appeas to stabilize after that point.

three stars

This system is in fact a bit tricky to simulate. If I change the number of simulation steps I get a different result. This happens because the system is chaotic, which means that all the small errors in the simulation amplify over time (especially when the stars are close to each other), and this causes two almost identical runs to diverge eventually.

Is it correct though?

In the simulation above I used 10k steps. Below I instead use 20k steps, which means that the time step is half as long. We can see that the outcome is quite different after a while.

three stars

Here we have 100k steps:

three stars

Here we have 1M steps:

three stars

Here we have 10M steps:

three stars

It seems like it finally stabilised on a solution. That’s great, but if the simulation were to continue I think these would also start to disagree.

The long term perspective

If we extend the simulation to cover more time we find that in most simulations a star is eventually ejected, like in the examples below. It seems like one needs to use very small time steps to not have this happen within the time window.

Let’s have a closer look and simulate 20 times more time.

If we use 1M steps we get this:

three stars

If we use 20M steps we get this:

three stars

This has certainly not stabilised yet, which goes to show how difficult it is to simulate chaotic systems. There are most certainly better ways to simulate (e.g. using variable time step) so that might be something to try some day.

Idea: Variable time step based on neighboring probes

Instead of just simulating the initial conidition through time with fixed time steps one could simulate both the state and a few neighboring states (where you add a tiny random offset). After a simulation step one could check how much the neighbors diverged from the main trajectory and if the distance is too big you could conclude that the region is very unstable and that a smaller time step is needed. You could then discard that simulation step and try again with half the time step. Once you are successful you can sample new neighbors and continue. After each successful advancement one could also increase the time step a bit again so that it eventually comes back to normal.