Gravisim

Gravisim is a program to simulate the behavior of masses under the influence of their gravity.

**Update:**Fixed formatting error**Update:**Fixed formatting error**Update:**Fixed small error**Update:**Fixed another errorGravisim is a program, or rather a collection of programs to simulate the behavior of masses under the influence of their gravity meaning it calculates the trajectories of these masses. Currently, only two dimensions are respected, the extension to the third one is a mere question of performance of calculation. Gravisim currently simplifies the bodies in question to be masses concentrated in one point. The program

Gravisim does not simplify scenarios insofar as to reduce n-mass problems to 2 mass problems or superpositions of those - it however provides for the possibility to insert bodies with neglectible masses, ie. bodies that do not influence other bodies by their gravitation. This can be usefull when simulating planetary rings for example. Instead, it solves equations of motion straight away. In particular, the equations derive from Newton's equation

where

with

whereas in here, the equations to solve are

The solution is to transform this equation into two equations

and

You should respect that in order to solve the resulting equations properly, however, bear in mind that all of these have to be solved at once! However, it is worth the try. Look at the image above. you can well make out a swing-by of one of the small masses along the orbiting moon. Amazing! In order to ensure that the solver does indeed work properly, I had it fed the data of the sun, earth and moon:

You can see from the last picture, that the moon performs a little bit more than three orbits, which is quite consistent with reality. Nice :)

Gravisim has been implemented in plain C using the GNU scientific library for numerically finding the roots of the appearing equations.

Currently, Gravisim produces plain columns of numbers that have to be visualized using appropriate tools like Gnuplot. For the future, it is planned to implement appropriate renders to produce neat movies - lets wait and see. The latest code can be obtained via Google Code.

*suite*is still quite incomplete, however, it already produces nice results. For example, here it has been initialized to simulate a scenario where there is a massive central body surrounded by nine masses of neglectable masses and a moon with a mass smaller than the central body. Here is the trajectories of these bodies:Image: One central mass surrounded by nine bodies of neglectable mass and a moon of slightly less mass than the central mass |

`a = f / m`

where

`f`

denotes the force vector acting on a body, `m`

being the mass of the body and `a`

being the acceleration the body experiences. The force induced upon a body by another one can be calculated by Newton's law of gravitation `f = G * ( m m_i / r_i^2 r_i / |r_i| ) `

with

`G`

being the gravitational constant, `m`

the mass of the body, `m_i`

the mass of the body inducing the force, `r_i`

the distance vector in between the two bodies pointing from the inducing body. The force acting upon a body under the gravitational influence of several bodies, all the force vectors need only be summarized, and what you get is a differential equation describing the movement of this body. The system of all differential equations describing the movements of all bodies together is a complete description of evolution of the system. Gravisim uses an implicit Runge-Kutta method, the Gauss-Lagrange scheme in particular. It suffers otwo problems though. The first problem is, that due to using an implicit scheme, the resulting equations cannot be solved straight away, instead the roots of the equations have to be found numerically. Another problem is, that Runge-Kutta methods are designed to numerically solve differential equations of the form`dF/ dx = H(x, F)`

whereas in here, the equations to solve are

`a = f / m = d^2 x / dt^2`

The solution is to transform this equation into two equations

`dx / dt = v`

and

`dv / dt = f / m`

You should respect that in order to solve the resulting equations properly, however, bear in mind that all of these have to be solved at once! However, it is worth the try. Look at the image above. you can well make out a swing-by of one of the small masses along the orbiting moon. Amazing! In order to ensure that the solver does indeed work properly, I had it fed the data of the sun, earth and moon:

Image: Here is the result for a quarter of a simulated year with the sun in the center |

Image: Here the same with the earth being fixed at the origin |

Image: And here zoomed into the image, showing the orbit of the moon |

Gravisim has been implemented in plain C using the GNU scientific library for numerically finding the roots of the appearing equations.

Currently, Gravisim produces plain columns of numbers that have to be visualized using appropriate tools like Gnuplot. For the future, it is planned to implement appropriate renders to produce neat movies - lets wait and see. The latest code can be obtained via Google Code.