satellitesfactory 0.0.3

Satellite factory — classify, build and catalogue natural satellites for any planetary system: Solar System moons (Moon, Galileans, Titan, Triton…) or custom configurations.
Documentation
use crate::config::parameters::*;

pub fn geometric_albedo(bond_albedo: f64, phase_integral: f64) -> f64 {
    bond_albedo / (phase_integral + 1e-30)
}

pub fn apparent_magnitude(absolute_mag: f64, distance_au: f64, phase_angle: f64) -> f64 {
    let phi = 1.0 - (phase_angle / std::f64::consts::PI);
    absolute_mag + 5.0 * distance_au.log10() - 2.5 * (phi.max(0.01)).log10()
}

pub fn reflected_flux(
    albedo: f64,
    radius: f64,
    distance_from_star: f64,
    distance_from_planet: f64,
) -> f64 {
    let star_flux =
        STEFAN_BOLTZMANN * 5778.0_f64.powi(4) * (6.957e8_f64 / distance_from_star).powi(2);
    let cross = std::f64::consts::PI * radius * radius;
    albedo * star_flux * cross
        / (4.0 * std::f64::consts::PI * distance_from_planet * distance_from_planet)
}

pub fn thermal_emission_flux(temperature: f64, radius: f64, distance: f64) -> f64 {
    let luminosity =
        4.0 * std::f64::consts::PI * radius * radius * STEFAN_BOLTZMANN * temperature.powi(4);
    luminosity / (4.0 * std::f64::consts::PI * distance * distance)
}

pub fn equilibrium_temperature(star_luminosity: f64, distance: f64, albedo: f64) -> f64 {
    (star_luminosity * (1.0 - albedo)
        / (16.0 * std::f64::consts::PI * STEFAN_BOLTZMANN * distance * distance))
        .powf(0.25)
}

pub fn opposition_surge(phase_angle: f64, surge_amplitude: f64) -> f64 {
    1.0 + surge_amplitude * (-phase_angle / 0.05).exp()
}

pub fn phase_curve_lambertian(phase_angle: f64) -> f64 {
    let phi = std::f64::consts::PI - phase_angle;
    (phi.sin() + (std::f64::consts::PI - phi) * phi.cos()) / std::f64::consts::PI
}

pub fn transit_depth_satellite(r_satellite: f64, r_star: f64) -> f64 {
    (r_satellite / r_star).powi(2)
}