Computational Astrophysics · Interactive Learning Module
Please enter your details to continue.
The N-body problem asks: given N point masses interacting solely through Newtonian gravity, how do their positions and velocities evolve with time? For N ≥ 3 no general closed-form solution exists — numerical integration is required. This simulator solves the equations of motion for up to 4 bodies in real time using three user-selectable integrators.
The gravitational force on body i due to body j:
where G = 6.674 × 10¹¹ N m² kg² is the gravitational constant.
Summing over all pairs for body i:
This yields 6N coupled first-order ODEs (3 position + 3 velocity per body).
For an isolated system E = constant. Energy drift is a key diagnostic of integrator accuracy.
Also conserved. Large drifts in Lz indicate numerical instability or a large timestep.
The simulator shifts all bodies into the CoM frame at initialisation — ensuring zero net linear momentum.
Simple but not symplectic — energy grows monotonically. Suitable only for qualitative demonstrations.
Recommended for long integrations. Symplectic — exhibits bounded rather than drifting energy error.
4th-order accuracy per step. More accurate than Verlet for smooth orbits but not symplectic. 4 force evaluations per step.
Initial velocities are set to vcirc around Body 1, producing approximately circular orbits.
Earth's period: T ≈ 365.25 days at a = 1 AU.
Prevents numerical divergence at very close separations.
Perfectly integrable. Earth orbits in an ellipse; period ≈ 365.25 days. Ideal for verifying energy and Lz conservation.
Moon orbits Earth at ~0.00257 AU. Demonstrates hierarchical three-body stability; Moon period ≈ 27.3 days.
A 4th body near the inner system can cause orbital resonances, perturbations, or ejections — illustrating deterministic chaos sensitive to initial conditions.
Run the same preset with all three integrators and compare energy drift over 10+ orbits to concretely see the impact of integrator choice.
CSV columns: sapid, student_name, time_days, body_name, x_AU, y_AU, vx_ms, vy_ms, mass_kg, energy_j, lz_kgm2s. JSON includes full metadata (integrator, G scale, body names). The Python script uses matplotlib to reproduce the orbital plot from the exported CSV.
| Time (days) | Body | x (AU) | y (AU) | vx (m/s) | vy (m/s) | Mass (kg) |
|---|---|---|---|---|---|---|
| No data yet — run the simulation with "Log data" checked. | ||||||
| Timestamp (ISO) | Name | SAPID |
|---|---|---|
| No login records yet. | ||
This interactive module is part of the Computational Astrophysics curriculum. Students explore Newton's law of gravitation through hands-on numerical simulation, compare integration algorithms, and analyse conservation laws in multi-body gravitational systems.
References used to ensure scientific accuracy of this module. Open-access links are provided where available.