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

功能

  • CR3BP 系统建模:地月、日地、日木等天体系统,拉格朗日点计算,Jacobi 常数
  • 星历动力学:基于 SPICE 内核的 N 体引力计算,支持多天体摄动
  • 太阳辐射压 (SRP):CR3BP_SRP_Dynamics 子类,支持光学系数参数化
  • 周期轨道:DRO、ARO、RO、Halo、Lyapunov、Lissajous、Butterfly、Dragonfly
  • 设计算法:微分修正、多重打靶法、自然延拓、伪弧长延拓、稳定性分析
  • 转移轨道:DRO-RO 转移搜索 (网格搜索 + NLP 优化)
  • 可视化: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.from_known_system("earth_moon")
system.compute_libration_points()
system.info()

星历动力学

from e2m2e.core import EphemerisSystem, EphemerisDynamics, SPICEManager

spice = SPICEManager()
spice.load_kernels_from_directory("./kernels/")

ephemeris_system = EphemerisSystem(
    bodies=["EARTH", "MOON", "SUN"],
    reference_epoch="2025-06-21T11:00:06"
)
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, convert_to_j2000

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

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

if result.converged:
    state_j2000 = convert_to_j2000(result.state_patch, system)

转移轨道设计

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,
    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         # CR3BP_System - 系统定义、平动点
│   ├── dynamics.py       # CR3BP_Dynamics - 运动方程、STM
│   ├── srp_dynamics.py   # CR3BP_SRP_Dynamics - 太阳辐射压扰动
│   ├── orbit.py          # Orbit, OrbitFamily - 轨道数据结构
│   ├── coordinate.py     # 坐标变换
│   ├── ephemeris_system.py      # EphemerisSystem - 星历系统
│   ├── ephemeris_dynamics.py    # EphemerisDynamics - N 体动力学
│   └── spice.py                 # SPICE 内核管理
├── algorithms/           # 微分修正、延拓、打靶、稳定性分析
├── 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

引用

@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 = {4.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-4.2.0.tar.gz (378.7 kB view details)

Uploaded Source

Built Distribution

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

e2m2e-4.2.0-py3-none-any.whl (162.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for e2m2e-4.2.0.tar.gz
Algorithm Hash digest
SHA256 babdb324a2405a975bb795b97f3a9aa47c2b182fc4b3b0da5f0ec3f34accd87b
MD5 1718c48ecdbda90f7997266d70682eea
BLAKE2b-256 42d43105772fe07322341aaff4c43677af477d3a8b827e2e85b7edaac1cd0706

See more details on using hashes here.

Provenance

The following attestation bundles were made for e2m2e-4.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-4.2.0-py3-none-any.whl.

File metadata

  • Download URL: e2m2e-4.2.0-py3-none-any.whl
  • Upload date:
  • Size: 162.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for e2m2e-4.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6eab5019f559e60cfd89114faede950138e2aae6024053e3caec3e64388def31
MD5 79b0462bf7d13d01c9606212781c5810
BLAKE2b-256 a0ae460efabaca4d22ce119f2fc79ce7b5ad3c4a0cb589a5ad3a79d28ab98e5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for e2m2e-4.2.0-py3-none-any.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