moons 0.0.3

Moon celestial simulation crate for the MilkyWay SolarSystem workspace
Documentation
use moons::interactions::earth_tides::{farside_bulge_m, subearth_bulge_m};
use moons::interactions::orbital_dynamics::{
    libration_factor, orbital_energy_j_per_kg, resonance_offset_deg,
};
use moons::physics::orbit::LunarOrbit;
use moons::physics::rotation::MoonRotation;
use moons::physics::tides::TidalResponse;

fn ensure_earth_context() {
    let earth_context = moons::interactions::earths::ensure_earths_binary_or_simulate();
    assert!(earth_context.orbital_radius_km > 147_000_000.0);
}

#[test]
fn libration_factor_stays_close_to_unity() {
    ensure_earth_context();
    let factor = libration_factor(std::f64::consts::FRAC_PI_2);
    assert!(factor > 1.0);
    assert!(factor < 1.1);
}

#[test]
fn specific_orbital_energy_is_negative_for_bound_orbit() {
    ensure_earth_context();
    let orbit = LunarOrbit::new();
    let energy = orbital_energy_j_per_kg(orbit, orbit.semi_major_axis_m);
    assert!(energy < 0.0);
}

#[test]
fn synchronous_spin_has_small_resonance_offset() {
    ensure_earth_context();
    let orbit = LunarOrbit::new();
    let rotation = MoonRotation::new();
    assert!(resonance_offset_deg(orbit, rotation.sidereal_period_s).abs() < 0.1);
}

#[test]
fn subearth_and_farside_bulges_are_positive() {
    ensure_earth_context();
    let response = TidalResponse::current();
    assert!(subearth_bulge_m(response) > 0.0);
    assert!(farside_bulge_m(response) > 0.0);
}