Skip to main content

hpr_sim/
lib.rs

1//! The 6-DOF flight engine: state, launch rail phase, integrators, events, recovery, separation and
2//! the recorder.
3//!
4//! Four pages of the guide cover the flight: [How a flight is simulated][guide-flight],
5//! [Rigid-body flight][guide-rigid-body], [Time integration][guide-integration] and
6//! [Recovery][guide-recovery]. They give the models, their sources, how well they are validated
7//! and what they leave out.
8//!
9//! [guide-flight]: https://hpr.fusionspace.co/how-a-flight-is-simulated.html
10//! [guide-rigid-body]: https://hpr.fusionspace.co/physics/flight.html
11//! [guide-integration]: https://hpr.fusionspace.co/physics/integration.html
12//! [guide-recovery]: https://hpr.fusionspace.co/physics/recovery.html
13//!
14//! - [`flight`]: a [`Simulation`] of a rocket, its [`Environment`] and its [`Rail`], flown from
15//!   ignition through the pad, rail and free-flight phases to the ground.
16//! - [`dynamics`]: the rigid-body equations of motion with varying mass and jet damping.
17//! - [`rail`]: the rail's geometry and friction, and where a design's guides leave it.
18//! - [`recovery`]: recovery devices, their triggers and inflation, the descent under them, and
19//!   separation into bodies that each fly to their own landing.
20//! - [`shifts`]: mass that moves along the airframe in flight, and what it does to the mass
21//!   properties.
22//! - [`releases`]: mass released in flight, the rest flying on and the part falling on its own.
23//! - [`recorder`]: the [`Observer`] trait, flight [`Sample`]s and the channel [`Recorder`].
24//! - [`integrator`]: adaptive Dormand–Prince 5(4) with dense output, and fixed-step RK4, advancing
25//!   to stop times and events.
26//! - [`events`]: event directions and Brent's root finder.
27//! - [`metrics`]: what a flight comes to: its peaks, apogee, stability margins, optimum ejection
28//!   delays and landings.
29//! - [`envelope`]: the operating envelope's four flags: past the validated range, at high angle of
30//!   attack, outside the core band and beyond the envelope.
31//! - [`flutter`]: a fin's flutter speed and margin by NACA TN 4197's criterion.
32//! - [`free_body`]: a rigid body of a given mass and inertia, with no design or motor, flown on
33//!   the flight's gravity, rotation and integrator: the body published check cases fly.
34//! - [`export`]: a recording as CSV or JSON, and the flight path and landings as GeoJSON or KML.
35//!
36//! The crate flies a rocket from the pad to the ground under parachutes, streamers or tumbling. A
37//! separation's bodies each fly to their own landing. In staging, each motor lights at its own
38//! time. A separation with the nose's body still to burn lets that body fly on as a sustainer
39//! while the booster descends ([`flight`]).
40//!
41//! A cluster flies one motor in each of its tubes, and a tube or a motor can be set never to light.
42//! A `.ork` file's staging settings and clusters fly too.
43
44pub mod dynamics;
45pub mod envelope;
46pub mod environment;
47pub mod error;
48pub mod events;
49pub mod export;
50pub mod flight;
51pub mod flutter;
52pub mod free_body;
53pub mod histories;
54pub mod integrator;
55pub mod issues;
56pub mod metrics;
57pub mod pieces;
58pub mod rail;
59pub mod recorder;
60pub mod recovery;
61pub mod releases;
62pub mod shifts;
63mod staging;
64pub mod state;
65
66pub use dynamics::Phase;
67pub use envelope::EnvelopeFlag;
68pub use environment::Environment;
69pub use error::SimError;
70pub use events::{Direction, EVENT_TIME_RESOLUTION_S, RootError, find_root};
71pub use export::TrackPoint;
72pub use flight::{
73    EventKind, FlightEvent, FlightResult, FlightSettings, Simulation, Termination, UserEvent,
74};
75pub use flutter::{FlutterMargin, FlutterPanel};
76pub use free_body::{FreeBody, FreeBodyLoads, LoadInputs, Loads, NoLoads};
77pub use histories::{MassHistory, ThrustHistory};
78pub use integrator::{
79    Adaptive, Advance, DEFAULT_STEP_LIMIT, IntegrationError, Integrator, Method, OdeSystem,
80    SettingsError, Stats, Step,
81};
82pub use issues::{IssueWarning, KnownIssue};
83pub use metrics::{BodyPeak, FlightMetrics, FlightSummary};
84pub use pieces::{Ejection, Parting};
85pub use rail::{Guides, Rail};
86pub use recorder::{Channel, FlightStep, Observer, Recorder, Sample};
87pub use recovery::{
88    BodyEvent, BodyFlight, BodySample, CanopyType, Device, DeviceDrag, Inflation, Separation,
89    StreamerModel, Trigger, terminal_speed_m_s,
90};
91pub use releases::{MassRelease, ReleasedFlight};
92pub use shifts::{MIN_SHIFT_DURATION_S, MassShift};
93pub use staging::FlownVehicle;
94pub use state::{STATE_LEN, State};
95
96#[cfg(test)]
97mod testing;
98
99#[cfg(test)]
100mod tests;