Expand description
Python bindings for hpr-sim: the hpr Python package.
Guide: Python shows the package in use, and Start here says what works today and how far to trust it.
The package wraps the hpr builder, the same four types in the same order, and a Monte
Carlo run of them:
Environment: the launch site, the standard atmosphere, a wind (constant, or a Python function of height) and a gravity model.Motor: a motor from the built-in catalog, or a RASP.engor RockSim.rsefile.Rocket: parts added from the nose back, the motor and the parachutes; or a design read from a.hpr,.hprz,.orkor rocket JSON file.Flight: the rocket flown from a rail as soon as it is made, with its metrics, its events and its recording as NumPy arrays; with aDragTableor a Python function of the Mach number, another drag in place of hpr’s (models).MonteCarlo: the rocket flown many times, each flight’s inputs scattered about the nominal flight’s, ashpr mcflies it (montecarlo): the library’shpr_analysis::montecarlo::MonteCarlorun on every core, itsRunTableas NumPy arrays.
How far to trust it: the bindings add no physics. Each call hands its arguments to the
hpr builder and returns what it returns, so a flight made in Python runs the same code as
the one the Rust builder makes from the same numbers; the package’s tests fly the builder’s
example rocket and match every digit the Rust example prints (the last digits can differ
between a release and a debug build). The guide’s Accuracy page says how
good the models themselves are.
Values cross into Python in SI units, named in every argument and attribute (length_m,
apogee_m, max_speed_m_s), as in the Rust API. Records such as a flight’s summary cross as
dictionaries, made from the same serde form the Rust types write as JSON. Errors raise
hpr.HprError, a ValueError, whose message is the Rust error’s.
The crate is built by maturin (crates/hpr-py/pyproject.toml) into one wheel per operating
system, on CPython’s stable ABI (abi3), so it serves CPython 3.10 and later. Its tests are Python’s, in
crates/hpr-py/tests/, run by pytest on the built wheel.
Structs§
- HprError
- An error from hpr-sim: an input out of its domain, a part out of order, a motor or material that isn’t there, or a flight that failed. The message is the library’s.