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 sciforge::hub::prelude::biology::ecology::{
    shannon_diversity, simpson_diversity, species_area,
};
pub struct Ecosystem {
    pub name: &'static str,
    pub areakm2: f64,
    pub speciescounts: Vec<u64>,
    pub netprimaryproductivitygcm2yr: f64,
    pub meantemperaturec: f64,
    pub annualprecipitationmm: f64,
}
impl Ecosystem {
    pub fn totalspecies(&self) -> u64 {
        self.speciescounts.len() as u64
    }
    pub fn totalindividuals(&self) -> u64 {
        self.speciescounts.iter().sum()
    }
    pub fn shannonindex(&self) -> f64 {
        let proportions: Vec<f64> = self
            .speciescounts
            .iter()
            .map(|&c| c as f64 / self.totalindividuals() as f64)
            .collect();
        shannon_diversity(&proportions)
    }
    pub fn simpsondiversity(&self) -> f64 {
        let proportions: Vec<f64> = self
            .speciescounts
            .iter()
            .map(|&c| c as f64 / self.totalindividuals() as f64)
            .collect();
        simpson_diversity(&proportions)
    }
    pub fn expectedspeciesfromarea(&self, z: f64, c: f64) -> f64 {
        species_area(c, z, self.areakm2)
    }
    pub fn totalnppgcyr(&self) -> f64 {
        self.netprimaryproductivitygcm2yr * self.areakm2 * 1e6
    }
    pub fn biomassturnovertimeyr(&self, biomassgcm2: f64) -> f64 {
        biomassgcm2 / self.netprimaryproductivitygcm2yr
    }
}
pub fn tropicalrainforest() -> Ecosystem {
    Ecosystem {
        name: "Tropical Rainforest",
        areakm2: 17000000.0,
        speciescounts: vec![1000, 800, 600, 500, 400, 300, 200, 150, 100, 80],
        netprimaryproductivitygcm2yr: 2200.0,
        meantemperaturec: 25.0,
        annualprecipitationmm: 2500.0,
    }
}
pub fn borealforest() -> Ecosystem {
    Ecosystem {
        name: "Boreal Forest",
        areakm2: 15000000.0,
        speciescounts: vec![500, 400, 300, 200, 100, 50],
        netprimaryproductivitygcm2yr: 800.0,
        meantemperaturec: -5.0,
        annualprecipitationmm: 500.0,
    }
}
pub fn coralreef() -> Ecosystem {
    Ecosystem {
        name: "Coral Reef",
        areakm2: 284300.0,
        speciescounts: vec![2000, 1500, 1000, 800, 600, 400, 300, 200, 100, 50],
        netprimaryproductivitygcm2yr: 2500.0,
        meantemperaturec: 26.0,
        annualprecipitationmm: 0.0,
    }
}