earths 0.0.4

High-fidelity Earth simulation engine — orbit, atmosphere, geology, hydrology, biosphere, terrain, lighting, rendering, satellites, and temporal systems with full scientific coupling
Documentation
use crate::temporal::calendar::SECONDSPERDAY;
use sciforge::hub::prelude::biology::plant_biology::photosynthesis::{
    farquhar_c3, vcmax_temperature_response,
};
use sciforge::hub::prelude::constants::elements::atomic_mass;
pub struct Vegetation {
    pub name: &'static str,
    pub leafareaindex: f64,
    pub maxphotosynthesisumolm2s: f64,
    pub rootdepthm: f64,
    pub carbonstockkgcm2: f64,
}
impl Vegetation {
    pub fn photosynthesisrate(&self, co2ppm: f64, lightumolm2s: f64, tempc: f64) -> f64 {
        let tempk = tempc + crate::CELSIUSTOKELVIN;
        let vcmax = vcmax_temperature_response(self.maxphotosynthesisumolm2s, 65330.0, tempk);
        let ci = co2ppm * 0.7;
        let jmax = vcmax * 1.67;
        let j = jmax * lightumolm2s / (lightumolm2s + 2.1 * jmax);
        farquhar_c3(vcmax, ci, 42.75, 404.9, 278.4, 210.0, j, 1.0)
    }
    pub fn canopyphotosynthesis(&self, leafrate: f64) -> f64 {
        leafrate * self.leafareaindex * (1.0 - (-0.5 * self.leafareaindex).exp())
    }
    pub fn transpirationmmday(&self, vpdkpa: f64, stomatalconductance: f64) -> f64 {
        stomatalconductance * vpdkpa * self.leafareaindex * SECONDSPERDAY / 1000.0
    }
    pub fn nppkgcm2yr(&self, gppumolm2s: f64) -> f64 {
        let carbonkgperumol = atomic_mass(6) * 1e-6;
        let gppkgc = gppumolm2s * carbonkgperumol * 1e-3 * crate::SECONDSPERYEAR;
        gppkgc * 0.5
    }
    pub fn carbonresidencetimeyr(&self, npp: f64) -> f64 {
        self.carbonstockkgcm2 / npp
    }
}
pub fn tropicalbroadleaf() -> Vegetation {
    Vegetation {
        name: "Tropical Broadleaf",
        leafareaindex: 6.0,
        maxphotosynthesisumolm2s: 40.0,
        rootdepthm: 3.0,
        carbonstockkgcm2: 18.0,
    }
}
pub fn temperategrassland() -> Vegetation {
    Vegetation {
        name: "Temperate Grassland",
        leafareaindex: 2.5,
        maxphotosynthesisumolm2s: 25.0,
        rootdepthm: 1.5,
        carbonstockkgcm2: 0.7,
    }
}
pub fn coniferousforest() -> Vegetation {
    Vegetation {
        name: "Coniferous Forest",
        leafareaindex: 4.5,
        maxphotosynthesisumolm2s: 15.0,
        rootdepthm: 2.0,
        carbonstockkgcm2: 12.0,
    }
}
pub fn beerlambertlightextinction(lightabove: f64, lai: f64, extinctioncoeff: f64) -> f64 {
    lightabove * (-extinctioncoeff * lai).exp()
}