Science and the Mathematics of Gravity

Bodies such as stars and planets move under their mutual gravitational attraction based on
Newton’s Inverse-Square Law of Gravity. For a number of bodies these laws are expressed as a relatively simple set of coupled differential equations. Although the equations are relatively simple they have become a celebrated mathematical and computational problem to solve effectively, know as the gravitational N-Body problem.

The key problem with calculations of the N-Body problem is that the bodies don’t just move around each other nicely. What happens in reality is that a few of the bodies (typically the larger ones) form tight binaries - taking up most of the (negative) potential energy in the system. The other bodies get thrown out - either escaping the system altogether or forming a loose cloud around these few binaries. For very large systems the effect of these binaries is reduced. However. for a system that is primarily intended to show moving art images of up to about 40-bodies, these few binaries will dominate the dynamics and throw off a significant percentage of the rest.
Another consequence of this is that the system will work on several different timescales - with the tight binaries moving very fast in tight orbits and the loose cloud of other bodies moving more sedately.

While this is right for the real science, visually the images look much more interesting if they are close together. Fortunately it is possible to make some small changes to the equations to reduce these problems and make the interaction of the images interesting.

  • We add a small “long-range” force to the system (increasing with the distance away), so that this effect is negligible when the bodies are close but if one is thrown away by the dynamics of the other bodies it will eventually be pulled back into the system.
  • We give the bodies a radius - and add a short-range repulsive force to push them apart when they collide. This is set so that the attractive and repulsive forces are in balance just before the two bodies touch - and if they get closer the propulsive force grows strongly. The effect is that the bodies bounce off each other instead of forming tight binaries.

Visually the system is much more interesting when the images are close together - so we allow the user to interact with the system to take energy out and force the bodies to be closer together. As there is a short-range repulsive force as well as the long-range gravitational attraction, the system will settle down to low-energy vibrating “blob”...

Sverre Aarseth

The “Grand Master” of these N-Body calculations is Sverre Aarseth from the Institute of Astronomy in Cambridge. One of the authors (DW) had the privilege of working with Sverre ~ 30years ago in Cambridge before moving onto other things… Sverre posts the FORTRAN source code of all his many NBODY codes to make them widely available.

Because of the modifications we made above to the system, it is not necessary to get too sophisticated (
and anyway our main focus is to make the dynamics visually interesting rather than specific science). However we do need to make these calculations in real-time and to reduce as much as possible the CPU stress on the IPad processor, so that we can get smooth animation at the screen frame rate of 60-frames per second using as little of the CPU processor time as possible. Hence we still need to use an efficient integrator for the equations - and Sverre’s nbody0.f code is the perfect template for this. Our integrator for the equations is therefore a direct translation of this FORTRAN code into C - with additions to take account of the long range force and the short-range repulsion to deal with the collisions. Each of the moving bodies is calculated with its own individual time step and the steps are made to high accuracy. The calculations take only a few percent of the frame interval to complete for each step in order to minimise the battery load.

Real Science?

While we cannot claim that our models here are a realistic representation of stellar clusters or planetary systems, there are some real science insights and understanding that can be picked up from observing how the bodies move.

  • Circular orbits are unstable. Eventually even the tiniest errors get amplified into slight difference in position and the neighbouring spheres are drawn to each other.
  • The system tends to split into a few closely bound groups with the remaining bodies moving away from the centre to distribute the energy released when the groups collapse.
  • if you take energy out of the system then it collapses into a “blob” of spheres held apart by the repulsive forces.
  • If you stop taking energy out, the system it will keep on vibrating and moving for ever.
  • If you drag a sphere out of the group to let it fall back and collide with the remaining, the energy of the collision is dissipated into the other spheres..

Stacks Image 2432
Stacks Image 6170