Skip to content

About

GPU-capable surface fluxes between atmosphere, ocean, and land via Monin-Obukhov Similarity Theory

Topics

Resources

Stars

25 stars

Watchers

10 watching

Forks

Latest commit

 

History

404 Commits

Folders and files

Repository files navigation

SurfaceFluxes.jl Logo

SurfaceFluxes.jl

A package for computing turbulent surface fluxes of momentum, heat, and moisture between the atmosphere and land, ocean, and sea ice surfaces using Monin-Obukhov Similarity Theory (MOST).

SurfaceFluxes.jl solves the MOST equations with a fixed number of residual evaluations and no data-dependent control flow, so it broadcasts over heterogeneous surfaces on CPUs and GPUs and differentiates with automatic differentiation. It is used in the CliMA atmosphere, land, and ocean models.

Documentation stable dev
Version version
License license
Tests gha ci buildkite
Code Coverage codecov
Downloads Downloads

Installation

SurfaceFluxes.jl is a registered Julia package:

using Pkg
Pkg.add("SurfaceFluxes")

The parameter constructors used below load default values from ClimaParams.jl.

Features

  • MOST solver: A bracketed, branch-free solve for the stability parameter ζ with a fixed number of residual evaluations, reporting a convergence flag. States beyond the critical bulk Richardson number saturate at the stable limit.
  • Universal functions: Businger et al. (1971), Gryanik et al. (2020), and Grachev et al. (2007).
  • Discretization schemes: Point values (finite differences) or layer averages (finite volumes) following Nishizawa & Kitamura (2018).
  • Surface models: Constant roughness lengths, wind-dependent roughness over the ocean (COARE 3.0), and canopy roughness and displacement height from height and plant area index (Raupach 1994); constant or convective (Deardorff) gustiness.
  • Roughness sublayer corrections: Exponential (Garratt 1980; Physick & Garratt 1995) or linear corrections to the MOST profiles above tall canopies, consistent with their stability dependence.
  • Stability caps: A constant cap on the stability parameter in stable stratification, or a cap at the stability of maximum sensible heat flux, which keeps the heat flux increasing with the surface–air temperature difference and prevents runaway surface cooling.
  • Dynamic skin states: Surface temperature and humidity updated inside the solve through user-supplied callbacks (e.g., a surface energy balance).
  • Prescribed conditions: Fluxes and diagnostics from prescribed exchange coefficients, fully prescribed fluxes, or prescribed heat fluxes with a drag coefficient, in place of the iterative solve.
  • Profile recovery: Wind, temperature, and humidity at arbitrary heights from the computed fluxes, including the roughness sublayer and stability cap corrections, and screen-level diagnostics (2 m temperature and humidity, 10 m wind).
  • GPU and AD compatibility: Type-stable kernels that broadcast over arrays of heterogeneous surfaces with CUDA.jl, and derivatives with ForwardDiff.jl and Enzyme.
  • Thermodynamics: Moist-air properties from Thermodynamics.jl.

Quick Example

using SurfaceFluxes
import SurfaceFluxes.Parameters as SFP
import SurfaceFluxes.UniversalFunctions as UF

# Create parameters
FT = Float64
param_set = SFP.SurfaceFluxesParameters(FT, UF.BusingerParams)

# Compute surface fluxes
result = surface_fluxes(
    param_set,
    T_int,           # Interior temperature [K]
    q_tot,           # Interior total specific humidity [kg/kg]
    q_liq,           # Interior liquid specific humidity [kg/kg]
    q_ice,           # Interior ice specific humidity [kg/kg]
    ρ_int,           # Interior density [kg/m³]
    T_sfc,           # Surface temperature [K]
    q_sfc,           # Surface specific humidity [kg/kg]
    Φ_sfc,           # Surface geopotential [m²/s²]
    Δz,              # Height above surface [m]
    d,               # Displacement height [m]
    u_int,           # Interior wind (u, v) [m/s]
    u_sfc,           # Surface wind (u, v) [m/s]
)

# Access results
result.shf      # Sensible heat flux [W/m²]
result.lhf      # Latent heat flux [W/m²]
result.evaporation  # Evaporation rate [kg/(m²·s)]
result.ustar    # Friction velocity [m/s]
result.ρτxz     # Momentum flux, x-component [N/m²]
result.ρτyz     # Momentum flux, y-component [N/m²]
result.Cd       # Drag coefficient [-]
result.g_h      # Heat conductance Ch * U_eff [m/s]
result.T_sfc    # Surface temperature [K] (final)
result.q_vap_sfc # Surface vapor specific humidity [kg/kg] (final)
result.ζ        # Stability parameter (Δz - d) / L_MO [-]
result.L_MO     # Monin-Obukhov length [m]
result.L_eff    # Obukhov length at which the (capped) coefficients were evaluated [m]
result.converged # Solver convergence status

The surface model is set with a SurfaceFluxConfig, whose positional fields are the roughness model, the gustiness model, the moisture model, the roughness sublayer model, and the stability cap (the last three default to MoistModel(), NoRoughnessSubLayer(), and NoStabilityCap()):

h = 20.0  # canopy height [m]
config = SurfaceFluxConfig(
    ConstantRoughnessParams(0.1h, 0.01h),       # apparent z0m, z0s [m]
    ConstantGustinessSpec(1.0),                 # gustiness [m/s]
    MoistModel(),
    ExponentialRSL(c_m = 0.7, c_h = 0.7, z_RSL = 2h - 0.67h),
    MaxHeatFluxStabilityCap(),
)
result = surface_fluxes(param_set, T_int, q_tot, q_liq, q_ice, ρ_int, T_sfc, q_sfc,
    Φ_sfc, Δz, 0.67h, u_int, u_sfc, nothing, config)

Documentation

The full documentation, including the mathematical formulation of MOST, the universal function parameterizations, the roughness sublayer and stability cap formulations, the prescribed-condition modes, and the API reference, is available at the stable docs. Release notes are in NEWS.md.

Contributing

Contributors should follow the shared CliMA engineering standards in docs/dev-guides/, which cover architecture, performance, code quality, documentation, and workflows. These are vendored from CliMA/DeveloperGuides and synced automatically each month. The repo's AGENTS.md is a starting point for AI agents with repo-specific guidance.

About

GPU-capable surface fluxes between atmosphere, ocean, and land via Monin-Obukhov Similarity Theory

Topics

Resources

Stars

25 stars

Watchers

10 watching

Forks

Releases

Packages

Used by

Contributors

Languages