dwarfplanetsfactory 0.0.1

Dwarf planet factory — classify, build and catalogue dwarf planets of any type: Kuiper belt, scattered disk, plutino, cold classical, detached, binary, Ceres-type, and sednoid.
Documentation
use crate::config::parameters;

/// Lightcurve amplitude (mag) from axial ratio a/b
/// For a triaxial body viewed equator-on: Δm ≈ 2.5 log10(a/b)
pub fn amplitude_from_axis_ratio(a_over_b: f64) -> f64 {
    if a_over_b <= 1.0 {
        return 0.0;
    }
    2.5 * a_over_b.log10()
}

/// Infer axial ratio from observed lightcurve amplitude
pub fn axis_ratio_from_amplitude(amplitude_mag: f64) -> f64 {
    if amplitude_mag <= 0.0 {
        return 1.0;
    }
    10.0_f64.powf(amplitude_mag / 2.5)
}

/// Rotation period (s) from lightcurve period, assuming double-peaked
pub fn rotation_from_lightcurve(lightcurve_period_s: f64) -> f64 {
    lightcurve_period_s
}

/// Spin rate (rad/s) from rotation period
pub fn spin_rate(rotation_period_s: f64) -> f64 {
    if rotation_period_s < 1.0 {
        return 0.0;
    }
    2.0 * parameters::PI / rotation_period_s
}

/// Critical spin rate (rad/s) above which a rubble pile disaggregates
/// ω_crit = sqrt(4/3 π G ρ)
pub fn critical_spin_rate(density: f64) -> f64 {
    (4.0 / 3.0 * parameters::PI * parameters::G * density).sqrt()
}

/// Whether the body is rotationally stable
pub fn is_rotationally_stable(rotation_period_s: f64, density: f64) -> bool {
    spin_rate(rotation_period_s) < critical_spin_rate(density)
}

/// Jacobi ellipsoid threshold: for a homogeneous body, the spin at
/// which the equilibrium shape becomes triaxial
pub fn jacobi_spin_threshold(density: f64) -> f64 {
    // Roughly 0.374 * sqrt(π G ρ)
    0.374 * (parameters::PI * parameters::G * density).sqrt()
}

/// Phase coefficient β (mag/deg) — typical for icy surfaces
pub fn phase_coefficient(albedo: f64) -> f64 {
    // Higher albedo -> lower phase coefficient
    0.04 + 0.02 * (1.0 - albedo)
}