pub fn iterate_surface_temp(
    planet: &mut Planetesimal,
    ecosphere_radius: &f64,
    rng: &mut dyn RngCore,
) -> f64 {
    let mut albedo = 0.0;
    let mut water = 0.0;
    let mut clouds = 0.0;
    let mut ice = 0.0;

    let mut optical_depth = opacity(planet.molecule_weight, planet.surface_pressure_bar);
    let mut effective_temp = eff_temp(ecosphere_radius, &planet.a, &EARTH_ALBEDO);
    let mut greenhouse_rise =
        green_rise(optical_depth, effective_temp, planet.surface_pressure_bar);
    let mut surface_temp_kelvin = effective_temp + greenhouse_rise;
    let mut previous_temp = surface_temp_kelvin - 5.0;

    while (surface_temp_kelvin - previous_temp).abs() > 1.0 {
        previous_temp = surface_temp_kelvin;
        water = hydrosphere_fraction(&planet.volatile_gas_inventory, &planet.radius);
        clouds = cloud_fraction(
            surface_temp_kelvin,
            planet.molecule_weight,
            planet.radius,
            water,
        );
        ice = ice_fraction(&water, &surface_temp_kelvin);

        if surface_temp_kelvin >= planet.boiling_point_kelvin
            || surface_temp_kelvin <= FREEZING_POINT_OF_WATER
        {
            water = 0.0;
        }
        albedo = planet_albedo(&water, &clouds, &ice, &planet.surface_pressure_bar, rng);
        optical_depth = opacity(planet.molecule_weight, planet.surface_pressure_bar);
        effective_temp = eff_temp(ecosphere_radius, &planet.a, &albedo);
        greenhouse_rise = green_rise(optical_depth, effective_temp, planet.surface_pressure_bar);
        surface_temp_kelvin = effective_temp + greenhouse_rise;
    }
    planet.hydrosphere = water;
    planet.cloud_cover = clouds;
    planet.ice_cover = ice;
    planet.albedo = albedo;
    planet.surface_temp_kelvin = surface_temp_kelvin;
    surface_temp_kelvin
}
/// The temperature calculated is in degrees Kelvin.
The temperature calculated is in degrees Kelvin.
The temperature calculated is in degrees Kelvin .
pub fn iterate_surface_temp(
    planet: &mut Planetesimal,
    ecosphere_radius: &f64,
    rng: &mut dyn RngCore,
) -> f64 {
    let mut albedo = 0.0;
    let mut water = 0.0;
    let mut clouds = 0.0;
    let mut ice = 0.0;
    let mut optical_depth = opacity(planet.molecule_weight, planet.surface_pressure_bar);
    let mut effective_temp = eff_temp(ecosphere_radius, &planet.a, &EARTH_ALBEDO);
    let mut greenhouse_rise =
        green_rise(optical_depth, effective_temp, planet.surface_pressure_bar);
    let mut surface_temp_kelvin = effective_temp + greenhouse_rise;
    let mut previous_temp = surface_temp_kelvin - 5.0;
    while (surface_temp_kelvin - previous_temp).abs() > 1.0 {
        previous_temp = surface_temp_kelvin;
        water = hydrosphere_fraction(&planet.volatile_gas_inventory, &planet.radius);
        clouds = cloud_fraction(
            surface_temp_kelvin,
            planet.molecule_weight,
            planet.radius,
            water,
        );
        ice = ice_fraction(&water, &surface_temp_kelvin);
        if surface_temp_kelvin >= planet.boiling_point_kelvin
            || surface_temp_kelvin <= FREEZING_POINT_OF_WATER
        {
            water = 0.0;
        }
        albedo = planet_albedo(&water, &clouds, &ice, &planet.surface_pressure_bar, rng);
        optical_depth = opacity(planet.molecule_weight, planet.surface_pressure_bar);
        effective_temp = eff_temp(ecosphere_radius, &planet.a, &albedo);
        greenhouse_rise = green_rise(optical_depth, effective_temp, planet.surface_pressure_bar);
        surface_temp_kelvin = effective_temp + greenhouse_rise;
    }
    planet.hydrosphere = water;
    planet.cloud_cover = clouds;
    planet.ice_cover = ice;
    planet.albedo = albedo;
    planet.surface_temp_kelvin = surface_temp_kelvin;
    surface_temp_kelvin
}
pub fn iterate_surface_temp ( planet : & mut Planetesimal , ecosphere_radius : & f64 , rng : & mut dyn RngCore , ) -> f64 { let mut albedo = 0.0 ; let mut water = 0.0 ; let mut clouds = 0.0 ; let mut ice = 0.0 ; let mut optical_depth = opacity ( planet . molecule_weight , planet . surface_pressure_bar ) ; let mut effective_temp = eff_temp ( ecosphere_radius , & planet . a , & EARTH_ALBEDO ) ; let mut greenhouse_rise = green_rise ( optical_depth , effective_temp , planet . surface_pressure_bar ) ; let mut surface_temp_kelvin = effective_temp + greenhouse_rise ; let mut previous_temp = surface_temp_kelvin - 5.0 ; while ( surface_temp_kelvin - previous_temp ) . abs ( ) > 1.0 { previous_temp = surface_temp_kelvin ; water = hydrosphere_fraction ( & planet . volatile_gas_inventory , & planet . radius ) ; clouds = cloud_fraction ( surface_temp_kelvin , planet . molecule_weight , planet . radius , water , ) ; ice = ice_fraction ( & water , & surface_temp_kelvin ) ; if surface_temp_kelvin >= planet . boiling_point_kelvin || surface_temp_kelvin <= FREEZING_POINT_OF_WATER { water = 0.0 ; } albedo = planet_albedo ( & water , & clouds , & ice , & planet . surface_pressure_bar , rng ) ; optical_depth = opacity ( planet . molecule_weight , planet . surface_pressure_bar ) ; effective_temp = eff_temp ( ecosphere_radius , & planet . a , & albedo ) ; greenhouse_rise = green_rise ( optical_depth , effective_temp , planet . surface_pressure_bar ) ; surface_temp_kelvin = effective_temp + greenhouse_rise ; } planet . hydrosphere = water ; planet . cloud_cover = clouds ; planet . ice_cover = ice ; planet . albedo = albedo ; planet . surface_temp_kelvin = surface_temp_kelvin ; surface_temp_kelvin }
The temperature calculated is in degrees Kelvin.
The temperature calculated is in degrees Kelvin .
planet
&mut Planetesimal
ecosphere_radius
&f64
rng
&mut dyn RngCore
planet
&mut Planetesimal
ecosphere_radius
&f64
rng
&mut dyn RngCore