marss 0.0.3

Mars celestial simulation crate for the MilkyWay SolarSystem workspace
Documentation
use sciforge::hub::domain::common::constants::SIGMA_SB;
use sciforge::hub::domain::meteorology::radiation::{
    planck_function, solar_constant, solar_zenith_angle, stefan_boltzmann_flux,
};

pub struct MarsClimateState {
    pub co2_surface_pressure_pa: f64,
    pub dust_optical_depth: f64,
    pub global_mean_temp_k: f64,
    pub albedo: f64,
}

impl MarsClimateState {
    pub fn current() -> Self {
        Self {
            co2_surface_pressure_pa: crate::SURFACE_PRESSURE_PA,
            dust_optical_depth: crate::MEAN_DUST_OPTICAL_DEPTH,
            global_mean_temp_k: crate::MEAN_TEMPERATURE_K,
            albedo: crate::BOND_ALBEDO,
        }
    }

    pub fn global_storm() -> Self {
        Self {
            co2_surface_pressure_pa: crate::SURFACE_PRESSURE_PA,
            dust_optical_depth: crate::GLOBAL_STORM_OPTICAL_DEPTH,
            global_mean_temp_k: 220.0,
            albedo: 0.30,
        }
    }

    pub fn outgoing_longwave_radiation(&self) -> f64 {
        stefan_boltzmann_flux(self.global_mean_temp_k)
    }

    pub fn absorbed_solar_radiation(&self) -> f64 {
        let s = solar_constant() / (crate::SEMI_MAJOR_AXIS_AU * crate::SEMI_MAJOR_AXIS_AU);
        s * (1.0 - self.albedo) / 4.0
    }

    pub fn energy_imbalance(&self) -> f64 {
        self.absorbed_solar_radiation() - self.outgoing_longwave_radiation()
    }

    pub fn effective_emission_temperature(&self) -> f64 {
        let s = solar_constant() / (crate::SEMI_MAJOR_AXIS_AU * crate::SEMI_MAJOR_AXIS_AU);
        ((s * (1.0 - self.albedo)) / (4.0 * SIGMA_SB)).powf(0.25)
    }

    pub fn greenhouse_effect_k(&self) -> f64 {
        self.global_mean_temp_k - self.effective_emission_temperature()
    }

    pub fn seasonal_pressure_variation_pa(&self) -> f64 {
        self.co2_surface_pressure_pa * 0.25
    }
}

pub fn solar_zenith(latitude_deg: f64, declination_deg: f64, hour_angle_deg: f64) -> f64 {
    solar_zenith_angle(latitude_deg, declination_deg, hour_angle_deg)
}

pub fn planck_spectral_radiance(wavelength_m: f64, temperature_k: f64) -> f64 {
    planck_function(wavelength_m, temperature_k)
}

pub fn obliquity_range_deg() -> (f64, f64) {
    (15.0, 35.0)
}

pub fn mean_insolation() -> f64 {
    solar_constant() / (crate::SEMI_MAJOR_AXIS_AU * crate::SEMI_MAJOR_AXIS_AU)
}