GSim

Fig. 1: Evolution of a gravitating system including a planet and five moons. The total linear and angular momenta are conserved to roundoff, while the energy holds its value to roughly one part per million. The energy oscillations are an expected consequence of the symplectic integrator.
Fig. 2: Evolution of 1024 elastic particles within an elastic box, beginning with random velocities thrown from a uniform probability distribution. The red tracer particle starts in the upper-left-most corner, and can be seen to perform a random walk around the stage. Due to the vanishing potential field, the symplectic integrator is able to conserve energy to within roundoff error.

Here I describe a personal hobby project that began as an attempt to combine two of my favorite interests: simulation and animation. The result is a cute Java application called GSim. It is essentially an N-body simulator, in which each body interacts with every other, producing fascinating dynamics. The source code and example state configurations are located in the GSim Git Repository.

Features

The GSim code is developed in OpenJDK on a simple model-view-controller architecture. It is designed to evolve a state (a list of body positions, velocities, masses, and possibly charges) from one moment in time to the next, according to Newton's classical laws of motion. Various interactions and potential fields can be enabled, which induce acceleration on the bodies. At each frame, the current position of each body is rendered on the central stage. The user is able to interact with the stage through several channels, including a simple click-and-drag interface. The simulation provides numerical accuracy feedback to the user through realtime measurements of conserved quantities, such as the total system energy. The list of included features expands frequently: