Skip to main content

Earth to Moon, Moon to Earth — 地月空间转移轨道设计库

Project description

e2m2e — Earth to Moon, Moon to Earth

地月空间转移轨道设计库

License: Apache 2.0 Python Version PyPI CI

e2m2e 是一个用于设计地月空间运行轨道和转移轨道的 Python 库,基于圆型限制性三体问题 (CR3BP) 和星历 N 体动力学建模。

PyPI

e2m2e 围绕“建模—生成—转移—检查”组织工作流。你可以先建立地月空间的动力学模型,再生成或修正一条轨道,必要时把它转换到更精确的星历模型,最后通过可视化检查设计结果。

核心能力覆盖:

  • 建模:CR3BP 系统、星历系统、力模型组合、坐标系与积分器族
  • 生成:周期轨道族、微分修正、多重打靶、延拓、稳定性分析
  • 正规化:Hamiltonian 正规化流水线,把平动点附近轨道化简为少数表征参数
  • 转移:网格搜索 + NLP 优化的转移轨道设计
  • 检查:2D/3D 轨道绘图、Jacobi 常数图、稳定性分析图

更详细的能力按模块列出:

动力学建模

  • CR3BP 系统(地月、日地、日木等)、平动点与 Jacobi 常数
  • 星历系统:基于 SPICE 内核的 N 体引力,可配置力模型
  • 力模型组合:重力场、大气阻力、太阳光压(cannonball + 圆锥地影/月影)、脉冲/有限推力;按名注册、启用/禁用、序列化到 JSON
  • 积分器族:RK(PD45/PD78/RK89)、Adams-Bashforth-Moulton、Cowell 8 阶,自适应与固定步长

坐标系

  • J2000/ICRS/ITRF 层级转换、GAST/极移,标准轴/原点定义,与 GMAT 兼容

轨道生成与分析

  • 周期轨道族:DRO、ARO、RO、Halo、Lyapunov、Lissajous、Butterfly、Dragonfly
  • 微分修正(对称 2D/3D/Halo)、多重打靶(含两级)、自然/伪弧长延拓、稳定性分析
  • LEO/GEO 参考轨道快速创建

转移设计

  • 转移轨道搜索与优化(网格搜索 + NLP),如 DRO-RO

Hamiltonian 正规化

  • 一键式流水线 NormalFormPipeline:动力学替代 → quasi-Floquet 变换 → 中心流形化简 → 表征参数 (q1, p1, I2, θ2, I3, θ3)
  • 把 CR3BP 平动点附近的复杂非线性动力学化简为少数几乎不变的参数,用于轨道识别与高保真外推。可选依赖 pip install e2m2e[normal-form],示例见 examples/normal_form_example.py

可视化

  • 2D/3D 轨道绘图、Jacobi 常数图、稳定性分析图

安装

pip install e2m2e

从源码安装:

git clone https://github.com/cislunarspace/e2m2e.git
cd e2m2e
uv sync

开发依赖:

uv sync --group dev

SPICE 内核

星历动力学需要 NASA SPICE 内核文件,放置在 kernels/ 目录或 $SPICE_KERNEL_DIR 指定的路径。

常用内核: de440.bsp (行星星历)、moon_pa_de440_200625.bsp (月球姿态)、pck00011.tpc (行星常数)。

内核下载: NASA NAIF

快速开始

创建 CR3BP 系统

from e2m2e.core import CR3BP_System

system = CR3BP_System(mu=0.01215, primary="earth", secondary="moon")
system.compute_libration_points()
system.info()

星历动力学

from e2m2e.core import EphemerisSystem, EphemerisDynamics, SPICEManager

spice = SPICEManager()
kernel = spice.find_ephemeris_kernel("./kernels/")
spice.load_kernel(kernel)

ephemeris_system = EphemerisSystem(
    bodies=["EARTH", "MOON", "SUN"],
    spice=spice,
    origin="EARTH",
    frame="J2000",
)
dynamics = EphemerisDynamics(system=ephemeris_system)

生成 DRO 轨道族

from e2m2e.core import CR3BP_System, Orbit, CR3BP_Dynamics
from e2m2e.algorithms import DifferentialCorrection, Continuation

system = CR3BP_System(mu=0.01215, primary="earth", secondary="moon")
dynamics = CR3BP_Dynamics(system=system)

# 种子轨道
initial_state = [0.79188556619742, 0.0, 0.0, 0.0, 0.53682, 0.0]
seed_orbit = Orbit(states=[initial_state], times=[0])

# 微分修正
corrector = DifferentialCorrection(dynamic=dynamics)
corrector.setup_2D_symmetric_x_fixed_x0(x0=initial_state[0])
seed_dro = corrector.iterate_correction(initial_guess=seed_orbit)

# 延拓生成轨道族
continuation = Continuation(corrector=corrector)
family = continuation.natural_continuation(
    seed_orbit=seed_dro,
    param_range=(0.14, 0.9),
    step_size=0.005,
)

多重打靶法

from e2m2e.algorithms import MultipleShooting, sample_patch_points

ms = MultipleShooting(dynamics=dynamics)
t_patch, state_patch = sample_patch_points(seed_dro, n_points=5)

result = ms.correct(
    t_patch=t_patch,
    state_patch=state_patch,
    max_iter=50,
    tolerance=1e-10,
    var_time=True,
)

if result.converged:
    print(f"收敛,最大残差 {result.max_residual:.2e}")

转移轨道设计

from e2m2e.transfer import Transfer

