Skip to main content

Crate hpr

Crate hpr 

Source
Expand description

The hpr-sim library facade: a builder API for environments, motors, rockets and flights, and the workspace’s crates re-exported.

Guide: Start here says what works and how far to trust it, Getting started flies a first rocket, and The builder walks through this crate’s API. The guide module is the same walk-through in this reference, in five short chapters.

Four types make a flight, in the order a program needs them:

  • Environment: the launch site, the atmosphere and the wind.
  • Motor: a motor from the built-in catalog or a RASP .eng file.
  • Rocket: parts added from the nose back, the motor, and the recovery devices.
  • Flight: the rocket flown from a rail, with its apogee, speeds and landing.

How far to trust it: the builder adds no physics of its own. It makes the same design tree and flies the same simulation as the crates below it, and a test flies a rocket built both ways to the same numbers, bit for bit. So its numbers are as good as those models are; the guide’s Accuracy page says how good that is, with every comparison made.

use hpr::rocket::{Fins, Mass, MotorTube, Nose, Tube, material};
use hpr::{
    CanopyType, Device, DeviceDrag, Environment, FinPlanform, Flight, Motor, NoseShape,
    Position, Rocket, Trigger,
};

let environment = Environment::new(32.99, -106.97, 1400.0)?;
let ogive = NoseShape::Ogive { radius_ratio: 1.0 };
let planform = FinPlanform::Trapezoidal {
    root_chord_m: 0.1,
    tip_chord_m: 0.04,
    span_m: 0.045,
    sweep_m: 0.05,
};
let mut rocket = Rocket::new("Small", 0.0563)?;
rocket
    .add_nose(Nose::hollow(ogive, 0.22, 0.0015, material("abs")?))?
    .add_tube(Tube::new(0.9, 0.00115, material("kraft_phenolic")?))?
    .add_fins(Fins::new(3, planform, 0.003175, material("birch_plywood")?))?
    .add_motor_tube(MotorTube::new(0.2, 0.029, 0.001, material("kraft_phenolic")?))?
    .add_mass(Mass::new(0.2, Position::Top { aft_offset_m: 0.07 }))?
    .set_motor(Motor::from_catalog("H54")?.with_delay_s(10.0)?)?
    .add_parachute(Device::new(
        "parachute",
        DeviceDrag::canopy(CanopyType::FlatCircular, 0.9),
        Trigger::MotorDelay { motor: 0 },
    ));
let flight = Flight::builder(&rocket, &environment, 1.8).fly()?;
assert!(flight.apogee_m().is_some_and(|apogee_m| apogee_m > 1000.0));

The builder makes the same things the crates below it use, and hands them over: a rocket’s Rocket::design is an hpr_design::Rocket, a flight’s FlightBuilder::simulation an hpr_sim::Simulation. For what the builder doesn’t offer, such as staging, clusters, pods or mass shifts, build those with the crates, which this one re-exports by name.

The net feature adds hpr-net (as hpr::hpr_net): the cache, the offline mode, the HTTP transport, a launch site’s weather from Open-Meteo (hpr_net::open_meteo), weather-balloon soundings from the University of Wyoming’s archive (hpr_net::wyoming), NOAA’s GFS and RAP forecasts (hpr_net::nomads), a site’s height above sea level from Open-Meteo (hpr_net::elevation), motor stock and prices from motor.fusionspace.co (hpr_net::motor_finder), and motor records and thrust curves from ThrustCurve.org (hpr_net::thrustcurve). The parquet feature turns on hpr-sim’s Parquet export (hpr_sim::export::parquet). ork flies the stage separation an OpenRocket .ork file describes.

Re-exports§

pub use environment::Environment;
pub use error::CatalogProblem;
pub use error::Error;
pub use error::Order;
pub use flight::Flight;
pub use flight::FlightBuilder;
pub use motor::Motor;
pub use rocket::Rocket;
pub use hpr_aero;
pub use hpr_analysis;
pub use hpr_atmos;
pub use hpr_core;
pub use hpr_design;
pub use hpr_flightdata;
pub use hpr_forensics;
pub use hpr_format;
pub use hpr_io;
pub use hpr_motor;
pub use hpr_net;
pub use hpr_sim;

Modules§

environment
Where and in what weather a rocket flies.
error
The facade’s error type.
flight
A flight: a rocket launched from a rail in an environment, flown to the ground.
guide
A guide to the hpr crate, in the API reference: what to read first, and how the pieces fit.
motor
A solid rocket motor, ready to go in a rocket’s motor tube.
ork
Flying what an OpenRocket .ork file says about staging and recovery.
rocket
A rocket built part by part, from the nose back.

Structs§

Device
A recovery device: a drag area, when it opens, and how it fills.
Separation
A separation: the stack comes apart at a stage boundary and every body descends under its own devices (docs/physics/recovery.md, and the decision record on separation, ADR-014).

Enums§

CanopyType
A canopy type with printed data in Knacke’s tables.
DeviceDrag
What gives a device its drag area C_D S.
EnvelopeFlag
One flag a flight raises, with the peak that raised it. Serialized with a flag tag in snake case.
FinCrossSection
The shape of a fin’s section along its chord.
FinPlanform
The outline of one fin.
NoseShape
The shape of a nose cone, or of a transition’s profile.
Position
Where an attached part sits along its parent. Offsets are positive aft.
Trigger
When a device’s charge fires.