StationAir

Struct StationAir 

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

The air at the shooter: station altitude, temperature, pressure and relative humidity, with the density and speed of sound they give.

Every field is private and there is no Default, so a station cannot be built without its humidity, and its density and sound speed cannot disagree about that humidity. Build one with Self::new. Self::with_density_ratio exists only for legacy 4-tuple callers that hold a density ratio of their own.

use ballistics_engine::{RelativeHumidity, StationAir};

let station = StationAir::new(0.0, 15.0, 1013.25, RelativeHumidity::DEFAULT).unwrap();
assert!(station.density_kg_m3() < 1.225); // moist air is lighter than dry
assert!(station.speed_of_sound_mps() > 340.29); // and carries sound faster

// Air that cannot exist is refused: saturated air at 100 C needs more vapour pressure than
// the 1013.25 hPa the air has.
let saturated = RelativeHumidity::try_percent(100.0).unwrap();
assert!(StationAir::new(0.0, 100.0, 1013.25, saturated).is_err());

Implementations§

Source§

impl StationAir

Source

pub fn new( altitude_m: f64, temperature_c: f64, pressure_hpa: f64, humidity: RelativeHumidity, ) -> Result<Self, AtmosphereError>

The station air at altitude_m (geometric, above mean sea level), temperature_c, absolute station pressure pressure_hpa and humidity.

The density and sound speed are calculate_atmosphere’s at exactly these inputs, so a station built here matches every solver that resolves its air through that function, to the bit. The density ratio is density / 1.225.

§Errors

Those are the only temperatures refused (check_station_temperature_c is the rule on its own): outside 173.15-373.15 K (-100 °C to 100 °C) the humidity terms are extrapolated, never refused. Below 173.15 K the saturation vapour pressure and the CIPM compressibility are evaluated at 173.15 K (they clamp their temperature there), and above 373.15 K they are carried past the range they are fitted to. Dry air holds no vapour at any temperature, so at 0 % neither term is reached. A station whose lapse takes the air to absolute zero aloft is accepted here and refused by the flight that reaches that height (AtmosphereErrorReason::AirAloftBelowAbsoluteZero).

Source

pub fn with_density_ratio( altitude_m: f64, temperature_c: f64, pressure_hpa: f64, density_ratio: f64, humidity: RelativeHumidity, ) -> Result<Self, AtmosphereError>

A station that keeps a caller-held density_ratio (density / 1.225 kg/m³) verbatim.

For legacy (altitude, temperature, pressure, ratio) 4-tuples only, through KernelAtmosphere::from_legacy_params: the caller asserts that the ratio was built at this humidity. Everywhere else use Self::new, which cannot pair a density with the wrong humidity. The sound speed is the station’s own at humidity, as in new.

§Errors

Those of Self::new, plus a density_ratio that is not finite or not in (0, 2).

Source

pub fn altitude_m(&self) -> f64

Station geometric altitude above mean sea level, m. The altitude lapse starts here.

Source

pub fn temperature_c(&self) -> f64

Station temperature, °C.

Source

pub fn pressure_hpa(&self) -> f64

Absolute station pressure, hPa.

Source

pub fn humidity(&self) -> RelativeHumidity

Station relative humidity.

Source

pub fn density_ratio(&self) -> f64

Station density over 1.225 kg/m³.

Source

pub fn density_kg_m3(&self) -> f64

Station air density, kg/m³ (CIPM-2007, humid).

Source

pub fn speed_of_sound_mps(&self) -> f64

Station speed of sound, m/s (moist air). The reference for station Mach.

Trait Implementations§

Source§

impl Clone for StationAir

Source§

fn clone(&self) -> StationAir

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for StationAir

Source§

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

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

impl PartialEq for StationAir

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Copy for StationAir

Source§

impl StructuralPartialEq for StationAir

Auto Trait Implementations§

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
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> 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> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,