1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//! # aero_atmos: an Atmospheric and Aeronautical Calculations Library
//!
//! ## Atmospheric Models
//!
//! This library provides functions and calculations based on standard atmospheric models.
//!
//! Numerous atmospheric models have been published. This crate seeks to replicate the calculations contained in these models.
//!
//! It is intended that this crate will support these atmospheric models:
//!
//! - [x] ICAO ISA, Doc 7488/3 (1993)
//! - [ ] US Standard Atmosphere (1976)
//! - [ ] ISO Standard Atmosphere, ISO 2533, (1975)
//!
//! ## Aerodynamics
//!
//! This library does not yet support aerodynamic calculations. In the future, the intent is
//! to provide integration between atmospheric models and aerodynamic calculations.
//!
//! # Examples
//!
//! Get the ISA Standard Pressure at a Given Geopotential Altitude
//!
//! ```rust
//! use aero_atmos::InternationalStandardAtmosphere;
//!
//! // uom Altitude units
//! use uom::si::length::meter;
//! use uom::si::f64::Length;
//!
//! // uom Pressure units
//! use uom::si::pressure::pascal;
//! use uom::si::f64::Pressure;
//!
//! // Create a new uom Length representing 16,000 meters of Geopotential Altitude.
//! // Any input unit can be used, so long as it is within the range -5 to 80 km.
//! let altitude = uom::si::f64::Length::new::<uom::si::length::meter>(16_000.0);
//!
//! // Calculate the ISA standard pressure at the given geopotential altitude.
//! let pressure = InternationalStandardAtmosphere::altitude_to_pressure(altitude);
//!
//! match pressure {
//! // prints ~ "p = 101325.0 Pa"
//! Ok(p) => println!("p = {} Pa", p.get::<uom::si::pressure::pascal>()),
//! // should not print an error message, since the altitude is within the valid range for the ISA model
//! Err(e) => println!("Error calculating pressure: {:?}", e),
//! }
//! ```
//!
//! Convert between Geopotential and Geometric Altitudes
//!
//! The ISA uses an appoximation formula to convert between geopotential and geometric altitudes.
//!
//! ```rust
//! use aero_atmos::InternationalStandardAtmosphere;
//!
//! // Altitude units
//! use uom::si::length::{meter, foot};
//! use uom::si::f64::Length;
//!
//! // Create a new uom Length representing 10,000 feet of Geometric Altitude.
//! let geometric_altitude = Length::new::<foot>(10_000.0);
//!
//! // Convert to Geopotential Altitude.
//! // This example shocases the `uom` crate's ability to handle multiple units.
//! let geopotential_altitude = InternationalStandardAtmosphere::altitude_geometric_to_geopotential(geometric_altitude);
//!
//! match geopotential_altitude {
//! Ok(alt) => {
//! // prints something like "Geopotential Altitude at 10,000 feet Geometric: 9995.0 feet"
//! println!("Geopotential Altitude at 10,000 feet Geometric: {} feet", alt.get::<foot>());
//! },
//! Err(e) => println!("Error converting altitude: {:?}", e),
//! }
//!```
//!
//! Get the Geometric altitude for a given pressure.
//!
//! ```rust
//! use aero_atmos::InternationalStandardAtmosphere;
//! use aero_atmos::dbg_sci;
//!
//! // Altitude units
//! use uom::si::length::{meter, foot};
//! use uom::si::f64::Length;
//!
//! // Pressure units
//! use uom::si::pressure::pascal;
//! use uom::si::f64::Pressure;
//!
//! // Create a new uom Pressure representing 50,000 Pa.
//! let pressure = Pressure::new::<pascal>(50_000.0);
//!
//! // First, we calculate the Geopotential Altitude for the given pressure.
//! // In Doc 7488/3 Table 7, 50_000 pa is about 5_574.0 meters.
//! let geopotential_altitude = InternationalStandardAtmosphere::altitude_from_pressure(pressure).unwrap();
//! dbg_sci!(geopotential_altitude.get::<meter>(), 4);
//! // prints something like "[src/main.rs:31] geopotential_altitude.get::<meter>() = 5.5744e3"
//!
//! // Then, we convert the Geopotential Altitude to Geometric Altitude.
//! let geometric_altitude = InternationalStandardAtmosphere::altitude_geopotential_to_geometric(geopotential_altitude).unwrap();
//! dbg_sci!(geometric_altitude.get::<meter>(), 4);
//! // prints something like "[src/main.rs:36] geometric_altitude.get::<meter>() = 5.5793e3"
//! ```
pub use InternationalStandardAtmosphere;
/// Precision constant for testing. 0.05%.
///
/// Most or all tests comnpare the output of these functions to the
/// tabular data in the tables of the ICAO Doc 7488/3 (1993). Most or all
/// functions are tested to this precision.
pub const PRECISION: f64 = 0.0005;