moons 0.0.1

Moon celestial simulation crate for the MilkyWay SolarSystem workspace
Documentation
use crate::GALACTIC_COSMIC_RAY_DOSE_MSV_DAY;

#[derive(Debug, Clone, Copy, PartialEq)]
pub struct RadiationEnvironment {
    pub solar_particle_event_flux: f64,
    pub galactic_cosmic_ray_dose_msv_day: f64,
    pub regolith_shielding_g_cm2: f64,
}

impl RadiationEnvironment {
    pub fn nominal_surface() -> Self {
        Self {
            solar_particle_event_flux: 0.2,
            galactic_cosmic_ray_dose_msv_day: GALACTIC_COSMIC_RAY_DOSE_MSV_DAY,
            regolith_shielding_g_cm2: 0.0,
        }
    }

    pub fn sheltered(regolith_depth_m: f64) -> Self {
        Self {
            solar_particle_event_flux: 0.05,
            galactic_cosmic_ray_dose_msv_day: GALACTIC_COSMIC_RAY_DOSE_MSV_DAY,
            regolith_shielding_g_cm2: regolith_depth_m.max(0.0) * 150.0,
        }
    }

    pub fn effective_daily_dose_msv(&self) -> f64 {
        let attenuation = (-self.regolith_shielding_g_cm2 / 180.0).exp();
        self.galactic_cosmic_ray_dose_msv_day * attenuation + self.solar_particle_event_flux * 0.5
    }
}

pub fn annual_crew_dose_msv(environment: RadiationEnvironment) -> f64 {
    environment.effective_daily_dose_msv() * 365.25
}