use sciforge::hub::prelude::constants::elements::atomic_mass;
pub struct ExosphereSpecies {
pub name: &'static str,
pub symbol: &'static str,
pub molar_mass_kg_mol: f64,
pub column_density_m2: f64,
pub scale_height_m: f64,
}
pub struct ExosphereEndpoint {
pub body_radius_m: f64,
pub species: Vec<ExosphereSpecies>,
}
fn he_molar() -> f64 {
atomic_mass(2) * 1e-3
}
fn ne_molar() -> f64 {
atomic_mass(10) * 1e-3
}
fn ar_molar() -> f64 {
atomic_mass(18) * 1e-3
}
fn na_molar() -> f64 {
atomic_mass(11) * 1e-3
}
fn k_molar() -> f64 {
atomic_mass(19) * 1e-3
}
fn h_molar() -> f64 {
atomic_mass(1) * 1e-3
}
impl ExosphereEndpoint {
pub fn moon() -> Self {
Self {
body_radius_m: crate::MOON_RADIUS_M,
species: vec![
ExosphereSpecies {
name: "Helium",
symbol: "He",
molar_mass_kg_mol: he_molar(),
column_density_m2: 4e13,
scale_height_m: 420_000.0,
},
ExosphereSpecies {
name: "Neon",
symbol: "Ne",
molar_mass_kg_mol: ne_molar(),
column_density_m2: 2e13,
scale_height_m: 250_000.0,
},
ExosphereSpecies {
name: "Argon-40",
symbol: "Ar",
molar_mass_kg_mol: ar_molar(),
column_density_m2: 1e14,
scale_height_m: 100_000.0,
},
ExosphereSpecies {
name: "Sodium",
symbol: "Na",
molar_mass_kg_mol: na_molar(),
column_density_m2: 1e13,
scale_height_m: 120_000.0,
},
ExosphereSpecies {
name: "Potassium",
symbol: "K",
molar_mass_kg_mol: k_molar(),
column_density_m2: 1e11,
scale_height_m: 90_000.0,
},
ExosphereSpecies {
name: "Atomic hydrogen",
symbol: "H",
molar_mass_kg_mol: h_molar(),
column_density_m2: 1e12,
scale_height_m: 1_000_000.0,
},
],
}
}
pub fn density_at_altitude(&self, species_symbol: &str, altitude_m: f64) -> f64 {
self.species
.iter()
.find(|s| s.symbol == species_symbol)
.map(|s| {
let n_surface = s.column_density_m2 / s.scale_height_m;
n_surface * (-altitude_m / s.scale_height_m).exp()
})
.unwrap_or(0.0)
}
pub fn total_column_density(&self) -> f64 {
self.species.iter().map(|s| s.column_density_m2).sum()
}
pub fn sodium_glow_intensity(&self) -> f64 {
self.species
.iter()
.find(|s| s.symbol == "Na")
.map(|s| s.column_density_m2 * 1e-13)
.unwrap_or(0.0)
}
}