The solar carousel revisited, now with actual numbers!

Begin LogEntry_0011
StarDate 197731.19


In our last log entry we showed you our simplified analytical orbits, while these give us an overview of how the orbits should look as a function of their angle \(\theta\) in our coordinate system, it does not give us a way of knowing where a planet should be at a given time.


To find these we have to go back to our (New-1000kg-type?) gravity in it's vector-form, \(\vec{F} = G \frac{m_{1}m_{2}}{r^{2}} \hat{u}_{r}\), where \(\hat{u}_r = \frac{\vec{r}}{r}\). Like we mentioned in the last log entry, our star is significantly more massive than our planets, so we can safely make the assumption that we can ignore interplanetary gravitational attraction, in essence for each planet we're only looking at the planet and sun system.

Now to simulate these orbits we will have to do it numerically, and thus we have to find a way to do this. We spent a considerable amount of time in our library to figure out a sensible way to do this, the first method we managed to comprehend was the Oi-ler method. 

Bildet kan inneholde: tekst, blå, linje, plott, design.
Fig 1. Illustration of how the Oi-ler method works.

In the Oi-ler method the general formula is \(y_{i+1} = y_{i} + hf(x_{i}, y_{i})\), where \(y_{i+1} \) is the value of the function we're trying to approximate at the next step, \(y_{i}\) is the value of the current step, \(f(x_{i}, y_{i})\) is the value of the derivative of the function at the current point \((x_{i}, y_{i})\), and \(h\) is the step size of the approximation. Using this method we can easily approximate a simple function, in essence you approximate the curve of the solution by using the tangent in each interval of step size \(h\)

BUT! Our system is not really a simple function, so we can't apply this method to our current problem, but understanding it made understanding the next method significantly easier, Oi-ler-Chrome-R!


We can write this method on vector form, to make it easier to see how it applies to our problem:

 \(\vec{v}_{n+1} = \vec{v}_{n} + \vec{a}_{n}(\vec{r}_{n})\Delta t\)

\(\vec{r}_{n+1} = \vec{r}_{n} + \vec{v}_{n}\Delta t\)

Here we update our velocity based on the acceleration(gravitational in our problem) for each step, and then we update our position based on our now updated velocity. This seems perfect for our system! 

We implemented this solution, once our little robots started doing their calculations and came back with plots of our newly simulated orbits, they looked like this:

Bildet kan inneholde: sirkel, linje, plott, diagram, fargerikhet.
Fig 2. Planetary orbits simulated using Oi-ler-Chrome-R

This does look pretty similar to the analytical orbits, and if we were to overlay them they would overlap pretty well, but our robots again seemed to disagree with our assesment. We asked them to validate it, and they wrote:

I'm sorry Dave, I'm afraid nature can't do that.

The biggest relative deviation was for planet 7, 
which drifted 10.1395 % from its actual position.

We still have no idea who Dave is, but we were thankful(and surprised) to see that they gave us information about what the issue was. 

We did try to improve the accuracy of the simulation by lowering our timestep \(\Delta t\), but this was at the cost of significantly longer calculation times, and thus more pen and paper. We quickly figured out that this approach was infeasible in the long run, back to the library!


After spending a lot of time trying to figure out better ways to do this, we decided to take a break and play some games. We had both heard of this ancient game called "Frogger" and assumed the entry called "Leapfrog" was a similar game, but to our dismay when we opened the entry it was just more sciency stuff! (We should have figured the library wouldn't have fun games to be honest)


After our initial exasperation had passed we decided to look into it, and this turned out to be exactly what we were looking for! It was about a concept called "Leapfrog integration", which is similar to something called Velocity Velvetcake integration(which was significantly harder to grasp), but in essence it is pretty simple. The positions and velocities are updated in a staggered manner, unlike in the Oi-ler-Chrome-R method, which means that we update the positions at each full step and the velocities at each half step, like so:

\(\vec{a}_{i} = \vec{a}(\vec{r}_i)\)

\(\vec{v}_{i+\frac{1}{2}} = \vec{v}_{i-\frac{1}{2}} + \vec{a}_{i}\Delta t\)

\(\vec{r}_{i+1} = \vec{r}_{i} + \vec{v}_{i+\frac{1}{2}}\Delta t\)

Bildet kan inneholde: tekst, blå, linje, plott, diagram.
Fig 3. Illustration of how the leapfrog integration works

This method is significantly better because it manages to conserve the energy of the system, whereas the Oi-ler-Chrome-R method does not. We did actually go a step further with this, and rearranged it into what is either called a "kick-flip" or "kick-drift" form, we're not sure which, which is setup like this:


\(\vec{a}_{i} = \vec{a}(\vec{r}_i)\)

\(\vec{v}_{i+\frac{1}{2}} = \vec{v}_{i} + \vec{a}_{i} \frac{\Delta t}{2}\)

\(\vec{r}_{i+1} = \vec{r}_{i} + \vec{v}_{i+\frac{1}{2}} \Delta t\)

\(\vec{v}_{i+1} = \vec{v}_{i+\frac{1}{2}} + \vec{a}_{i+1} \frac{\Delta t}{2}\)

This is very similar to the regular leapfrog but in our experience conserves energy even better. We then managed to program this with our bots and ran it, and it worked!

Bildet kan inneholde: sirkel, linje, plott, diagram, fargerikhet.
Fig 4. Planetary orbits simulated using "kick-flip"/"kick-drift" leapfrog integration.



Our robot helpers actually seemed excited that we had managed this, which is understandable given how many times we've failed and how much math we've had them do recently. They wrote out he message:

I'm happy Dave, nature can indeed do that!
The biggest relative deviation was for planet 2, 
which drifted 0.807694 % from its actual position.
Your planet trajectories were satisfyingly calculated. Well done!
*** Achievement unlocked: Well-behaved planets! ***


Now we have positional data for our planets for the next 20 years, and as such we can now figure out when to launch to travel home. We however have much work to do before this!


We've also figured that we need to verify that our simulations are indeed correct by ourselves(we did disagree with the robots earlier), and in the time between now and our next entry we're going to look into Kep-ler's laws and see if our simulations can be verified using these.


End LogEntry_0011



Fig 1 sourced from:

Fig 3 sourced from:

Publisert 23. sep. 2020 15:38 - Sist endret 23. sep. 2020 15:38