pub enum KernelAtmosphere {
Station(StationAir),
#[non_exhaustive] Uniform {
density_kg_m3: f64,
speed_of_sound_mps: f64,
},
}Expand description
The atmosphere a trajectory kernel flies.
Self::Station carries station air, humidity included, and the air varies with altitude
and downrange zones through air_at. Self::Uniform is direct mode: one density and
sound speed at every point.
Neither variant can hold unvalidated air. StationAir has private fields, and Uniform
can only be built by Self::uniform or Self::from_legacy_params outside this crate.
Match it with ..:
use ballistics_engine::KernelAtmosphere;
let atmosphere = KernelAtmosphere::uniform(1.1, 330.0).unwrap();
match atmosphere {
KernelAtmosphere::Uniform { density_kg_m3, speed_of_sound_mps, .. } => {
assert_eq!((density_kg_m3, speed_of_sound_mps), (1.1, 330.0));
}
KernelAtmosphere::Station(_) => unreachable!(),
}use ballistics_engine::KernelAtmosphere;
// Bypassing `uniform`'s validation does not compile (E0639: the variant is
// `#[non_exhaustive]`).
let atmosphere = KernelAtmosphere::Uniform { density_kg_m3: -1.0, speed_of_sound_mps: 0.0 };Variants§
Station(StationAir)
Station-referenced air, humidity included.
#[non_exhaustive]Uniform
Direct mode: the caller’s density and speed of sound, unchanged at every point.
Fields
This variant is marked as non-exhaustive
Implementations§
Source§impl KernelAtmosphere
impl KernelAtmosphere
Sourcepub fn uniform(
density_kg_m3: f64,
speed_of_sound_mps: f64,
) -> Result<Self, AtmosphereError>
pub fn uniform( density_kg_m3: f64, speed_of_sound_mps: f64, ) -> Result<Self, AtmosphereError>
Direct-mode air: one density and speed of sound at every point.
A density of exactly 0 is a vacuum: the flight feels gravity and nothing else, exactly as
0.49.0’s compute_derivatives flew the (0, c, 0, 0) tuple. -0.0
is the same vacuum and is stored as 0.0.
use ballistics_engine::KernelAtmosphere;
assert!(KernelAtmosphere::uniform(0.0, 340.29).is_ok()); // a vacuum
assert!(KernelAtmosphere::uniform(-1.0, 340.29).is_err());§Errors
A density_kg_m3 that is not finite or not in [0, 2), or a speed_of_sound_mps that
is not finite or not above 200. The upper density and lower sound-speed bounds are the
ones 0.49.0’s compute_derivatives used to recognise direct mode; its other kernels
differed (fast_integrate required a density above 0).
Sourcepub fn from_legacy_params(
params: (f64, f64, f64, f64),
humidity: RelativeHumidity,
) -> Result<Self, AtmosphereError>
pub fn from_legacy_params( params: (f64, f64, f64, f64), humidity: RelativeHumidity, ) -> Result<Self, AtmosphereError>
The one-line migration from the legacy kernel 4-tuple, at the humidity the caller states.
(density, speed_of_sound, 0.0, 0.0), the direct-mode sentinel, becomesSelf::uniform(which validates it;humidityis unused, the caller’s sound speed already being given).(altitude_m, temperature_c, pressure_hpa, density_ratio), standard mode, becomes aStationAir::with_density_ratioathumidity. A finite ratio<= 0means “not supplied” and becomes1.0(MBA-1157); a ratio at or above 2 is refused.
§Errors
Those of Self::uniform or StationAir::with_density_ratio.
Trait Implementations§
Source§impl Clone for KernelAtmosphere
impl Clone for KernelAtmosphere
Source§fn clone(&self) -> KernelAtmosphere
fn clone(&self) -> KernelAtmosphere
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for KernelAtmosphere
impl Debug for KernelAtmosphere
Source§impl PartialEq for KernelAtmosphere
impl PartialEq for KernelAtmosphere
impl Copy for KernelAtmosphere
impl StructuralPartialEq for KernelAtmosphere
Auto Trait Implementations§
impl Freeze for KernelAtmosphere
impl RefUnwindSafe for KernelAtmosphere
impl Send for KernelAtmosphere
impl Sync for KernelAtmosphere
impl Unpin for KernelAtmosphere
impl UnwindSafe for KernelAtmosphere
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.