Skip to content

Remove magic numbers in code #1596

@tapios

Description

@tapios

I added a set of TODO's in ClimaLand, which should be addressed sequentially:

  • Replace compute_ρ_sfc by calls to surface_density from SurfaceFluxes.jl (once there's a new release)
  • Update derivative ∂ρsfc∂Tc to be consistent with new surface density calculation
  • Remove remaining calls to Thermodynamics.PhaseEquil_* in update to new SurfaceFluxes.jl (and replace to calls to functional Thermodynamics API)
  • Replace magic numbers by well-defined parameters (with names and dimensions); use parameters from ClimaParams wherever possible. For example, this code block contains a number (1370) that looks to be total solar irradiance, which should come from ClimaParams, as well as several hard-coded constants that are dimensional:
    k₀ = FT(1370 * (1 + 0.033 * cos(2π * DOY / 365))) * cosθs
    kₜ = SW_d / k₀
    if kₜ 0.3
    diff_frac = FT(
    kₜ * (1 - 0.232 * kₜ + 0.0239 * cosθs - 6.82e-4 * T + 0.0195 * RH),
    )
    elseif kₜ 0.78
    diff_frac = FT(
    kₜ *
    (1.329 - 1.716 * kₜ + 0.267 * cosθs - 3.57e-3 * T + 0.106 * RH),
    )
    else
    diff_frac =
    FT(kₜ * (0.426 * kₜ + 0.256 * cosθs - 3.49e-3 * T + 0.0734 * RH))
    end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions