air_at

Function air_at 

Source
pub fn air_at(
    atmosphere: &KernelAtmosphere,
    zones: Option<&AtmoSock>,
    downrange_m: f64,
    altitude_m: f64,
) -> LocalAir
Expand description

The air at one point of a flight: the ONE per-step air computation.

downrange_m selects a zone of zones; altitude_m is the point’s geometric altitude above mean sea level (the world-vertical altitude, not the shot-frame y).

  • KernelAtmosphere::Uniform returns the caller’s density and sound speed unchanged at every point, and ignores zones.

  • KernelAtmosphere::Station picks a base: the zone that covers downrange_m when zones holds any (its temperature, pressure and humidity, with a CIPM density ratio at that humidity), otherwise the station itself. An empty zone set means the station. The lapse always starts at the station altitude. The base air is well mixed: its water-vapour mole fraction x_v (from its own temperature, pressure and humidity) is held at every height, for all three steps:

    1. temperature and pressure follow the ICAO layers in geopotential height, with the virtual-temperature hydrostatic exponent: the dry one times the moist-air molar-mass ratio M_m / M_a = 1 - x_v (1 - M_v / M_a);
    2. density is the base ratio scaled by (T_base · P) / (P_base · T), the base composition;
    3. the speed of sound is moist_speed_of_sound’s formula at the local temperature and the base x_v.

    The temperature and pressure of steps 1 and 2 are returned too. At the base air’s own height this is that air exactly (the sound speed is StationAir::speed_of_sound_mps to the bit); at 0 % every step is the dry one, sqrt(1.4 · 287.0531 · T) for the sound speed.

    Held aloft, x_v exceeds saturation in the colder air: at every height above a saturated station, and from about 2.2 km above a 15 °C / 50 % station and 0.4 km above a 35 °C / 90 % one. At +3 km it is 1.35 times saturation over the first and 2.06 times over the second, and at +10 km 34 and 29 times. Condensation is not modelled.

    The base x_v, and a zone’s density ratio, are fixed for the flight, so they are computed once, when the station (StationAir::new) or the zones (AtmoSock::new) are built. This lookup evaluates no saturation pressure; build the station and the zones once per flight, not per step.

zones must already have passed AtmoSock::validate, as every validated kernel entry checks them once (crate::trajectory_integration::try_integrate_trajectory, TrajectorySolver, fast_integrate*). This per-step lookup does not: an unvalidated zone humidity outside 0-100 is clamped into it, and a NaN one gives NaN air, never steam.

Where the lapse from the base temperature reaches absolute zero (183 km above 15 °C at sea level, 1.54 km above a 10 K station) there is no air: from that height the result is not finite. Every trajectory kernel refuses a flight that reaches it, at the step that gets there, as AtmosphereErrorReason::AirAloftBelowAbsoluteZero on the temperature.