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 o2_molar() -> f64 {
2.0 * atomic_mass(8) * 1e-3
}
fn h2_molar() -> f64 {
2.0 * atomic_mass(1) * 1e-3
}
fn o_molar() -> f64 {
atomic_mass(8) * 1e-3
}
fn h2o_molar() -> f64 {
(2.0 * atomic_mass(1) + atomic_mass(8)) * 1e-3
}
impl ExosphereEndpoint {
pub fn ganymede() -> Self {
Self {
body_radius_m: crate::GANYMEDE_RADIUS_M,
species: vec![
ExosphereSpecies {
name: "Molecular oxygen",
symbol: "O2",
molar_mass_kg_mol: o2_molar(),
column_density_m2: 1e19,
scale_height_m: 100_000.0,
},
ExosphereSpecies {
name: "Molecular hydrogen",
symbol: "H2",
molar_mass_kg_mol: h2_molar(),
column_density_m2: 1e17,
scale_height_m: 400_000.0,
},
ExosphereSpecies {
name: "Atomic oxygen",
symbol: "O",
molar_mass_kg_mol: o_molar(),
column_density_m2: 5e17,
scale_height_m: 180_000.0,
},
ExosphereSpecies {
name: "Water vapor",
symbol: "H2O",
molar_mass_kg_mol: h2o_molar(),
column_density_m2: 1e16,
scale_height_m: 30_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()
}
}