use crate::satellites::io::{IOMASS, JUPITERIODISTANCE};
use sciforge::hub::domain::astronomy::celestial::gravitational_force;
use sciforge::hub::domain::common::constants::{AU, G, SOLAR_MASS};
pub struct TidalForce {
pub bodymass: f64,
pub bodydistance: f64,
}
impl TidalForce {
pub fn fromio() -> Self {
Self {
bodymass: IOMASS,
bodydistance: JUPITERIODISTANCE,
}
}
pub fn fromsun() -> Self {
Self {
bodymass: SOLAR_MASS,
bodydistance: 5.2044 * AU,
}
}
pub fn tidalacceleration(&self) -> f64 {
2.0 * G * self.bodymass * crate::JUPITEREQUATORIALRADIUS / self.bodydistance.powi(3)
}
pub fn tidalpotential(&self, theta: f64) -> f64 {
let r = crate::JUPITEREQUATORIALRADIUS;
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 = *crate::SURFACEGRAVITY;
crate::H2LOVE * self.tidalacceleration() * crate::JUPITEREQUATORIALRADIUS / gsurface
}
pub fn gravitationalattraction(&self) -> f64 {
gravitational_force(crate::JUPITERMASS, self.bodymass, self.bodydistance)
}
}
pub fn springtideamplitude() -> f64 {
let io = TidalForce::fromio();
let sun = TidalForce::fromsun();
io.tidalbulgeheight() + sun.tidalbulgeheight()
}
pub fn neaptideamplitude() -> f64 {
let io = TidalForce::fromio();
let sun = TidalForce::fromsun();
(io.tidalbulgeheight() - sun.tidalbulgeheight()).abs()
}
pub fn iotosolartideratio() -> f64 {
let io = TidalForce::fromio();
let sun = TidalForce::fromsun();
io.tidalacceleration() / sun.tidalacceleration()
}