earths 0.0.3

High-fidelity Earth simulation engine — orbit, atmosphere, geology, hydrology, biosphere, terrain, lighting, rendering, satellites, and temporal systems with full scientific coupling
Documentation
pub struct HeatWave {
    pub maxtemperaturec: f64,
    pub durationdays: u32,
    pub relativehumiditypercent: f64,
}
impl HeatWave {
    pub fn heatindexc(&self) -> f64 {
        let t = self.maxtemperaturec;
        let rh = self.relativehumiditypercent;
        let tf = t * 9.0 / 5.0 + 32.0;
        let hif = -42.379 + 2.04901523 * tf + 10.14333127 * rh
            - 0.22475541 * tf * rh
            - 6.83783e-3 * tf * tf
            - 5.481717e-2 * rh * rh
            + 1.22874e-3 * tf * tf * rh
            + 8.5282e-4 * tf * rh * rh
            - 1.99e-6 * tf * tf * rh * rh;
        (hif - 32.0) * 5.0 / 9.0
    }
    pub fn wetbulbtemperaturec(&self) -> f64 {
        let t = self.maxtemperaturec;
        let rh = self.relativehumiditypercent;
        t * (0.151977 * (rh + 8.313659f64).sqrt()).atan() + (t + rh).atan() - (rh - 1.676331).atan()
            + 0.00391838 * rh.powf(1.5) * (0.023101 * rh).atan()
            - 4.686035
    }
    pub fn dangerlevel(&self) -> &'static str {
        let hi = self.heatindexc();
        if hi >= 54.0 {
            "Extreme danger"
        } else if hi >= 41.0 {
            "Danger"
        } else if hi >= 32.0 {
            "Extreme caution"
        } else if hi >= 27.0 {
            "Caution"
        } else {
            "Normal"
        }
    }
    pub fn excessmortalityfactor(&self) -> f64 {
        let threshold = 30.0;
        if self.maxtemperaturec <= threshold {
            1.0
        } else {
            1.0 + 0.03 * (self.maxtemperaturec - threshold) * self.durationdays as f64
        }
    }
}
pub fn saturationvaporpressurepa(tempc: f64) -> f64 {
    610.78 * (17.27 * tempc / (tempc + 237.3)).exp()
}
pub fn dewpointc(tempc: f64, relativehumidity: f64) -> f64 {
    let a = 17.27;
    let b = 237.3;
    let alpha = a * tempc / (b + tempc) + (relativehumidity / 100.0).ln();
    b * alpha / (a - alpha)
}