jupiters 0.0.3

Jupiter celestial simulation crate for the MilkyWay SolarSystem workspace
Documentation
use sciforge::hub::domain::common::constants::SIGMA_SB;

pub const INTERIORMETALLICHYDROGENDENSITY: f64 = 1000.0;

pub struct CryoLake {
    pub name: &'static str,
    pub surfaceareakm2: f64,
    pub maxdepthm: f64,
    pub volumekm3: f64,
    pub temperaturek: f64,
}

impl CryoLake {
    pub fn meandepthm(&self) -> f64 {
        if self.surfaceareakm2.abs() < 1e-30 {
            return 0.0;
        }
        self.volumekm3 * 1e9 / (self.surfaceareakm2 * 1e6)
    }

    pub fn shorelinedevelopmentratio(&self, shorelinekm: f64) -> f64 {
        shorelinekm
            / (2.0 * std::f64::consts::PI * (self.surfaceareakm2 / std::f64::consts::PI).sqrt())
    }

    pub fn residencetimeyears(&self, outflowm3s: f64) -> f64 {
        if outflowm3s.abs() < 1e-30 {
            return f64::INFINITY;
        }
        self.volumekm3 * 1e9 / (outflowm3s * crate::SECONDSPERYEAR)
    }

    pub fn thermalenergyjoulesrelative(&self, reftempk: f64) -> f64 {
        let rho = INTERIORMETALLICHYDROGENDENSITY;
        let cp = 14300.0;
        let dt = self.temperaturek - reftempk;
        let volumem3 = self.volumekm3 * 1e9;
        rho * cp * volumem3 * dt
    }

    pub fn longwaveradiationwm2(&self, emissivity: f64) -> f64 {
        emissivity * SIGMA_SB * self.temperaturek.powi(4)
    }
}

pub fn hypotheticalmetallichydrogenocean() -> CryoLake {
    CryoLake {
        name: "Hypothetical Metallic Hydrogen Ocean",
        surfaceareakm2: 0.0,
        maxdepthm: 0.0,
        volumekm3: 0.0,
        temperaturek: 10000.0,
    }
}