Orbit Family Example
This example demonstrates how to compute families of periodic orbits in the Circular Restricted Three-Body Problem (CR3BP).
Computing orbit families in the CR3BP
1"""Example script: continuation-based generation of a Halo-orbit halo_family.
2
3Run with
4 python examples/orbit_family.py
5"""
6
7import os
8import sys
9
10sys.path.append(os.path.join(os.path.dirname(__file__), "..", "src"))
11
12from hiten import System
13from hiten.algorithms import ContinuationPipeline
14from hiten.algorithms.types.states import SynodicState
15from hiten.algorithms.continuation.config import _OrbitContinuationConfig
16from hiten.system.family import OrbitFamily
17from hiten.utils.log_config import logger
18
19
20def main() -> None:
21 """Generate and save a small Halo halo_family around the Earth-Moon L1 point.
22
23 This example demonstrates how to use the ContinuationPipeline predictor to
24 generate a halo_family of Halo orbits around the Earth-Moon L1 point.
25 """
26 num_orbits = 50
27 system = System.from_bodies("earth", "moon")
28 l1 = system.get_libration_point(1)
29
30 halo_seed = l1.create_orbit('halo', amplitude_z= 0.2, zenith='southern')
31 halo_seed.correct(max_attempts=25, max_delta=1e-3)
32
33 current_z = halo_seed.initial_state[SynodicState.Z] # 0 for planar Lyapunov halo_seed
34 target_z = current_z + 5.0 # introduce out-of-plane Z
35 step_z = (target_z - current_z) / (num_orbits - 1)
36
37 config= _OrbitContinuationConfig(
38 target=([current_z], [target_z]),
39 step=((step_z),),
40 state=(SynodicState.Z,),
41 max_members=50,
42 extra_params=dict(max_attempts=50, tol=1e-12),
43 stepper="secant",
44 )
45
46 state_parameter = ContinuationPipeline.with_default_engine(config=config)
47
48 result = state_parameter.generate(halo_seed)
49
50 logger.info(f"Generated {len(result.family)} orbits (success rate {result.success_rate:.2%})")
51
52 family = OrbitFamily.from_result(result)
53 family.propagate()
54 family.plot()
55
56if __name__ == "__main__":
57 main()