jupiters 0.0.3

Jupiter celestial simulation crate for the MilkyWay SolarSystem workspace
Documentation
use sciforge::hub::domain::meteorology::radiation::{
    planck_function, radiative_forcing_co2, solar_constant, solar_zenith_angle,
    stefan_boltzmann_flux,
};
use sciforge::hub::prelude::constants::SIGMA_SB;

pub const JUPITEREQUILIBRIUMTEMPK: f64 = 110.0;
pub const JUPITEREFFECTIVETEMPK: f64 = 124.4;
pub const JUPITERALBEDO: f64 = crate::BONDALBEDO;

pub struct ClimateState {
    pub nh3fraction: f64,
    pub globalmeantempk: f64,
    pub albedo: f64,
    pub internalheatwm2: f64,
}

impl ClimateState {
    pub fn current() -> Self {
        Self {
            nh3fraction: 0.00026,
            globalmeantempk: crate::ONEBARTEMPK,
            albedo: JUPITERALBEDO,
            internalheatwm2: crate::INTERNALHEATINGWM2,
        }
    }

    pub fn outgoinglongwaveradiation(&self) -> f64 {
        stefan_boltzmann_flux(self.globalmeantempk)
    }

    pub fn absorbedsolarradiation(&self) -> f64 {
        solar_constant() * (1.0 - self.albedo) / (4.0 * 5.2044 * 5.2044)
    }

    pub fn internalplussolarheatflux(&self) -> f64 {
        self.absorbedsolarradiation() + self.internalheatwm2
    }

    pub fn energyimbalance(&self) -> f64 {
        self.internalplussolarheatflux() - self.outgoinglongwaveradiation()
    }

    pub fn effectiveemissiontemperature(&self) -> f64 {
        let flux = self.internalplussolarheatflux();
        (flux / SIGMA_SB).powf(0.25)
    }

    pub fn ammoniagreenhouseeffectk(&self) -> f64 {
        self.globalmeantempk - self.effectiveemissiontemperature()
    }

    pub fn nh3radiativeforcing(&self) -> f64 {
        0.036 * (self.nh3fraction * 1e6).sqrt()
    }
}

pub fn solarzenith(latitudedeg: f64, declinationdeg: f64, hourangledeg: f64) -> f64 {
    solar_zenith_angle(latitudedeg, declinationdeg, hourangledeg)
}

pub fn planckspectralradiance(wavelengthm: f64, temperaturek: f64) -> f64 {
    planck_function(wavelengthm, temperaturek)
}

pub fn solarfluxatjupiter() -> f64 {
    solar_constant() / (5.2044 * 5.2044)
}

pub fn co2doublingforcing() -> f64 {
    radiative_forcing_co2(560.0, 280.0)
}