KernelAtmosphere

Enum KernelAtmosphere 

Source
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
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§density_kg_m3: f64

Air density, kg/m³, in [0, 2); exactly 0 is a vacuum, with no drag at all.

§speed_of_sound_mps: f64

Speed of sound, m/s, above 200.

Implementations§

Source§

impl KernelAtmosphere

Source

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).

Source

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, becomes Self::uniform (which validates it; humidity is unused, the caller’s sound speed already being given).
  • (altitude_m, temperature_c, pressure_hpa, density_ratio), standard mode, becomes a StationAir::with_density_ratio at humidity. A finite ratio <= 0 means “not supplied” and becomes 1.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

Source§

fn clone(&self) -> KernelAtmosphere

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 KernelAtmosphere

Source§

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

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

impl PartialEq for KernelAtmosphere

Source§

fn eq(&self, other: &KernelAtmosphere) -> 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 KernelAtmosphere

Source§

impl StructuralPartialEq for KernelAtmosphere

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,