jupiters 0.0.3

Jupiter celestial simulation crate for the MilkyWay SolarSystem workspace
Documentation
use sciforge::hub::domain::geology::tectonics::{
    airy_root, euler_pole_velocity, flexural_rigidity, geothermal_gradient, heat_flow,
    isostatic_equilibrium,
};

pub const METALLICHYDROGENDENSITY: f64 = 1000.0;
pub const ROCKYCOREDENSITY: f64 = 25000.0;
pub const INTERIORVISCOSITY: f64 = 1e20;
pub const METALLICHYDROGENTHICKNESS: f64 = 40000000.0;

pub struct InteriorConvectionCell {
    pub name: &'static str,
    pub eulerpolelatdeg: f64,
    pub eulerpolelondeg: f64,
    pub angularvelocitydegmyr: f64,
    pub areakm2: f64,
}

impl InteriorConvectionCell {
    pub fn velocityatpoint(&self, latdeg: f64, londeg: f64) -> f64 {
        let lat1 = self.eulerpolelatdeg.to_radians();
        let lon1 = self.eulerpolelondeg.to_radians();
        let lat2 = latdeg.to_radians();
        let lon2 = londeg.to_radians();
        let angulardistance =
            (lat1.sin() * lat2.sin() + lat1.cos() * lat2.cos() * (lon2 - lon1).cos()).acos();
        euler_pole_velocity(
            self.angularvelocitydegmyr.to_radians() / crate::SECONDSPERYEAR / 1e6,
            crate::JUPITERMEANRADIUS,
            angulardistance,
        )
    }

    pub fn velocitycmperyear(&self, latdeg: f64, londeg: f64) -> f64 {
        self.velocityatpoint(latdeg, londeg) * crate::SECONDSPERYEAR * 100.0
    }
}

pub fn equatorialcell() -> InteriorConvectionCell {
    InteriorConvectionCell {
        name: "Equatorial Convection",
        eulerpolelatdeg: 0.0,
        eulerpolelondeg: 0.0,
        angularvelocitydegmyr: 0.005,
        areakm2: 1e10,
    }
}

pub fn polarcell() -> InteriorConvectionCell {
    InteriorConvectionCell {
        name: "Polar Convection",
        eulerpolelatdeg: 85.0,
        eulerpolelondeg: 0.0,
        angularvelocitydegmyr: 0.002,
        areakm2: 5e9,
    }
}

pub fn metallichydrogenrootdepth(layerheightm: f64) -> f64 {
    airy_root(layerheightm, METALLICHYDROGENDENSITY, ROCKYCOREDENSITY)
}

pub fn metallichydrogenflexuralrigidity(
    thicknessm: f64,
    youngsmodulus: f64,
    poissonsratio: f64,
) -> f64 {
    flexural_rigidity(youngsmodulus, thicknessm, poissonsratio)
}

pub fn surfaceheatflow(conductivity: f64, tempgradient: f64) -> f64 {
    heat_flow(conductivity, tempgradient)
}

pub fn temperatureatdepth(surfacetemp: f64, depthm: f64, gradientkperm: f64) -> f64 {
    surfacetemp + geothermal_gradient(surfacetemp, depthm, gradientkperm)
}

pub fn isostaticbalance(layerthickness: f64) -> f64 {
    isostatic_equilibrium(METALLICHYDROGENDENSITY, layerthickness, ROCKYCOREDENSITY)
}