transfer = Transfer(dynamics)
result = transfer.set_orbit(start=dro_orbit, end=ro_orbit).optimize(
    initial_guess={"alpha": 1.0, "transfer_time": 15.0, "t_ins": 5.0},
    alpha_range=(0.5, 2.5),
)

底层搜索 + NLP 两步法:

from e2m2e.transfer import TransferSearch, DROTRONLPOptimizer, NLPOptimizationVariables

# 搜索
searcher = TransferSearch(dynamics=dynamics)
results = searcher.search(
    alpha_min=0.5, alpha_max=2.5,
    n_alpha=101, n_departure=200,
    max_transfer_time=200.0,
    intersection_threshold=0.05,
    min_distance_threshold=0.02,
    collision_earth_radius=6378.0 / 384400.0,
    collision_moon_radius=1737.0 / 384400.0,
    integration_dt=0.01,
    departure_orbit=dro_orbit, arrival_orbit=ro_orbit,
)

# NLP 优化
optimizer = DROTRONLPOptimizer(
    system=system, dynamics=dynamics,
    departure_orbit=dro_orbit, arrival_orbit=ro_orbit,
    departure_state=dro_orbit.states[0]
)
result = optimizer.optimize(
    initial_guess=NLPOptimizationVariables(alpha=1.0, transfer_time=5.0, t_ins=3.0),
)

可视化

from e2m2e.visualization import PlotConfig, FamilyPlotter

config = PlotConfig(title=32, label=28)
config.apply_rcparams()

plotter = FamilyPlotter(system, config)
plotter.plot_family_2d(family, jacobi_values, title="DRO Family")

项目结构

e2m2e/
├── core/                 # 系统、动力学、轨道、坐标系、星历
│   ├── system.py         # System 抽象基类
│   ├── cr3bp_system.py   # CR3BP_System - 系统定义、平动点
│   ├── dynamics.py       # CR3BP_Dynamics - 运动方程、STM
│   ├── orbit.py          # Orbit, OrbitFamily - 轨道数据结构
│   ├── coordinate_system.py  # CoordinateSystem - 坐标系定义
│   ├── synodic_j2000.py  # SynodicJ2000System - synodic ↔ J2000 转换器
│   ├── ephemeris_system.py  # EphemerisSystem - 星历系统
│   ├── ephemeris_dynamics.py # EphemerisDynamics - N 体动力学
│   └── spice.py          # SPICE 内核管理
├── algorithms/           # 微分修正、延拓、打靶、稳定性分析、Hamiltonian 正规化
├── transfer/             # 转移轨道搜索与优化
├── mbse/                 # 基于模型的系统工程
└── visualization/        # 2D/3D 绘图

文档

测试

uv run pytest tests/

代码规范

uv run ruff check .          # 检查
uv run ruff check --fix .    # 自动修复
uv run ruff format .         # 格式化

贡献

  1. Fork 本仓库
  2. 创建功能分支 (git checkout -b feature/amazing-feature)
  3. 提交更改 (git commit -m 'Add amazing feature')
  4. 推送到分支 (git push origin feature/amazing-feature)
  5. 开启 Pull Request

更新日志

CHANGELOG.md

引用

@software{e2m2e,
  title = {e2m2e: Earth to Moon, Moon to Earth Transfer Orbit Design Library},
  author = {ouyangjiahong},
  email = {ouyangjiahong22@nudt.edu.cn},
  url = {https://github.com/cislunarspace/e2m2e},
  version = {5.1.0},
  year = {2026},
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

e2m2e-5.1.0.tar.gz (278.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

e2m2e-5.1.0-cp310-abi3-win_amd64.whl (510.0 kB view details)

Uploaded CPython 3.10+Windows x86-64

e2m2e-5.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (644.6 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

File details

Details for the file e2m2e-5.1.0.tar.gz.

File metadata

  • Download URL: e2m2e-5.1.0.tar.gz
  • Upload date:
  • Size: 278.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for e2m2e-5.1.0.tar.gz
Algorithm Hash digest
SHA256 65475044ccd3622ad9c6ca0c9aa0befc2f02c49ee24a81b41d3c7fb209578381
MD5 58f64d2987db93fdc2d48935fc68d007
BLAKE2b-256 d5143a07008524387a84695fd543094f4f60230b8ff7c215ee5dece115f9b7db

See more details on using hashes here.

Provenance

The following attestation bundles were made for e2m2e-5.1.0.tar.gz:

Publisher: release.yml on cislunarspace/e2m2e

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file e2m2e-5.1.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: e2m2e-5.1.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 510.0 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for e2m2e-5.1.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e3961115ee4383f061a0498841c95b2992481e8b4b9d277d9c2caa415a7eaae3
MD5 2b8bf00dc10708702fdd7e73ec69d67b
BLAKE2b-256 bd4b1a1fe453b9088c3fff979b1fa984d46a9aee4137dfaae109f30f3fbfb988

See more details on using hashes here.

Provenance

The following attestation bundles were made for e2m2e-5.1.0-cp310-abi3-win_amd64.whl:

Publisher: release.yml on cislunarspace/e2m2e

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file e2m2e-5.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for e2m2e-5.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4b10d819b8807ec73e098a15ce30f6e2d6a000d9765e82d2687c9053fe9e8869
MD5 4c4cc9b739d8f87c4cf7ea4c6b77b02d
BLAKE2b-256 f649331c0f61a26d5d140b5b914ad27a39a7f2b11195823f0449fec757992592

See more details on using hashes here.

Provenance

The following attestation bundles were made for e2m2e-5.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on cislunarspace/e2m2e

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page