Heteroclinic Connection Example

This example demonstrates how to compute heteroclinic connections between periodic orbits in the Circular Restricted Three-Body Problem (CR3BP).

Computing heteroclinic connections in the CR3BP
 1"""Example script: Detecting heteroclinic connections between two manifolds.
 2
 3This example demonstrates how to use the ConnectionPipeline class with the to find impulsive transfers between
 4manifolds in the CR3BP.
 5
 6Run with
 7    python examples/heteroclinic_connection.py
 8"""
 9
10import os
11import sys
12
13sys.path.append(os.path.join(os.path.dirname(__file__), "..", "src"))
14
15from hiten.algorithms.connections import ConnectionPipeline
16from hiten.algorithms.connections.config import ConnectionConfig
17from hiten.algorithms.connections.options import ConnectionOptions
18from hiten.algorithms.poincare import SynodicMapConfig
19from hiten.system import System
20
21
22def main() -> None:
23    system = System.from_bodies("earth", "moon")
24    mu = system.mu
25
26    l1 = system.get_libration_point(1)
27    l2 = system.get_libration_point(2)
28
29    halo_l1 = l1.create_orbit('halo', amplitude_z=0.5, zenith='southern')
30    halo_l1.correct()
31    halo_l1.propagate()
32
33    halo_l2 = l2.create_orbit('halo', amplitude_z=0.3663368, zenith='northern')
34    halo_l2.correct()
35    halo_l2.propagate()
36
37    manifold_l1 = halo_l1.manifold(stable=True, direction='positive')
38    manifold_l1.compute(integration_fraction=0.9, step=0.005)
39
40    manifold_l2 = halo_l2.manifold(stable=False, direction='negative')
41    manifold_l2.compute(integration_fraction=1.0, step=0.005)
42
43    section_cfg = SynodicMapConfig(
44        section_axis="x",
45        section_offset=1 - mu,
46        plane_coords=("y", "z"),
47    )
48
49    config = ConnectionConfig(
50        section=section_cfg,
51        direction=-1, 
52    )
53
54    options = ConnectionOptions(
55        delta_v_tol=1,
56        ballistic_tol=1e-8,
57        eps2d=1e-3,
58    )
59
60    # Create connection using the factory method with unified config
61    conn = ConnectionPipeline.with_default_engine(config=config)
62
63    result = conn.solve(manifold_l1, manifold_l2, options=options)
64
65    print(result)
66
67    conn.plot(dark_mode=True)
68
69    conn.plot_connection(dark_mode=True)
70
71
72if __name__ == "__main__":
73    main()