/// Fogg's information for this routine came from Dole "Habitable Planets for Man", Blaisdell Publishing Company, NY, 1964. From this, he came up with his eq.12, which is the equation for the base_angular_velocity below.
/// Going a bit further, he found an equation for the change in angular velocity per time (dw/dt) from P. Goldreich and S. Soter's paper "Q in the Solar System" in Icarus, vol 5, pp.375-389 (1966).
/// Comparing to the change in angular velocity for the Earth, we can come up with an approximation for our new planet (his eq.13) and take that into account.
Fogg's information for this routine came from Dole "Habitable Planets for Man", Blaisdell Publishing Company, NY, 1964. From this, he came up with his eq.12, which is the equation for the base_angular_velocity below.
Going a bit further, he found an equation for the change in angular velocity per time (dw/dt) from P. Goldreich and S. Soter's paper "Q in the Solar System" in Icarus, vol 5, pp.375-389 (1966).
Comparing to the change in angular velocity for the Earth, we can come up with an approximation for our new planet (his eq.13) and take that into account.
Fogg ' s information for this routine came from Dole " Habitable Planets for Man " Blaisdell Publishing Company NY 1964 . From this he came up with his eq . 12 which is the equation for the base_angular_velocity below . Going a bit further he found an equation for the change in angular velocity per time ( dw / dt ) from P . Goldreich and S . Soter ' s paper " Q in the Solar System " in Icarus vol 5 pp . 375 - 389 ( 1966 ) . Comparing to the change in angular velocity for the Earth we can come up with an approximation for our new planet ( his eq . 13 ) and take that into account .
pub fn day_length(planet: &mut Planetesimal, stellar_mass: &f64, main_sequence_age: &f64) -> f64 {
    let planet_mass_in_grams = planet.mass * SOLAR_MASS_IN_GRAMS;
    let equatorial_radius_in_cm = planet.radius * CM_PER_KM;
    let year_in_hours = planet.orbital_period_days;
    let k2 = match planet.is_gas_giant {
        true => 0.24,
        false => 0.33,
    };
    let base_angular_velocity =
        (2.0 * J * planet_mass_in_grams).sqrt() / (k2 * equatorial_radius_in_cm.powf(2.0));
    let change_in_angular_velocity = CHANGE_IN_EARTH_ANG_VEL
        * (planet.density / EARTH_DENSITY)
        * (equatorial_radius_in_cm / EARTH_RADIUS_IN_CM)
        * (EARTH_MASS_IN_GRAMS / planet_mass_in_grams)
        * stellar_mass.powf(2.0)
        * (1.0 / planet.a.powf(6.0));
    let ang_velocity = base_angular_velocity + (change_in_angular_velocity * main_sequence_age);
    let (stopped, day_in_hours) = match ang_velocity <= 0.0 {
        true => (true, INCREDIBLY_LARGE_NUMBER),
        false => (
            false,
            RADIANS_PER_ROTATION / (SECONDS_PER_HOUR * ang_velocity),
        ),
    };
    if day_in_hours >= year_in_hours || stopped {
        if planet.e > 0.1 {
            let spin_resonance_factor = (1.0 - planet.e) / (1.0 + planet.e);
            planet.resonant_period = true;
            return spin_resonance_factor * year_in_hours;
        } else {
            return year_in_hours;
        }
    }
    day_in_hours
}
pub fn day_length ( planet : & mut Planetesimal , stellar_mass : & f64 , main_sequence_age : & f64 ) -> f64 { let planet_mass_in_grams = planet . mass * SOLAR_MASS_IN_GRAMS ; let equatorial_radius_in_cm = planet . radius * CM_PER_KM ; let year_in_hours = planet . orbital_period_days ; let k2 = match planet . is_gas_giant { true => 0.24 , false => 0.33 , } ; let base_angular_velocity = ( 2.0 * J * planet_mass_in_grams ) . sqrt ( ) / ( k2 * equatorial_radius_in_cm . powf ( 2.0 ) ) ; let change_in_angular_velocity = CHANGE_IN_EARTH_ANG_VEL * ( planet . density / EARTH_DENSITY ) * ( equatorial_radius_in_cm / EARTH_RADIUS_IN_CM ) * ( EARTH_MASS_IN_GRAMS / planet_mass_in_grams ) * stellar_mass . powf ( 2.0 ) * ( 1.0 / planet . a . powf ( 6.0 ) ) ; let ang_velocity = base_angular_velocity + ( change_in_angular_velocity * main_sequence_age ) ; let ( stopped , day_in_hours ) = match ang_velocity <= 0.0 { true => ( true , INCREDIBLY_LARGE_NUMBER ) , false => ( false , RADIANS_PER_ROTATION / ( SECONDS_PER_HOUR * ang_velocity ) , ) , } ; if day_in_hours >= year_in_hours || stopped { if planet . e > 0.1 { let spin_resonance_factor = ( 1.0 - planet . e ) / ( 1.0 + planet . e ) ; planet . resonant_period = true ; return spin_resonance_factor * year_in_hours ; } else { return year_in_hours ; } } day_in_hours }
Fogg's information for this routine came from Dole "Habitable Planets for Man", Blaisdell Publishing Company, NY, 1964.
Fogg ' s information for this routine came from Dole " Habitable Planets for Man " Blaisdell Publishing Company NY 1964 .
planet
&mut Planetesimal
stellar_mass
&f64
main_sequence_age
&f64