Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Examples and quick starts

The examples are deliberately small and deterministic. Runtime statements are orientation for a release build, not performance guarantees; use the maintained benchmark harnesses for measurements.

Rust quick start

Add the native crate and propagate a normalized circular orbit:

use pykep_core::astro::propagation::propagate_lagrangian;

fn main() -> pykep_core::Result<()> {
    let initial = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0];
    let final_state =
        propagate_lagrangian(&initial, core::f64::consts::FRAC_PI_2, 1.0)?;
    assert!((final_state[1] - 1.0).abs() < 1e-12);
    Ok(())
}

From this workspace, run cargo run --release -p pykep-examples --bin propagation. The default feature set includes the embedded VSOP2013 coefficients; use pykep-core with default-features = false when they are not needed.

Python quick start

Install a wheel in a virtual environment and use the same Rust core:

python -m venv .venv
.venv/bin/python -m pip install target/wheels/pykep_rust-*.whl
.venv/bin/python python/examples/elements_propagation.py
import numpy as np
import pykep_rust as pk

states = np.tile([1.0, 0.0, 0.0, 0.0, 1.0, 0.0], (4096, 1))
times = np.linspace(0.0, 1.0, len(states))
result = pk.propagate_lagrangian_batch(states, times, 1.0, workers=8)
assert result.shape == (4096, 6)

The Python package ships type information and accepts NumPy batch arrays only at float64; see python-api.md and batch-processing.md.

Runnable matrix

CapabilityRust binaryPython scriptUnits and expected outputRuntime / features
Epoch/anomalyepoch-anomaliesepoch_anomalies.pyMJD2000 days/radians; 180-day offset and exact round tripsConstant, normally <1 ms; default
Elementselementselements_propagation.pySI/radians; finite state and stable element round tripConstant, normally <1 ms; default
Propagation/STMpropagationelements_propagation.pyNormalized or consistent SI; quarter orbit / 60-second stateConstant, normally <1 ms; default
Lambertlambertlambert.pyNormalized; seven ordered zero/multi-revolution branchesBounded, normally <1 ms; default
Ephemeridesephemeris-comparisonephemeris_comparison.pyMJD2000, metres, m/s; two finite frame-labelled statesFirst call normally <1 ms; default vsop2013
Gravity assistgravity-assistgravity_assist.pySI/radians; constraints, positive delta-v, outgoing velocityConstant, normally <1 ms; default
Sims–Flanaganlow-thrust-legslow_thrust_legs.pyConsistent units; 7 mismatch values and 7 × 13 JacobianFour segments, normally <1 ms; default
CR3BP/ZOHdynamicsdynamics.pyNormalized; finite six-/seven-state propagationTwo short adaptive solves, normally <1 ms; default
Batch throughputcore Criterion benchesbatch.pyNormalized; newly owned 4096 × 6 outputOne native O(N) call; NumPy

Every Rust binary is compiled by the workspace test and clippy gates. Every Python script is executed by python/tests/test_examples.py, including from the clean-wheel CI matrix.

Documentation map

  • conventions.md defines units, epochs, frames, layout, and accuracy interpretation.
  • Dynamics, Pontryagin, zero-order-hold, ephemeris, Sims–Flanagan, and generic ZOH-leg behavior have dedicated module guides in this directory.
  • python-migration.md maps the C++/Python upstream surface and records deliberate differences and unavailable ecosystem areas.
  • The decisions/ records explain fixed-size types, errors, VSOP data, and adaptive-integration dependencies.
  • performance.md gives benchmark methodology and results.
  • status.md, source-map.md, and validation.md state implemented scope, limitations, and evidence without implying support for deferred modules.