use asteroidsfactory::config::parameters::*;
use asteroidsfactory::engine::{collisions, evolution, orbits};
use asteroidsfactory::physics::{gravity, thermal};

fn main() {
    let mass = sphere_mass(500.0, 2500.0);
    let g_bind = gravity::gravitational_binding_energy(mass, 500.0);
    let roche_f = gravity::roche_limit_fluid(7.0e7, 1326.0, 2500.0);
    let roche_r = gravity::roche_limit_rigid(7.0e7, 1326.0, 2500.0);
    let tidal = gravity::tidal_force(SOLAR_MASS, 500.0, AU);
    let spec_h = gravity::specific_angular_momentum(AU, 0.1, SOLAR_MASS);
    let e_orb = gravity::orbital_energy(mass, SOLAR_MASS, AU);

    assert!(g_bind > 0.0);
    assert!(roche_f > roche_r);
    assert!(tidal > 0.0);
    assert!(spec_h > 0.0);
    assert!(e_orb < 0.0);

    let t_eq = thermal::equilibrium_temperature_detailed(SOLAR_LUMINOSITY, 2.5, 0.15, 0.9);
    let drift = thermal::yarkovsky_drift_rate(500.0, 2500.0, 2.5, 0.15, 45.0);
    let torque = thermal::yorp_torque_estimate(500.0, 2.5, 0.15);
    let ti = thermal::thermal_inertia_estimate(2500.0, 0.1, 800.0);
    let skin = thermal::diurnal_skin_depth(0.1, 2500.0, 800.0, 6.0 * 3600.0);

    assert!(t_eq > 100.0 && t_eq < 400.0);
    assert!(drift.abs() > 0.0);
    assert!(torque > 0.0);
    assert!(ti > 0.0);
    assert!(skin > 0.0);

    let n = orbits::mean_motion(2.5, SOLAR_MASS);
    let s_period = orbits::synodic_period(YEAR, 1.88 * YEAR);
    let tj = orbits::tisserand_from_elements(2.5, 0.1, 0.1, 5.2);
    let kl = orbits::kozai_lidov_period(11.86 * YEAR, 0.001, AU, 5.2 * AU, 0.05);

    assert!(n > 0.0);
    assert!(s_period > 0.0);
    assert!(tj > 2.0 && tj < 4.0);
    assert!(kl > 0.0);

    let v_imp = collisions::impact_velocity(15000.0, 500.0);
    let q_star = collisions::catastrophic_disruption_threshold(5000.0, 2700.0);
    let spec_e = collisions::specific_impact_energy(v_imp, 1.0e15, 1.0e10);
    let coll_lt = evolution::collisional_lifetime_estimate(5000.0, 2.5);
    let yark = evolution::yarkovsky_semi_major_drift(500.0, 2500.0, 2.5, 45.0);
    let weather = evolution::space_weathering_timescale(2.5);

    assert!(v_imp > 15000.0);
    assert!(q_star > 0.0);
    assert!(spec_e > 0.0);
    assert!(coll_lt > 0.0);
    assert!(yark.abs() > 0.0);
    assert!(weather > 0.0);

    let sum = g_bind
        + roche_f
        + roche_r
        + tidal
        + spec_h
        + e_orb.abs()
        + t_eq
        + drift.abs()
        + torque
        + ti
        + skin
        + n
        + s_period
        + tj
        + kl
        + v_imp
        + q_star
        + spec_e
        + coll_lt
        + yark.abs()
        + weather;
    assert!(sum > 0.0);
}
