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 crate::satellites::moon::{EARTHMOONDISTANCE, LUNARMASS};
use sciforge::hub::domain::astronomy::celestial::gravitational_force;
use sciforge::hub::domain::common::constants::{AU, EARTH_MASS, EARTH_RADIUS, G, SOLAR_MASS};
pub struct TidalForce {
    pub bodymass: f64,
    pub bodydistance: f64,
}
impl TidalForce {
    pub fn frommoon() -> Self {
        Self {
            bodymass: LUNARMASS,
            bodydistance: EARTHMOONDISTANCE,
        }
    }
    pub fn fromsun() -> Self {
        Self {
            bodymass: SOLAR_MASS,
            bodydistance: AU,
        }
    }
    pub fn tidalacceleration(&self) -> f64 {
        2.0 * G * self.bodymass * EARTH_RADIUS / self.bodydistance.powi(3)
    }
    pub fn tidalpotential(&self, theta: f64) -> f64 {
        let r = EARTH_RADIUS;
        let d = self.bodydistance;
        let m = self.bodymass;
        let base = -G * m * r * r / (d * d * d) * (1.5 * theta.cos().powi(2) - 0.5);
        (1.0 + crate::K2LOVE) * base
    }
    pub fn tidalbulgeheight(&self) -> f64 {
        let gsurface = G * EARTH_MASS / (EARTH_RADIUS * EARTH_RADIUS);
        crate::H2LOVE * self.tidalacceleration() * EARTH_RADIUS / gsurface
    }
    pub fn gravitationalattraction(&self) -> f64 {
        gravitational_force(EARTH_MASS, self.bodymass, self.bodydistance)
    }
}
pub fn springtideamplitude() -> f64 {
    let moon = TidalForce::frommoon();
    let sun = TidalForce::fromsun();
    moon.tidalbulgeheight() + sun.tidalbulgeheight()
}
pub fn neaptideamplitude() -> f64 {
    let moon = TidalForce::frommoon();
    let sun = TidalForce::fromsun();
    (moon.tidalbulgeheight() - sun.tidalbulgeheight()).abs()
}
pub fn lunartosolartideratio() -> f64 {
    let moon = TidalForce::frommoon();
    let sun = TidalForce::fromsun();
    moon.tidalacceleration() / sun.tidalacceleration()
}