N-Body: Two-Dimensional N-Body Gravitational Dynamics Simulation
For each of the N particles...
- Calculate the pairwise gravitational force via Newton’s Universal Law of Gravitation and the principle of superposition.
- Use Newton’s Second Law to calculate the particle’s acceleration.
- Assume the above acceleration is constant within the time interval Δt and update the velocity: v = v + Δt a.
- Assume the above velocity is constant within the time interval Δt, and update the position: r = r + Δt v
./NBody <total-time> <time-step> Options: - total-time: The duration of the entire simulation. - time-step: delta_t, the incremental change in time
Use the Makefile to build the Nbody executable then run the simulation by loading the initial conditions from planets.txt and passing the total-time & time-step values as command line arguments.
./NBody 157788000.0 25000.0 < planets.txt
libsfml was used for drawing the particles.