Gravitational Restricted Astrodynamics Variational Integration Toolkit
A comprehensive toolkit for numerical integration and trajectory optimization in the Planar Circular Restricted Three-Body Problem (PCR3BP), specifically configured for the Earth-Moon system.
The project evaluates the effectiveness of classical Newtonian schemes against symplectic methods based on Hamiltonian formalism. The toolkit provides:
- Newtonian Integrators: High-order explicit schemes (Verner, Dormand-Prince, Adams-Bashforth) for efficient short-term propagation.
- Symplectic Integrators: Implicit methods (Gauss, Lobatto) designed to preserve the geometric structure and energy stability in long-term simulations of non-separable Hamiltonian systems.
-
Trajectory Optimization: Algorithm for determining low-energy transfers using stable and unstable manifolds associated with Lyapunov orbits around the
$L_1$ point.
The system describes the motion of a massless test particle under the influence of two primary masses,
Newtonian Formulation
In the rotating frame, the equations of motion are derived directly from Newton's laws, explicitly accounting for the Coriolis force, centrifugal force and the gravitational pull of the two primaries:
where the distances to the primary bodies are defined as:
Hamiltonian Formulation
The system is described by a non-separable Hamiltonian function
where generalized momenta are
Energy Integral (Jacobi Constant)
The system possesses a conserved quantity known as the Jacobi constant (
- Newtonian Methods: Euler, Midpoint, RK4, Verner9 (9th order), Dormand-Prince 8 (8th order), Adams-Bashforth 5
- Hamiltonian Methods: Gauss-Legendre collocation (symplectic), Lobatto IIIA-IIIB pairs, Explicit Partitioned Runge-Kutta (EPRK)
- Energy Conservation Analysis: Automated testing across multiple energy levels and integration parameters
- Trajectory Optimization: HEO-to-Lyapunov orbit transfers via invariant manifolds
- Visualization Tools: Heatmaps, comparison plots, effective potential surfaces
- Automated Benchmarking: Performance metrics, energy drift analysis, method ranking
- Julia 1.10.0 or higher (tested with Julia 1.10.0)
git clone https://github.com/kasprzakewa/GRAVITy.git
cd GRAVITy
julia --project=. -e 'using Pkg; Pkg.instantiate()'For detailed installation instructions, see INSTALL.md.
Test all numerical integration methods:
julia --project=. GRAVITy.jl testTest only Newtonian methods (Euler, RK4, Vern9, DP8, AB5):
julia --project=. GRAVITy.jl test --newtonianTest only Hamiltonian methods (Gauss, Lobatto, EPRK):
julia --project=. GRAVITy.jl test --hamiltonianRun invariant manifold trajectory optimization example:
julia --project=. GRAVITy.jl trajectoryGenerate plots and analysis from test results:
julia --project=. GRAVITy.jl analyzeThis creates comparison plots and heatmaps in results/plots/.
Display all available commands:
julia --project=. GRAVITy.jl helpGRAVITy/
├── GRAVITy.jl # Main entry point (CLI)
├── src/ # Core modules
│ ├── CommonUtils.jl # CR3BP utilities, test cases
│ ├── NewtonianMethods.jl # Classical ODE integrators
│ ├── HamiltonianMethods.jl # Symplectic integrators
│ └── TrajectoryOptimization.jl # Manifold computations
├── utils/ # Analysis and testing scripts
│ ├── run_tests.jl # Comprehensive test runner
│ ├── run_trajectory_optimization.jl # Optimization example
│ └── analyze_and_plot_results.jl # Visualization
├── results/ # Output files and plots
└── example_data/ # Sample trajectory data
The toolkit tests methods across three energy level regimes in the Earth-Moon PCR3BP:
- E < E_L1: Below L1 Lagrange point energy (bounded lunar orbits)
- E_L1 < E < E_L2: Between L1 and L2 energies (transition orbits)
- E_L4 < E: Above L4/L5 energy (high-energy orbits)
Each test case varies:
- Time step (dt): 0.001, 0.01, 0.1
- Integration time (T): 10, 50, 100 dimensionless units
results/newtonian_methods/newtonian_methods_results.csv- Newtonian methods benchmark dataresults/hamiltonian_methods/hamiltonian_methods_results.csv- Hamiltonian methods benchmark dataresults/pcr3bp_results.csv- Combined results
Generated in results/plots/[method_type]/:
- Heatmaps: Energy drift and computation time across parameter space
- Fixed T plots: Energy conservation vs. time step for fixed integration time
- Fixed dt plots: Energy conservation vs. integration time for fixed time step
Running tests produces detailed summaries:
NEWTONIAN METHODS SUMMARY
========================================
Verner's 9th order method:
E < E_L1: Best |ΔE| = 2.44e-15 (dt=0.01, time=2.88s)
Dormand-Prince 8th order method:
E < E_L1: Best |ΔE| = 6.88e-15 (dt=0.01, time=2.63s)
OVERALL RANKING BY ENERGY CONSERVATION
========================================
1. Verner's 9th order method (E < E_L1): |ΔE| = 2.44e-15
2. Verner's 9th order method (E_L1 < E < E_L2): |ΔE| = 2.66e-15
3. Dormand-Prince 8th order method (E_L1 < E < E_L2): |ΔE| = 6.44e-15
...
See LICENSE file for details.