Skip to main content

Motor

Struct Motor 

Source
pub struct Motor { /* private fields */ }
Expand description

A commercial solid motor: its designation, its case’s size, its thrust curve and masses, and the delay of its ejection charge, if it has one.

Three ways to get one:

use hpr::Motor;

let motor = Motor::from_catalog("H54")?.with_delay_s(10.0)?;
assert_eq!(motor.designation(), "168H54-10A");
assert_eq!(motor.diameter_m(), 0.029);

It serializes, for a record of what was flown, but doesn’t deserialize: its constructors check what goes in.

Implementations§

Source§

impl Motor

Source

pub fn new( designation: &str, motor: SolidMotor, diameter_m: f64, length_m: f64, ) -> Result<Self, Error>

A motor of case diameter diameter_m and length length_m, called designation, with no ejection delay.

§Errors

Error::EmptyDesignation for an empty designation, and Error::Domain for a diameter or length that isn’t finite and positive.

Source

pub fn from_catalog(name: &str) -> Result<Self, Error>

The motor in hpr-sim’s built-in catalog whose designation or common name is name, ignoring case, spaces and hyphens ("H54", "168H54-10A", "k 400"), with its first bundled thrust curve. Only motors with a bundled curve can be found: 32 today, listed on the motor page. The delay is not set, whatever the designation says: give it with Motor::with_delay_s.

§Errors
  • Error::NoSuchMotor if no motor with a bundled curve matches.
  • Error::AmbiguousMotor if several motors match, as a common name can ("I175" matches two); each is listed by its designation, which finds it alone.
  • Error::Motor if the catalog or the motor’s curve can’t be read (never, for the bundled ones: their tests read them all).
Source

pub fn from_eng(text: &str) -> Result<Self, Error>

The one motor in the text of a RASP .eng file, with the file’s size, masses and thrust curve (SolidMotor::from_envelope). The file’s warnings and its list of delays are dropped (read the file with hpr_motor::eng::parse to see them): set the delay with Motor::with_delay_s. A .eng file doesn’t say what kind of motor it holds, so a hybrid’s file is read as a solid motor; hpr models solid motors only.

§Errors

Error::Motor if the text isn’t a motor file or its numbers don’t make a motor, and Error::MotorCount if it holds more than one motor or none.

Source

pub fn from_rse(text: &str) -> Result<Self, Error>

The one motor in the text of a RockSim .rse file, with the file’s size, masses (grams, converted) and thrust curve (SolidMotor::from_envelope). As with Motor::from_eng, the file’s warnings, its delays and the center-of-gravity column some files carry are dropped (read the file with hpr_motor::rse::parse to see them). A hybrid, which the file’s Type names, is refused: hpr models solid motors only.

§Errors

Error::Motor if the text isn’t a motor file, its numbers don’t make a motor, or it is a hybrid; Error::MotorCount if it holds more than one motor.

Source

pub fn with_delay_s(self, delay_s: f64) -> Result<Self, Error>

The same motor with an ejection charge delay_s seconds after burnout.

§Errors

Error::Domain for a delay that is negative or not finite.

Source

pub fn with_delay(self, delay: Delay) -> Result<Self, Error>

The same motor with delay as its ejection delay: a time, or a plugged motor (Delay::Plugged), which has no ejection charge.

§Errors

Error::Domain for a time that is negative or not finite.

Source

pub fn designation(&self) -> &str

The designation, such as 168H54-10A.

Source

pub fn diameter_m(&self) -> f64

The case’s outer diameter, m.

Source

pub fn length_m(&self) -> f64

The case’s length, m.

Source

pub fn delay(&self) -> Option<Delay>

The ejection delay, if one is set.

Source

pub fn solid_motor(&self) -> &SolidMotor

The motor model: thrust curve, propellant and case masses.

Trait Implementations§

Source§

impl Clone for Motor

Source§

fn clone(&self) -> Motor

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 Debug for Motor

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Motor

Source§

fn eq(&self, other: &Motor) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Motor

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Motor

Auto Trait Implementations§

§

impl Freeze for Motor

§

impl RefUnwindSafe for Motor

§

impl Send for Motor

§

impl Sync for Motor

§

impl Unpin for Motor

§

impl UnsafeUnpin for Motor

§

impl UnwindSafe for Motor

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.