GSim
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:
- Integration
- Störmer-Verlet 2nd and 4th order
- Runge-Kutta 2nd and 4th order
- Variable temporal step size
- Interactions
- Newtonian gravitational potential
- Lennard-Jones molecular potential
- Linear downward potential
- Elastic scattering
- Boundary Conditions
- None (open boundary)
- Elastic reflective box
- Torroidal periodicity ("Pac Man")
- Spherical periodicity
- Interactive Stage
- Live rendering of body positions
- Add body by clicking on the stage to set position, drag to set velocity
- Add body by entering position, velocity, and mass parameters in the control panel
- Load and save configurations to state files
- Run/pause, undo, reset, and set frame to center-of-mass/center-of-momentum frame
- Plotting
- Realtime graphical line plots showing conserved quantities
- Variable sample frequency
- Adjustable domain window