marss 0.0.3

Mars celestial simulation crate for the MilkyWay SolarSystem workspace
Documentation
use sciforge::hub::domain::common::constants::R_GAS;

pub struct PolarCap {
    pub name: &'static str,
    pub radius_km: f64,
    pub ice_thickness_m: f64,
    pub water_ice_volume_km3: f64,
    pub co2_ice_volume_km3: f64,
}

impl PolarCap {
    pub fn total_volume_km3(&self) -> f64 {
        self.water_ice_volume_km3 + self.co2_ice_volume_km3
    }

    pub fn water_ice_mass_kg(&self) -> f64 {
        self.water_ice_volume_km3 * 1e9 * crate::ICE_DENSITY
    }

    pub fn co2_ice_mass_kg(&self) -> f64 {
        self.co2_ice_volume_km3 * 1e9 * crate::CO2_ICE_DENSITY
    }

    pub fn area_km2(&self) -> f64 {
        std::f64::consts::PI * self.radius_km * self.radius_km
    }

    pub fn global_equivalent_layer_m(&self) -> f64 {
        self.water_ice_volume_km3 * 1e9 / crate::MARS_SURFACE_AREA
    }
}

pub fn north_polar_cap() -> PolarCap {
    PolarCap {
        name: "Planum Boreum",
        radius_km: 600.0,
        ice_thickness_m: 3_000.0,
        water_ice_volume_km3: 1_200_000.0,
        co2_ice_volume_km3: 0.0,
    }
}

pub fn south_polar_cap() -> PolarCap {
    PolarCap {
        name: "Planum Australe",
        radius_km: 400.0,
        ice_thickness_m: 3_700.0,
        water_ice_volume_km3: 1_600_000.0,
        co2_ice_volume_km3: 9_500.0,
    }
}

pub fn seasonal_co2_frost_mass_kg_m2() -> f64 {
    500.0
}

pub fn seasonal_cap_edge_latitude(winter_solstice_fraction: f64) -> f64 {
    90.0 - 40.0 * winter_solstice_fraction
}

pub fn ice_stability_depth(latitude_deg: f64) -> f64 {
    if latitude_deg.abs() > 60.0 {
        0.0
    } else if latitude_deg.abs() > 30.0 {
        (60.0 - latitude_deg.abs()) * 0.1
    } else {
        5.0 + (30.0 - latitude_deg.abs()) * 0.5
    }
}

pub fn co2_sublimation_rate(temperature_k: f64) -> f64 {
    let t_ref = crate::CO2_FROST_POINT_K;
    let l_sub = 5.7e5;
    let m_co2 = crate::CO2_MOLAR_MASS;
    let p_sat = crate::SURFACE_PRESSURE_PA
        * ((l_sub * m_co2 / R_GAS) * (1.0 / t_ref - 1.0 / temperature_k)).exp();
    p_sat * (m_co2 / (2.0 * std::f64::consts::PI * R_GAS * temperature_k)).sqrt()
}

pub fn total_polar_water_gel_m() -> f64 {
    let n = north_polar_cap();
    let s = south_polar_cap();
    (n.water_ice_volume_km3 + s.water_ice_volume_km3) * 1e9 / crate::MARS_SURFACE_AREA
}