Project phases
Week 1 — The problem and the first integrals
- Write the Hamiltonian and derive the equations of motion. Implement
aceleraciones(masas, posiciones)in and verify Newton’s third law: to machine precision. - Implement
energia,momentoLineal,momentoAngularand tests that they are zero or constant in simple configurations (two equal masses at rest; center of mass at the origin). - Choose units: for the reference problems; for the Solar System, au, years and solar masses ().
Week 2 — RK4
- Implement a generic RK4 for with the state (lesson 2).
- Convergence test with the circular two-body problem (, , , ): position error after one period for . The log–log slope must be ≈ 4.
- Energy drift: integrate 1 000 periods with and plot against : it grows secularly (linearly). Measure the slope.
- Optional: RK45 with adaptive step and tolerance; compare the number of evaluations of for the same error.
Week 3 — Leapfrog (kick-drift-kick)
- Implement the KDK leapfrog: ; ; . Check that it is second order (slope ≈ 2) and time-reversible: integrating steps with and with returns the initial state to round-off precision.
- Energy drift over 1 000 periods: oscillates with no secular drift. Explain the result with the modified Hamiltonian (lesson 1).
- Angular momentum: show that the leapfrog conserves it exactly for central forces (to round-off) and check it; RK4 does not.
- Fourth-order Yoshida composition from three leapfrogs; verify order 4 and that it still has no energy drift.
Week 4 — Reference solutions
- Figure-eight: with Simó’s conditions, integrate one period with and verify that the state returns to the initial one with error and that , . Plot the trajectory and compare it with the simulator N bodies.
- Burrau’s Pythagorean problem: integrate up to with fixed-step leapfrog and with RK4; observe the spikes of at the close encounters and the ejection of mass 3 around . Try : does the escape time change? Is that a failure of the integrator or a property of the system?
- Add a softening () and discuss how much it alters the physics; alternatively, implement block variable time steps.
Week 5 — Chaos
- Implement Benettin’s method: integrate two trajectories separated by , renormalize every and accumulate . Estimate for Burrau on (the lesson reports with ) and for the circular two-body orbit (it should tend to 0 like ).
- Plot for the figure-eight with a perturbation of : slow growth (Simó’s linear stability) versus the exponential growth of Burrau.
- Discuss why the finite-time exponent depends on , on and on , and how to report it honestly.
Week 6 — Report and comparison
- Report with: equations, description of the methods, convergence graphs (measured slopes), energy and angular-momentum drift, figure-eight and Burrau, Lyapunov, and a table of computational cost (force evaluations per unit of error).
- Compare your implementation with the portal’s
src/lib/math/nbody.ts: run your tests against both and document the differences (if you find a bug in the portal, report it with a minimal case). - A 10-minute presentation with a live demonstration: the panel chooses and the student shows the energy drift of each method.
Mathematics in the project
- Hamilton’s equations: , .
- Order of a method: global error ; it is measured by the slope of against .
- Symplecticity: the leapfrog preserves the 2-form ; by backward error analysis it solves exactly a modified Hamiltonian close to , which bounds over times exponentially long in .
- Angular momentum in leapfrog: for central forces because .
- Lyapunov: ; in practice, the average of Benettin renormalizations.
Assessment rubric
| Criterion | Insufficient | Satisfactory | Good | Outstanding |
|---|---|---|---|---|
| Implementation and tests | Code without tests or incorrect | Correct RK4 and leapfrog with conservation tests | Tests of order, reversibility and references (figure-eight, Burrau) | Documented library, Yoshida or adaptive step, comparison with the portal |
| Numerical analysis | No order measurement | Convergence slopes measured | Explanation of the drift with the modified Hamiltonian | Discusses computational cost and the limits of regularization |
| Chaos | Does not estimate | Benettin implemented; for Burrau | Compares with two bodies and the figure-eight; discusses the parameter dependence | Analyzes Burrau’s escape time against and interprets it |
| Report and presentation | Incomplete | Complete with graphs and conclusions | Quality figures, reproducible, public code | Live demonstration and well-founded critique of the reference code |
Variants and extensions
- Barnes–Hut: octree for and comparison of error against (lesson 3).
- Real Solar System: JPL Horizons initial conditions for the Sun + 8 planets; integrate 1 000 years with leapfrog and measure the drift of Mercury’s perihelion (non-relativistic) and the energy.
- Resonances: Sun–Jupiter–asteroid system and the appearance of the Kirkwood gaps (resonances lesson).
- KS regularization: for close encounters in Burrau.
Inclusion
- A computational project, compatible with screen readers and keyboard input; the figures have textual descriptions and equivalent tables.
- In pairs, one implements RK4 and the other leapfrog with the same interface, and then they swap to review.
- The language is freely chosen; test skeletons are provided in Python and TypeScript.
Safety
- A desk project, with no physical risks; eye breaks during long programming sessions.
- As everywhere on the portal: never look at the Sun directly or with instruments without an ISO 12312-2 certified filter.