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
impl StationAir
Sourcepub fn new(
altitude_m: f64,
temperature_c: f64,
pressure_hpa: f64,
humidity: RelativeHumidity,
) -> Result<Self, AtmosphereError>
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
altitude_m,temperature_corpressure_hpanot finite:AtmosphereErrorReason::NotFinite.temperature_c <= -273.15:AtmosphereErrorReason::AtOrBelowAbsoluteZero.pressure_hpa <= 0:AtmosphereErrorReason::NonPositivePressure.- Impossible air, refused by exactly the
atmosphere.density_altitudeservice’s test (an uncapped water-vapour mole fraction that is NaN or at least 1):AtmosphereErrorReason::ImpossibleAir, onhumidity_percent, or ontemperature_cfor humid air above water’s critical point (647.096 K), and for dry air there too hot for the CIPM-2007 density to stay positive (about 90,000 K at 1013.25 hPa); or onpressure_hpafor a pressure so far beyond any air’s (above about 4e156 Pa) that the density is not finite and positive.
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).
Sourcepub fn with_density_ratio(
altitude_m: f64,
temperature_c: f64,
pressure_hpa: f64,
density_ratio: f64,
humidity: RelativeHumidity,
) -> Result<Self, AtmosphereError>
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).
Sourcepub fn altitude_m(&self) -> f64
pub fn altitude_m(&self) -> f64
Station geometric altitude above mean sea level, m. The altitude lapse starts here.
Sourcepub fn temperature_c(&self) -> f64
pub fn temperature_c(&self) -> f64
Station temperature, °C.
Sourcepub fn pressure_hpa(&self) -> f64
pub fn pressure_hpa(&self) -> f64
Absolute station pressure, hPa.
Sourcepub fn humidity(&self) -> RelativeHumidity
pub fn humidity(&self) -> RelativeHumidity
Station relative humidity.
Sourcepub fn density_ratio(&self) -> f64
pub fn density_ratio(&self) -> f64
Station density over 1.225 kg/m³.
Sourcepub fn density_kg_m3(&self) -> f64
pub fn density_kg_m3(&self) -> f64
Station air density, kg/m³ (CIPM-2007, humid).
Sourcepub fn speed_of_sound_mps(&self) -> f64
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
impl Clone for StationAir
Source§fn clone(&self) -> StationAir
fn clone(&self) -> StationAir
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StationAir
impl Debug for StationAir
Source§impl PartialEq for StationAir
impl PartialEq for StationAir
impl Copy for StationAir
impl StructuralPartialEq for StationAir
Auto Trait Implementations§
impl Freeze for StationAir
impl RefUnwindSafe for StationAir
impl Send for StationAir
impl Sync for StationAir
impl Unpin for StationAir
impl UnwindSafe for StationAir
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.