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::domain::geology::petrology::{
    differentiation_index, liquidus_temperature, mg_number, solidus_depression,
    total_alkali_silica, viscosity_arrhenius,
};
pub struct Magma {
    pub sio2wtpercent: f64,
    pub na2owtpercent: f64,
    pub k2owtpercent: f64,
    pub mgowtpercent: f64,
    pub feowtpercent: f64,
    pub h2owtpercent: f64,
    pub temperaturec: f64,
}
impl Magma {
    pub fn basaltic() -> Self {
        Self {
            sio2wtpercent: 49.0,
            na2owtpercent: 2.5,
            k2owtpercent: 0.5,
            mgowtpercent: 8.0,
            feowtpercent: 10.0,
            h2owtpercent: 1.0,
            temperaturec: 1200.0,
        }
    }
    pub fn andesitic() -> Self {
        Self {
            sio2wtpercent: 58.0,
            na2owtpercent: 3.5,
            k2owtpercent: 1.5,
            mgowtpercent: 4.0,
            feowtpercent: 7.0,
            h2owtpercent: 3.0,
            temperaturec: 1000.0,
        }
    }
    pub fn rhyolitic() -> Self {
        Self {
            sio2wtpercent: 72.0,
            na2owtpercent: 4.0,
            k2owtpercent: 4.0,
            mgowtpercent: 0.5,
            feowtpercent: 2.0,
            h2owtpercent: 5.0,
            temperaturec: 800.0,
        }
    }
    pub fn mgnumber(&self) -> f64 {
        mg_number(self.mgowtpercent, self.feowtpercent)
    }
    pub fn totalalkali(&self) -> f64 {
        total_alkali_silica(self.na2owtpercent + self.k2owtpercent, self.sio2wtpercent)
    }
    pub fn liquidustempc(&self) -> f64 {
        liquidus_temperature(self.sio2wtpercent, self.h2owtpercent, 1000.0)
    }
    pub fn viscositypas(&self) -> f64 {
        let tempk = self.temperaturec + crate::CELSIUSTOKELVIN;
        let a = crate::VISCOSITYSHAWA;
        let ea = crate::EAVISCOSITYMAGMA;
        viscosity_arrhenius(a, ea, tempk)
    }
    pub fn solidusdepressionc(&self) -> f64 {
        solidus_depression(self.h2owtpercent, 1000.0, 1.0)
    }
    pub fn differentiationidx(&self) -> f64 {
        differentiation_index(
            self.sio2wtpercent,
            self.na2owtpercent,
            self.k2owtpercent,
            0.0,
        )
    }
}
pub fn volcanicexplosivityindex(ejectavolumekm3: f64) -> u8 {
    if ejectavolumekm3 < 1e-6 {
        0
    } else if ejectavolumekm3 < 1e-4 {
        1
    } else if ejectavolumekm3 < 1e-3 {
        2
    } else if ejectavolumekm3 < 1e-2 {
        3
    } else if ejectavolumekm3 < 0.1 {
        4
    } else if ejectavolumekm3 < 1.0 {
        5
    } else if ejectavolumekm3 < 10.0 {
        6
    } else if ejectavolumekm3 < 100.0 {
        7
    } else {
        8
    }
}