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:
Motor::from_catalog: a motor from the catalog built into hpr-sim, by its designation or common name, with the catalog’s size, masses and thrust curve.Motor::from_eng: a RASP.engfile’s text, as ThrustCurve.org serves it, orMotor::from_rse: a RockSim.rsefile’s.Motor::new: aSolidMotoryou built withhpr_motor, and its case’s size.
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
impl Motor
Sourcepub fn new(
designation: &str,
motor: SolidMotor,
diameter_m: f64,
length_m: f64,
) -> Result<Self, Error>
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.
Sourcepub fn from_catalog(name: &str) -> Result<Self, Error>
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::NoSuchMotorif no motor with a bundled curve matches.Error::AmbiguousMotorif several motors match, as a common name can ("I175"matches two); each is listed by its designation, which finds it alone.Error::Motorif the catalog or the motor’s curve can’t be read (never, for the bundled ones: their tests read them all).
Sourcepub fn from_eng(text: &str) -> Result<Self, Error>
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.
Sourcepub fn from_rse(text: &str) -> Result<Self, Error>
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.
Sourcepub fn with_delay_s(self, delay_s: f64) -> Result<Self, Error>
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.
Sourcepub fn with_delay(self, delay: Delay) -> Result<Self, Error>
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.
Sourcepub fn designation(&self) -> &str
pub fn designation(&self) -> &str
The designation, such as 168H54-10A.
Sourcepub fn diameter_m(&self) -> f64
pub fn diameter_m(&self) -> f64
The case’s outer diameter, m.
Sourcepub fn solid_motor(&self) -> &SolidMotor
pub fn solid_motor(&self) -> &SolidMotor
The motor model: thrust curve, propellant and case masses.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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