Periodic Orbits Example
This example demonstrates how to compute periodic orbits in the Circular Restricted Three-Body Problem (CR3BP).
Computing periodic orbits in the CR3BP
1"""Example script: generation of several families of periodic orbits (Vertical,
2Halo, planar Lyapunov) around an Earth-Moon libration point.
3
4Run with
5 python examples/periodic_orbits.py
6"""
7
8import os
9import sys
10
11sys.path.append(os.path.join(os.path.dirname(__file__), "..", "src"))
12
13from hiten.system import (HaloOrbit, LyapunovOrbit, System,
14 VerticalOrbit)
15from hiten.utils.log_config import logger
16
17
18def main() -> None:
19 # Build system & centre manifold
20 system = System.from_bodies("earth", "moon")
21 l_point = system.get_libration_point(1)
22 cm = l_point.get_center_manifold(degree=6)
23 cm.compute()
24
25 ic_seed = cm.to_synodic([0.0, 0.0], 0.6, "q3") # Good initial guess from CM
26 logger.info("Initial conditions (CM to physical coordinates): %s", ic_seed)
27
28 # Specifications for each family we wish to generate
29 orbit_specs = [
30 {
31 "cls": VerticalOrbit,
32 "name": "Vertical",
33 "kwargs": {"initial_state": ic_seed},
34 "diff_corr_attempts": 100,
35 "finite_difference": True,
36 },
37 {
38 "cls": HaloOrbit,
39 "name": "Halo",
40 "kwargs": {"amplitude_z": 0.2, "zenith": "southern"},
41 "diff_corr_attempts": 10,
42 "finite_difference": False,
43 },
44 {
45 "cls": LyapunovOrbit,
46 "name": "Planar Lyapunov",
47 "kwargs": {"amplitude_x": 0.1},
48 "diff_corr_attempts": 100,
49 "finite_difference": False,
50 },
51 ]
52
53 for spec in orbit_specs:
54
55 orbit = l_point.create_orbit(spec["cls"], **spec["kwargs"])
56
57 # Differential correction, propagation & basic visualisation
58 orbit.correct(max_attempts=spec["diff_corr_attempts"], max_delta=1e-2, finite_difference=spec["finite_difference"])
59 print(f"Corrected state: {orbit.initial_state} | Period: {orbit.period}")
60 orbit.propagate(steps=1000)
61 orbit.plot("rotating")
62
63if __name__ == "__main__":
64 main()