Skip to main content

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.2.0},
  year = {2026},
}

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.2.0.tar.gz (3.0 MB view details)

Uploaded Source

Built Distributions

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

e2m2e-5.2.0-cp310-abi3-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.10+Windows x86-64

e2m2e-5.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB view details)

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

File details

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

File metadata

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

File hashes

Hashes for e2m2e-5.2.0.tar.gz
Algorithm Hash digest
SHA256 9dfc6607be93ff0825a0385dd8488a773dbead7c9362c23e5c5e77657edfe82e
MD5 315db5b2848f3e708b0605d8044aca5a
BLAKE2b-256 b5897c694685c123967d89bb23f802f8a074f4d44e331a06950da1f28bb4d1f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for e2m2e-5.2.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.2.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: e2m2e-5.2.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.2 MB
  • 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.2.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9b82c53a51dc19f04d2c591ff60721c224935944f84c3fd648a1084d56fa0af3
MD5 5be2cb73d28acd5c6e713fca31d46557
BLAKE2b-256 9a04448b8373ea6cb8fd17e52610f3d42fa8c6e7776baca9d2ff160183a09c8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for e2m2e-5.2.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.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for e2m2e-5.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 418c6b7e5c6c43a0008489cc9bbe48f0c0b6d9fd949491ed5f7a2ac5f2d6a3cd
MD5 68aeab0ced40696309824d79379bbd59
BLAKE2b-256 66a32fddab53b4aaebdb8ea5ebfdbcdec0ec15b163e30d1d0280da007409aa64

See more details on using hashes here.

Provenance

The following attestation bundles were made for e2m2e-5.2.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.

Release history Release notifications | RSS feed

5.8.6

4 files

5.8.5

4 files

5.8.4

4 files

5.8.3

4 files

5.8.2

4 files

5.8.1

4 files

5.8.0

4 files

5.7.3

4 files

5.7.2

4 files

5.7.1

4 files

5.6.10

4 files

5.6.9

4 files

5.6.8

3 files

5.6.7

3 files

5.6.6

3 files

5.6.5

3 files

5.6.4

3 files

5.6.3

3 files

5.6.2

3 files

5.6.1

3 files

5.6.0

3 files

5.5.0

3 files

5.3.1

3 files

This release

5.2.0 This release

3 files

5.1.0

3 files

5.0.0

2 files

4.2.0

2 files

4.1.0

2 files

4.0.0

2 files

3.1.11

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page