EJK's Programs: Gravity


Created using orbital data for Jupiter, Io, Europa, and Ganymede which were changed to create elliptical orbits. Simulation then run long enough to fill every possible place the moons could take. Simulation of imaginary planets with masses between those of Mars and Venus, setup into a binary planet in mutual orbit with a 3rd. Shows ~3 orbits of the white planet. The Magenta and White planets end up orbiting each other; In the end, Green makes one extremely elliptical orbit and then gets launched out of the system.


Download Gravity - Latest version: 20051227
Online Manual



Gravity is a small, simple program I wrote that (can you guess?) simulates gravity! Specifically, it simulates a universe with one force (gravity) described by Newton's F=M1M2G/R^2 that acts on particles. You need to have OpenGL, GLU, and SDL installed before you can compile it.

UPDATE: I have started working with a research group and I'm working on medium to long term astrodynamic simulations. I used Gravity as the base to begin writing a serious orbit integrator. I've stripped the GUI from the research program and upgraded it to a 6th order symplectic integrator, as well as adding various other bits. I may have to images to post soon.

Note: One of the nice things about a simulation is that it doesn't necessarily have to simulate reality. I've been experimenting with things like modifying the gravitational formula and having negative mass and other things. It's quite interesting to observe the results. Download it and see what you can do!

The universe of Gravity is totally unregulated in that once you specify initial mass, position, and velocity, you can't control what the particles do. In practice, this means two things: First, when writing a universe, you have to carefully balance the momentum of the system or it will drift off. Second, any particle that gets slingshotted out of the system will not bounce back and (more importantly) will impart a net momentum to the remaining particles.


Gravplayer is a companion program to Gravity. It plays back the files generated by the framesave option in Gravity. It's usage is simply 'gravplayer --world [file to play]'. Once it loads the file (which will very easily be millions of frames long if you let gravity run for a while), it opens a window showing the entire path the particles traced while Gravity was running that can be rotated and moved about in freely.

For two-dimensional simulations, Gravplayer is useful for examining close orbits. For three-dimensional ones, the advantage is obvious - You can see what those dots were *really* doing.


Keplertest is another companion to Gravity. It takes a framesave generated by a particular world setup (The package comes with worlds/kepler) that has one massive planet at <0,0,0> and one massless dot orbiting it exclusively in the x-y plane. From there, it proceeds to verify Kepler's 3rd law (equal areas in equal time), or rather Gravity's compliance with it.


I hope you find my program useful! Contact ejkeever AT nerdshack DOT com if you have questions, comments, or did something after reading the FIXMEs.