Skip to main content

FlightBuilder

Struct FlightBuilder 

Source
pub struct FlightBuilder<'a> { /* private fields */ }
Expand description

How a flight is launched: which rocket, where, and from what rail. Made by Flight::builder; FlightBuilder::fly flies it.

Implementations§

Source§

impl FlightBuilder<'_>

Source

pub fn inclination_deg(self, inclination_deg: f64) -> Self

The rail’s angle above the horizon, degrees: 90, the default, is vertical, and 85 leans 5° off it. (OpenRocket’s launch rod angle is measured from the vertical instead: its 5° is 85 here.)

Source

pub fn heading_deg(self, heading_deg: f64) -> Self

The direction the rail leans toward, clockwise from true north, degrees: 0, the default, is north and 90 is east. A wind’s direction is where it blows from, so a rail leaning into a west wind has both at 270. On a vertical rail the heading still turns the rocket about its axis, which way its fins face. That matters to a set of one or two fins, whose lift depends on which way the air meets them; three or more equal fins lift nearly the same whichever way they face.

Source

pub fn rail(self, rail: Rail) -> Self

The whole rail, in place of the one Flight::builder made: its length, its angles in radians, the rocket’s roll on it and its friction (Rail). FlightBuilder::inclination_deg and FlightBuilder::heading_deg, called before or after, still set its angles.

Source

pub fn settings(self, settings: FlightSettings) -> Self

The integrator and its limits, in place of the defaults (FlightSettings).

Source

pub fn separation(self, separation: Separation) -> Self

Flies with separation: at its trigger the stack comes apart at a stage boundary, and each part flies on to its own landing (Simulation::with_separation, which has the rules). Every part needs a recovery device on the rocket, each on its own part (hpr_sim::Device::on_body); for a .ork file, crate::ork::separated_recovery makes them. Each separated part’s landing is in FlightSummary::body_landings.

Source

pub fn separations(self, separations: Vec<Separation>) -> Self

Flies with separations, in the order they fire, each at a stage boundary further forward than the one before: a stack that drops its stages one at a time under power (Simulation::with_separations, which has the rules). As FlightBuilder::separation, every part needs a device of its own; for a .ork file, crate::ork::separations and crate::ork::separated_recovery make them. In place of any set before.

Source

pub fn drag_model(self, model: impl DragModel + 'static) -> Self

Flies model’s drag in place of hpr’s drag buildup: a model of your own, from a wind tunnel, another tool or your flights, or hpr’s own adjusted (hpr_aero::custom, Simulation::with_drag_model). The model gives the zero-lift drag coefficient on the rocket’s reference area, by default a circle of its largest body diameter; unlike a drag table’s, a model’s number isn’t rescaled, so a curve measured on another area is converted before it is returned. The normal force, center of pressure, roll and damping stay hpr’s, so the stability margin a Rocket reports doesn’t change. The last model or table set is the one flown (FlightBuilder::drag_table), and every flight of this builder shares it.

use hpr::hpr_aero::{AeroError, DragModel, DragQuery};

/// hpr's own drag, 20% higher.
#[derive(Debug)]
struct Rougher;

impl DragModel for Rougher {
    fn zero_lift_drag(&self, query: &DragQuery<'_>) -> Result<f64, AeroError> {
        Ok(1.2 * query.buildup()?.zero_lift_coefficient)
    }
}

let environment = Environment::new(32.99, -106.97, 1400.0)?;
let launch = Flight::builder(&rocket, &environment, 1.8);
let own = launch.fly()?.apogee_m().ok_or("no apogee")?;
let rougher = launch.drag_model(Rougher).fly()?.apogee_m().ok_or("no apogee")?;
assert!(rougher < own);
Source

pub fn shared_drag_model(self, model: Arc<dyn DragModel>) -> Self

As FlightBuilder::drag_model, with a model already shared: one model, a large table say, flown by many builders without a copy for each.

Source

pub fn drag_table(self, table: DragTable) -> Self

Flies table’s drag in place of hpr’s drag buildup: another tool’s zero-lift drag coefficient C_D0 against Mach number, as RocketPy’s power_off_drag and power_on_drag curves are (DragTable, Simulation::with_drag_table). Its power-on curve, where it has one, is flown while a motor thrusts, and its power-off curve at every other time. A table read by DragTable::from_csv interpolates linearly between its Mach numbers and holds its end values past them; one built from hpr_core::interp::Table1Ds interpolates and extrapolates as they say. A table on a reference diameter of its own (DragTable::with_reference_diameter_m) is rescaled to the rocket’s reference area by the ratio of the two areas, C_D0 · (d_table / d_rocket)². The normal force, center of pressure, roll and damping stay hpr’s. The last model or table set is the one flown (FlightBuilder::drag_model). A flight that meets a negative coefficient in the table, drag that would push the rocket along, stops with an error that says so.

use hpr::hpr_aero::DragTable;

let environment = Environment::new(32.99, -106.97, 1400.0)?;
let launch = Flight::builder(&rocket, &environment, 1.8);
// C_D0 of 0.45 up to Mach 0.8, 0.6 by Mach 1.2; 0.05 less while the motor burns.
let table = DragTable::from_csv(
    "mach,cd\n0,0.45\n0.8,0.45\n1.2,0.6\n",
    Some("mach,cd\n0,0.40\n0.8,0.40\n1.2,0.55\n"),
)?;
let tabled = launch.clone().drag_table(table).fly()?.apogee_m().ok_or("no apogee")?;
let own = launch.fly()?.apogee_m().ok_or("no apogee")?;
assert_ne!(tabled, own);
Source

pub fn simulation(&self) -> Result<Simulation, Error>

The Simulation FlightBuilder::fly runs, for what the facade doesn’t offer: user events, staging, mass shifts and the rest of hpr_sim.

§Errors
Source

pub fn inputs(&self) -> Result<FlightInputs, Error>

Everything the flight is flown from, as hpr_analysis::montecarlo::FlightInputs: what a Monte Carlo run disperses (hpr_analysis::montecarlo).

§Errors
  • Error::NoMotor for a rocket with no motor.
  • Error::Domain for an inclination outside (0°, 90°] or a heading that isn’t finite.
  • Error::Sim for a rail that isn’t positive in length or whose friction is negative.
Source

pub fn fly(&self) -> Result<Flight, Error>

Flies the rocket from the rail to the ground.

§Errors

As FlightBuilder::simulation, and Error::Sim for a flight that fails on the way, such as a model asked about a flow it doesn’t cover.

Source

pub fn fly_with(&self, observer: &mut dyn Observer) -> Result<Flight, Error>

Flies the rocket, showing observer every step of the flight as it goes: a hpr_sim::Recorder keeps a trajectory, and an Observer of your own can watch for anything.

§Errors

As FlightBuilder::fly, and whatever observer returns.

Trait Implementations§

Source§

impl<'a> Clone for FlightBuilder<'a>

Source§

fn clone(&self) -> FlightBuilder<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for FlightBuilder<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for FlightBuilder<'a>

§

impl<'a> !UnwindSafe for FlightBuilder<'a>

§

impl<'a> Freeze for FlightBuilder<'a>

§

impl<'a> Send for FlightBuilder<'a>

§

impl<'a> Sync for FlightBuilder<'a>

§

impl<'a> Unpin for FlightBuilder<'a>

§

impl<'a> UnsafeUnpin for FlightBuilder<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.