API Reference

Adapt.adapt — Method
adapt(
    ::Terrarium.NumberFormatAdaptor{NF},
    obj
) where NF<:Number

Adaptor that reconstructs arbitrary data structures with all numeric values converted to the specified number format NF.

source
Base.merge — Method

Merges all of the given Variables containers into a single container.

source
Oceananigans.Advection.cell_advection_timescale — Function
cell_advection_timescale(
    state,
    grid,
    soil::SoilEnergyWaterCarbon,
    constants::PhysicalConstants
)
cell_advection_timescale(
    state,
    grid,
    soil::SoilEnergyWaterCarbon,
    constants::PhysicalConstants,
    surface_hydrology::Union{Nothing, Terrarium.AbstractSurfaceHydrology}
)
cell_advection_timescale(
    state,
    grid,
    soil::SoilEnergyWaterCarbon,
    constants::PhysicalConstants,
    surface_hydrology::Union{Nothing, Terrarium.AbstractSurfaceHydrology},
    timestepper::Union{Nothing, Terrarium.AbstractTimeStepper}
)

Return the minimum over the soil column of the time scales of the explicit transport terms: the advective CFL limit of the explicit first-order upwind advection of sensible heat by the soil water flux (see advective_heat_flux), and the explicit water outflow limit of the hydrology (water_outflow_timescale). The advective limit is Inf without water flow (e.g. NoFlow hydrology) and when the model's timestepper integrates internal_energy implicitly (the implicit operator is unconditionally stable). The evapotranspiration sink of an optional surface_hydrology enters the outflow limit.

source
Oceananigans.Advection.cell_advection_timescale — Method
cell_advection_timescale(integrator::ModelIntegrator)

Return the advective stability timescale (seconds) of the integrator, used by the Oceananigans TimeStepWizard for an advective CFL constraint. For SoilModel and LandModel this is the minimum of the timescale of the explicit upwind advection of sensible heat by the soil water flux (see advective_heat_flux), Inf without water flow and when internal_energy is integrated implicitly, and of the explicit water outflow limit (water_outflow_timescale). Models that transport nothing advectively return Inf.

source
Oceananigans.Advection.cell_advection_timescale — Method
cell_advection_timescale(
    state,
    grid,
    energy::SoilThermodynamics,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
) where NF

Return the minimum over all cells of the advective timescale $τ = C Δz / (C_w |j_w|)$ (compute_heat_advection_timescale) for a Richards-equation hydrology, with j_w the Darcy flux through the faces of the cell.

source
Oceananigans.BoundaryConditions.getbc — Method
getbc(::Variable{name}, i::Integer, j::Integer, grid::AbstractGrid, clock, fields) where {name}

Implementation of Oceananigans.BoundaryConditions.getbc for variable placeholders that retrieves the input Field from fields and returns the value at the given index.

source
Oceananigans.Diagnostics.cell_diffusion_timescale — Function
cell_diffusion_timescale(
    state,
    grid,
    soil::SoilEnergyWaterCarbon,
    constants::PhysicalConstants
)
cell_diffusion_timescale(
    state,
    grid,
    soil::SoilEnergyWaterCarbon,
    constants::PhysicalConstants,
    timestepper::Union{Nothing, Terrarium.AbstractTimeStepper}
)

Return the minimum diffusive timescale over the coupled soil processes as the minimum of the individual energy (heat conduction) and hydrology (Richards) timescales. If the model's timestepper integrates internal_energy (saturation_water_ice) implicitly (see AbstractIMEX), the energy (hydrology) timescale is Inf.

source
Oceananigans.Diagnostics.cell_diffusion_timescale — Method
cell_diffusion_timescale(
    state,
    grid,
    snow::SingleLayerSnow,
    constants::PhysicalConstants
)

Return the minimum thermal diffusion timescale $τ = \max(d_{\text{snow}}, d_{\text{min}})² \, C_{\text{snow}} / κ_{\text{snow}}$ over the grid for the snow-top conduction operator, mirroring the cell_diffusion_timescale pattern used for soil. Uses the same floored conduction thickness (min_snow_conduction_thickness) that enters the actual conductive-flux calculations (compute_snow_surface_heat_flux, compute_snow_basal_heat_flux), so the reported timescale reflects the stability limit of the discretization as implemented — the floor bounds it below for a vanishing pack, while a genuinely thick pack still reports its own (longer, less restrictive) timescale rather than being pinned to the floor.

source
Oceananigans.Diagnostics.cell_diffusion_timescale — Method
cell_diffusion_timescale(
    state,
    grid,
    energy::SoilThermodynamics,
    soil::Terrarium.AbstractSoil,
    args...
)

Return the minimum thermal diffusion timescale $τ = Δz² C / κ$ over the soil column for the SoilThermodynamics energy process, where κ is the bulk thermal conductivity (W m⁻¹ K⁻¹) and C the bulk volumetric heat capacity (J m⁻³ K⁻¹). This is the diffusive stability limit of the explicit heat conduction operator, whose effective temperature diffusivity is $α = κ / C$.

The sensible heat capacity is used (not the apparent capacity, which includes the latent heat of phase change); since the apparent capacity is never smaller, the reported timescale is conservative near the freezing front.

source
Oceananigans.Diagnostics.cell_diffusion_timescale — Method
cell_diffusion_timescale(integrator::ModelIntegrator)

Return the minimum diffusive stability timescale $τ = Δz² / D$ (seconds) over all grid cells of the integrator, where D is the largest effective diffusivity among the model's diffusive processes. This is the diagnostic consumed by the Oceananigans TimeStepWizard to enforce a diffusive Courant–Friedrichs–Lewy (CFL) constraint of the form $Δt ≈ \mathrm{diffusive\_cfl} · τ$.

The generic fallback (for models without an implemented diffusive timescale) returns Inf, i.e. no diffusive restriction, mirroring the Oceananigans infinite_diffusion_timescale convention.

source
Oceananigans.Diagnostics.cell_diffusion_timescale — Method
cell_diffusion_timescale(
    state,
    grid,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    soil::Terrarium.AbstractSoil,
    args...
) where NF

Return the minimum hydraulic diffusion timescale $τ = Δz² (∂θ/∂ψ) / K$ over the soil column for a Richards-equation SoilHydrology, where K is the (variably saturated) hydraulic conductivity (m s⁻¹) and ∂θ/∂ψ the specific moisture capacity (m⁻¹). This is the diffusive stability limit of the explicit Richards operator, whose effective moisture diffusivity is $D = K ∂ψ/∂θ = K / (∂θ/∂ψ)$.

As the soil saturates, $∂θ/∂ψ → 0$ and the timescale tends to zero: explicit Richards is stiff near saturation, which is precisely the regime motivating implicit timestepping. The TimeStepWizard's min_change bound keeps the step from collapsing to zero in a single adjustment.

source
Oceananigans.Fields.set! — Method
set!(field::Field, kf::KernelFunction, fields)
set!(field::Field, kf::KernelFunction, clock, fields)

Set field by evaluating the kernel function kf at every node of field, reading from fields (and clock, for non-autonomous kernel functions). The operation is constructed on the grid of field and its location.

source
Oceananigans.Grids.λnodes — Function
λnodes(grid; ...)
λnodes(grid, ::Union{Center, Face}, args...; kwargs...)

Longitudes (degrees) of the active (masked) columns of grid, as a host Vector ordered like the horizontal index of the grid. This extends the Oceananigans accessor for curvilinear grids so that λnodes/φnodes give the geographic coordinates of a horizontal position on both a LatitudeLongitudeGrid and a ColumnRingGrid; on the latter, both are indexed by column.

source
Oceananigans.Grids.φnodes — Function
φnodes(grid; ...)
φnodes(grid, ::Union{Center, Face}, args...; kwargs...)

Latitudes (degrees) of the active (masked) columns of grid, as a host Vector ordered like the horizontal index of the grid. See λnodes.

source
Oceananigans.OutputWriters.serializeproperty! — Method
serializeproperty!(file, address, grid)

Serialize a ColumnRingGrid as the RectilinearGrid it wraps. The rings and mask fields are intentionally discarded, so Fields will be read back as plain RectilinearGrids.

source
Oceananigans.Simulations.run! — Method
run!(
    integrator;
    steps,
    period,
    Δt,
    checkpointing,
    show_progress
)

Run the simulation for steps or a given time period with timestep size Δt (in seconds or Dates.Period).

source
Oceananigans.TimeSteppers.update_state! — Method
update_state!(state::StateVariables, model::AbstractModel, inputs::InputSources; compute_tendencies = true)

Update the state for the given model and inputs; this includes calling update_inputs! and compute_auxiliary! as well as compute_tendencies!, if compute_tendencies = true.

source
Oceananigans.Utils.launch! — Method
launch!(
    grid,
    ::Union{Type{<:XY}, XY},
    kernel!,
    first_arg,
    other_args...;
    kwargs...
)

Launch kernel! over grid with the work layout given by workspec, passing grid itself as the kernel's second argument so that kernels can be written in terms of the model's grid. The work specification muist be given as a Terrarium VarDims, i.e. XY or XYZ.

source
Terrarium.AmbientCO2 — Method

Creates a TracerGas for ambient CO2 with concentration prescribed by an input variable with the given name.

source
Terrarium.ExponentialSpacing — Method
ExponentialSpacing(; Δz_min, Δz_max, N)

Construct an Oceananigans ExponentialDiscretization for a soil column of N layers whose thickness grows geometrically with depth, from Δz_min at the surface to Δz_max at the bottom. The total depth of the column follows from the layer thicknesses,

D = Δz_min (ρᴺ - 1) / (ρ - 1),    ρ = (Δz_max / Δz_min)^(1 / (N - 1))

where ρ is the ratio between the thicknesses of successive layers. Oceananigans parameterizes the same geometric family by the e-folding scale of its exponential coordinate mapping, which for the spacings above is D / (N log ρ). Note that Oceananigans orders cell interfaces bottom-up, so the first cell of the returned discretization is the thick bottom layer.

For a column of constant layer thickness, use UniformSpacing instead; the exponential mapping is degenerate when Δz_min == Δz_max.

using Terrarium

z = ExponentialSpacing(Δz_min = 0.05, Δz_max = 100.0, N = 50)
(num_layers(z), round(z.faces[1], digits = 3), z.faces[end])

# output
(50, -695.654, 0.0)
source
Terrarium.FreeDrainage — Method

Alias for PrescribedGradient representing a Neumann-type zero pressure gradient at the bottom of the soil column, thereby allowing free drainage of water.

source
Terrarium.GeothermalHeatFlux — Function

Alias for FluxBoundaryCondition on internal_energy with name geothermal_heat_flux representing the geothermal heat flux at the bottom boundary of the soil column.

source
Terrarium.HomogeneousSoilStratigraphy — Method
HomogeneousSoilStratigraphy(
    ::Type{NF};
    texture::SoilTexture,
    porosity::Terrarium.AbstractSoilPorosity
) where NF

Convenience constructor that creates a SoilStratigraphy with a single ConstantSoilHorizon.

source
Terrarium.InfiltrationFlux — Method

Alias for a discrete-form FluxBoundaryCondition on saturation_water_ice that normalizes the physical infiltration flux (m/s of water depth) by the top-of-soil porosity at evaluation time, since saturation_water_ice is the dimensionless saturation (VWC / porosity). See saturation_infiltration_bc.

source
Terrarium.LitterfallFlux — Method

Alias for FluxBoundaryCondition on density_soc with name litter representing litter fall inputs to top layer soil organic carbon.

source
Terrarium.SoilGridsStratigraphy — Method
SoilGridsStratigraphy(
    ::Type{NF};
    porosity::Terrarium.AbstractSoilPorosity,
    horizon1::Terrarium.AbstractSoilHorizon,
    horizon2::Terrarium.AbstractSoilHorizon,
    horizon3::Terrarium.AbstractSoilHorizon,
    horizon4::Terrarium.AbstractSoilHorizon,
    horizon5::Terrarium.AbstractSoilHorizon,
    horizon6::Terrarium.AbstractSoilHorizon
) where NF -> SoilStratigraphy{NF, 6, <:NTuple{6, Terrarium.AbstractSoilHorizon{NF}}} where NF

Convenience constructor that creates a SoilStratigraphy with six horizons corresponding to the six depth intervals defined by the SoilGridsV2 dataset. The porosity parameterization is applied to all six default horizons; pass explicit horizon* arguments to override individual horizons (in which case porosity does not apply to those).

source
Terrarium.SoilHeatFlux — Function

Alias for FluxBoundaryCondition on internal_energy with name soil_heat_flux representing the net heat flux into the top of the soil column. Without snow this equals the surface energy balance ground_heat_flux; with snow it is the (blended) conductive flux across the snow base.

source
Terrarium.UniformSpacing — Method
UniformSpacing(; Δz, N)

Construct the cell interfaces of a soil column of N layers of constant thickness Δz, spanning a total depth of N * Δz with the surface at z = 0. The number format of the returned interfaces follows that of Δz, so it also determines the default number format of a grid built from them.

This is a convenience for the uniformly spaced case, which Oceananigans expresses as a plain range of cell interfaces; UniformSpacing(Δz = 0.1, N = 10) is equivalent to range(-10 * 0.1, 0, length = 11). See ExponentialSpacing for a column whose layers grow with depth.

using Terrarium

z = UniformSpacing(Δz = 0.1, N = 10)
(num_layers(z), first(z), last(z))

# output
(10, -1.0, 0.0)
source
Terrarium._get_fields_expr — Method

Generation-time helper for get_fields. Given the type Vars of a tuple of AbstractVariables and Namespaces, builds an expression that retrieves all matching fields from state_ex (an expression evaluating to the state container) and vars_ex (an expression evaluating to the variable tuple). The recursion over namespaces is performed here, at expansion time, so that the generated body for get_fields contains no self-call. This is what makes the method type stable: a runtime self-recursive get_fields would otherwise trigger inference's recursion limiting and widen the return type of the nested namespace lookups to an abstract NamedTuple.

source
Terrarium.add_scaled! — Method
add_scaled!(out, field, factor)

Add factor times field to out over the interior of their common grid, out ← out + factor * field, e.g. to form or remove an explicit increment. Fields without a vertical location (e.g. snow variables) are updated once per column. Not exported.

source
Terrarium.adjust_saturation_profile! — Function
adjust_saturation_profile!(state, grid, hydrology::SoilHydrology, runoff = nothing, strat = nothing, bgc = nothing, energy = nothing)

Redistribute over- and undersaturation in the soil columns of state (see redistribute_saturation_profile!). With runoff = nothing, excess water reaching the surface is discarded; otherwise it is routed into the surface_excess_water pool of runoff as a water depth (m), using the porosity of the topmost layer from strat and bgc.

With an optional SoilThermodynamics energy process, the sensible heat of the water moves with it (compute_redistributed_heat!), so the heat of the excess water leaves the column; this requires strat and bgc.

source
Terrarium.adjust_saturation_profile! — Method
adjust_saturation_profile!(
    out,
    i,
    j,
    grid,
    fields,
    hydrology::SoilHydrology{NF, VerticalFlow, SaturationClosure, SoilHydraulics} where {VerticalFlow<:Terrarium.AbstractVerticalFlow, SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    ::Nothing,
    energy,
    strat,
    bgc
) where NF

Kernel function that adjusts the saturation profile at i, j and discards any excess water reaching the surface. Used for standalone soil hydrology, where no surface runoff process owns a water pool.

source
Terrarium.adjust_saturation_profile! — Method
adjust_saturation_profile!(
    out,
    i,
    j,
    grid,
    fields,
    hydrology::SoilHydrology{NF, VerticalFlow, SaturationClosure, SoilHydraulics} where {VerticalFlow<:Terrarium.AbstractVerticalFlow, SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    runoff::Terrarium.AbstractSurfaceRunoff,
    energy,
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
) where NF

Kernel function that adjusts the saturation profile at i, j and routes any excess water reaching the surface into the surface_excess_water pool owned by the given surface runoff process, as a water depth (m): the excess saturation times the thickness and porosity (porosity_top) of the topmost layer.

source
Terrarium.advective_heat_flux — Method
advective_heat_flux(
    i,
    j,
    k,
    grid,
    fields,
    energy::Terrarium.AbstractThermodynamics,
    args...
)

Advective heat flux (W/m², positive upward) at the cell face i, j, k. The default is zero, i.e. no heat is transported by a moving medium; see the method for soil water flow following the Richards equation.

source
Terrarium.advective_heat_flux — Method
advective_heat_flux(
    i,
    j,
    k,
    grid,
    fields,
    energy::SoilThermodynamics,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    args...
) where NF

Upwind advective heat flux C_w T_up j_w (W/m², positive upward) at face i, j, k, the first-order upwind discretization of C_w T j_w, with j_w (m/s) the water_flux of the step (compute_advective_water_flux) and C_w the water heat capacity of the SoilThermalProperties, consistent with the energy closure. T_up is the temperature of cell k for j_w < 0 and of cell k - 1 otherwise, clamped to the column at the boundary faces. Only the sensible heat of liquid water is advected; ice is immobile.

Under Implicit time stepping, only the boundary inflow is explicit (compute_boundary_advective_energy_tendency); the rest is part of the implicit heat operator (compute_implicit_advective_velocity!). The heat of water entering through flux boundary conditions on saturation_water_ice (e.g. InfiltrationFlux) is added by compute_boundary_advected_heat!.

source
Terrarium.aerodynamic_resistance — Method
aerodynamic_resistance(i, j, grid, fields, atmos::PrescribedAtmosphere)

Compute the aerodynamic resistance (inverse conductance) at grid cell i, j.

source
Terrarium.aerodynamic_resistance — Method
aerodynamic_resistance(
    i,
    j,
    grid,
    fields,
    atmos::Terrarium.AbstractAtmosphere,
    evapotranspiration::PALADYNCanopyEvapotranspiration{NF},
    ::Terrarium.AbstractVegetation
) where NF

Compute the aerodynamic resistance between the ground and canopy as a function of LAI and SAI.

source
Terrarium.air_density — Method
air_density(i, j, grid, fields, atmos::AbstractAtmosphere, constants::PhysicalConstants)

Compute density (kg m⁻³) of a parcel of air under current atmospheric conditions.

source
Terrarium.air_pressure — Method
air_pressure(i, j, grid, fields, ::PrescribedAtmosphere)

Retrieve or compute the air pressure at the current time step.

source
Terrarium.air_temperature — Method
air_temperature(i, j, grid, fields, ::PrescribedAtmosphere)

Retrieve or compute the air temperature at the current time step.

source
Terrarium.albedo — Method
albedo(i, j, grid, fields, albedo::ConstantAlbedo)

Return the surface albedo at grid point i, j.

source
Terrarium.albedo — Method
albedo(i, j, grid, fields, ::AbstractAlbedo)

Return the current albedo at the given indices.

source
Terrarium.ambient_co2 — Method
ambient_co2(i, j, grid, fields, ::PrescribedAtmosphere)

Return the current prescribed ambient CO2 concentration level.

source
Terrarium.auxiliary — Function
auxiliary(name, loc; ...)
auxiliary(name, loc, ctor; ...)
auxiliary(
    name,
    loc,
    ctor,
    params;
    units,
    eltype,
    closure,
    bounds,
    desc
)

Convenience constructor method for AuxiliaryVariable.

source
Terrarium.auxiliary_fields — Method
auxiliary_fields(state, components...)

Retrieves all Fields from state corresponding to auxiliary variables defined on the given components.

source
Terrarium.canopy_domain — Method
canopy_domain(::Oceananigans.Grids.AbstractGrid)

Return the spatial discretization of the canopy domain of grid, or nothing if the canopy is not vertically resolved. Grids which are not land grids never resolve a canopy domain.

source
Terrarium.canopy_evaporation_conductance — Method
canopy_evaporation_conductance(
    ::PALADYNCanopyEvapotranspiration,
    f_can,
    rₐ
)

Compute the canopy evaporation vapor conductance [m/s] from the current canopy saturation fraction f_can and aerodynamic resistance rₐ.

source
Terrarium.canopy_water — Function
canopy_water(i, j, grid, fields, ::AbstractCanopyInterception)

Compute or retrieve the current canopy water storage [m].

source
Terrarium.celsius_to_kelvin — Method
celsius_to_kelvin(c::ThermodynamicConstants, T)

Convert the given temperature in °C to Kelvin based on the constant temperature_water_freeze.

source
Terrarium.check_domain_compatibility — Method
check_domain_compatibility(ground, domain, name)

Check that the domain grid named name is compatible with the ground domain grid, i.e. that both share the same horizontal discretization, numeric type, and architecture. Throws an ArgumentError if not. Note that this is a host-side check which must never be invoked from a kernel.

source
Terrarium.checkfinite! — Function
checkfinite!(field)
checkfinite!(field, name)

Check whether the given field has any NaN or Inf values and raise an error if NaNs are detected.

source
Terrarium.closure! — Function
closure!(
    state,
    grid,
    soil::SoilEnergyWaterCarbon,
    constants::PhysicalConstants
)
closure!(
    state,
    grid,
    soil::SoilEnergyWaterCarbon,
    constants::PhysicalConstants,
    surface_hydrology::Union{Nothing, Terrarium.AbstractSurfaceHydrology}
)

Compute the forward closure mapping for soil hydrology and energy, in that order.

An optional surface_hydrology process may be supplied (by the coupled LandModel) so that excess water removed from an oversaturated soil surface is routed into the surface_excess_water pool owned by its runoff scheme (get_surface_runoff). Without it (standalone soil), the excess is discarded.

source
Terrarium.closure! — Method
closure!(
    state,
    grid,
    closure::SnowEnergyTemperatureClosure,
    snow::SingleLayerSnow,
    constants::PhysicalConstants,
    args...
)

Forward closure: recover snow_temperature and snow_liquid_fraction from the prognostic snow_energy.

source
Terrarium.closure! — Method
closure!(state, grid, closure::AbstractClosureRelation, process, args...)

Apply closure for process on the given grid with additional implementation-specific args.

source
Terrarium.closure! — Method
closure!(state, grid, proc::AbstractProcess, args...)

Apply the forward closure mappings for the process proc on the given grid with additional implementation-specific args defined by the coupling interface for the process type. The default implementation calls invclosure! with args for each closure returned by closures.

source
Terrarium.closure! — Method
closure!(state, model::AbstractModel)

Apply all closure relations defined for the given model, i.e. update the variables that are determined by the prognostic state. This is also where a model enforces constraints on its prognostic state that are not part of the tendencies, such as the redistribution of oversaturation in the soil (adjust_saturation_profile!) or the non-negativity of the snow water equivalent (enforce_snow_constraints!). Timesteppers call it at the end of each step (and between the stages of multi-stage schemes), after all prognostic variables have been updated.

source
Terrarium.closure! — Method
closure!(
    state,
    grid,
    closure::SoilSaturationPressureClosure,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    soil::Terrarium.AbstractSoil
) where NF
closure!(
    state,
    grid,
    closure::SoilSaturationPressureClosure,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    soil::Terrarium.AbstractSoil,
    runoff::Union{Nothing, Terrarium.AbstractSurfaceRunoff},
    args...
) where NF

Computes pressure_head $Ψ = ψm + ψz + ψh$ from the current saturation_water_ice state, after redistributing over- and undersaturation (adjust_saturation_profile!) and updating the water table.

An optional runoff process routes excess water removed from an oversaturated soil surface into the runoff-owned surface_excess_water pool; without it the excess is discarded. With SoilThermodynamics, the sensible heat of redistributed water is moved in internal_energy and that of the excess is removed; the energy closure, which runs after this one in closure! of SoilEnergyWaterCarbon, then recomputes the temperature.

source
Terrarium.closure_fields — Method
closure_fields(state, components...)

Retrieves all Fields from state corresponding to closure variables defined on the given components.

source
Terrarium.closures — Method
closures(proc::AbstractProcess)

Return a tuple of AbstractClosureRelations defined by the given processes type. Note that this is a type-stable, @generated function that is compiled for each argument type.

source
Terrarium.compute_APAR — Method
compute_APAR(
    photo::LUEPhotosynthesis{NF},
    traits::PlantTraits{NF},
    swdown::NF,
    LAI::NF
) where NF

Computes absorbed PAR limited by the fraction of PAR assimilated at ecosystem level APAR [mol/m²/s], [21, Eq. (62)].

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_Ag — Method
compute_Ag(
    photo::LUEPhotosynthesis{NF},
    c_1::NF,
    c_2::NF,
    APAR::NF,
    Vc_max::NF,
    β::NF
) where NF

Computes the gross photosynthesis rate Ag [kgC/m²/s], [22, Eq. (2)].

References

  • [22] Haxeltine & Prentice, Global Biogeochemical Cycles (1996)
source
Terrarium.compute_C_veg_tend — Method
compute_C_veg_tend(vegcarbon_dynamics, traits, LAI_b, NPP)

Computes the C_veg tendency based on NPP and the balanced Leaf Area Index LAI_b, [21, Eq. (72)]

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_GPP — Method
compute_GPP(
    ::LUEPhotosynthesis{NF},
    An::NF,
    Rd::NF
) where NF

Compute Gross Primary Production from net assimilation An and leaf respiration Rd [kgC/m²/s].

source
Terrarium.compute_JE_JC — Method
compute_JE_JC(
    photo::LUEPhotosynthesis{NF},
    c_1::NF,
    c_2::NF,
    APAR::NF,
    Vc_max::NF
) where NF -> Tuple{Any, Any}

Computes the PAR-limited and the rubisco-activity-limited photosynthesis rates JE and JC [kgC/m²/s], [22, Eqs. (3, 5)].

References

  • [22] Haxeltine & Prentice, Global Biogeochemical Cycles (1996)
source
Terrarium.compute_NPP — Method
compute_NPP(autoresp, GPP, Ra)

Computes Net Primary Productivity NPP as the difference between Gross Primary Production GPP and autotrophic respiration Ra in [kgC/m²/s].

source
Terrarium.compute_PAR — Method
compute_PAR(
    photo::LUEPhotosynthesis{NF},
    swdown::NF
) where NF

Computes NET Photosynthetically Active Radiation PAR [mol/m²/s].

source
Terrarium.compute_Ra — Method
compute_Ra(
    autoresp,
    vegcarbon_dynamics,
    traits,
    T_air,
    T_soil,
    Rd,
    phen,
    C_veg,
    GPP
)

Computes autotrophic respiration Ra as the sum of maintenance respiration Rm and growth respiration Rg in [kgC/m²/s].

source
Terrarium.compute_Rd — Method
compute_Rd(
    photo::LUEPhotosynthesis,
    Vc_max::NF,
    β::NF
) where NF

Computes the leaf respiration rate Rd [kgC/m²/s], [22, Eq. (10)] and [21, Eq. (10)].

References

  • [22] Haxeltine & Prentice, Global Biogeochemical Cycles (1996)
  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_Rm — Method
compute_Rm(
    autoresp,
    vegcarbon_dynamics,
    traits,
    T_air,
    T_soil,
    Rd,
    phen,
    C_veg
)

Computes maintenance respiration Rm in [kgC/m²/s].

source
Terrarium.compute_Vc_max — Method
compute_Vc_max(
    photo::LUEPhotosynthesis{NF},
    c_1::NF,
    PAR::NF,
    Kc::NF,
    Ko::NF,
    Γ_star::NF,
    pres_i::NF,
    pres_O2::NF
) where NF

Computes the maximum carboxylation capacity Vc_max [kgC/m²/s], following the coordination hypothesis (acclimation), see [23] Box 2. Note: this is not the same formula as in the [21] paper, this implementation is taken from the PALADYN code

References

  • [23] Harrison et al., New Phytologist (2021)
  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_albedo! — Method
compute_albedo!(
    out,
    i,
    j,
    grid,
    fields,
    albedo::DiagnosticAlbedo,
    vegetation::Union{Nothing, Terrarium.AbstractVegetation},
    snow::Union{Nothing, Terrarium.AbstractSnow},
    args...
)
source
Terrarium.compute_assimilation_factors — Method
compute_assimilation_factors(
    photo::LUEPhotosynthesis{NF},
    constants::MaterialConstants{NF},
    Γ_star::NF,
    T_stress::NF,
    Kc::NF,
    Ko::NF,
    pres_i::NF,
    pres_O2::NF
) where NF -> Tuple{Any, Any}

Computes factors for light-limited c_1 [kgC/mol] and RuBisCO-limited c_2 [dimensionless] assimilation. Follows [21, Eqs. (C4-C5)] and [22].

  • c1: quantum efficiency × temperature factor × carbon mass / denominator, used in JE = c1 × APAR
  • c2: dimensionless coefficient relating enzyme capacity to assimilation, used in JC = c2 × Vc_max

References

  • [22] Haxeltine & Prentice, Global Biogeochemical Cycles (1996)
  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)H
source
Terrarium.compute_autotrophic_respiration — Function
compute_autotrophic_respiration(
    i, j, grid, fields,
    autoresp::AbstractAutotrophicRespiration,
    vegcarbon::AbstractVegetationCarbonDynamics,
    atmos::AbstractAtmosphere,
    args...
)

Cell-level autotrophic respiration computation. Implementations should compute autotrophic respiration and related diagnostics (e.g. NPP) for the given cell.

source
Terrarium.compute_autotrophic_respiration — Method
compute_autotrophic_respiration(
    i,
    j,
    grid,
    fields,
    autoresp::PALADYNAutotrophicRespiration,
    vegcarbon_dynamics::PALADYNCarbonDynamics,
    phenology::Terrarium.AbstractPhenology,
    traits::PlantTraits,
    atmos::Terrarium.AbstractAtmosphere
) -> Tuple{Any, Any}

Compute autotrophic respiration following the scheme of [21].

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_auxiliary! — Function
compute_auxiliary!(
    state,
    grid,
    snow::SingleLayerSnow,
    constants::PhysicalConstants
)
compute_auxiliary!(
    state,
    grid,
    snow::SingleLayerSnow,
    constants::PhysicalConstants,
    timestepper::Union{Nothing, Terrarium.AbstractTimeStepper}
)

Diagnose the snow geometric properties (snow_depth, snow_cover_fraction) from the current snow water equivalent and bulk density, and the meltwater_flux from the liquid fraction if snow_water_equivalent is integrated explicitly by timestepper. Under implicit integration, meltwater_flux holds the drainage of the last implicit step instead (see implicit_update!).

source
Terrarium.compute_auxiliary! — Function
compute_auxiliary!(
    state,
    grid,
    evaporation::BareGroundEvaporation,
    ::NoCanopyInterception,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere
)
compute_auxiliary!(
    state,
    grid,
    evaporation::BareGroundEvaporation,
    ::NoCanopyInterception,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    soil::Union{Nothing, Terrarium.AbstractSoil}
)
compute_auxiliary!(
    state,
    grid,
    evaporation::BareGroundEvaporation,
    ::NoCanopyInterception,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    soil::Union{Nothing, Terrarium.AbstractSoil},
    snow::Union{Nothing, Terrarium.AbstractSnow}
)
source
Terrarium.compute_auxiliary! — Function
compute_auxiliary!(state, model::AbstractModel)

Compute updates to all auxiliary variables based on the current prognostic state of the model.

compute_auxiliary!(state, grid, process::AbstractProcess, args...)

Compute all auxiliary state variables for the given process on grid. Implementations of AbstractProcess may define additional args that correspond to different process coupling interfaces.

source
Terrarium.compute_auxiliary! — Function
compute_auxiliary!(
    state,
    grid,
    runoff::DirectSurfaceRunoff,
    canopy_interception::Terrarium.AbstractCanopyInterception,
    soil::Terrarium.AbstractSoil
)
compute_auxiliary!(
    state,
    grid,
    runoff::DirectSurfaceRunoff,
    canopy_interception::Terrarium.AbstractCanopyInterception,
    soil::Terrarium.AbstractSoil,
    snow::Union{Nothing, Terrarium.AbstractSnow},
    args...
)
source
Terrarium.compute_auxiliary! — Function
compute_auxiliary!(
    state,
    grid,
    veg::PrognosticVegetation,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere
)
compute_auxiliary!(
    state,
    grid,
    veg::PrognosticVegetation,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    soil::Union{Nothing, Terrarium.AbstractSoil},
    args...
)

Compute auxiliary variables for all vegetation component processes based on the given atmospheric inputs defined by atmos and (optionally) soil state. If soil = nothing, stress factors due to soil temperature and moisture availability will be ignored.

source
Terrarium.compute_auxiliary! — Function
compute_auxiliary!(state, grid, albedo::DiagnosticAlbedo)
compute_auxiliary!(
    state,
    grid,
    albedo::DiagnosticAlbedo,
    vegetation::Union{Nothing, Terrarium.AbstractVegetation}
)
compute_auxiliary!(
    state,
    grid,
    albedo::DiagnosticAlbedo,
    vegetation::Union{Nothing, Terrarium.AbstractVegetation},
    snow::Union{Nothing, Terrarium.AbstractSnow},
    args...
)

Diagnose the blended surface albedo and emissivity, weighting the bare-ground, vegetation, and snow values by the vegetated area fraction of the optional vegetation component and the snow-covered area fraction of the optional snow component.

source
Terrarium.compute_auxiliary! — Function
compute_auxiliary!(
    state,
    grid,
    hydrology::SurfaceHydrology,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere
)
compute_auxiliary!(
    state,
    grid,
    hydrology::SurfaceHydrology,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    soil::Union{Nothing, Terrarium.AbstractSoil}
)
compute_auxiliary!(
    state,
    grid,
    hydrology::SurfaceHydrology,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    soil::Union{Nothing, Terrarium.AbstractSoil},
    vegetation::Union{Nothing, Terrarium.AbstractVegetation}
)
compute_auxiliary!(
    state,
    grid,
    hydrology::SurfaceHydrology,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    soil::Union{Nothing, Terrarium.AbstractSoil},
    vegetation::Union{Nothing, Terrarium.AbstractVegetation},
    snow::Union{Nothing, Terrarium.AbstractSnow},
    args...
)
source
Terrarium.compute_auxiliary! — Function
compute_auxiliary!(
    state,
    grid,
    veg::PrescribedVegetation,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere
)
compute_auxiliary!(
    state,
    grid,
    veg::PrescribedVegetation,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    soil::Union{Nothing, Terrarium.AbstractSoil},
    args...
)

Compute auxiliary variables for all vegetation component processes based on the given atmospheric inputs defined by atmos and (optionally) soil state. If soil = nothing, stress factors due to soil temperature and moisture availability will be ignored.

source
Terrarium.compute_auxiliary! — Function
compute_auxiliary!(state, grid, seb::SurfaceEnergyBalance)
compute_auxiliary!(
    state,
    grid,
    seb::SurfaceEnergyBalance,
    vegetation::Union{Nothing, Terrarium.AbstractVegetation}
)
compute_auxiliary!(
    state,
    grid,
    seb::SurfaceEnergyBalance,
    vegetation::Union{Nothing, Terrarium.AbstractVegetation},
    snow::Union{Nothing, Terrarium.AbstractSnow},
    args...
)
source
Terrarium.compute_auxiliary! — Method
compute_auxiliary!(
    state,
    grid,
    rad::DiagnosedRadiativeFluxes,
    seb::Terrarium.AbstractSurfaceEnergyBalance,
    consts::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    args...
)
source
Terrarium.compute_auxiliary! — Method
compute_auxiliary!(
    state,
    grid,
    tur::DiagnosedTurbulentFluxes,
    seb::Terrarium.AbstractSurfaceEnergyBalance,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    args...
)
source
Terrarium.compute_auxiliary! — Method
compute_auxiliary!(
    state,
    grid,
    photo::LUEPhotosynthesis,
    stomcond::Terrarium.AbstractStomatalConductance,
    traits::PlantTraits,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    args...
)
source
Terrarium.compute_auxiliary! — Method
compute_auxiliary!(
    state,
    grid,
    stomcond::MedlynStomatalConductance,
    traits::PlantTraits,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    args...
)
source
Terrarium.compute_auxiliary! — Method
compute_auxiliary!(
    state,
    grid,
    autoresp::PALADYNAutotrophicRespiration,
    vegcarbon::Terrarium.AbstractVegetationCarbonDynamics,
    phenology::Terrarium.AbstractPhenology,
    traits::PlantTraits,
    atmos::Terrarium.AbstractAtmosphere
)
source
Terrarium.compute_auxiliary! — Method
compute_auxiliary!(
    state,
    grid,
    evapotranspiration::PALADYNCanopyEvapotranspiration,
    interception::Terrarium.AbstractCanopyInterception,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    soil::Terrarium.AbstractSoil,
    vegetation::Terrarium.AbstractVegetation,
    args...
)
source
Terrarium.compute_auxiliary! — Method
compute_auxiliary!(
    state,
    grid,
    phenol::PALADYNPhenology,
    vegcarbon::PALADYNCarbonDynamics,
    atmos::Terrarium.AbstractAtmosphere
)
source
Terrarium.compute_auxiliary! — Method
compute_auxiliary!(
    state,
    grid,
    rad::PrescribedRadiativeFluxes,
    seb::Terrarium.AbstractSurfaceEnergyBalance,
    atmos::Terrarium.AbstractAtmosphere,
    args...
)
source
Terrarium.compute_auxiliary! — Method
compute_auxiliary!(
    state,
    grid,
    soc::SinglePoolSoilCarbon,
    soil::Terrarium.AbstractSoil,
    args...
)

Compute the soil organic carbon respiration rate in each soil layer.

source
Terrarium.compute_auxiliary! — Method
compute_auxiliary!(
    state,
    grid,
    soil::SoilEnergyWaterCarbon,
    constants::PhysicalConstants
)

Compute auxiliary variables for soil energy, water, and carbon state variables on grid based on the given values in constants.

source
Terrarium.compute_auxiliary! — Method
compute_auxiliary!(
    state,
    grid,
    ghf::Terrarium.AbstractGroundHeatFlux,
    seb::Terrarium.AbstractSurfaceEnergyBalance,
    args...
)
source
Terrarium.compute_auxiliary! — Method
compute_auxiliary!(
    state,
    grid,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    soil::Terrarium.AbstractSoil,
    args...
) where NF
source
Terrarium.compute_balanced_leaf_area_index — Method
compute_balanced_leaf_area_index(
    vegcarbon_dynamics,
    traits,
    C_veg
)

Computes LAI_b, the balanced Leaf Area Index based on the vegetation carbon pool C_veg (assuming with bwl = 1), [21, Eqs. (76-79)].

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_boundary_advected_energy_tendency — Method
compute_boundary_advected_energy_tendency(
    i,
    j,
    k,
    grid,
    fields,
    saturation_tendency,
    energy::SoilThermodynamics,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
) where NF

Internal energy tendency C_w T φ G_s (W/m³) at i, j, k of water entering (G_s > 0) or leaving (G_s < 0) the cell through flux boundary conditions on saturation_water_ice, with G_s = saturation_tendency[i, j, k], porosity φ, and cell temperature T. Infiltration thus enters at the temperature of the top cell.

source
Terrarium.compute_boundary_advected_heat! — Method
compute_boundary_advected_heat!(
    state,
    grid,
    energy::SoilThermodynamics,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
) where NF

Add the sensible heat of water crossing the column boundaries through flux boundary conditions on saturation_water_ice (e.g. InfiltrationFlux) to the internal energy tendency (compute_boundary_advected_energy_tendency). Must be called right after the hydrology boundary conditions, while the saturation tendency holds only their contributions. No-op without water flow.

source
Terrarium.compute_boundary_advective_energy_tendency — Method
compute_boundary_advective_energy_tendency(
    i,
    j,
    k,
    grid,
    fields,
    energy::Terrarium.AbstractThermodynamics,
    args...
)

Compute the part of the internal energy tendency ∂U∂t at i, j, k due to the advective heat flux through the boundary faces of the column that remains explicit when the interior fluxes are integrated implicitly (see BackwardEuler). The default is zero, i.e. no heat is transported by a moving medium; see the method for soil water flow following the Richards equation.

source
Terrarium.compute_boundary_advective_energy_tendency — Method
compute_boundary_advective_energy_tendency(
    i,
    j,
    k,
    grid,
    fields,
    energy::SoilThermodynamics,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    args...
) where NF

Explicit advective energy tendency at i, j, k under Implicit time stepping: the heat of water entering the column through the boundary faces with the Darcy flux at tⁿ, at the temperature of the boundary cell. Outflow is implicit (compute_implicit_advection_tendency), so that it cannot remove more heat than a cell holds.

source
Terrarium.compute_boundary_conditions! — Function
compute_boundary_conditions!(state, model::AbstractModel)

Compute all internal and external boundary conditions for spatially explicit prognostic and auxiliary variables defined on the model. This should typically be invoked after compute_auxiliary! but before compute_tendencies!.

compute_boundary_conditions!(state, grid, process::AbstractProcess, args...)

Compute boundary conditions for all spatially explicit prognostic and auxiliary variables defined by the given process on grid.

source
Terrarium.compute_boundary_conditions! — Method
compute_boundary_conditions!(
    state,
    grid,
    soil::SoilEnergyWaterCarbon
)

Compute boundary conditions (and halo regions) for soil energy and hydrology. The sensible heat of water entering or leaving the column through flux boundary conditions on saturation_water_ice (e.g. InfiltrationFlux) is added to the energy tendency by compute_boundary_advected_heat!, after the hydrology boundary conditions (the saturation tendency then holds only their contribution).

source
Terrarium.compute_boundary_conditions! — Method
compute_boundary_conditions!(
    state,
    grid,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
) where NF

Fill the pressure_head halo and apply the top/bottom flux boundary conditions for saturation_water_ice. The fields passed to those boundary conditions are built explicitly here (rather than using state.inputs, which only carries declared input variables) so that a discrete-form condition like saturation_infiltration_bc can read auxiliary fields (infiltration) and per-horizon namespaces (via strat/bgc) that only exist once the full state does. infiltration is only merged in when present, since standalone (non-LandModel) configurations may not declare it at all.

source
Terrarium.compute_boundary_darcy_flux_divergence — Method
compute_boundary_darcy_flux_divergence(
    i,
    j,
    k,
    grid,
    fields
)

Part of the Darcy flux divergence at i, j, k due to the two boundary faces of the column (bottom face of cell k = 1, top face of cell k = Nz), omitting all interior faces:

(δ_{k,Nz} j_{w,k+½} - δ_{k,1} j_{w,k-½}) / Δz_k,

with j_w the darcy_flux. This is the explicit part when the interior fluxes are integrated implicitly (see BackwardEuler). The boundary fluxes are computed from the pressure_head halo: they vanish for the default (no-flux) conditions and carry the prescribed flux for a gradient condition on pressure_head. Flux boundary conditions on saturation_water_ice (e.g. InfiltrationFlux) are added separately by compute_boundary_conditions!.

source
Terrarium.compute_boundary_energy_tendency — Method
compute_boundary_energy_tendency(
    i,
    j,
    k,
    grid,
    fields,
    energy::Terrarium.AbstractThermodynamics,
    args...
)

Internal energy tendency ∂U∂t at i, j, k from the diffusive_heat_flux q through the boundary faces of the column only (bottom of k = 1, top of k = Nz):

∂U∂t = -(δ_{k,Nz} q_{k+½} - δ_{k,1} q_{k-½}) / Δz_k.

Zero for flux and no-flux conditions, whose halos have zero gradient (flux conditions are added separately); nonzero, e.g., for a gradient condition on temperature.

source
Terrarium.compute_canopy_interception — Method
compute_canopy_interception(
    canopy_interception::PALADYNCanopyInterception{NF},
    precip,
    LAI,
    SAI
) where NF

Compute I_can, the canopy rain interception, following [21, Eq. (42)].

References

  • [21] Willeit and Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_canopy_water_tendency — Method
compute_canopy_water_tendency(
    ::PALADYNCanopyInterception{NF},
    I_can,
    E_can,
    R_can
) where NF

Compute the W_can tendency and removal rate following [21, Eq. (41)].

References

  • [21] Willeit and Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_constant_temperature — Method
compute_constant_temperature(
    i,
    j,
    k,
    grid,
    fields,
    ::ConstantSoilTemperature
)

Initial temperature at cell (i, j, k) taken from the initial_surface_temperature (°C) field.

source
Terrarium.compute_energy_tendencies! — Method
compute_energy_tendencies!(
    tendencies,
    i,
    j,
    k,
    grid,
    fields,
    energy::SoilThermodynamics,
    ::Explicit,
    args...
)

Add the explicitly integrated part of the internal energy tendency at i, j, k when internal_energy is integrated explicitly, i.e. the full tendency (compute_energy_tendency).

source
Terrarium.compute_energy_tendencies! — Method
compute_energy_tendencies!(
    tendencies,
    i,
    j,
    k,
    grid,
    fields,
    energy::SoilThermodynamics,
    ::Implicit,
    args...
)

Add the explicitly integrated part of the internal energy tendency at i, j, k when internal_energy is integrated implicitly: the interior fluxes belong to the implicit operator, so only the diffusive fluxes through the boundary faces (compute_boundary_energy_tendency) and the heat of water entering through them (compute_boundary_advective_energy_tendency) remain.

source
Terrarium.compute_energy_tendency — Method
compute_energy_tendency(
    i,
    j,
    k,
    grid,
    fields,
    energy::Terrarium.AbstractThermodynamics,
    args...
)

Compute the internal energy tendency ∂U∂t as the divergence of the diffusive and advective heat fluxes,

∂U∂t = -∂z(q_diff + q_adv),

where q_diff is the diffusive_heat_flux and q_adv the advective_heat_flux (zero unless the soil water flows).

source
Terrarium.compute_evapotranspiration_conductances — Function
compute_evapotranspiration_conductances(
    i,
    j,
    grid,
    fields,
    evaporation::BareGroundEvaporation,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere
)
compute_evapotranspiration_conductances(
    i,
    j,
    grid,
    fields,
    evaporation::BareGroundEvaporation,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    soil::Union{Nothing, Terrarium.AbstractSoil}
)

Compute the skin-driven ground evaporation vapor conductance β/rₐ at grid cell i, j for the given bare-ground evaporation scheme. This conductance is independent of the skin temperature.

source
Terrarium.compute_evapotranspiration_conductances! — Function
compute_evapotranspiration_conductances!(
    out,
    i,
    j,
    grid,
    fields,
    evaporation::BareGroundEvaporation,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere
)
compute_evapotranspiration_conductances!(
    out,
    i,
    j,
    grid,
    fields,
    evaporation::BareGroundEvaporation,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    soil::Union{Nothing, Terrarium.AbstractSoil}
)

Compute and store the skin-driven ground evaporation vapor conductance on grid for the given bare-ground evaporation scheme.

source
Terrarium.compute_evapotranspiration_conductances! — Method
compute_evapotranspiration_conductances!(
    out,
    i,
    j,
    grid,
    fields,
    evapotranspiration::PALADYNCanopyEvapotranspiration,
    interception::Terrarium.AbstractCanopyInterception,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    soil::Terrarium.AbstractSoil,
    vegetation::Terrarium.AbstractVegetation,
    args...
)

Compute and store the skin-driven vapor conductances on grid for the given scheme evapotranspiration and process dependencies.

source
Terrarium.compute_evapotranspiration_conductances — Method
compute_evapotranspiration_conductances(
    i,
    j,
    grid,
    fields,
    evapotranspiration::PALADYNCanopyEvapotranspiration,
    interception::Terrarium.AbstractCanopyInterception,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    soil::Terrarium.AbstractSoil,
    vegetation::Terrarium.AbstractVegetation,
    args...
) -> Tuple{Any, Any, Any}

Compute the skin-driven vapor conductances (ground_evaporation_conductance, canopy_evaporation_conductance, and transpiration_conductance) at grid cell i, j for the given scheme evapotranspiration and process dependencies. These conductances are independent of the skin temperature.

source
Terrarium.compute_f_temp — Method
compute_f_temp(autoresp, T_air, T_soil)

Computes temperature factors f_temp_air and f_temp_soil for autotrophic respiration.

source
Terrarium.compute_gdd_tendency — Method
compute_gdd_tendency(phenol, gdd, T_air)

Compute the growing-degree-day tendency d(gdd)/dt [K⋅day/s] at a single grid point.

Heat above the base temperature is accumulated (in degree-days per second) and, below the base temperature, the accumulator relaxes toward zero with timescale gdd_relaxation_time. The relaxation provides a continuous surrogate for the discrete annual reset of the original scheme.

source
Terrarium.compute_ground_heat_flux! — Method
compute_ground_heat_flux!(
    out,
    i,
    j,
    grid,
    fields,
    ghf::DiagnosedGroundHeatFlux,
    skinT::Terrarium.AbstractSkinTemperature,
    seb::Terrarium.AbstractSurfaceEnergyBalance
)

Per-cell mutating variant used by the fused surface-energy-balance kernel: store the ground heat flux into the auxiliary output field out.

source
Terrarium.compute_ground_heat_flux! — Method
compute_ground_heat_flux!(
    out,
    i,
    j,
    grid,
    fields,
    ::PrescribedGroundHeatFlux,
    ::Terrarium.AbstractSkinTemperature,
    ::Terrarium.AbstractSurfaceEnergyBalance
)

The prescribed ground heat flux is an input field, so the fused surface-energy-balance kernel leaves it untouched.

source
Terrarium.compute_ground_heat_flux! — Method
compute_ground_heat_flux!(
    state,
    grid,
    ::PrescribedGroundHeatFlux,
    args...
)

The ground heat flux is a prescribed input variable, so there is nothing to diagnose.

source
Terrarium.compute_ground_heat_flux! — Method
compute_ground_heat_flux!(
    state,
    grid,
    ghf::Terrarium.AbstractGroundHeatFlux,
    skinT::Terrarium.AbstractSkinTemperature,
    seb::Terrarium.AbstractSurfaceEnergyBalance
)

Compute and store ground_heat_flux on grid, dispatching on ghf and skinT to the type-specific kernel function. For PrescribedGroundHeatFlux this is a no-op, since the field is an input.

source
Terrarium.compute_ground_heat_flux — Method
compute_ground_heat_flux(
    i,
    j,
    grid,
    fields,
    ::DiagnosedGroundHeatFlux,
    skinT::ImplicitSkinTemperature,
    ::Terrarium.AbstractSurfaceEnergyBalance
)

Compute the conductive ground heat flux from the current skin_temperature and ground_temperature.

source
Terrarium.compute_ground_heat_flux — Method
compute_ground_heat_flux(
    i,
    j,
    grid,
    fields,
    ghf::DiagnosedGroundHeatFlux,
    ::PrescribedSkinTemperature,
    seb::Terrarium.AbstractSurfaceEnergyBalance
)

For PrescribedSkinTemperature, set the ground heat flux directly to the demand, i.e. G₀ = R_net + H_s + H_l.

source
Terrarium.compute_ground_heat_flux_demand — Function
compute_ground_heat_flux_demand(ghf::AbstractGroundHeatFlux, args...)

Return the ground heat flux demanded by the rest of the surface energy balance, which the skin temperature schemes invert their conduction relations against.

source
Terrarium.compute_ground_heat_flux_demand — Method
compute_ground_heat_flux_demand(
    i,
    j,
    grid,
    fields,
    ghf::DiagnosedGroundHeatFlux,
    seb::Terrarium.AbstractSurfaceEnergyBalance
)

Compute the ground heat flux demand at grid cell i, j: the flux implied by the radiative budget and the turbulent fluxes, G = R_net + H_s + H_l. This is the quantity the implicit skin temperature solve inverts its conduction relation against. The radiative and turbulent flux terms are read through the accessors of the seb sub-processes that own them.

source
Terrarium.compute_ground_heat_flux_demand — Method
compute_ground_heat_flux_demand(
    i,
    j,
    grid,
    fields,
    ghf::PrescribedGroundHeatFlux,
    ::Terrarium.AbstractSurfaceEnergyBalance
)

When the ground heat flux is prescribed, the demand is the prescribed flux; the surface energy budget is not re-closed from the radiative and turbulent terms.

source
Terrarium.compute_ground_heat_flux_demand — Method
compute_ground_heat_flux_demand(
    ::DiagnosedGroundHeatFlux,
    R_net,
    H_s,
    H_l
)

Compute the residual ground heat flux that would close the surface energy balance. With all fluxes positive upward (aligned with +z), the energy arriving at the skin from below must balance the radiative and turbulent losses above, so G = R_net + H_s + H_l.

source
Terrarium.compute_heat_advection_timescale — Method
compute_heat_advection_timescale(
    i,
    j,
    k,
    grid,
    fields,
    energy::SoilThermodynamics,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
) where NF

Kernel function returning the advective timescale $τ = C Δz / (C_w |j_w|)$ at cell i, j, k, with C the bulk volumetric heat capacity of the cell, C_w that of liquid water, and |j_w| the larger magnitude of the darcy_flux through the two faces of the cell. This is the stability limit of the explicit upwind advection, which changes the cell temperature at the rate C_w j_w / C (m/s). Cells without flow return Inf.

source
Terrarium.compute_hydraulic_diffusion_timescale — Method
compute_hydraulic_diffusion_timescale(
    i,
    j,
    k,
    grid,
    fields,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
) where NF

Kernel function returning the hydraulic diffusion timescale $Δz² (∂θ/∂ψ) / K$ at cell i, j, k. The hydraulic conductivity K is evaluated at the cell centre from the local soil composition; the specific moisture capacity ∂θ/∂ψ is the analytic derivative of the soil-water retention curve (from FreezeCurves) evaluated at the matric potential ψₘ, reconstructed from the stored total pressure_head by removing its hydrostatic and elevation components. Cells with zero hydraulic conductivity (fully dry or frozen) impose no restriction and return Inf.

source
Terrarium.compute_hydraulics! — Function
compute_hydraulics!(state, grid, hydrology::SoilHydrology, soil::AbstractSoil, args...)

Compute all state-dependent hydraulic auxiliaries such as hydraulic conductivity and field capacity, and wilting point.

source
Terrarium.compute_hydraulics! — Method
compute_hydraulics!(
    out,
    i,
    j,
    k,
    grid,
    fields,
    hydrology::SoilHydrology,
    args...
)

Kernel function that computes dynamic soil hydraulic properties.

source
Terrarium.compute_hydraulics! — Method
compute_hydraulics!(
    out,
    i,
    j,
    k,
    grid,
    fields,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
) where NF

Computes the unsaturated hydraulic conductivity for RichardsEq configurations of SoilHydrology.

source
Terrarium.compute_implicit_advection_diagonal — Method
compute_implicit_advection_diagonal(
    i,
    j,
    k,
    grid,
    face_velocity,
    Δt
)

Upwind advection part of the main diagonal of row k, Δt (max(u_{k+½}, 0) - min(u_{k-½}, 0)) / Δz^c_k, i.e. the outflow of ϕ_k through both faces, including the boundary faces of the column. It is nonnegative, which with the nonpositive advective off-diagonals keeps the system an M-matrix.

source
Terrarium.compute_implicit_advection_lower_diagonal — Method
compute_implicit_advection_lower_diagonal(
    i,
    j,
    k′,
    grid,
    face_velocity,
    Δt
)

Upwind advection part of the lower diagonal at index k′ (row k = k′ + 1), -Δt max(u_{k-½}, 0) / Δz^c_k: an upward velocity through the lower face carries ϕ_{k-1} into cell k. Zero at the bottom (k = 1).

source
Terrarium.compute_implicit_advection_tendency — Method
compute_implicit_advection_tendency(
    i,
    j,
    k,
    grid,
    face_velocity,
    ϕ
)

Advective tendency -[∂z(u ϕ_up)]_k, the rate of change of the conserved quantity from the upwind fluxes (compute_implicit_advective_flux) through the faces of cell k, used for the conservative update after each solve. Through the boundary faces of the column only the outflow u ϕ_k is included; the inflow enters through the right-hand side. Zero without advection (face_velocity = nothing).

source
Terrarium.compute_implicit_advection_upper_diagonal — Method
compute_implicit_advection_upper_diagonal(
    i,
    j,
    k,
    grid,
    face_velocity,
    Δt
)

Upwind advection part of the upper diagonal of row k, Δt min(u_{k+½}, 0) / Δz^c_k: a downward velocity through the upper face carries ϕ_{k+1} into cell k. Zero at the top (k = Nz).

source
Terrarium.compute_implicit_advective_flux — Method
compute_implicit_advective_flux(
    i,
    j,
    k,
    grid,
    face_velocity,
    ϕ
)

First-order upwind advective flux u ϕ_up through face i, j, k, with ϕ_up taken from the cell below the face (k - 1) for u > 0 and above it (k) otherwise, as in the coefficients of the TridiagonalOperator.

source
Terrarium.compute_implicit_advective_velocity! — Method
compute_implicit_advective_velocity!(face_velocity, i, j, k, grid, fields, energy, hydrology)

Store the advective face velocity C_w j_w (W/m²/K) of the implicit heat operator at face i, j, k in face_velocity, and at the top boundary face for k = Nz, with j_w the water flux (m/s) of the step through the face (compute_advective_water_flux) and C_w the volumetric heat capacity of liquid water, as in the explicit advective_heat_flux. Through the boundary faces, the operator uses only the outflow (see TridiagonalOperator). A no-op without advection (face_velocity = nothing).

source
Terrarium.compute_implicit_capacity! — Method
compute_implicit_capacity!(
    diagonal_coefficient,
    i,
    j,
    k,
    grid,
    fields,
    energy::SoilThermodynamics,
    ::FreeWater,
    hydrology::Terrarium.AbstractSoilHydrology,
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry,
    constants::PhysicalConstants
)

Store the regularized apparent heat capacity C_app (J/m³/K) at cell i, j, k in diagonal_coefficient, for the FreeWater freeze curve,

C_app = C + C_pc    if 0 < F < 1 (phase change),
C_app = C           otherwise,

where C is the bulk heat capacity, F the liquid water fraction of the current iterate, and C_pc = 1.5 × 10⁸ J/m³/K a fixed regularization of the latent heat term (a Dirac delta at 0 °C for FreeWater). C_pc only damps the temperature change of phase-change cells between iterates and does not enter the conservative energy update. It is not applied to fully frozen or thawed cells, where it would slow the lagged temperature of cells that keep cooling (warming) and overestimate their conductive fluxes.

source
Terrarium.compute_implicit_capacity! — Method
compute_implicit_capacity!(
    diagonal_coefficient,
    i,
    j,
    k,
    grid,
    fields,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
) where NF

Store the specific moisture capacity C = ∂θ/∂ψ (1/m) of the current iterate at cell i, j, k in diagonal_coefficient (compute_specific_moisture_capacity), bounded below by minimum_moisture_capacity.

source
Terrarium.compute_implicit_conductivity! — Method
compute_implicit_conductivity!(
    face_conductivity,
    i,
    j,
    k,
    grid,
    fields,
    energy::SoilThermodynamics,
    hydrology::Terrarium.AbstractSoilHydrology,
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
)

Store the lagged thermal conductivity at face i, j, k in face_conductivity, interpolated as in the explicit diffusive_heat_flux.

source
Terrarium.compute_implicit_conductivity! — Method
compute_implicit_conductivity!(
    face_conductivity,
    i,
    j,
    k,
    grid,
    fields,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})}
) where NF

Store the hydraulic conductivity (m/s) of the current iterate at face i, j, k in face_conductivity, as in the explicit darcy_flux (darcy_conductivity).

source
Terrarium.compute_implicit_diffusion_lower_diagonal — Method
compute_implicit_diffusion_lower_diagonal(
    i,
    j,
    k′,
    grid,
    face_conductivity,
    Δt
)

Lower diagonal at index k′, which multiplies ϕ_{k′} in row k = k′ + 1 (the BatchedTridiagonalSolver convention): lower_{k′} = -Δt κ_{k-½} / (Δz^c_k Δz^f_{k-½}), zero at the bottom (k = 1).

source
Terrarium.compute_implicit_diffusion_tendency — Method
compute_implicit_diffusion_tendency(
    i,
    j,
    k,
    grid,
    face_conductivity,
    ϕ
)

Diffusive tendency [∂z(κ ∂z ϕ)]_k, the rate of change of the conserved quantity from the diffusive fluxes through the interior faces of cell k only (consistent with the masked coefficients), used for the conservative update after each solve. Mirrors the explicit diffusive_heat_flux with the lagged face_conductivity.

source
Terrarium.compute_implicit_energy_rhs — Method
compute_implicit_energy_rhs(
    i,
    j,
    k,
    grid,
    fields,
    diagonal_coefficient,
    explicit_energy
)

Right-hand side C_app Tᵐ - Uᵐ + U⁺ of the linearized system at iterate m of the implicit solver, with C_app = diagonal_coefficient and U⁺ = explicit_energy.

source
Terrarium.compute_implicit_energy_update — Method
compute_implicit_energy_update(
    i,
    j,
    k,
    grid,
    face_conductivity,
    face_velocity,
    temperature,
    explicit_energy,
    Δt
)

Conservative energy update U = U⁺ + Δt (Q_diff + Q_adv) at i, j, k from the implicit heating rates (W/m³) of conduction, Q_diff = ∂z(κ ∂z T) through the interior faces (compute_implicit_diffusion_tendency), and of advection, Q_adv = -∂z(C_w j_w T_up) through the interior faces and the boundary outflow (compute_implicit_advection_tendency), with U⁺ = explicit_energy, κ = face_conductivity, and C_w j_w = face_velocity (nothing without water flow).

source
Terrarium.compute_implicit_heat_coefficients! — Method
compute_implicit_heat_coefficients!(
    out,
    i,
    j,
    k,
    grid,
    fields,
    energy::SoilThermodynamics,
    fc::FreeWater,
    hydrology::Terrarium.AbstractSoilHydrology,
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry,
    constants::PhysicalConstants
)

Store the lagged apparent heat capacity (compute_implicit_capacity!), face conductivity (compute_implicit_conductivity!), and, with water flow, advective face velocity (compute_implicit_advective_velocity!) at i, j, k in out.diagonal_coefficient, out.face_conductivity, and out.face_velocity.

source
Terrarium.compute_implicit_linear_coefficient — Method
compute_implicit_linear_coefficient(i, j, k, grid, args...)

Coefficient L_k (1/s) of an implicit linear term L ϕ in row k, e.g. a linear sink or a linearized boundary flux; zero by default. args are the trailing arguments of solve! after Δt, for dispatch. A nonzero L must also enter the conservative update as Δt L ϕ.

source
Terrarium.compute_implicit_meltwater_coefficients! — Method
compute_implicit_meltwater_coefficients!(
    out,
    i,
    j,
    grid,
    fields,
    explicit_water,
    snow::SingleLayerSnow{NF},
    constants::PhysicalConstants,
    Δt
) where NF

Diagonal G′(θᵐ) and right-hand side G′(θᵐ) θᵐ − G(θᵐ) at grid cell i, j of the Newton step for the liquid fraction, with G(θ) = W_i / (1 − θ) + Δt M_r(θ, W_i / (1 − θ)) − W⁺, the storage-limited outflow M_r (compute_meltwater_outflow), the ice content W_i (compute_snow_ice_content), and W⁺ = explicit_water. The linearization point is the liquid fraction 1 − W_i / Wᵐ of the current iterate, bounded to [0, θ⁺]. The coefficients are the identity for a pack without ice or snow, which compute_implicit_snow_water_update! treats separately.

source
Terrarium.compute_implicit_saturation_update — Method
compute_implicit_saturation_update(
    i,
    j,
    k,
    grid,
    fields,
    face_conductivity,
    explicit_saturation,
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry,
    Δt
)

Saturation ξ = ξ⁺ + Δt Q_diff / φ at i, j, k, with Q_diff = ∂z(K ∂z Ψ) (1/s) through the interior faces (compute_implicit_diffusion_tendency), ξ⁺ = explicit_saturation, and K = face_conductivity.

source
Terrarium.compute_implicit_snow_water_update! — Method
compute_implicit_snow_water_update!(
    out,
    i,
    j,
    grid,
    fields,
    explicit_water,
    snow::SingleLayerSnow{NF},
    constants::PhysicalConstants,
    Δt
) where NF

Snow water equivalent W = W_i / (1 − θ) at grid cell i, j from the solved liquid fraction θ = snow_liquid_fraction, bounded to [min(L_c, θ⁺), θ⁺] with the capillary retention L_c, so that W ≤ W⁺ = explicit_water and a Newton step that undershoots the root at the switch between the branches of the outflow drains neither ice nor capillary water, and the drainage meltwater_flux = (W⁺ − W) / Δt. A pack without ice (W_i = 0) takes the exact solution W = max(W⁺ − Δt K_sat, W⁺ / (1 + Δt (1 − L_c) / τ_m)) of its step, and a step without snow (W⁺ ≤ 0) leaves W = W⁺.

source
Terrarium.compute_implicit_water_flow_coefficients! — Method
compute_implicit_water_flow_coefficients!(
    out,
    i,
    j,
    k,
    grid,
    fields,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
) where NF

Store the capacity (compute_implicit_capacity!) and face conductivity (compute_implicit_conductivity!) at i, j, k in out.

source
Terrarium.compute_implicit_water_flow_rhs — Method
compute_implicit_water_flow_rhs(
    i,
    j,
    k,
    grid,
    fields,
    diagonal_coefficient,
    explicit_saturation,
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
)

Right-hand side C Ψᵐ - φ (ξᵐ - ξ⁺) at i, j, k, with C = diagonal_coefficient and ξ⁺ = explicit_saturation.

source
Terrarium.compute_implicit_water_flux — Method
compute_implicit_water_flux(
    i,
    j,
    k,
    grid,
    water_flux,
    face_conductivity,
    pressure_head
)

Darcy flux q = -K ∂z Ψ (m/s, positive upward) at interior face i, j, k, with K = face_conductivity; at the bottom face, the current water_flux (from tⁿ) is kept.

source
Terrarium.compute_infiltration — Method
compute_infiltration(
    runoff::DirectSurfaceRunoff{NF},
    influx,
    sat_top,
    max_infil
) where NF

Compute infiltration from the given influx (water available for infiltration), saturation of the uppermost soil layer sat_top, and the maximum allowed infiltration max_infil.

source
Terrarium.compute_kinetic_parameters — Method
compute_kinetic_parameters(
    photo::LUEPhotosynthesis{NF},
    T_air::NF
) where NF -> Tuple{Any, Any, Any}

Computes kinetic parameters τ, Kc, Ko based on temperature using Q10 temperature response. Follows enzyme kinetics from [22], Appendix C.

  • τ: Rubisco specificity factor (CO₂ to O₂ carboxylation ratio), dimensionless
  • Kc: Michaelis-Menten constant for CO₂ [Pa]
  • Ko: Michaelis-Menten constant for O₂ [Pa]

References

  • [22] Haxeltine & Prentice, Global Biogeochemical Cycles (1996)
source
Terrarium.compute_latent_heat_flux — Method
compute_latent_heat_flux(
    ::DiagnosedTurbulentFluxes,
    Q_h,
    ρₐ,
    L
)

Compute the latent heat flux as a function of the humidity flux Q_h [m/s], the density ρₐ [kg/m³] of air, and the specific latent heat of vaporization or sublimation L [J/kg].

source
Terrarium.compute_latent_heat_flux — Method
compute_latent_heat_flux(
    i,
    j,
    grid,
    fields,
    tur::DiagnosedTurbulentFluxes{NF},
    skinT::Terrarium.AbstractSkinTemperature,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere
) where NF
compute_latent_heat_flux(
    i,
    j,
    grid,
    fields,
    tur::DiagnosedTurbulentFluxes{NF},
    skinT::Terrarium.AbstractSkinTemperature,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    surface_hydrology::Union{Nothing, Terrarium.AbstractSurfaceHydrology}
) where NF
compute_latent_heat_flux(
    i,
    j,
    grid,
    fields,
    tur::DiagnosedTurbulentFluxes{NF},
    skinT::Terrarium.AbstractSkinTemperature,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    surface_hydrology::Union{Nothing, Terrarium.AbstractSurfaceHydrology},
    snow::Union{Nothing, Terrarium.AbstractSnow}
) where NF

Compute the latent heat flux at i, j based on the current skin temperature and atmospheric conditions. When an evapotranspiration scheme is provided, uses the ET-aware humidity flux; otherwise uses bare ground evaporation.

With a snow component, the flux is partitioned by snow-covered area fraction f_snow: the snow-free fraction (1 − f_snow) evaporates from the ground/canopy (latent heat of vaporization), while the snow-covered fraction sublimates from the snowpack (latent heat of sublimation, see compute_snow_sublimation_flux). Without snow it reduces to the bare ground/canopy latent flux.

source
Terrarium.compute_leaf_area_index — Method
compute_leaf_area_index(phenol, ϕ, LAI_b)

Compute the instantaneous leaf area index LAI = ϕ·LAI_b from the phenology factor ϕ and the balanced leaf area index LAI_b.

source
Terrarium.compute_leaf_carbon — Method
compute_leaf_carbon(vegcarbon_dynamics, traits, LAI_b)

Computes the leaf carbon C_leaf = LAI_b / SLA (kgC/m²) implied by the balanced Leaf Area Index LAI_b and the specific leaf area SLA, [21, Eqs. (76-79)]. Together with compute_root_carbon and compute_stem_carbon, this partitions the single vegetation carbon pool, C_leaf + C_root + C_stem = C_veg; the tissue pools are diagnostic, not prognostic.

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_longwave_up — Method
compute_longwave_up(::DiagnosedRadiativeFluxes, constants::PhysicalConstants, L_down, Ts, ϵ)

Compute outgoing longwave radiation from incoming longwave radiation L_down, surface temperature Ts, and emissivity ϵ.

source
Terrarium.compute_matric_potential — Method
compute_matric_potential(i, j, k, grid, fields)

Matric potential ψₘ = Ψ - ψ_h - ψ_z (m) at cell i, j, k, reconstructed from the total pressure_head Ψ by removing the hydrostatic head ψ_h = max(0, z₀ - z) below the water table z₀ and the elevation head ψ_z = z - z_ref relative to the soil surface z_ref, as in SoilSaturationPressureClosure.

source
Terrarium.compute_meltwater_flux! — Method
compute_meltwater_flux!(
    out,
    i,
    j,
    grid,
    fields,
    snow::SingleLayerSnow,
    ::Explicit
)

Store the storage-limited Darcy-type meltwater outflow M_r (m/s SWE) at grid cell i, j in meltwater_flux, evaluated at the diagnosed liquid water fraction and the snow water equivalent of the pack (see compute_meltwater_outflow). A no-op under implicit integration of snow_water_equivalent, where the implicit step sets it.

source
Terrarium.compute_meltwater_outflow — Method
compute_meltwater_outflow(
    hydraulics::ConstantSnowHydraulics,
    θ_liq::NF,
    W_snow::NF
) where NF

Meltwater outflow M_r (m/s, SWE) from a snowpack with snow water equivalent W_snow (m). Liquid water in excess of the capillary retention L_c drains from the snowpack with a cubic conductivity [5] (in excess-saturation form), K_sat · S*³ with S* = max(θ_liq − L_c, 0) / (1 − L_c), where θ_liq is the liquid fraction of the water substance. This Darcy rate does not depend on the amount of water in the pack, so it is additionally limited by the excess liquid water depth max(θ_liq − L_c, 0) · W_snow drained over the timescale τ_m:

M_r = min(K_sat · S*³, max(θ_liq − L_c, 0) · max(W_snow, 0) / τ_m)

Outflow vanishes smoothly as θ_liq → L_c or W_snow → 0, so a thin pack cannot drain more water than it stores; explicit time steps should not exceed τ_m.

References

  • [5] Tarboton, Chowdhury and Jackson (1994)
source
Terrarium.compute_meltwater_outflow_derivative — Method
compute_meltwater_outflow_derivative(
    hydraulics::ConstantSnowHydraulics,
    θ_liq::NF,
    W_ice::NF
) where NF

Derivative dM_r/dθ_liq (m/s) of the meltwater outflow (compute_meltwater_outflow) with respect to the liquid fraction θ_liq at a fixed ice content W_ice (m SWE), i.e. with the snow water equivalent W_snow = W_ice / (1 − θ_liq). It is the derivative of the active branch of the outflow: 3 K_sat S*² / (1 − L_c) where the Darcy rate is the smaller one, and W_ice (1 − L_c) / (τ_m (1 − θ_liq)²) where the storage limit is; zero below the capillary retention L_c. Requires θ_liq < 1.

source
Terrarium.compute_phenology — Function
compute_phenology(i, j, grid, fields, phenol::AbstractPhenology, atmos::AbstractAtmosphere)

Cell-level phenology computation. Implementations return phenology factors and derived LAI at the given index i, j, using atmospheric inputs (e.g. air temperature) where required by the scheme.

source
Terrarium.compute_phenology — Method
compute_phenology(
    i,
    j,
    grid,
    fields,
    phenol::PALADYNPhenology,
    atmos::Terrarium.AbstractAtmosphere
) -> Tuple{Any, Any}

Compute the phenology factor and instantaneous leaf area index (LAI) at a single grid point.

source
Terrarium.compute_phenology_factor — Method
compute_phenology_factor(phenol, gdd, T_air)

Compute the phenology factor ϕ [-] from accumulated growing degree days gdd and air temperature T_air.

The cold-deciduous factor combines the growth-phase ramp gdd / gdd_crit [21, Eq. (83)] with a senescence ramp that declines linearly from 1 at T_gdd_base to 0 at T_gdd_base − T_senescence_range. Taking the minimum reproduces all three PALADYN regimes (linear green-up, held at 1 when mature and warm, temperature-driven senescence). The result is then blended with the evergreen value of 1 via the prescribed deciduous fraction.

source
Terrarium.compute_photosynthesis — Function
compute_photosynthesis(i, j, grid, fields, photo::AbstractPhotosynthesis, atmos::AbstractAtmosphere)

Cell-level photosynthesis computation. Implementations compute leaf respiration and net assimilation for a single horizontal cell and return the pair (Rd, An, GPP) or similar outputs as required by the photosynthesis scheme.

source
Terrarium.compute_photosynthesis! — Method
compute_photosynthesis!(
    out,
    i,
    j,
    grid,
    fields,
    photo::LUEPhotosynthesis,
    stomcond::Terrarium.AbstractStomatalConductance,
    traits::PlantTraits,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere
)

Calls compute_photosynthesis and stores the results in out.

source
Terrarium.compute_photosynthesis — Method
compute_photosynthesis(
    i,
    j,
    grid,
    fields,
    photo::LUEPhotosynthesis,
    stomcond::Terrarium.AbstractStomatalConductance,
    traits::PlantTraits,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere
) -> Tuple{Any, Any, Any}

Compute photosynthesis, leaf respiration, and gross primary production at a single grid point. Returns instantaneous rates in (kgC/m²/s) for integration by the timestepper.

source
Terrarium.compute_plant_available_water — Function
compute_plant_available_water(
    i, j, k, grid, fields,
    paw::AbstractPlantAvailableWater,
    soil::AbstractSoil
)

Comptue the plant-available water fraction for grid cell i, j and soil layer k.

source
Terrarium.compute_plant_available_water! — Method
compute_plant_available_water!(
    out,
    i,
    j,
    k,
    grid,
    fields,
    paw::FieldCapacityLimitedPAW{NF},
    strat::Terrarium.AbstractStratigraphy,
    hydrology::Terrarium.AbstractSoilHydrology,
    bgc::Terrarium.AbstractSoilBiogeochemistry,
    args...
) where NF

Mutating wrapper for compute_plant_available_water that stores the result in out.

source
Terrarium.compute_plant_available_water — Method
compute_plant_available_water(
    i,
    j,
    k,
    grid,
    fields,
    paw::FieldCapacityLimitedPAW{NF},
    strat::Terrarium.AbstractStratigraphy,
    hydrology::Terrarium.AbstractSoilHydrology,
    bgc::Terrarium.AbstractSoilBiogeochemistry
) where NF

Compute the plant avaialble water given the current soil stratigraphy, hydrology, and biogeochemistry state in fields.

source
Terrarium.compute_precip_ground — Method
compute_precip_ground(
    ::PALADYNCanopyInterception{NF},
    precip,
    I_can,
    R_can
)

Compute rainfall_ground, the rate of rain reaching the ground, following a modified version of [21, Eq. (44)]. Instead of subtracting the tendency, we just directly subtract interception and add the removal rate R_can.

References

  • [21] Willeit and Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_pres_i — Method
compute_pres_i(photo::LUEPhotosynthesis, λc, pres_a)

Computes intercellular CO2 partial pressure [Pa], [21, Eq. (67)].

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_quasi_steady_state_temperature — Method
compute_quasi_steady_state_temperature(
    i,
    j,
    k,
    grid,
    fields,
    init::QuasiThermalSteadyState
)

Quasi-steady-state temperature T₀ - Qgeo / k_eff * z at cell (i, j, k) from the initial_surface_temperature (°C) and geothermal_heat_flux (W/m²) fields.

source
Terrarium.compute_radiative_fluxes! — Method
compute_radiative_fluxes!(
    out,
    i,
    j,
    grid,
    fields,
    rad::PrescribedRadiativeFluxes,
    atmos::Terrarium.AbstractAtmosphere,
    args...
)

Compute net radiation and store in auxiliary fields at a grid point.

source
Terrarium.compute_redistributed_heat! — Method
compute_redistributed_heat!(out, i, j, k, grid, fields, energy, strat, bgc, k_source, Δs)

Change out.internal_energy of cell i, j, k by the sensible heat C_w T φ Δs of a saturation change Δs by redistributed water, with C_w the water heat capacity of the energy process, φ the porosity of cell k, and T the temperature of the cell k_source that the water leaves. A no-op without a SoilThermodynamics energy process.

source
Terrarium.compute_relative_leaf_area — Method
compute_relative_leaf_area(
    i,
    j,
    grid,
    fields,
    traits::PlantTraits{NF}
) where NF

Return the leaf area index at grid point i, j relative to the maximum leaf area index of the given plant traits, LAI / LAI_max, clamped to the unit interval.

source
Terrarium.compute_resp10 — Method
compute_resp10(autoresp)

Computes resp10, the tissue respiration rate at 10 °C per unit tissue nitrogen (kgC/kgN/day).

This is a placeholder that returns the constant parameter resp10. In PALADYN ([21]), the rate of tree PFTs varies with the temperature of the coldest month, between 0.011 for tropical and 0.066 kgC/kgN/day for extratropical trees.

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_respiration! — Method
compute_respiration!(
    out,
    i,
    j,
    k,
    grid,
    fields,
    soc::SinglePoolSoilCarbon{NF},
    soil::Terrarium.AbstractSoil
) where NF

Compute the respiration rate at index i, j, k and store it in out.respiration_rate.

source
Terrarium.compute_respiration_assimilation — Method
compute_respiration_assimilation(
    photo::LUEPhotosynthesis{NF},
    traits::PlantTraits{NF},
    constants::MaterialConstants{NF},
    T_air::NF,
    swdown::NF,
    pres::NF,
    co2::NF,
    LAI::NF,
    λc::NF,
    β::NF
) where NF -> Tuple{Any, Any}

Compute and return leaf respiration [kgC/m²/s] and net assimilation [kgC/m²/s] rates.

source
Terrarium.compute_respiration_rate — Method
compute_respiration_rate(
    resp::Terrarium.SoilCarbonRespiration{NF},
    C,
    T
) where NF

Compute the decomposition (heterotrophic respiration) rate (kg/m³/s) of soil organic carbon with density C (kg/m³) at temperature T (°C), R = kref ⋅ Q10^((T - Tref) / 10) ⋅ C.

source
Terrarium.compute_root_carbon — Method
compute_root_carbon(vegcarbon_dynamics, traits, LAI_b)

Computes the fine root carbon C_root (kgC/m²) implied by the balanced Leaf Area Index LAI_b. Root carbon is assumed equal to leaf carbon (see compute_leaf_carbon), [21, Eqs. (76-79)].

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_saturation_boundary_flux — Method
compute_saturation_boundary_flux(
    bc::Oceananigans.BoundaryConditions.BoundaryCondition{<:Flux},
    i,
    j,
    grid,
    clock,
    fields
)

Kernel function returning the flux (positive upward) of the flux boundary condition bc on saturation_water_ice at column i, j, and zero for other boundary conditions.

source
Terrarium.compute_saturation_closure! — Method
compute_saturation_closure!(
    state,
    grid,
    closure::SoilSaturationPressureClosure,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    soil::Terrarium.AbstractSoil,
    runoff::Union{Nothing, Terrarium.AbstractSurfaceRunoff},
    energy::Union{Nothing, Terrarium.AbstractSoilThermodynamics}
) where NF

Saturation–pressure closure of a Richards-equation hydrology: redistribute over- and undersaturation (adjust_saturation_profile!), routing surface excess water to runoff and moving the heat of the redistributed water in the internal_energy of energy (either may be nothing to skip the routing or the heat transfer), then update the water table and compute the pressure_head. Shared by closure! and the implicit Richards step, whose intermediate iterations skip the routing and the heat transfer.

source
Terrarium.compute_saturation_tendency! — Function
compute_saturation_tendency!(
    saturation_water_ice_tendency,
    i,
    j,
    k,
    grid,
    clock,
    fields,
    hydrology::SoilHydrology,
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry,
    constants::PhysicalConstants,
    evtr::Union{Nothing, Terrarium.AbstractEvapotranspiration}
)
compute_saturation_tendency!(
    saturation_water_ice_tendency,
    i,
    j,
    k,
    grid,
    clock,
    fields,
    hydrology::SoilHydrology,
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry,
    constants::PhysicalConstants,
    evtr::Union{Nothing, Terrarium.AbstractEvapotranspiration},
    timestepping::Timestepping
)
source
Terrarium.compute_sensible_heat_flux — Method
compute_sensible_heat_flux(
    i,
    j,
    grid,
    fields,
    tur::DiagnosedTurbulentFluxes,
    skinT::Terrarium.AbstractSkinTemperature,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere
)

Compute the sensible heat flux at i, j based on the current skin temperature and atmospheric conditions.

source
Terrarium.compute_sensible_heat_flux — Method
compute_sensible_heat_flux(
    ::DiagnosedTurbulentFluxes,
    Q_T,
    ρₐ,
    cₐ
)

Compute the sensible heat flux [W/m²] as a function of the bulk aerodynamic temperature gradient Q_T [K m/s] and the density ρₐ [kg/m³] and specific heat capacity cₐ [J/kg K] of air.

source
Terrarium.compute_shortwave_up — Method
compute_shortwave_up(::DiagnosedRadiativeFluxes, S_down, α)

Compute outgoing shortwave radiation from the incoming shortwave radiation S_down and albedo α.

source
Terrarium.compute_skin_temperature — Method
compute_skin_temperature(
    i,
    j,
    grid,
    fields,
    skinT::ImplicitSkinTemperature{NF},
    seb::Terrarium.AbstractSurfaceEnergyBalance,
    constants::PhysicalConstants,
    snow::Terrarium.AbstractSnow
) where NF

Invert the (linear) area-weighted conduction relation for the implicit skin temperature Ts given the atmosphere-side demanded flux G (see compute_ground_heat_flux_demand), by equating G to the area-weighted sum of the unblended ground and snow-top conductive fluxes, (1 − f_snow)·2κg(Tg − Ts)/Δzg + f_snow·2κsnow(Tsnow − Ts)/dsnow.

source
Terrarium.compute_skin_temperature — Method
compute_skin_temperature(
    i,
    j,
    grid,
    fields,
    skinT::ImplicitSkinTemperature{NF},
    seb::Terrarium.AbstractSurfaceEnergyBalance,
    args...
) where NF

Invert the (linear) ground-only conduction relation for the implicit skin temperature Ts given the atmosphere-side demanded flux G* (see compute_ground_heat_flux_demand): Ts = Tg − G*/(2κg/Δzg). This is the no-snow special case (f_snow = 0) of the snow-aware method below; it is a separate method (rather than a default snow = nothing) purely so it can skip the unused snow_thermal_interface/snow_cover_fraction calls.

source
Terrarium.compute_skin_temperature_residual! — Function
compute_skin_temperature_residual!(
    out,
    i,
    j,
    grid,
    fields,
    skinT::ImplicitSkinTemperature,
    seb::Terrarium.AbstractSurfaceEnergyBalance,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere
)
compute_skin_temperature_residual!(
    out,
    i,
    j,
    grid,
    fields,
    skinT::ImplicitSkinTemperature,
    seb::Terrarium.AbstractSurfaceEnergyBalance,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    hydrology::Union{Nothing, Terrarium.AbstractSurfaceHydrology}
)
compute_skin_temperature_residual!(
    out,
    i,
    j,
    grid,
    fields,
    skinT::ImplicitSkinTemperature,
    seb::Terrarium.AbstractSurfaceEnergyBalance,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    hydrology::Union{Nothing, Terrarium.AbstractSurfaceHydrology},
    snow::Union{Nothing, Terrarium.AbstractSnow}
)

Surface-energy-balance residual at grid cell i, j, in temperature space: Ts_prev − Ts_implicit, where Ts_implicit is the exact conduction-side inverse (see compute_skin_temperature) of the atmosphere-side demanded flux supplied by the ground heat flux sub-process (see compute_ground_heat_flux_demand), which for DiagnosedGroundHeatFlux is G_demand = R_net(Ts_prev) + H(Ts_prev) + LE(Ts_prev).

source
Terrarium.compute_snow_basal_heat_flux — Method
compute_snow_basal_heat_flux(
    i,
    j,
    grid,
    fields,
    snow::SingleLayerSnow,
    soil::Terrarium.AbstractSoil,
    constants::PhysicalConstants
)

Snow→soil basal conductive heat flux Q_base [W/m²] at grid cell i, j, positive upward (soil → snow), as the series-resistance conduction between the soil's top half-cell and the snow layer: Q_base = (T_soil − T_snow) / (Δz_soil/(2κ_soil) + d_snow/(2κ_snow)). Both the local soil top-layer thermal conductivity κ_soil and the snow conductivity κ_snow are recovered from their respective composition/density schemes rather than stored. The snow-side conduction thickness is floored at min_snow_conduction_thickness as d_snow → 0, matching the floor used elsewhere in the snow thermodynamics; without the soil-side term this reduces to the previous snow-resistance-only closure, which is only valid once the soil resistance is genuinely negligible next to the (floored) snow's.

source
Terrarium.compute_snow_cover_fraction — Method
compute_snow_cover_fraction(
    cover::FractionalSnowCover{NF},
    swe::NF
) where NF

Sub-grid snow-covered area fraction f_snow = W_snow/(W_snow + W_ref) ∈ [0,1) from the snow water equivalent W_snow [m] and the reference level W_ref (half_coverage), clamping negative SWE (which can occur transiently in the prognostic state) to zero cover.

source
Terrarium.compute_snow_depth — Method
compute_snow_depth(
    ::Terrarium.AbstractSnow,
    W_snow::NF,
    ρ_snow::NF,
    ρ_w::NF
) where NF

Snow layer depth d_snow = W_snow·ρ_w/ρ_snow [m], converting the water-equivalent depth W_snow [m] to the physical snow depth using the water density ρ_w and the bulk snow density ρ_snow.

source
Terrarium.compute_snow_diffusion_timescale — Method
compute_snow_diffusion_timescale(
    i,
    j,
    grid,
    fields,
    snow::SingleLayerSnow,
    constants::PhysicalConstants
)

Kernel function returning the snow thermal diffusion timescale $\max(d_{\text{snow}}, d_{\text{min}})² \, C_{\text{snow}} / κ_{\text{snow}}$ at grid cell i, j, with the bulk thermal conductivity and heat capacity computed from the local snow density and liquid fraction.

source
Terrarium.compute_snow_energy_tendency — Method
compute_snow_energy_tendency(
    i,
    j,
    grid,
    fields,
    snow::SingleLayerSnow,
    atmos::Terrarium.AbstractAtmosphere,
    constants::PhysicalConstants
)

Depth-integrated snow energy tendency [W/m²] at grid cell i, j (all fluxes positive upward):

dŪ_snow/dt = Q_base − Q_top + Q_precip + Q_subl

where Q_top/Q_base are the surface/basal heat fluxes, which like the snow state are grid-cell means scaled by the snow cover fraction f (f·S and f·Q_base, see compute_snow_interface_fluxes!), Q_precip the advected precipitation heat (see compute_snow_precip_heat_flux), and Q_subl an advective correction for sublimation.

The sublimation correction Q_subl = ρ_w·L_sl·E_subl is required because the latent heat flux carries the full sublimation enthalpy ρ_w·L_sg·E_subl, whereas the mass leaving the snowpack departs as ice, whose specific enthalpy relative to the liquid-water reference is −L_sl. Adding back ρ_w·L_sl·E_subl leaves the snowpack with a net loss of ρ_w·(L_sg − L_sl)·E_subl = ρ_w·L_lg·E_subl, the vaporization enthalpy carried by the departing vapor.

Note that no explicit meltwater energy term appears because meltwater drains as liquid water at 0 °C, which is the zero-enthalpy reference (U = 0) of the FreeWater closure, so it carries no enthalpy out of the snowpack.

The conductive/sublimation terms Q_base - Q_top + Q_subl are gated to zero when the pack is empty at the start of the step (W == 0), since they are otherwise evaluated against a degenerate zero-depth layer (Q_top/Q_base conduction targets floored at min_conduction_thickness, giving an arbitrarily large flux relative to a genuinely-thin pack's tiny heat capacity). Q_prcp is not gated: it is a pure source term from the precipitation rate alone, well-defined regardless of the existing pack depth. Gating it too — as a previous implementation did, multiplying the whole dUdt including Q_prcp by W > 0 — zeroed the energy input on the very first step any snow accumulates onto bare ground (W is read before that step's mass increment), leaving the freshly-fallen, physically cold snow with zero recorded enthalpy. Under the FreeWater closure (U = 0 ≡ liquid water at 0 °C) that reads as instantaneously fully melted, triggering spurious immediate Darcy drainage regardless of how cold the air actually was.

source
Terrarium.compute_snow_ice_content — Method
compute_snow_ice_content(
    i,
    j,
    grid,
    fields,
    explicit_water,
    constants::PhysicalConstants
)

Ice content W_i = −Ū⁺ / (ρ_w L_f) (m SWE) of the snowpack at grid cell i, j, clamped to [0, W⁺], from the explicit stage W⁺ = explicit_water and the snow energy Ū⁺; unchanged by the meltwater drainage.

source
Terrarium.compute_snow_interface_fluxes! — Method
compute_snow_interface_fluxes!(
    out,
    i,
    j,
    grid,
    fields,
    snow::SingleLayerSnow,
    seb::Terrarium.AbstractSurfaceEnergyBalance,
    soil::Terrarium.AbstractSoil,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere
)

Diagnose the snow↔surface/soil coupling fluxes at grid cell i, j, run after the surface energy balance: the blended soil-top heat flux f·Q_base + (1 − f)·G (with G the bare-ground ground_heat_flux; used only as the soil's top boundary condition), the grid-cell-mean snow-base flux f·Q_base (see compute_snow_basal_heat_flux), the grid-cell-mean snow-top conductive flux f·S (see compute_snow_surface_heat_flux), and the snow surface sublimation rate (see compute_snow_sublimation_flux, the same snow-fraction vapor flux the surface energy balance uses for the latent-flux partition). All snowpack fluxes are grid-cell means scaled by the snow cover fraction f (as is the sublimation) since the snow state is a grid-cell mean. The column (soil + snow) then loses (1 − f)·G + f·S, the flux delivered to the skin.

source
Terrarium.compute_snow_interface_fluxes! — Method
compute_snow_interface_fluxes!(
    state,
    grid,
    ::Nothing,
    args...
)

Launch compute_snow_interface_fluxes! to diagnose the snow↔surface/soil coupling fluxes from the snow state and the surface energy balance outputs: the blended soil-top heat flux (soil_heat_flux), the grid-cell-mean snow-base flux (snow_basal_heat_flux), the grid-cell-mean snow-top conductive flux (snow_surface_heat_flux; both drive the snowpack's own energy tendency), and the snow surface sublimation rate (sublimation, the snow-fraction bulk-aerodynamic vapor flux at the converged skin temperature). Must run after the surface energy balance (which sets ground_heat_flux and the skin temperature). No-op when there is no snowpack (snow === nothing).

source
Terrarium.compute_snow_precip_heat_flux — Method
compute_snow_precip_heat_flux(
    ::Terrarium.AbstractSnow,
    constants::PhysicalConstants,
    P_s::NF,
    R_on_snow::NF,
    T_air::NF
) where NF

Advected heat flux [W/m²] carried into the snowpack by precipitation, relative to liquid water at 0 °C (the U = 0 reference of the FreeWater enthalpy closure). Fresh snow P_s arrives as ice, which sits L_sl below the liquid reference, plus sensible heat for T_air < 0; rain-on-snow R_on_snow arrives as liquid carrying only its sensible heat for T_air > 0. The latent heat released when rain refreezes in a cold pack is captured implicitly by the enthalpy closure, so it is not added here (adding L_sl would double-count relative to the liquid-water reference).

source
Terrarium.compute_snow_properties! — Function
compute_snow_properties!(
    out,
    i,
    j,
    grid,
    fields,
    snow::SingleLayerSnow,
    constants::PhysicalConstants
)
compute_snow_properties!(
    out,
    i,
    j,
    grid,
    fields,
    snow::SingleLayerSnow,
    constants::PhysicalConstants,
    water_timestepping::Timestepping
)

Compute the snow depth and cover fraction at grid cell i, j, and the meltwater outflow if snow_water_equivalent is integrated explicitly (see compute_meltwater_flux!).

source
Terrarium.compute_snow_sublimation_flux — Method
compute_snow_sublimation_flux(
    i,
    j,
    grid,
    fields,
    ::Nothing,
    atmos,
    constants,
    skinT
)

Snow-surface sublimation rate [m/s SWE] at grid cell i, j. The snow surface is treated as saturated: a bulk-aerodynamic vapor flux Δq/rₐ evaluated at the skin temperature, with Δq taken over ice for a sub-freezing surface (the saturation humidity already dispatches over ice for T ≤ 0 — see saturation_specific_humidity_vapor). The water-vapor mass flux ρₐ·Δq/rₐ is converted to a snow-water-equivalent rate via ρ_w. Zero without snow (i.e. when snow === nothing).

source
Terrarium.compute_snow_surface_heat_flux — Method
compute_snow_surface_heat_flux(
    i,
    j,
    grid,
    fields,
    snow::SingleLayerSnow,
    constants::PhysicalConstants
)

Snow-top conductive heat flux [W/m²] at grid cell i, j (positive upward, i.e. energy leaving the snow top into the skin), S = 2κ_snow(T_snow − T_skin)/max(d_snow, d_min) — the same unblended snow conduction target the skin-temperature solve closes against (see Terrarium.snow_thermal_interface). This is a per-unit-snow-area flux; the snowpack energy tendency (compute_snow_energy_tendency's Q_top) uses the grid-cell mean f_snow·S, which is applied at the call site in compute_snow_interface_fluxes!.

source
Terrarium.compute_snow_tendencies! — Function
compute_snow_tendencies!(
    tendencies,
    i,
    j,
    grid,
    fields,
    snow::SingleLayerSnow,
    atmos::Terrarium.AbstractAtmosphere,
    constants::PhysicalConstants
)
compute_snow_tendencies!(
    tendencies,
    i,
    j,
    grid,
    fields,
    snow::SingleLayerSnow,
    atmos::Terrarium.AbstractAtmosphere,
    constants::PhysicalConstants,
    water_timestepping::Timestepping
)

Accumulate the snow water-equivalent and depth-integrated energy tendencies at grid cell i, j from the mass and energy balances (see compute_snow_water_tendency and compute_snow_energy_tendency).

source
Terrarium.compute_snow_volumetric_energy — Method
compute_snow_volumetric_energy(
    Ū_snow::NF,
    d_snow::NF,
    d_min::NF
) where NF

Volumetric snow internal energy U_snow = Ū_snow/max(d_snow, d_min) [J/m³] from the depth-integrated energy Ū_snow [J/m²] and the snow depth d_snow [m]. The depth is floored at the minimum thermal thickness d_min (see min_snow_conduction_thickness) rather than a machine-eps offset. This bounds the snow temperature recovered downstream: with only an eps offset, any residual Ū_snow over a vanishing d_snow gives a huge U_snow and hence a snow temperature far below physical bounds, which then corrupts the (cover-fraction-blended) skin temperature and basal heat flux. Flooring at d_min gives a thin snowpack a bounded effective heat capacity C_snow·d_min, so it stores negligible energy and is thermally transient — the ground heat flux passes essentially unmediated to the soil (f_snow → 0 in the blend) while the pack still stores mass and modifies the surface albedo.

source
Terrarium.compute_snow_volumetric_heat_capacity — Method
compute_snow_volumetric_heat_capacity(
    ::Terrarium.AbstractSnow{NF},
    constants::PhysicalConstants,
    ρ_snow::NF,
    liq::NF
) where NF

Bulk volumetric heat capacity C_snow [J/m³/K] of the snowpack treated as an ice–liquid–air mixture, given the bulk snow density ρ_snow [kg/m³] and the liquid water fraction liq ∈ [0,1] of the water substance. The water-substance mass per unit snow volume is ρ_snow, of which (1 − liq) is ice and liq is liquid; the remaining void space is dry air. The corresponding constituent volume fractions are

\[\begin{aligned} θ_{ice} &= ρ_{snow}·(1 − liq)/ρ_i,\ θ_{liq} &= ρ_{snow}·liq/ρ_w,\ θ_{air} &= 1 − θ_{ice} − θ_{liq} \end{aligned}\]

and the heat capacity is the volume-weighted sum over the ice and liquid constituents, C_snow = cp_i·ρ_i·θ_ice + cp_w·ρ_w·θ_liq. The air's own sensible-heat storage (≈0.1%) is neglected; note the air is still reflected in the bulk density ρ_snow < ρ_ice.

source
Terrarium.compute_snow_water_tendency — Method
compute_snow_water_tendency(
    i,
    j,
    grid,
    fields,
    snow::SingleLayerSnow{NF},
    atmos::Terrarium.AbstractAtmosphere
) where NF
compute_snow_water_tendency(
    i,
    j,
    grid,
    fields,
    snow::SingleLayerSnow{NF},
    atmos::Terrarium.AbstractAtmosphere,
    water_timestepping::Timestepping
) where NF

Snow water equivalent (SWE) tendency (m/s) at grid cell i, j:

dW_snow/dt = S + R_snow − M − E_subl

where S is snowfall, R_snow = f_snow · rainfall the rain intercepted by the snow-covered fraction, M the Darcy meltwater outflow (see snow_meltwater_flux), and E_subl the sublimation rate. M is omitted under implicit integration of snow_water_equivalent, where the implicit step drains the meltwater.

source
Terrarium.compute_soc_advective_flux — Method
compute_soc_advective_flux(
    i,
    j,
    k,
    grid,
    fields,
    transport::Terrarium.SoilCarbonTransport
)

Compute the advective soil organic carbon flux q_a = ω ⋅ C (kg/m²/s) at index i, j, k.

source
Terrarium.compute_soc_diffusive_flux — Method
compute_soc_diffusive_flux(
    i,
    j,
    k,
    grid,
    fields,
    transport::Terrarium.SoilCarbonTransport
)

Compute the diffusive soil organic carbon flux qd = -Db ⋅ ∂C/∂z (kg/m²/s) at the lower cell face of index i, j, k.

source
Terrarium.compute_soc_tendency! — Method
compute_soc_tendency!(
    tend,
    i,
    j,
    k,
    grid,
    fields,
    soc::SinglePoolSoilCarbon,
    soil::Terrarium.AbstractSoil
)

Compute the soil organic carbon tendency at index i, j, k and add it to tend.density_soc.

source
Terrarium.compute_soc_tendency — Method
compute_soc_tendency(
    i,
    j,
    k,
    grid,
    fields,
    soc::SinglePoolSoilCarbon,
    soil::Terrarium.AbstractSoil
)

Compute the soil organic carbon tendency (kg/m³/s) at index i, j, k, ∂C/∂t = -∂qd/∂z - ∂qa/∂z - R, where qd and qa are the diffusive and advective fluxes and R is the respiration rate. Litter inputs enter through the top boundary condition.

source
Terrarium.compute_specific_humidity_difference — Method
compute_specific_humidity_difference(
    i,
    j,
    grid,
    fields,
    atmos::Terrarium.AbstractAtmosphere,
    c::PhysicalConstants,
    T
)

Computes the specific humidity difference [kg/kg] between a saturated surface at temperature T [°C] and the current atmospheric fields.

source
Terrarium.compute_stem_carbon — Method
compute_stem_carbon(vegcarbon_dynamics, traits, LAI_b)

Computes the stem carbon C_stem = awl · LAI_b (kgC/m²) implied by the balanced Leaf Area Index LAI_b and the allometric coefficient awl (assuming bwl = 1), [21, Eqs. (76-79)].

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_stomatal_conductance — Function
compute_stomatal_conductance(
    i, j, grid, fields,
    stomcond::AbstractStomatalConductance,
    photo::AbstractPhotosynthesis,
    atmos::AbstractAtmosphere,
    constants::PhysicalConstants,
    args...
)

Cell-level stomatal conductance computation. Returns stomatal/canopy conductance and internal CO₂ ratio for the specified cell.

source
Terrarium.compute_stomatal_conductance — Method
compute_stomatal_conductance(
    i,
    j,
    grid,
    fields,
    stomcond::MedlynStomatalConductance{NF},
    traits::PlantTraits{NF},
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    args...
) where NF

Compute stomatal conductance (gstm) and leaf-to-air CO₂ ratio (λc) at a grid point. Returns tuple (gstm, λc) for use in photosynthesis and transpiration calculations.

source
Terrarium.compute_stomatal_conductance — Method
compute_stomatal_conductance(
    stomcond::MedlynStomatalConductance{NF},
    traits::PlantTraits{NF},
    constants::PhysicalConstants{NF},
    vpd,
    T_air,
    pres,
    co2_ppm,
    An,
    LAI,
    β
) where NF

Compute canopy-level water conductance (m/s) from the [24] optimal stomatal conductance model, gₛ = g₀ + D (1 + g₁/√VPD) Aₙ/cₐ, where the diffusivity ratio D is that of the corrigendum [25]. Includes minimum conductance and light extinction effects based on LAI, scaled by soil moisture factor β.

References

  • [24] Medlyn et al., Global Change Biology (2011)
  • [25] Medlyn et al., Global Change Biology (2012)
source
Terrarium.compute_surface_drainage — Method
compute_surface_drainage(
    runoff::DirectSurfaceRunoff{NF},
    surface_excess_water
) where NF

Compute surface drainage flux from the current surface_excess_water resevoir state.

source
Terrarium.compute_surface_energy_fluxes! — Function
compute_surface_energy_fluxes!(
    state,
    grid,
    seb::SurfaceEnergyBalance,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere
)
compute_surface_energy_fluxes!(
    state,
    grid,
    seb::SurfaceEnergyBalance,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    hydrology::Union{Nothing, Terrarium.AbstractSurfaceHydrology},
    args...
)

Compute the surface energy fluxes on grid based on the current atmospheric state.

source
Terrarium.compute_surface_energy_fluxes! — Function
compute_surface_energy_fluxes!(
    out,
    i,
    j,
    grid,
    fields,
    seb::SurfaceEnergyBalance,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere
)
compute_surface_energy_fluxes!(
    out,
    i,
    j,
    grid,
    fields,
    seb::SurfaceEnergyBalance,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    hydrology::Union{Nothing, Terrarium.AbstractSurfaceHydrology}
)
compute_surface_energy_fluxes!(
    out,
    i,
    j,
    grid,
    fields,
    seb::SurfaceEnergyBalance,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    hydrology::Union{Nothing, Terrarium.AbstractSurfaceHydrology},
    snow::Union{Nothing, Terrarium.AbstractSnow},
    args...
)

Fused kernel function that computes the radiative and turbulent fluxes, as well as the ground heat flux based on the current skin temperature and humidity fluxes.

source
Terrarium.compute_surface_energy_fluxes! — Function
compute_surface_energy_fluxes!(state, grid, ::AbstractSurfaceEnergyBalance, args...)

Compute the surface energy fluxes and skin temperature from the current state and grid. The required args are implementation dependent.

source
Terrarium.compute_surface_excess_water_tendency! — Method
compute_surface_excess_water_tendency!(
    tendencies,
    i,
    j,
    grid,
    fields,
    runoff::DirectSurfaceRunoff{NF}
) where NF

Kernel function for computing the tendency of the prognostic surface_excess_water pool in the grid column i, j. The pool is drained at the surface drainage rate D = compute_surface_drainage, capped so that a single step cannot remove more water than is present (min(D, S)). The tendency is returned as a negative rate (a removal) consistent with the positive-upward flux convention used by the other surface hydrology tendencies, so that surface_excess_water += ∂S∂t * Δt draws the pool down.

source
Terrarium.compute_surface_humidity_flux — Method
compute_surface_humidity_flux(
    i,
    j,
    grid,
    fields,
    evaporation::BareGroundEvaporation,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    args...
)

Evaluate the bare-ground, kinematic surface humidity flux [m/s] from the current skin temperature and evaporation conductance in fields.

source
Terrarium.compute_surface_humidity_flux — Method
compute_surface_humidity_flux(
    i,
    j,
    grid,
    fields,
    evtr::PALADYNCanopyEvapotranspiration,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    args...
)

Compute the kinematic surface humidity flux [m/s] from the current skin temperature and conductances in fields.

source
Terrarium.compute_surface_humidity_fluxes — Method

Compute unscaled transpiration, evaporation_ground, and evaporation_canopy fluxes on grid. Following the implementation of PALADYN, Qh_can is clamped to be strictly positive (no canopy dew formation).

source
Terrarium.compute_surface_runoff! — Function
compute_surface_runoff!(
    out, i, j, grid, fields,
    runoff::DirectSurfaceRunoff{NF},
    canopy_interception::AbstractCanopyInterception,
    soil_hydrology::AbstractSoilHydrology
) where {NF}

Compute surface runoff in grid cell i, j and store the result in out.surface_runoff. Runoff is computed based on the ground-reaching precipitation rate provided by canopy_interception and the soil saturation state provided by soil_hydrology.

source
Terrarium.compute_surface_runoff — Method
compute_surface_runoff(
    runoff::DirectSurfaceRunoff,
    influx,
    surface_drainage,
    infil
)

Compute surface runoff as precipitation + surface_drainage - infiltration.

source
Terrarium.compute_surface_upwelling_radiation — Method
compute_surface_upwelling_radiation(
    i,
    j,
    grid,
    fields,
    rad::PrescribedRadiativeFluxes,
    args...
) -> NamedTuple{(:surface_shortwave_up, :surface_longwave_up), <:Tuple{Any, Any}}

Compute upwelling shortwave and longwave radiation at a grid point.

source
Terrarium.compute_tendencies! — Function
compute_tendencies!(
    state,
    grid,
    soil::SoilEnergyWaterCarbon,
    constants::PhysicalConstants
)
compute_tendencies!(
    state,
    grid,
    soil::SoilEnergyWaterCarbon,
    constants::PhysicalConstants,
    surface_hydrology::Union{Nothing, Terrarium.AbstractSurfaceHydrology}
)
compute_tendencies!(
    state,
    grid,
    soil::SoilEnergyWaterCarbon,
    constants::PhysicalConstants,
    surface_hydrology::Union{Nothing, Terrarium.AbstractSurfaceHydrology},
    timestepper::Union{Nothing, Terrarium.AbstractTimeStepper}
)

Compute tendencies for soil energy, water, and carbon state variables on grid based on the given values in constants.

An optional surface_hydrology process may be supplied (by the coupled LandModel) so that its evapotranspiration scheme (get_evapotranspiration) is applied as a sink term in the soil water tendency. Without it (standalone soil), no evapotranspiration is removed from the soil.

The parent model's timestepper resolves the Timestepping classes of internal_energy and saturation_water_ice, which are passed on to the energy and hydrology compute_tendencies!. Without a timestepper (nothing) both are Explicit().

source
Terrarium.compute_tendencies! — Function
compute_tendencies!(
    state,
    grid,
    energy::SoilThermodynamics,
    soil::Terrarium.AbstractSoil
)
compute_tendencies!(
    state,
    grid,
    energy::SoilThermodynamics,
    soil::Terrarium.AbstractSoil,
    constants::Union{Nothing, PhysicalConstants}
)
compute_tendencies!(
    state,
    grid,
    energy::SoilThermodynamics,
    soil::Terrarium.AbstractSoil,
    constants::Union{Nothing, PhysicalConstants},
    timestepping::Timestepping
)

Compute the explicitly integrated part of the internal energy tendency of energy. The Timestepping argument is the class of internal_energy (see timestepping(state, ::Val)), i.e. how the variable is integrated, not which part of the tendency is computed. Explicit: the whole tendency is integrated explicitly, i.e. the full divergence of the diffusive and advective heat fluxes. Implicit: the fluxes through the interior faces are integrated by the implicit sub-stepper (BackwardEuler), so only the diffusive fluxes and the advective inflow through the boundary faces remain. Flux boundary conditions are included in both cases.

source
Terrarium.compute_tendencies! — Function
compute_tendencies!(state, model::AbstractModel)

Compute tendencies for all prognostic state variables for model stored in the given state. This method should be called after compute_auxiliary!.

compute_tendencies!(state, grid, process::AbstractProcess, args...)

Compute the tendencies of all prognostic state variables for the given process on grid. Implementations of AbstractProcess may define additional args that correspond to different process coupling interfaces.

source
Terrarium.compute_tendencies! — Function
compute_tendencies!(
    state,
    grid,
    snow::SingleLayerSnow,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere
)
compute_tendencies!(
    state,
    grid,
    snow::SingleLayerSnow,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    timestepper::Union{Nothing, Terrarium.AbstractTimeStepper}
)

Compute the snow water-equivalent and depth-integrated energy tendencies (see compute_snow_tendencies!), driven by the atmospheric precipitation inputs and the prescribed surface/basal heat fluxes and sublimation. The meltwater outflow is omitted if snow_water_equivalent is integrated implicitly by timestepper.

source
Terrarium.compute_tendencies! — Method
compute_tendencies!(
    state,
    grid,
    canopy_interception::PALADYNCanopyInterception,
    evapotranspiration::Terrarium.AbstractEvapotranspiration,
    args...
)
source
Terrarium.compute_tendencies! — Method
compute_tendencies!(
    state,
    grid,
    veg_dynamics::PALADYNVegetationDynamics,
    vegcarbon_dynamics::PALADYNCarbonDynamics,
    traits::PlantTraits,
    args...
)
source
Terrarium.compute_tendencies! — Method
compute_tendencies!(
    state,
    grid,
    veg::PrognosticVegetation,
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    args...
)

Compute tendencies for carbon and vegetation dynamics.

source
Terrarium.compute_tendencies! — Method
compute_tendencies!(
    state,
    grid,
    soc::SinglePoolSoilCarbon,
    soil::Terrarium.AbstractSoil,
    args...
)

Compute the tendency of the soil organic carbon density in each soil layer.

source
Terrarium.compute_tendencies! — Method
compute_tendencies!(
    state,
    grid,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    soil::Terrarium.AbstractSoil,
    constants::PhysicalConstants
) where NF
compute_tendencies!(
    state,
    grid,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    soil::Terrarium.AbstractSoil,
    constants::PhysicalConstants,
    evtr::Union{Nothing, Terrarium.AbstractEvapotranspiration}
) where NF
compute_tendencies!(
    state,
    grid,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    soil::Terrarium.AbstractSoil,
    constants::PhysicalConstants,
    evtr::Union{Nothing, Terrarium.AbstractEvapotranspiration},
    timestepping::Timestepping
) where NF

Compute the saturation tendency of the Richards-equation hydrology, with the evapotranspiration sink of evtr (if given) and the user-defined vwc_forcing as source terms. timestepping is the resolved Timestepping class of saturation_water_ice (see timestepping(state, ::Val)). Under Explicit the full divergence of the Darcy flux is added. Under Implicit the fluxes through the interior faces are omitted (integrated by the implicit sub-stepper, see BackwardEuler), leaving the fluxes through the two boundary faces (see compute_boundary_darcy_flux_divergence). The flux boundary conditions on saturation_water_ice (e.g. InfiltrationFlux) from compute_boundary_conditions! and the source terms are part of the tendency in both cases.

The Darcy fluxes at tⁿ through all faces are stored in water_flux (compute_water_flux), with which the soil energy advects heat. Under Implicit time stepping, the implicit step overwrites the interior fluxes with those of its conservative update (see implicit_update!).

source
Terrarium.compute_thermal_conductivity — Method
compute_thermal_conductivity(
    i,
    j,
    k,
    grid,
    fields,
    energy::SoilThermodynamics,
    hydrology::Terrarium.AbstractSoilHydrology,
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
)
source
Terrarium.compute_thermal_conductivity — Method
compute_thermal_conductivity(
    snow::SingleLayerSnow,
    constants::MaterialConstants,
    ρ_snow
)

Bulk snow thermal conductivity κ_snow [W/m/K], delegating to the process's thermal conductivity scheme with the bulk density ρ_snow.

source
Terrarium.compute_thermal_conductivity — Method
compute_thermal_conductivity(
    cond::PowerLawSnowThermalConductivity{NF},
    constants::MaterialConstants{NF},
    ρ_snow::NF
) where NF

Bulk snow thermal conductivity via the density power law κ_snow = a·(ρ_snow/ρ_w)^b ([18]).

source
Terrarium.compute_thermal_diffusion_timescale — Method
compute_thermal_diffusion_timescale(
    i,
    j,
    k,
    grid,
    fields,
    energy::SoilThermodynamics,
    hydrology::Terrarium.AbstractSoilHydrology,
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
)

Kernel function returning the thermal diffusion timescale $Δz² C / κ$ at cell i, j, k, with the bulk thermal conductivity κ and heat capacity C computed from the local soil composition.

source
Terrarium.compute_turbulent_fluxes! — Method
compute_turbulent_fluxes!(
    out,
    i,
    j,
    grid,
    fields,
    tur::DiagnosedTurbulentFluxes,
    skinT,
    constants,
    atmos,
    hydrology,
    snow
)

Compute the turbulent (sensible and latent) heat fluxes from the current skin temperature and store them into the auxiliary output fields out.

source
Terrarium.compute_turbulent_fluxes! — Method
compute_turbulent_fluxes!(
    out,
    i,
    j,
    grid,
    fields,
    ::PrescribedTurbulentFluxes,
    args...
)

Prescribed turbulent fluxes are input fields supplied by an external coupler (already present in fields), so there is nothing to compute or store.

source
Terrarium.compute_vadose_zone_saturation — Method
compute_vadose_zone_saturation(
    i,
    j,
    k,
    grid,
    fields,
    saturation
)

Saturation in the vadose zone at cell (i, j, k) from the vadose_zone_saturation input field. For a Saturation or a plain value, the field holds the saturation and is returned directly; for a VolumetricWaterContent, it holds the volumetric water content θ, which is divided by the soil porosity ϕ and capped at full saturation.

source
Terrarium.compute_vapor_pressure_deficit — Method
compute_vapor_pressure_deficit(
    i,
    j,
    grid,
    fields,
    atmos::Terrarium.AbstractAtmosphere,
    c::PhysicalConstants
)

Computes the vapor pressure deficit (VPD) [Pa] at atmospheric reference level given the current atmospheric fields

source
Terrarium.compute_vapor_pressure_difference — Method
compute_vapor_pressure_difference(
    i,
    j,
    grid,
    fields,
    atmos::Terrarium.AbstractAtmosphere,
    c::PhysicalConstants,
    T
)

Computes the vapor pressure difference [Pa] between a saturated surface at temperature T [°C] and the current atmospheric fields.

source
Terrarium.compute_veg_carbon_tendency — Function
compute_veg_carbon_tendency(i, j, grid, fields, vegcarbon::AbstractVegetationCarbonDynamics)

Cell-level vegetation-carbon tendency computation. Implementations compute the tendency for the total vegetation carbon pool at the given index i, j.

source
Terrarium.compute_veg_carbon_tendency — Method
compute_veg_carbon_tendency(
    i,
    j,
    grid,
    fields,
    vegcarbon_dynamics::PALADYNCarbonDynamics,
    traits::PlantTraits
)

Compute the tendency for the carbon vegetation pool given fields LAI_b and NPP.

source
Terrarium.compute_volumetric_water_content_tendency — Method
compute_volumetric_water_content_tendency(
    i,
    j,
    k,
    grid,
    clock,
    fields,
    hydrology,
    constants,
    evapotranspiration
)
compute_volumetric_water_content_tendency(
    i,
    j,
    k,
    grid,
    clock,
    fields,
    hydrology,
    constants,
    evapotranspiration,
    timestepping
)

Compute the volumetric water content (VWC) tendency at grid cell i, j k according to the Richardson-Richards equation. Note that the VWC tendency is not scaled by the porosity and is thus not the same as the saturation tendency. Like the energy tendency, it is the explicitly integrated part of the tendency, and timestepping is the class of saturation_water_ice: under Explicit (the default) the full divergence of the Darcy flux is included; under Implicit only the boundary-face fluxes are (compute_boundary_darcy_flux_divergence), the interior ones being integrated by the implicit sub-stepper.

source
Terrarium.compute_volumetric_water_content_tendency — Method
compute_volumetric_water_content_tendency(
    i,
    j,
    k,
    grid,
    clock,
    fields,
    hydrology::SoilHydrology{NF, VerticalFlow, SaturationClosure, SoilHydraulics} where {VerticalFlow<:Terrarium.AbstractVerticalFlow, SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    constants::PhysicalConstants,
    evtr::Union{Nothing, Terrarium.AbstractEvapotranspiration}
) where NF
compute_volumetric_water_content_tendency(
    i,
    j,
    k,
    grid,
    clock,
    fields,
    hydrology::SoilHydrology{NF, VerticalFlow, SaturationClosure, SoilHydraulics} where {VerticalFlow<:Terrarium.AbstractVerticalFlow, SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    constants::PhysicalConstants,
    evtr::Union{Nothing, Terrarium.AbstractEvapotranspiration},
    ::Timestepping
) where NF

Compute the volumetric water content (VWC) tendency at grid cell i, j k f. Note that the VWC tendency is not scaled by the porosity and is thus not the same as the saturation tendency.

source
Terrarium.compute_water_outflow_timescale — Method
compute_water_outflow_timescale(
    i,
    j,
    k,
    grid,
    clock,
    fields,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry,
    constants::PhysicalConstants,
    evtr::Union{Nothing, Terrarium.AbstractEvapotranspiration},
    timestepping::Timestepping,
    saturation_bcs::NamedTuple
) where NF

Kernel function returning the explicit water outflow timescale $τ = φ (s - s_res) Δz / q_out$ at cell i, j, k, with porosity φ, saturation s, the residual_saturation s_res, and the outflow $q_out = -Δz G_θ$ (m/s) where the explicit volumetric water content tendency $G_θ$ (compute_volumetric_water_content_tendency plus the flux boundary conditions saturation_bcs on saturation_water_ice, see compute_saturation_boundary_flux) is negative. Cells without net explicit outflow return Inf.

source
Terrarium.compute_water_table! — Method
compute_water_table!(
    water_table,
    i,
    j,
    grid,
    sat,
    ::SoilHydrology{NF, VerticalFlow, SaturationClosure, SoilHydraulics} where {VerticalFlow<:Terrarium.AbstractVerticalFlow, SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})}
) where NF

Kernel function that diagnoses the water table at grid cell i, j given the current soil saturation profile.

source
Terrarium.compute_Γ_star — Method
compute_Γ_star(
    photo::LUEPhotosynthesis{NF},
    τ::NF,
    pres_O2::NF
) where NF

Computes the CO₂ compensation point Γ_star [Pa]. The intercellular CO₂ partial pressure at which gross photosynthesis equals respiration. Follows [21, Eq. (C6)].

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_Λ_loc — Method
compute_Λ_loc(vegcarbon_dynamics, traits, LAI_b)

Computes the local litterfall rate Λ_loc based on the balanced Leaf Area Index LAI_b (assuming evergreen PFTs), [21, Eq. (75)].

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_γv — Method
compute_γv(veg_dynamics)

Computes the disturbance rateγv, [21, Eq. (80)].

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_λ_NPP — Method
compute_λ_NPP(vegcarbon_dynamics, traits, LAI_b)

Computes λ_NPP,a factor determining the partitioning of NPP between increase of vegetation carbon of the existing vegetated area and spreading of the given PFT based on the balanced Leaf Area Index LAI_b, [21, Eq. (74)].

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.compute_λc — Method
compute_λc(stomcond, vpd)

Computes the ratio of leaf-internal and air CO2 concentration λc = cᵢ/cₐ, derived from the optimal stomatal conductance model ([24]) in the corrected form of [25].

References

  • [24] Medlyn et al., Global Change Biology (2011)
  • [25] Medlyn et al., Global Change Biology (2012)
source
Terrarium.compute_ν_star — Method
compute_ν_star(veg_dynamics, ν)

Computes ν_star which is the maximum of the current vegetation fraction ν and the seed fraction ν_seed [-], to ensure that a PFT is always seeded.

source
Terrarium.compute_ν_tendency — Function
compute_ν_tendency(
    i, j, grid, fields,
    veg_dynamics::AbstractVegetationDynamics,
    vegcarbon::AbstractVegetationCarbonDynamics
)

Cell-level vegetation-fraction tendency computation used by vegetation dynamics. Implementations compute the local tendency value for ν at the given index i, j.

source
Terrarium.compute_ν_tendency — Method
compute_ν_tendency(
    i,
    j,
    grid,
    fields,
    veg_dynamics::PALADYNVegetationDynamics,
    vegcarbon_dynamics::PALADYNCarbonDynamics,
    traits::PlantTraits
)

Compute vegetation area fraction tendency at a single grid point from NPP-productivity and disturbance rates.

source
Terrarium.compute_ν_tendency — Method
compute_ν_tendency(
    veg_dynamics,
    vegcarbon_dynamics,
    traits,
    LAI_b,
    C_veg,
    NPP,
    ν
)

Computes the vegetation fraction tendency for a single PFT, [21, Eq. (73)].

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.convert_dt — Method
convert_dt(Δt)

Convert Δts to the given target Period or numeric type. Numeric types are always assumed to be in seconds.

source
Terrarium.coordinate_eltype — Method
coordinate_eltype(z)

Return the number format to use for a grid with vertical coordinate z when none is given explicitly. Oceananigans discretizations compute their cell interfaces in Float64, so only a coordinate given directly as an array of interfaces carries a number format of its own.

source
Terrarium.create_land_grid — Function
create_land_grid(grid::AbstractGrid, soil, snow, vegetation)::AbstractLandGrid

Construct the LandGrid for a model discretized on the spatial discretization grid whose ground, snow, and canopy domains are determined by the soil, snow, and vegetation process components. This is the standard interface through which model constructors turn the grid given by the user into the land grid stored by the model.

The default implementation returns a ground-only land grid, i.e. one for which the snow and canopy domains are not vertically resolved. This is correct for all currently implemented snow and vegetation schemes, which are 0D; schemes which resolve a vertical snow or canopy profile should add a method here which builds the corresponding domain grids.

source
Terrarium.darcy_conductivity — Method
darcy_conductivity(i, j, k, grid, ψ, K)

Hydraulic conductivity (m/s) used by the darcy_flux at face k: the minimum of K (defined on faces) at face k and at the adjacent face in the direction of the gradient of the total pressure head ψ (face k - 1 for ∂ψ/∂z < 0, else k + 1).

source
Terrarium.darcy_flux — Method
darcy_flux(i, j, k, grid, ψ, K)

Kernel function for computing the Darcy flux q = -K ∂ψ/∂z (m/s, positive upward) over layer faces from the total pressure head ψ and the face hydraulic conductivity K (see darcy_conductivity).

source
Terrarium.daytime_length — Method
daytime_length(i, j, grid, fields, ::AbstractAtmosphere{PR, <:LongShortWaveRadiation})

Retrieve the length of the day (in hours) at grid cell i, j. Defaults to a constant 12 hours if no input is provided.

source
Terrarium.debughook! — Method
debughook!(args...)

Provides a "hook" for handling debug calls from relevant callsites. Default implementations for Field and NamedTuple (assumed to be of Fields) simply forward to checkfinite!.

source
Terrarium.debugsite! — Method
debugsite!(args...)

Utility method that forwards args to debughook! if and only if debug mode is enabled. Debug mode is set by the global variable DEBUG which can be toggled by the user facing API debug!.

source
Terrarium.default_clock — Method
default_clock(
    model::Terrarium.AbstractModel{NF}
) where NF -> Clock{<:Any, <:Any, Float64, Int64, Int64}

Return the default Clock used by initialize for the given model. The generic method returns a plain host clock starting at time zero; architecture extensions may specialize on the model's grid to return an architecture-specific clock (e.g. TerrariumReactantExt returns a traced ConcreteRNumber-backed clock so that time advances inside the compiled step).

source
Terrarium.default_dt — Function
default_dt(timestepper::AbstractTimeStepper)

Get the current timestep size for the time stepper.

source
Terrarium.default_dt — Method
default_dt(integrator::ModelIntegrator)

Return the default timestep size for the given integrator, taken from its model's timestepper.

source
Terrarium.default_skin_temperature_solver — Method
default_skin_temperature_solver(
    ::Type{NF}
) where NF -> Terrarium.RootSolver{NF, RootSolvers.NewtonsMethod{T}, RootSolvers.CompactSolution, RootSolvers.ResidualTolerance{NF}} where {NF, T<:Union{Real, AbstractArray}}

Construct the default solver for the implicit skin temperature: a Newton root-finder (RootSolver backed by RootSolvers.jl) with a small iteration budget.

source
Terrarium.default_timestepper — Method
default_timestepper(::Type{NF})
default_timestepper(::Type{<:AbstractModel}, ::Type{NF})

Default timestepper for models: a single explicit ForwardEuler time stepper. Models may specialize it on their type: LandModel defaults to IMEX(ForwardEuler(NF; Δt = 900), BackwardEuler(NF)), and SoilModel to IMEX(ForwardEuler(NF; Δt = 3600), BackwardEuler(NF)) if its soil water flow follows the Richards equation and to ForwardEuler(NF) otherwise.

source
Terrarium.default_timestepping — Method
default_timestepping(hydrology::AbstractSoilHydrology)

Default Timestepping class of saturation_water_ice under an AbstractIMEX timestepper: Implicit for the Richards equation (SoilHydrology{NF, RichardsEq}) and Explicit otherwise.

julia> Terrarium.default_timestepping(SoilHydrology(Float64, RichardsEq()))
Implicit()

julia> Terrarium.default_timestepping(SoilHydrology(Float64, NoFlow()))
Explicit()
source
Terrarium.default_unsat_hydraulic_cond — Method
default_unsat_hydraulic_cond(
    ::Type{NF},
    ::SWRC
) where NF -> UnsatKLinear

Return the unsaturated hydraulic conductivity formulation that matches the soil water retention curve swrc: UnsatKBrooksCorey for BrooksCorey, UnsatKVanGenuchten for VanGenuchten, and UnsatKLinear otherwise.

julia> Terrarium.default_unsat_hydraulic_cond(Float32, BrooksCorey())
UnsatKBrooksCorey{Float32}(7.0f0)

julia> Terrarium.default_unsat_hydraulic_cond(Float32, VanGenuchten())
UnsatKVanGenuchten{Float32}(7.0f0)
source
Terrarium.density_pure_soc — Method
density_pure_soc(bgc::AbstractSoilBiogeochemistry)

Return the assumed constant density of pure organic material. The default implementation assumes there to be a property ρ_org defined on the type of bgc.

source
Terrarium.density_soc — Method
density_soc(i, j, k, grid, fields, bgc::AbstractSoilBiogeochemistry{NF}) where {NF}

Return the bulk soil organic carbon density ρsoc (kg/m³) at index i, j, k, i.e. the mass of organic material per unit volume of soil. The default implementation returns zero, corresponding to a purely mineral soil. Implementations of AbstractSoilBiogeochemistry should override this method; see `organicfraction` for how ρ_soc is converted to the organic fraction of the soil matrix.

source
Terrarium.describe_conflict — Method
describe_conflict(var1, var2)

Describe how two declarations of the same variable disagree. Used to report incompatible duplicates in terms of the attribute which differs rather than by printing both variables and leaving the reader to spot it.

source
Terrarium.diagnose_evaporation_flux — Method
diagnose_evaporation_flux(state, model::LandModel)

Return a KernelFunctionOperation that computes the evaporation flux [m/s liquid water] over all grid cells. The kinematic humidity flux is rescaled by the air-to-water density ratio and weighted by the snow-free area fraction.

source
Terrarium.diffusive_heat_flux — Method
diffusive_heat_flux(
    i,
    j,
    k,
    grid,
    fields,
    energy::Terrarium.AbstractThermodynamics,
    args...
)

Compute the diffusive (Fourier) heat flux q = -κ ∂T/∂z at the cell face i, j, k, interpolating the medium-specific thermal conductivity to the face.

source
Terrarium.domains_compatible — Method
domains_compatible(d1, d2)

Whether two declarations of the same variable agree on its domain. A declaration without a domain makes no claim and is compatible with any: this is what lets an InputSource, which generally cannot know which domain the variable it feeds belongs to, stay domain-agnostic and adopt whatever the declaring process states. Two different stated domains remain a conflict.

source
Terrarium.drag_coefficient — Method
drag_coefficient(i, j, grid, fields, aero::AbstractAerodynamics)

Compute the bulk drag coefficient for heat and moisture transfer at grid cell i, j.

source
Terrarium.emissivity — Method
emissivity(i, j, grid, fields, albedo::ConstantAlbedo)

Return the surface emissivity at grid point i, j.

source
Terrarium.emissivity — Method
emissivity(i, j, grid, fields, ::AbstractAlbedo)

Return the current emissivity at the given indices.

source
Terrarium.energy_to_temperature! — Method
energy_to_temperature!(
    out,
    i,
    j,
    grid,
    fields,
    ::SnowEnergyTemperatureClosure,
    snow::SingleLayerSnow{NF},
    constants::PhysicalConstants
) where NF

Recover the snow temperature and liquid water fraction from the depth-integrated energy at grid cell i, j.

source
Terrarium.energy_to_temperature — Method
energy_to_temperature(
    ::FreeWater,
    U::NF,
    ρLθ::NF,
    C::NF
) where NF

Calculate the inverse enthalpy function given the internal energy U (J/m³), volumetric latent heat content ρLθ (J/m³), and volumetric heat capacity C (J/m³/K) under the free water freezing characteristic.

source
Terrarium.enforce_snow_constraints! — Method
enforce_snow_constraints!(
    state,
    grid,
    snow::Terrarium.AbstractSnow
)

Enforce the constraints on the snow state that are not part of its tendencies: clip negative snow water equivalent to zero and remove the energy of a pack without snow. Called by closure! of models with snow before the snow closure, so that the closure sees an admissible state.

The clipping does not conserve mass; the water it adds to a pack that was overdrawn by an explicit step is not taken from anywhere.

source
Terrarium.explicit_stage! — Method
explicit_stage!(state, grid, timestepper, Δt, names)

Apply one explicit stage u += ∂u∂t*Δt to the prognostic fields of state listed in names, using their corresponding tendencies. It is the building block of the explicit timesteppers: ForwardEuler applies one stage per step, and multi-stage schemes such as Heun apply several. Where necessary, the per-field method explicit_stage!(field, tendency, grid, timestepper, Δt) can be specialized for schemes that need a different update.

source
Terrarium.explicit_stage! — Method

Accumulate tendency*Δt in the given prognostic field. This method can be overridden by specialized timestepping schemes as needed.

source
Terrarium.explicit_step! — Function
explicit_step!(integrator::ModelIntegrator, timestepper::AbstractTimeStepper, Δt, names::Tuple)

Integrate the prognostic variables in names over a step of size Δt with the explicit timestepper, starting from the current state. The step evaluates the auxiliary variables and tendencies itself (update_state!) and applies one or more explicit_stage!s; multi-stage schemes such as Heun also apply closure! between their stages. The closure at the end of the step and the clock tick are left to the caller: the single-timestepper timestep!, or an AbstractIMEX timestepper, which calls it on its explicit partner and then implicit_step! on its implicit partner before applying the closure once. Explicit timesteppers must implement this method.

source
Terrarium.explicit_step! — Method
explicit_step!(
    integrator::ModelIntegrator,
    timestepper::ForwardEuler,
    Δt,
    names::Tuple
)

Forward Euler step u ← u + Δt ∂u∂t for the prognostic variables in names: compute the auxiliary variables and tendencies at the current state, then apply a single explicit_stage!. The closure is left to the caller (see explicit_step!).

source
Terrarium.explicit_step! — Method
explicit_step!(
    integrator::ModelIntegrator,
    timestepper::Heun,
    Δt,
    names::Tuple
)

Heun step for the prognostic variables in names: a forward Euler predictor with the tendencies at the current state, followed by the closure and a corrector u ← u₀ + Δt (∂u∂t₀ + ∂u∂t₁) / 2 with the tendencies ∂u∂t₁ at the predictor state and the end of the step. The closure after the corrector is left to the caller (see explicit_step!).

source
Terrarium.fastiterate — Method
fastiterate(f!::F, iters::NTuple{N,Any}...) where {F,N}

Same as fastmap but simply invokes f! on each argument set without constructing a tuple.

source
Terrarium.fastmap — Method
fastmap(f::F, iter::NamedTuple...) where {F}

Same as map for NamedTuples but with guaranteed type stability. fastmap is a @generated function which unrolls calls to f into a loop-free tuple construction expression. All named tuples must have the same keys but in no particular order. The returned NamedTuple

source
Terrarium.fastmap — Method
fastmap(f::F, iter::NTuple{N,Any}...) where {F,N}

Same as map for NTuples but with guaranteed type stability. fastmap is a @generated function which unrolls calls to f into a loop-free tuple construction expression.

source
Terrarium.field_indices — Method
field_indices(
    indices::Tuple{Integer, Integer, Integer}
) -> Tuple{Integer, Integer, Integer}

Pad the grid indices to the three indices required to write to a Field. A 2D (XY) solve passes (i, j), but Oceananigans only defines setindex!(::Field, val, i, j, k) for exactly three indices.

source
Terrarium.findfirst_z — Method
findfirst_z(i, j, condition_func, z_nodes, field)

2D kernel function that finds the first coordinate in z_nodes where condition_func(field[i, j, k]). This implementation performs a linear scan over the z-axis and thus has time complexity O(N_z).

source
Terrarium.forcing — Method
forcing(
    i,
    j,
    k,
    grid,
    clock,
    fields,
    evapotranspiration::Terrarium.AbstractEvapotranspiration,
    ::Terrarium.AbstractSoilHydrology,
    args...
)

Compute and return the evapotranspiration forcing for soil moisture at the given indices i, j, k. The ET forcing is just the ground_evapotranspiration_flux rescaled by the thickness of layer k.

source
Terrarium.forcing — Method
forcing(i, j, k, grid, clock, fields, forcing::AbstractForcing, target::AbstractProcess, args...)

Return the value computed by the given Oceananigans forcing type, which should be an instance of either DiscreteForcing or ContinuousForcing. Note that target and additional args are only included for interface consistency and are not passed through to forcing.

source
Terrarium.get_albedo — Method
get_albedo(seb)

Return the albedo parameterization associated with the surface energy balance.

source
Terrarium.get_artifact — Method
get_artifact(name::String) -> String

Retrieve the path to the artifact with the given name. Throws an AssertionError if no artifact with name exists in Artifacts.toml.

source
Terrarium.get_asset — Method
get_asset(asset::Terrarium.AbstractLandAsset) -> String

Download (if necessary) the given asset and return the path to its data file within the installed artifact directory. The artifact is installed via get_artifact and the data file is located by its file_extension. Reading the file is left to the caller; use load_asset to read a variable into a data Field wrapped on the asset's native_grid.

source
Terrarium.get_cache — Method
get_cache(cache::AbstractTimeStepperCache, timestepper::AbstractTimeStepper)

Return the working cache for timestepper given the model's state.timestepper_cache. For a single timestepper this is the cache itself; an IMEX cache returns the sub-cache matching the timestepper's class.

source
Terrarium.get_closure — Method
get_closure(
    hydrology::SoilHydrology
) -> Terrarium.AbstractSoilWaterClosure

Return the saturation-pressure closure defined by the given hydrology process, or nothing if not defined for the given configuration.

source
Terrarium.get_constants — Method
get_constants(model::AbstractModel)::PhysicalConstants

Return the PhysicalConstants associated with the given model.

source
Terrarium.get_domain — Method
get_domain(grid, ::Terrarium.Ground)

Return the spatial discretization of grid for the model domain selected by domain, or nothing if grid does not resolve that domain vertically.

source
Terrarium.get_field — Method
get_field(
    state,
    ::Union{Terrarium.AbstractVariable{name}, Terrarium.Namespace{name}}
) where name

Retrieves the Field from state matching the name of the given variable.

source
Terrarium.get_fields — Method
get_fields(state, ns::Terrarium.Namespace)

Retrieves all Fields declared by the given Namespace from state, where state is assumed to correspond to the (nested) StateVariables of the namespace itself.

source
Terrarium.get_fields — Method
get_fields(state, vars)

Retrieves all Fields from state matching the names of the given variables. Any Namespaces in vars are resolved recursively and their fields are merged into the returned NamedTuple keyed by namespace name, with the namespace's own fields collected into a nested NamedTuple.

source
Terrarium.get_fields — Method
get_fields(state, components...; except)

Retrieves all non-tendency Fields from state defined on the given components.

source
Terrarium.get_fields — Method
get_fields(state, queries::Union{Symbol, Pair}...)

Retrieves fields with names given in queries and returns them in a NamedTuple. Each argument in queries can either be a Symbol corresponding to a field/variable defined in the namespace of state or a Pair{Symbol, Tuple} where the key is the child namespace and the value is a tuple of queries from that namespace.

Warning

This method relies on runtime dispatch and thus should not be used in performance-critical code. If you need to query fields for specific sets of variables or components, use one of the type-stable variants instead.

# initialize model state
state = StateVariables(model)
# get the temperature and saturation_water_ice fields
fields = get_fields(state, :temperature, :saturation_water_ice)
# extract temperature as well as variables from a namespace
nested_fields = get_fields(state, :temperature, :namespace => (:subvar1, :subvar2))
source
Terrarium.get_grid — Method
get_grid(model::AbstractModel)::AbstractGrid

Return the spatial grid associated with the given model.

source
Terrarium.get_hydraulic_properties — Method
get_hydraulic_properties(
    hydrology::SoilHydrology
) -> Terrarium.AbstractSoilHydraulics

Return the soil hydraulic properties defined by the given hydrology process.

source
Terrarium.get_initializer — Method
get_initializer(model::AbstractModel)::AbstractInitializer

Return the initializer associated with the given model.

source
Terrarium.get_swrc — Function
get_swrc(::AbstractUnsatK)

Return the soil water retention curve associated with the given unsaturated hydraulic conductivity scheme.

source
Terrarium.get_swrc — Method
get_swrc(hydrology::SoilHydrology)

Return the soil water retention curve from the hydraulic_properties associated with the given SoilHydrology configuration.

source
Terrarium.get_swrc — Method
get_swrc(hydrology::AbstractSoilHydrology)

Return the soil water retention curve from the hydraulic_properties associated with the given soil hydrology configuration.

source
Terrarium.ground_domain — Method
ground_domain(grid)

Return the spatial discretization of the ground (soil) domain of grid. Grids which are not land grids are their own ground discretization.

source
Terrarium.ground_evaporation_conductance — Method
ground_evaporation_conductance(
    ::PALADYNCanopyEvapotranspiration,
    β,
    rₐ,
    rₐ_can
)

Compute the ground evaporation conductance from the given resistance factor β and aerodynamic resistances.

source
Terrarium.ground_evaporation_resistance_factor — Function
ground_evaporation_resistance_factor(i, j, grid, fields, :AbstractGroundEvaporationResistanceFactor, args...)

Compute the resistance factor against ground evaporation [-] based on the current state and implementation-specific process dependencies in args.

source
Terrarium.ground_evapotranspiration_flux — Function
ground_evapotranspiration_flux(i, j, grid, fields, ::AbstractEvapotranspiration)

Return the total ground evapotranspiration flux [m/s], i.e. ground evaporation + plant transpiration, at cell i, j based on the current state.

source
Terrarium.ground_heat_flux — Method
ground_heat_flux(i, j, grid, fields, ::AbstractGroundHeatFlux)

Return the current ground heat flux at the given indices.

source
Terrarium.ground_thermal_interface — Method
ground_thermal_interface(
    i,
    j,
    grid,
    fields,
    skinT::ImplicitSkinTemperature
) -> Tuple{Any, Any, Any}

Return the conduction target (Tg, κ, Δz) for the snow-free ground: the uppermost ground layer's ground_temperature, the assumed surface conductivity κₛ, and the top ground cell thickness. This is always the unblended ground-only target, used both when there is no snow and (weighted by 1 - f_snow) for the bare-ground share of the skin-temperature solve when there is.

source
Terrarium.humidity_flux — Method
humidity_flux(::Terrarium.AbstractEvapotranspiration, Δq, g)

Compute an evapotranspiration flux (m/s, positive upwards) as the product of a vapor conductance g (m/s) and a specific humidity difference Δq (kg/kg).

source
Terrarium.hydraulic_conductivity — Function

Compute (variably saturated) hydraulic conductivity based on the given hydraulic properties, soil water retention curve (SWRC), and volumetric fractions.

source
Terrarium.hydraulic_conductivity — Method
hydraulic_conductivity(
    i,
    j,
    k,
    grid,
    fields,
    hydrology,
    strat,
    bgc
)

Compute the hydraulic conductivity at the center of the grid cell i, j, k.

source
Terrarium.ice_impedance_factor — Method
ice_impedance_factor(Ω, f)

Ice impedance factor I_ice = 10^(-Ω (1 - f)) [9], which reduces the hydraulic conductivity of partially frozen soil to account for the blocking of water-filled pores by ice, given the scaling parameter Ω and the unfrozen fraction f of the pore water.

References

  • [9] Westermann et al., Geoscientific Model Development (2023)
source
Terrarium.implicit_closure! — Function
implicit_closure!(state, model::AbstractModel, ::Iteration{name, target, final})

Process hook of the implicit solver. Re-evaluate the closure of variable name (and the auxiliary variables the next linearization needs) after implicit_update!, for the process that owns the variable only. A model typically forwards it to the regular process closure! of that process; only a closure with once-per-step side effects (e.g. routing excess water to runoff) needs its own method, which must restrict them to final = true (see the soil hydrology for an example).

source
Terrarium.implicit_closure! — Method
implicit_closure!(
    state,
    grid,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    soil::Terrarium.AbstractSoil,
    constants::PhysicalConstants,
    runoff::Union{Nothing, Terrarium.AbstractSurfaceRunoff},
    ::Terrarium.Iteration{name, target, false}
) where {NF, name, target}

Apply the saturation–pressure closure without its once-per-step effects after an intermediate iteration of the implicit step (compute_saturation_closure! without runoff routing or heat transfer), since every iteration restarts from the explicit stage, then update the hydraulic conductivity.

source
Terrarium.implicit_closure! — Method
implicit_closure!(
    state,
    grid,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    soil::Terrarium.AbstractSoil,
    constants::PhysicalConstants,
    runoff::Union{Nothing, Terrarium.AbstractSurfaceRunoff},
    ::Terrarium.Iteration{name, target, true}
) where {NF, name, target}

Apply the regular saturation–pressure closure! after the final iteration of the implicit step, which routes the surface excess to runoff and moves the heat of the redistributed water, then update the hydraulic conductivity.

source
Terrarium.implicit_operator — Method
implicit_operator(
    snow::SingleLayerSnow,
    state,
    grid,
    ::Val{:snow_water_equivalent}
) -> DiagonalOperator

Allocate the DiagonalOperator of the implicit meltwater drainage of snow_water_equivalent, solved in the liquid fraction snow_liquid_fraction (see implicit_variable).

Drainage removes liquid water at the zero-enthalpy reference (liquid water at 0 °C), so it changes neither the snow energy Ū nor the ice content W_i = (1 − θ) W = −Ū / (ρ_w L_f), clamped to [0, W]. With Ū⁺ and W⁺ = Wⁿ + Δt G_exp from the explicit stage (snowfall, rain, and sublimation), the backward Euler step of the drainage M_r(θ, W) (compute_meltwater_outflow) is a scalar equation per column in the liquid fraction θ, via W = W_i / (1 − θ):

G(θ) = W_i / (1 − θ) + Δt M_r(θ, W_i / (1 − θ)) − W⁺ = 0.

Each Picard iteration takes one Newton step: linearizing G about the iterate θᵐ, G(θ) ≈ G(θᵐ) + G′(θᵐ) (θ − θᵐ), and setting this to zero gives the diagonal system G′(θᵐ) θᵐ⁺¹ = G′(θᵐ) θᵐ − G(θᵐ) (see the snow mass balance docs for the convergence argument). Each iteration calls the hooks:

  1. linearize!: the diagonal G′(θᵐ) and right-hand side G′(θᵐ) θᵐ − G(θᵐ), at the liquid fraction θᵐ of the current iterate Wᵐ, bounded to [0, θ⁺];
  2. solve!: θᵐ⁺¹ in snow_liquid_fraction;
  3. implicit_update!: Wᵐ⁺¹ = W_i / (1 − θᵐ⁺¹) with min(L_c, θ⁺) ≤ θᵐ⁺¹ ≤ θ⁺, since the iteration starts from Wⁿ, which may lie below the root, and meltwater_flux ← (W⁺ − Wᵐ⁺¹) / Δt, the drainage passed on to the surface hydrology in the next step;
  4. implicit_closure!: the snow closure at the new iterate.

A fully liquid pack (W_i = 0, θ = 1) drains at min(K_sat, (1 − L_c) W / τ_m), so its step has the exact solution max(W⁺ − Δt K_sat, W⁺ / (1 + Δt (1 − L_c) / τ_m)), independent of the iterate.

source
Terrarium.implicit_operator — Method
implicit_operator(
    energy::SoilThermodynamics,
    hydrology::Terrarium.AbstractSoilHydrology,
    state,
    grid
)

Return the implicit operator of the soil internal energy: a TridiagonalOperator on ground_domain(grid) for heat conduction in temperature, with a face velocity for upwind advection of heat by the water flux if the hydrology lets the water flow (SoilHydrology with RichardsEq). Validates on the host that the freeze curve is FreeWater (the only one with an implemented regularized apparent heat capacity) and that temperature has no value boundary conditions (not yet supported). Flux boundary conditions on internal_energy and gradient boundary conditions on temperature are supported; the latter prescribe the diffusive flux -κ ∂T/∂z through the boundary face, which enters the explicit tendency via compute_boundary_energy_tendency.

The operator is the backward Euler step of ∂U/∂t = ∂z(κ ∂z T) - ∂z(C_w T j_w) + G_exp in temperature, with first-order upwind advection by the vertical water flux j_w (T_up the temperature of the upwind cell of a face) and a conservative update of the energy (see the soil energy docs for the derivation). With the Picard solver, for iterations m = 0, …, M-1, starting from U⁰ = Uⁿ (plus any heat moved by the closure of the water step) and T⁰ ← closure(U⁰):

  1. linearize!: Tᵐ ← closure(Uᵐ), lagged κᵐ (faces), regularized apparent heat capacity C_appᵐ (centers), advective face velocity C_w j_w (faces), and rhs = C_appᵐ Tᵐ - Uᵐ + U⁺ with U⁺ = U⁰ + Δt G_exp;
  2. solve!: C_appᵐ Tᵐ⁺¹ - Δt ∂z(κᵐ ∂z Tᵐ⁺¹) + Δt ∂z(C_w j_w T_upᵐ⁺¹) = rhs;
  3. implicit_update!: Uᵐ⁺¹ = U⁺ + Δt [∂z(κᵐ ∂z Tᵐ⁺¹) - ∂z(C_w j_w T_upᵐ⁺¹)] through the interior faces only;
  4. implicit_closure!: Tᵐ⁺¹ and the liquid water fraction ← closure(Uᵐ⁺¹).

The solver calls the hooks through the SoilModel/LandModel forwarding methods and the SoilEnergyWaterCarbon methods in soil_coupled.jl.

source
Terrarium.implicit_operator — Method
implicit_operator(model::AbstractModel, state, names::Tuple)

Return a newly allocated AbstractLinearOperator for the implicitly routed prognostic variables names of model (e.g. a SplitOperator of per-variable operators in solve order). Called once on the host at initialize; methods throw an ArgumentError for unsupported configurations, as does the fallback. SoilModel and LandModel forward to implicit_operator(soil::AbstractSoil, state, grid, names).

source
Terrarium.implicit_operator — Method
implicit_operator(
    soil::Terrarium.AbstractSoil,
    state,
    grid,
    names::Tuple{Vararg{Symbol}}
) -> Terrarium.SplitOperator

Return the implicit operator of the soil prognostic variables names on grid: a SplitOperator of per-variable operators that solves saturation_water_ice before internal_energy, whatever the order of names. The heat step then advects heat with the water flux of the current step (water_flux, see advective_heat_flux) and sees the end-of-step saturation, while the Richards step sees the beginning-of-step temperature and liquid water fraction (the effect of frozen ground on the hydraulic conductivity is lagged by one step). Other names follow in their given order and are rejected by the per-variable fallback.

source
Terrarium.implicit_operator — Method
implicit_operator(
    hydrology::Terrarium.AbstractSoilHydrology,
    state,
    grid
)

Fallback for hydrology processes without an implicit operator; throws an ArgumentError.

source
Terrarium.implicit_operator — Method
implicit_operator(
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    state,
    grid
) where NF

Allocate the TridiagonalOperator of saturation_water_ice on ground_domain(grid). Throws an ArgumentError unless the closure is the SoilSaturationPressureClosure and pressure_head has no value boundary conditions.

The operator is the backward Euler step of the Richards equation in the total pressure head Ψ, after the mass-conservative modified Picard iteration of [3]: with porosity φ, saturation ξ, and ξ⁺ = ξⁿ + Δt G_exp from the explicit stage, the water content is linearized about the iterate m, φ ξᵐ⁺¹ ≈ φ ξᵐ + Cᵐ (Ψᵐ⁺¹ - Ψᵐ) with the specific moisture capacity Cᵐ and the hydraulic conductivity Kᵐ lagged, giving the tridiagonal system Cᵐ Ψᵐ⁺¹ - Δt ∂z(Kᵐ ∂z Ψᵐ⁺¹) = Cᵐ Ψᵐ - φ (ξᵐ - ξ⁺) (see the soil hydrology docs for the derivation). Each Picard iteration m = 0, …, M-1, starting from ξ⁰ = ξⁿ, calls the hooks:

  1. linearize!: hydraulic conductivity, lagged Kᵐ (faces) and Cᵐ (centers, bounded below by minimum_moisture_capacity so that frozen saturated cells stay regular), and the right-hand side;
  2. solve!: the system above for Ψᵐ⁺¹;
  3. implicit_update!: ξᵐ⁺¹ = ξ⁺ + Δt ∂z(Kᵐ ∂z Ψᵐ⁺¹) / φ through the interior faces, which conserves water exactly, and water_flux ← -Kᵐ ∂z Ψᵐ⁺¹, the flux with which the heat step advects heat;
  4. implicit_closure!: redistribution of over- and undersaturation, water table, Ψᵐ⁺¹, and hydraulic conductivity. Since every iteration restarts from ξ⁺, only the final one routes surface excess water to the runoff pool and moves the heat of redistributed water.

The solver calls the hooks through the SoilModel/LandModel forwarding methods and the SoilEnergyWaterCarbon methods in soil_coupled.jl.

References

  • [3] Celia, Bouloutas, and Zarba, Water Resources Research 26, 1483–1496 (1990)
source
Terrarium.implicit_operator — Method
implicit_operator(snow::AbstractSnow, state, grid, ::Val{name})

Return the implicit operator of the snow prognostic variable name: a DiagonalOperator for the meltwater drainage of snow_water_equivalent (see linearize!). The fallback throws an ArgumentError.

source
Terrarium.implicit_operator — Method
implicit_operator(soil::AbstractSoil, state, grid, ::Val{name})

Return the implicit operator of the soil prognostic variable name on grid. SoilEnergyWaterCarbon returns that of the energy process for internal_energy and of the hydrology process for saturation_water_ice; this fallback throws an ArgumentError.

source
Terrarium.implicit_step! — Method
implicit_step!(integrator::ModelIntegrator, timestepper::AbstractTimeStepper, Δt, names::Tuple)

Apply the implicit part of a time step of size Δt with the implicit timestepper to the variables in names. Called by an AbstractIMEX timestepper after the explicit_step! of its explicit partner, so each prognostic field in names already holds u⁺ = uⁿ + Δt G_exp, where Δt G_exp = u⁺ - uⁿ is the explicit increment, which contains only the explicit terms. u⁺ is the right-hand side of the implicit system, which this method solves in place.

This is unrelated to (and does not extend) Oceananigans.TimeSteppers.implicit_step!.

Implicit timesteppers must implement this method; the fallback throws an ArgumentError, and implicit_step!(integrator, ::Nothing, Δt, names) is a no-op.

source
Terrarium.implicit_step! — Method
implicit_step!(
    integrator::ModelIntegrator,
    timestepper::BackwardEuler,
    Δt,
    names::Tuple
)

Apply the implicit Euler step to the prognostic variables in names. On entry, each prognostic field holds u⁺ = uⁿ + Δt G_exp and previous_state of the BackwardEulerCache holds uⁿ (see update_cache!). The step stores Δt G_exp = u⁺ - uⁿ of every variable in the explicit_stage of its ImplicitSolverWorkspace, resets every prognostic field to the initial iterate uⁿ, and then solves all variables with the solver-level implicit_step! (see Picard) using the operator and workspaces of the cache. Since all variables are reset before any is solved, processes see the other implicit variables at uⁿ (or at uⁿ⁺¹ once solved), never at u⁺. On exit, the prognostic fields hold uⁿ⁺¹ and the closure-derived auxiliary variables are consistent with them.

source
Terrarium.implicit_step! — Method
implicit_step!(
    solver::Picard,
    operator::AbstractLinearOperator,
    workspace::Terrarium.ImplicitSolverWorkspace,
    state,
    model::Terrarium.AbstractModel,
    Δt
)

Solve the implicit system of the variable of workspace with the Picard solver and the variable's linear operator. On entry, the prognostic field in state holds the initial iterate u⁰ (uⁿ for BackwardEuler, plus any change δ made by the closures of variables solved before it) and workspace.explicit_stage holds Δt G_exp. The step forms u⁺ = u⁰ + Δt G_exp in workspace.explicit_stage (keeping δ), then for each of the solver.iterations iterations calls linearize! (lagged coefficients of operator and workspace.rhs), solve! (for the target field of the Iteration label workspace.iteration), implicit_update! (conservative update from u⁺), and implicit_closure!, passing the label with its 1-based number and final = true in the last iteration only. On exit, the prognostic field holds uⁿ⁺¹ and the closure variables are consistent with it.

source
Terrarium.implicit_step! — Method
implicit_step!(
    solver::Picard,
    operator::Terrarium.SplitOperator,
    workspaces::NamedTuple,
    state,
    model::Terrarium.AbstractModel,
    Δt
)

Solve the implicit system of a SplitOperator with the Picard solver by operator splitting: the single-variable method below is applied to each component of operator in order, with the ImplicitSolverWorkspace of that variable from workspaces. Each variable is solved at the latest state of the variables solved before it and the initial iterate of those after it, and forms its explicit stage from its current field, as in a sequential split.

source
Terrarium.implicit_step! — Method
implicit_step!(solver::AbstractImplicitSolver, operator::AbstractLinearOperator, workspaces::NamedTuple, state, model::AbstractModel, Δt)
implicit_step!(solver::AbstractImplicitSolver, operator::AbstractLinearOperator, workspace::ImplicitSolverWorkspace, state, model::AbstractModel, Δt)

Solve the implicit system of model with solver and operator (from implicit_operator), using the hooks linearize!, solve!, implicit_update!, and implicit_closure!.

The first form solves all routed variables (workspaces is a NamedTuple of ImplicitSolverWorkspaces keyed by variable name); the second solves the single variable of workspace, e.g. one component of a SplitOperator. On entry, the prognostic fields hold the initial iterate and each explicit_stage holds Δt G_exp; on exit, the prognostic fields hold the solution and their closure variables are consistent with it. The fallbacks throw an ArgumentError.

source
Terrarium.implicit_update! — Function
implicit_update!(state, model::AbstractModel, operator::AbstractLinearOperator, explicit_stage, Δt, ::Iteration{name})

Process hook of the implicit solver. Update the prognostic variable name in state conservatively from the solved target and explicit_stage, using the fluxes implied by operator.

source
Terrarium.implicit_update! — Method
implicit_update!(
    state,
    grid,
    snow::SingleLayerSnow,
    constants::PhysicalConstants,
    operator::DiagonalOperator,
    explicit_water,
    Δt,
    ::Terrarium.Iteration{:snow_water_equivalent}
)

Update snow_water_equivalent from the solved liquid fraction and store the drainage of the step in meltwater_flux (compute_implicit_snow_water_update!).

source
Terrarium.implicit_update! — Method
implicit_update!(
    state,
    grid,
    energy::SoilThermodynamics,
    soil::Terrarium.AbstractSoil,
    operator::TridiagonalOperator,
    explicit_energy,
    Δt
)

Conservative update of the soil internal energy, Uᵐ⁺¹ = U⁺ + Δt [∂z(κ ∂z Tᵐ⁺¹) - ∂z(C_w j_w T_upᵐ⁺¹)], from the implicit diffusive and advective fluxes through the interior faces (compute_implicit_energy_update), with U⁺ = explicit_energy and the lagged face conductivity κ and face velocity C_w j_w of operator.

source
Terrarium.implicit_update! — Method
implicit_update!(
    state,
    grid,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    soil::Terrarium.AbstractSoil,
    operator::TridiagonalOperator,
    explicit_saturation,
    Δt
) where NF

Update saturation_water_ice conservatively from the solved pressure head (compute_implicit_saturation_update) and store the interior Darcy fluxes in water_flux (compute_implicit_water_flux).

source
Terrarium.implicit_variable — Method
implicit_variable(var::AbstractVariable)

Name of the field that the linear system of the implicitly integrated variable var is solved for if var has no closure: the variable itself by default. Processes may linearize in a derived field instead, e.g. the snow meltwater drainage of snow_water_equivalent in snow_liquid_fraction. Not exported.

source
Terrarium.initialize! — Function

Initialize input variables from the given input sources. The scope corresponds to the path of namespace names from the root namespace to state and is used to match namespaced input sources to their target variables; see varpath.

source
Terrarium.initialize! — Function
initialize!(state, model::AbstractModel)

Initialize all variables defined in state which are defined by model. This defaults to simply calling initialize!(state, model, get_initializer(model)).

initialize!(state, model::AbstractModel, initializer::AbstractInitializer)

Initialize the model state variables using the corresponding initializer. This method only needs to be implemented if initialization routines are necessary in addition to direct field/variable initializers.

initialize!(state, grid, process::AbstractProcess, args...)

Initialize all state variables associated with the given process on grid. Implementations of AbstractProcess may define additional args that correspond to different process coupling interfaces.

source
Terrarium.initialize! — Method
initialize!(inputs, grid, clock, fields, ::InputSource)

Initializes the input source, writing into the input inputs fields at model start. The grid and the full model state fields (read-only) are provided so that sources may compute their inputs from the grid geometry or other state variables. Namespace routing is handled by the caller (see [InputSources]). Default implementation does nothing.

source
Terrarium.initialize! — Method
initialize!(state, grid, ::ImplicitSkinTemperature, args...)

Seed the prognostic skin_temperature with the current ground_temperature so the implicit nonlinear solve starts from a physically sensible guess close to the root.

source
Terrarium.initialize! — Method
initialize!(
    state,
    grid,
    snow::SingleLayerSnow,
    constants::PhysicalConstants,
    args...
)

Initialize the snow internal energy by evaluating the inverse closure (temperature → energy). Assumes snow_temperature and snow_water_equivalent have already been initialized.

source
Terrarium.initialize! — Method
initialize!(
    state,
    grid,
    soil::SoilEnergyWaterCarbon,
    constants::PhysicalConstants
)

Initialize the soil energy, water, and carbon state variables on grid given the parameter values in constants.

source
Terrarium.initialize! — Method
initialize!(
    state,
    grid,
    energy::SoilThermodynamics,
    soil::Terrarium.AbstractSoil,
    constants::PhysicalConstants,
    args...
)
source
Terrarium.initialize! — Method

Resets the simulation clock to its initial time (the time of the clock when the integrator was constructed) and calls initialize!(state, model) on the underlying model which should reset all state variables to their values as defined by the model initializer.

source
Terrarium.initialize! — Method
initialize!(
    field::Oceananigans.Fields.AbstractField,
    grid::Oceananigans.Grids.AbstractGrid,
    init::Terrarium.AbstractFieldInitializer
) -> Union{Nothing, Field{LX, LY, LZ, O, G, I, D, T} where {LX, LY, LZ, G<:Union{Nothing, Oceananigans.Grids.AbstractGrid}, T, O, I, D}, FieldTimeSeries{LX, LY, LZ, <:Any, <:Oceananigans.OutputReaders.AbstractInMemoryBackend, I, D, G, T} where {LX, LY, LZ, G<:Union{Nothing, Oceananigans.Grids.AbstractGrid}, T, I, D}, Oceananigans.OutputReaders.GPUAdaptedFieldTimeSeries{LX, LY, LZ, <:Any, <:Oceananigans.OutputReaders.AbstractInMemoryBackend, T} where {LX, LY, LZ, T}}

Initialize field on grid with the given field initializer. The default implementation evaluates init(coords...) at the node coordinates of field.

source
Terrarium.initialize! — Method
initialize!(
    state,
    grid,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    soil::Terrarium.AbstractSoil,
    constants::PhysicalConstants,
    args...
) where NF
source
Terrarium.initialize! — Method
initialize!(state, inits::NamedTuple{names}) where names

Initialize the state with Field initializers (any valid argument to set!) in inits.

source
Terrarium.initialize — Method
initialize(integrator, params; clock, inputs)

Reconstruct the given integrator using the same underlying model populated with the given params. The clock and inputs can also optionally be updated via their respective keyword arguments.

source
Terrarium.initialize — Method
initialize(
    vars::OrderedCollections.OrderedDict{Symbol, <:Terrarium.AbstractVariable},
    grid::Oceananigans.Grids.AbstractGrid,
    clock::Clock,
    fields::OrderedCollections.OrderedDict{Symbol, Oceananigans.Fields.AbstractField},
    boundary_conditions::NamedTuple
) -> OrderedCollections.OrderedDict{Symbol, Oceananigans.Fields.AbstractField}

Initialize Fields on grid for each of the variables in the given OrderedDict vars. Any predefined boundary_conditions and fields will be passed through to initialize for each variable.

source
Terrarium.initialize — Method
initialize(timestepper::AbstractTimeStepper, state, progvars, model)

Allocate the time stepper cache for timestepper against the given state. progvars is the named tuple of prognostic variable metadata and model the owning AbstractModel; both are needed e.g. by AbstractIMEX timesteppers to resolve each variable's timestepping class.

source
Terrarium.initialize — Method
initialize(
    var::Terrarium.AbstractVariable,
    grid::Oceananigans.Grids.AbstractGrid,
    clock::Clock,
    fields::OrderedCollections.OrderedDict{Symbol, Oceananigans.Fields.AbstractField},
    boundary_conditions::NamedTuple
)

Initialize a Field on grid based on the given var metadata. The named tuple of boundary_conditions should follow the standard convention of (var1 = (; top, bottom, ...), var2 = (; top, bottom, ...)). If user_fields contains a Field matching the name of var, this field will be directly returned. Otherwise check the accumulated dict for fields from previous groups. Otherwise, the new Field is constructed using the given boundary_conditions.

source
Terrarium.initialize — Method
initialize(
    var::Terrarium.AuxiliaryVariable,
    grid::Oceananigans.Grids.AbstractGrid,
    clock::Clock,
    fields::OrderedCollections.OrderedDict{Symbol, Oceananigans.Fields.AbstractField},
    boundary_conditions::NamedTuple
)

Initialize a Field on grid for the given AuxiliaryVariable.

source
Terrarium.initialize — Method
initialize(
    timestepper::BackwardEuler{NF},
    state::StateVariables,
    progvars,
    model
) where NF -> Terrarium.BackwardEulerCache{<:Any, NamedTuple{names, T}, <:AbstractLinearOperator, NamedTuple{names1, T1}} where {names, T<:Tuple, names1, T1<:Tuple}

Allocate the BackwardEulerCache for the prognostic variables in progvars, which under an AbstractIMEX are exactly those routed to the implicit sub-stepper. Per-variable fields and ImplicitSolverWorkspaces are allocated with similar from the prognostic fields of state, the operator with implicit_operator(model, state, names), and the target of each variable with resolve_implicit_target.

Throws an ArgumentError if BackwardEuler is not the implicit sub-stepper of the model's AbstractIMEX timestepper, if any variable in progvars has a non-scalar element type (the implicit solvers are scalar only), if no implicit operator supports the configuration of the variables, or if a target cannot be resolved.

source
Terrarium.initialize — Method
initialize(::AbstractTimeStepper, state)

Initialize and return the AbstractTimeStepperCache holding any intermediate fields/state required by the given timestepper. Time steppers that need no working state fall back to the default implementation, which returns an EmptyCache.

source
Terrarium.initialize — Method
initialize(model::Terrarium.AbstractModel{NF}; ...) where NF
initialize(
    model::Terrarium.AbstractModel{NF},
    params;
    clock::Clock,
    inputs::InputSource,
    boundary_conditions,
    initializers,
    fields
) where NF

Creates and initializes a ModelIntegrator for the given model with input variables populated by the given inputs and optionally params . InputSources can be specified via the inputs keyword argument. This method allocates all necessary Fields for the state variables and subsequently calls initialize!(::ModelIntegrator).

Note that this method is not type stable and thus should not be called from Enzyme autodiff. To reinitialize the model for an existing state, use initialize!(state, model).

See the docstring for initialize(::AbstractModel) for further details.

source
Terrarium.input — Method
input(name, loc; default, units, eltype, bounds, desc)

Convenience constructor method for InputVariable.

source
Terrarium.input_fields — Method
input_fields(state, components...)

Retrieves all Fields from state corresponding to input variables defined on the given components.

source
Terrarium.invclosure! — Function
invclosure!(
    state,
    grid,
    soil::SoilEnergyWaterCarbon,
    constants::PhysicalConstants
)
invclosure!(
    state,
    grid,
    soil::SoilEnergyWaterCarbon,
    constants::PhysicalConstants,
    surface_hydrology::Union{Nothing, Terrarium.AbstractSurfaceHydrology}
)

Compute the inverse closure mapping for soil hydrology and energy, in that order.

See closure! for the role of the optional surface_hydrology process.

source
Terrarium.invclosure! — Method
invclosure!(
    state,
    grid,
    closure::SnowEnergyTemperatureClosure,
    snow::SingleLayerSnow,
    constants::PhysicalConstants,
    args...
)

Inverse closure: compute the prognostic snow_energy from a prescribed snow_temperature (used for initialization). snow_water_equivalent must be initialized first, since the snow depth d_snow enters the depth-integrated energy.

source
Terrarium.invclosure! — Method
invclosure!(state, grid, closure::AbstractClosureRelation, process::AbstractProcess, args...)

Apply the inverse of closure for the process proc on the given grid with additional implementation-specific args defined by the coupling interface for the process type.

source
Terrarium.invclosure! — Method
invclosure!(state, grid, proc::AbstractProcess, args...)

Apply the inverse closure mappings for the process proc on the given grid with additional implementation-specific args defined by the coupling interface for the process type. The default implementation calls invclosure! with args for each closure returned by closures.

source
Terrarium.invclosure! — Method
invclosure!(state, model::AbstractModel)

Apply the inverse of all closure relations defined for the given model.

source
Terrarium.invclosure! — Method
invclosure!(
    state,
    grid,
    closure::SoilSaturationPressureClosure,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    soil::Terrarium.AbstractSoil
) where NF
invclosure!(
    state,
    grid,
    closure::SoilSaturationPressureClosure,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    soil::Terrarium.AbstractSoil,
    runoff::Union{Nothing, Terrarium.AbstractSurfaceRunoff},
    args...
) where NF

Computes saturation_water_ice from the current pressure_head state.

See closure! for the role of the optional runoff process.

source
Terrarium.iterations — Method
iterations(::Terrarium.NewtonSolver{NF, N}) where {NF, N}

Number of Newton iterations performed by the given solver.

source
Terrarium.kelvin_to_celsius — Method
kelvin_to_celsius(c::ThermodynamicConstants, T)

Convert the given temperature in °C to Kelvin based on the constant temperature_water_freeze.

source
Terrarium.kernel — Method
kernel(func, args...; clock = false)

Return a KernelFunction that lazily constructs a KernelFunctionOperation from the given func and tuple of args when invoked, i.e:

ctor = kerenl(my_function, arg1, arg2)
...
kfo = ctor(grid, clock, fields)

This is intended to be used as a constructor for AuxiliaryVariables:

myvar(i, j, k, grid, fields) = clamp(fields.x[i, j, k], zero(eltype(grid)), one(eltype(grid)))

auxvar = auxiliary(:myvar, Ground(XYZ()), kernel(myvar))
source
Terrarium.kernel_operation — Method
kernel_operation(
    func,
    state,
    grid,
    args...;
    location,
    with_clock
)

Return a KernelFunctionOperation over grid with the given state and trailing args.

source
Terrarium.latent_heat_flux — Method
latent_heat_flux(i, j, grid, fields, ::AbstractTurbulentFluxes)

Return the current latent heat flux at the given indices.

source
Terrarium.launch_kernel! — Method
launch_kernel!(
    grid,
    workspec,
    kernel!,
    first_arg,
    other_args...;
    kwargs...
)

Launch kernel! over grid with the Oceananigans workspec. grid is passed to the kernel as its second argument, after first_arg.

source
Terrarium.linearize! — Method
linearize!(
    operator::DiagonalOperator,
    rhs,
    state,
    grid,
    snow::SingleLayerSnow,
    constants::PhysicalConstants,
    explicit_water,
    Δt,
    ::Terrarium.Iteration{:snow_water_equivalent}
)

Fill the diagonal and right-hand side of the Newton step for the liquid fraction of the meltwater drainage (compute_implicit_meltwater_coefficients!), given the explicit stage W⁺ = explicit_water.

source
Terrarium.linearize! — Method
linearize!(
    operator::TridiagonalOperator,
    rhs,
    state,
    grid,
    energy::SoilThermodynamics,
    soil::Terrarium.AbstractSoil,
    constants::PhysicalConstants,
    explicit_energy,
    Δt
)

Linearize the implicit heat operator of the soil internal energy at the current iterate (linearly implicit backward Euler in temperature, conservative update of the internal energy). On entry, explicit_energy holds U⁺ = U⁰ + Δt G_exp, where G_exp contains the flux boundary conditions (e.g. SoilHeatFlux and GeothermalHeatFlux), the diffusive fluxes implied by gradient boundary conditions on temperature, the advective heat fluxes through the boundary faces, and the heat carried by water crossing the boundaries (compute_boundary_advected_heat!), but not the fluxes through the interior faces. This hook

  1. re-evaluates the energy closure, so that temperature and liquid water fraction are consistent with the internal energy and the current saturation (changed by the water step since tⁿ),
  2. evaluates the face conductivity κ (compute_implicit_conductivity!), the regularized apparent heat capacity C_app (compute_implicit_capacity!), and, with water flow, the advective face velocity C_w j_w from the water_flux of the step (compute_implicit_advective_velocity!), storing them in the face_conductivity, diagonal_coefficient, and face_velocity of operator,
  3. and assembles the right-hand side C_app Tᵐ - Uᵐ + U⁺ of C_app Tᵐ⁺¹ - Δt ∂z(κ ∂z Tᵐ⁺¹) + Δt ∂z(C_w j_w T_upᵐ⁺¹) = C_app Tᵐ - Uᵐ + U⁺ (compute_implicit_energy_rhs).

implicit_update! then updates the internal energy conservatively: for any number of iterations, the change of column-integrated energy is exactly Δt times the net boundary flux in G_exp.

source
Terrarium.linearize! — Method
linearize!(
    operator::TridiagonalOperator,
    rhs,
    state,
    grid,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    soil::Terrarium.AbstractSoil,
    constants::PhysicalConstants,
    explicit_saturation,
    Δt
) where NF

Update the hydraulic conductivity (compute_hydraulics!), fill the lagged capacity and face conductivity of operator (compute_implicit_water_flow_coefficients!), and assemble the right-hand side C Ψᵐ - φ (ξᵐ - ξ⁺) in rhs (compute_implicit_water_flow_rhs), with ξ⁺ = explicit_saturation. [3] recommend at least two iterations.

References

  • [3] Celia et al., Water Resources Research 26, 1483–1496 (1990)
source
Terrarium.linearize! — Method
linearize!(operator::AbstractLinearOperator, rhs, state, model::AbstractModel, explicit_stage, Δt, ::Iteration{name})

Process hook of the implicit solver. Fill the lagged coefficients of operator and the right-hand side rhs for variable name at the current iterate in state, given the explicit stage explicit_stage (u⁺ = uⁿ + Δt G_exp). The fallback throws an ArgumentError.

source
Terrarium.liquid_water_fraction — Function
liquid_water_fraction(i, j, k, grid, fields, ::AbstractSoilHydrology)

Compute or retrieve the current fraction of unfrozen water in the pore space.

source
Terrarium.liquid_water_fraction — Method
liquid_water_fraction(::FreeWater, U::NF, ρLθ::NF) where NF

Calculate the unfrozen water content from the given internal energy U (J/m³) and volumetric latent heat content ρLθ (J/m³).

source
Terrarium.litterfall_bc — Method
litterfall_bc(i, j, grid, clock, fields)

Discrete-form boundary-condition function (see LitterfallFlux), computes incoming litterfall carbon inputs to the soil. Note that module computes infiltration as positive downward, so it is negated here since fluxes are by convention positive upward.

source
Terrarium.load_asset — Method
load_asset(
    asset::Terrarium.AbstractLandAsset,
    name::String;
    NF,
    fill_value
)

Download (if necessary) the given asset via get_asset and read the variable name from its data file, returning a suitable Array-type based on the asset's file format. The asset's indices are applied when reading (e.g. to select a single time record), and fill_value replaces missing data; it defaults to NF(NaN).

The underlying read is dispatched to an I/O extension based on the asset's format; load Rasters.jl and NCDatasets.jl to enable reading NetCDF and other raster files.

source
Terrarium.load_asset — Method
load_asset(path, name, fmt, ::Type{NF}; indices, fill_value) where {NF}

Dispatch implemented by I/O backends which reads variable name from the asset file at path.

source
Terrarium.locate_asset_file — Method
locate_asset_file(
    dir::String,
    format::Terrarium.FileFormat
) -> String

Locate the single data file of the given format within an installed artifact directory dir, searching recursively. Errors unless exactly one matching file is found.

source
Terrarium.longwave_down — Method
longwave_down(i, j, grid, fields, ::AbstractAtmosphere{NF, PR, <:LongShortWaveRadiation})

Retrieve or compute the incoming/downwelling longwave radiation at the current time step.

source
Terrarium.longwave_up — Method
longwave_up(i, j, grid, fields, ::AbstractRadiativeFluxes)

Return the current outgoing (upwelling) longwave radiation at the given indices i, j.

source
Terrarium.matches_scope — Method
matches_scope(
    source::InputSource,
    scope::Tuple{Vararg{Symbol}}
) -> Union{Missing, Bool}

Determine whether the given source provides an input variable for the namespace at the given scope, where scope is the path of namespace names from the root namespace, i.e. () for the root namespace itself, (:ns1,) for its child namespace ns1, and so on.

source
Terrarium.min_snow_conduction_thickness — Method
min_snow_conduction_thickness(
    i,
    j,
    grid,
    fields,
    ::SingleLayerSnow
)

Minimum snow thickness (m) used to regularize the snow thermodynamics (conductive fluxes and the volumetric energy/temperature closure) as the pack thins toward zero: half the thickness of the uppermost soil grid cell, so the floor scales with the grid resolution rather than a fixed constant.

source
Terrarium.min_zᵃᵃᶠ — Method
min_zᵃᵃᶠ(i, j, k, grid, x)
min_zᵃᵃᶠ(i, j, k, grid, f, args...)

Computes the field or function at the vertical (z-axis) face by taking the min of the two adjacent vertical layers.

source
Terrarium.mineral_porosity — Function
mineral_porosity(::AbstractSoilPorosity, texture::SoilTexture)

Compute or retrieve the natural porosity of the mineral soil constitutents, i.e. excluding organic material.

source
Terrarium.mineral_texture — Function
organic_fraction(::AbstractSoilMatrix)

Return the SoilTexture describing the mineral component of the soil matrix.

source
Terrarium.mineral_thermal_conductivity — Method
mineral_thermal_conductivity(conductivities, texture)

Compute the thermal conductivity of the mineral grains for the given texture as the quartz-weighted geometric mean of the quartz and non-quartz mineral endpoints ([38]; [39]):

\[\lambda_{\text{min}} = \lambda_q^{\,q} \, \lambda_o^{\,1 - q}\]

where the quartz volume fraction $q$ is assumed equal to the sand fraction.

source
Terrarium.minimum_moisture_capacity — Function
minimum_moisture_capacity(hydraulics::AbstractSoilHydraulics)

Numerical lower bound (1/m) of the specific moisture capacity ∂θ/∂ψ used on the diagonal of the implicit Richards solve (see compute_implicit_capacity!). It plays the role of a small specific storage: in saturated cells ∂θ/∂ψ = 0, and a saturated cell whose faces have zero hydraulic conductivity (e.g. a frozen saturated cell) would otherwise give a singular row of the tridiagonal system.

source
Terrarium.normalize_texture! — Method
normalize_texture!(
    sand::Oceananigans.Fields.AbstractField{LX, LY, LZ, G, NF},
    silt::Oceananigans.Fields.AbstractField{LX, LY, LZ, G, NF},
    clay::Oceananigans.Fields.AbstractField{LX, LY, LZ, G, NF};
    default
) where {LX, LY, LZ, G, NF}

Normalize the given sand, silt, and clay fraction Fields in place such that the fractions sum to unity in each element, as required by the SoilTexture constructor.

source
Terrarium.ntdiff — Method
ntdiff(nt, other)

Filters out all entries from nt that exist in other; like setdiff but for NamedTuple. The retained keys are determined from the types alone, so no key filtering happens at run time.

source
Terrarium.organic_fraction — Method
organic_fraction(
    i,
    j,
    k,
    grid,
    fields,
    strat::SoilStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
)

Compute the organic fraction of solid material in the soil volume at index i, j, k.

source
Terrarium.organic_porosity — Function
organic_porosity(::AbstractSoilPorosity, texture::SoilTexture)

Compute or retrieve the natural porosity of the organic soil constitutents, i.e. excluding mineral material.

source
Terrarium.porosity — Method
porosity(
    i,
    j,
    k,
    grid,
    fields,
    strat::SoilStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
)

Compute the porosity of the soil volume at the given indices.

source
Terrarium.porosity — Method
porosity(horizon::Terrarium.AbstractSoilHorizon)

Return the porosity parameterization for the given soil horizon.

source
Terrarium.porosity_top — Method
porosity_top(
    i,
    j,
    grid,
    fields,
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
)

Porosity of the topmost soil layer at column i, j, i.e. porosity(i, j, Nz, grid, fields, strat, bgc) where Nz is the number of grid cells in the z-dimension. Intended for use as a 2D (XY) diagnostic or boundary condition term, e.g. via KernelFunctionOperation{Center, Center, Nothing}.

source
Terrarium.processes — Method
processes(obj::Union{AbstractCoupledProcesses, AbstractModel})

Return a tuple of AbstractProceses contained in the given model or coupled processes type. Note that this is a type-stable, @generated function that is compiled for each argument type.

source
Terrarium.prognostic — Method
prognostic(name, loc; units, eltype, closure, bounds, desc)

Convenience constructors for PrognosticVariable.

source
Terrarium.prognostic_fields — Method
prognostic_fields(state, components...)

Retrieves all Fields from state corresponding to prognostic variables defined on the given components.

source
Terrarium.rainfall — Method
rainfall(i, j, grid, fields, ::AbstractAtmosphere{NF, <:RainSnow})

Retrieve or compute the liquid precipitation (rainfall) at the current time step.

source
Terrarium.rainfall_ground — Function
rainfall_ground(i, j, grid, fields, ::AbstractCanopyInterception)

Compute or retrieve the current rate of precipitation reaching the ground [m/s].

source
Terrarium.redistribute_saturation_profile! — Method
redistribute_saturation_profile!(
    out,
    i,
    j,
    grid,
    fields,
    hydrology::SoilHydrology{NF, VerticalFlow, SaturationClosure, SoilHydraulics} where {VerticalFlow<:Terrarium.AbstractVerticalFlow, SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})}
) where NF
redistribute_saturation_profile!(
    out,
    i,
    j,
    grid,
    fields,
    hydrology::SoilHydrology{NF, VerticalFlow, SaturationClosure, SoilHydraulics} where {VerticalFlow<:Terrarium.AbstractVerticalFlow, SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    energy
) where NF
redistribute_saturation_profile!(
    out,
    i,
    j,
    grid,
    fields,
    hydrology::SoilHydrology{NF, VerticalFlow, SaturationClosure, SoilHydraulics} where {VerticalFlow<:Terrarium.AbstractVerticalFlow, SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    energy,
    strat
) where NF
redistribute_saturation_profile!(
    out,
    i,
    j,
    grid,
    fields,
    hydrology::SoilHydrology{NF, VerticalFlow, SaturationClosure, SoilHydraulics} where {VerticalFlow<:Terrarium.AbstractVerticalFlow, SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    energy,
    strat,
    bgc
) where NF

Kernel function that adjusts saturation profiles to account for oversaturation and undersaturation arising due to numerical error. This implementation scans over the saturation profiles at each lateral grid cell and redistributes excess water upward layer-by-layer until reaching the topmost layer, and saturation deficits below the residual saturation downward and then back upward, drawing on the water of the neighboring layers. Water is conserved unless the column as a whole holds less water than its residual saturation, in which case the topmost layer is filled up to the residual saturation. The remaining surface excess is returned as the excess saturation of the topmost layer times its thickness (m); the caller multiplies by the topmost porosity to get a water depth (m³/m²) to route into a surface water pool, or discards it. With an energy process, every saturation change also changes the internal energy in out by the sensible heat of the water (compute_redistributed_heat!).

source
Terrarium.relative_to_specific_humidity — Method
relative_to_specific_humidity(r_h, pr, T, c::ThermodynamicConstants)

Derives specific humidity from measured relative humidity r_h [%], air pressure pr [Pa], air temperature T [°C], and physical constants c. Assumes saturation over ice for T <= 0°C and over liquid water otherwise. Wrapper around q_vap_from_RH.

source
Terrarium.relaxed_update — Method
relaxed_update(
    relax::Terrarium.RelaxationFactor{NF},
    x_target::NF,
    x_old::NF
) where NF

Apply the under-relaxed fixed-point update to the skin temperature.

source
Terrarium.reset_inputs! — Method
reset_inputs!(
    state::StateVariables,
    vars::Terrarium.Variables
)

Reset all input Fields in state to the defaults declared by the corresponding input variables in vars (see InputVariable), recursing into namespaces. Inputs without a default are left unchanged. This is called by initialize!(::ModelIntegrator) with the variables of the current model, before any InputSources are applied, so that defaults always reflect the current model parameters while input sources take precedence over them.

source
Terrarium.resolve_implicit_target — Method
resolve_implicit_target(
    var::Terrarium.PrognosticVariable,
    state
)

Return the name of the field of state that the linear system of the implicitly integrated variable var is solved for (its target): varname of its closure if it has one, and implicit_variable of var otherwise (the variable itself by default). Implicit operators are thus linearized in the closure variable, e.g. temperature for internal_energy and pressure_head for saturation_water_ice. Called on the host when the BackwardEuler cache is allocated; throws an ArgumentError if the closure does not implement varname or state has no field of the resolved name. Not exported.

source
Terrarium.root_density — Function
root_density(::AbstractRootDistribution, z, args...)

Compute the continuous density function of the given root distirbution as a function of depth z. Note that this function must be integrated and normalized over the root zone in order to obtain the cumulative root fraction in each soil layer.

source
Terrarium.root_density — Method
root_density(
    rd::StaticExponentialRootDistribution{NF},
    z
) where NF

Compute the continuous density function of the root distirbution as a function of depth z.

source
Terrarium.root_fraction — Method

Returns a FunctionField that lazily computes the static root distribution on a 1D column grid.

The FunctionField takes (x, z) arguments, so this is restricted to land grids with a Flat lateral (y) dimension, i.e. those built on column discretizations.

source
Terrarium.run_timesteps! — Function
run_timesteps!(integrator, Δt, steps, checkpointing = false)

Advance integrator for the given number of steps of size Δt.

The generic (host) implementation is a plain loop and ignores checkpointing. ReactantState integrators override this method in TerrariumReactantExt, compiling the loop into a single traced program in which checkpointing selects the reverse-mode-AD checkpointing scheme (false, or a scheme such as Reactant.Periodic(n)).

source
Terrarium.safediv — Method
safediv(x, y)

Evaluates x / (y + eps(NF)) if and only if y != zero(y); returns Inf otherwise.

source
Terrarium.saturation_infiltration_bc — Method
saturation_infiltration_bc(
    i,
    j,
    grid,
    clock,
    fields,
    parameters
)

Discrete-form boundary-condition function (see InfiltrationFlux) computing -infiltration / por at column i, j, where infiltration is the physical infiltration flux (m/s of water depth, positive downward) and por is the porosity of the topmost soil layer (porosity_top). saturation_water_ice is the dimensionless saturation (VWC / porosity) so the flux crossing the top boundary must be normalized by porosity to be dimensionally consistent with the interior Richards tendency, which divides by porosity for the same reason (see compute_saturation_tendency!). Note that the hydrology ,odule computes infiltration as positive downward, so it is negated here since fluxes are by convention positive upward.

source
Terrarium.saturation_specific_humidity_vapor — Method
saturation_specific_humidity_vapor(c::ThermodynamicConstants, T, ρ)

Compute saturation specific humidity at temperature T (°C) and density ρ (kg/m³) via q_vap_saturation. Uses ice-phase saturation for T < -1°C, liquid-water saturation for T > 0°C, and linearly interpolates between the two in the range [-1, 0]°C to avoid a discontinuity at the freezing point that can break Newton-type root solvers.

source
Terrarium.saturation_water_ice — Function
saturation_water_ice(i, j, k, grid, fields, ::AbstractSoilHydrology)

Compute or retrieve the current saturation level of water + ice in the pore space.

source
Terrarium.seconds_per_year — Method
seconds_per_year(::Type{NF})

Return the number of seconds per (Julian) year of 365.25 days in the given number format.

source
Terrarium.select_keys — Method
select_keys(
    nt::NamedTuple,
    ::NamedTuple{names}
) where names -> NamedTuple

Return the entries of the NamedTuple nt with the keys of like, in the order of like. The keys are taken from the type of like, so the selection is resolved at compile time; together with fastiterate(f, nts::NamedTuple...) this iterates over a subset of nt type-stably, unlike indexing nt with a Symbol passed at run time.

source
Terrarium.shortwave_down — Method
shortwave_down(i, j, grid, fields, ::AbstractAtmosphere{NF, PR, <:LongShortWaveRadiation})

Retrieve or compute the incoming/downwelling shortwave radiation at the current time step.

source
Terrarium.shortwave_up — Method
shortwave_up(i, j, grid, fields, ::AbstractRadiativeFluxes)

Return the current outgoing (upwelling) shortwave radiation at the surface.

source
Terrarium.skin_temperature — Method
skin_temperature(i, j, grid, fields, ::AbstractSkinTemperature)

Return the current skin temperature at the given indices.

source
Terrarium.snow_cover_fraction — Function
snow_cover_fraction(i, j, grid, fields, ::AbstractSnow)

Compute or retrieve the sub-grid snow-covered area fraction f_snow ∈ [0,1].

source
Terrarium.snow_density — Method
snow_density(snow::SingleLayerSnow)

Bulk snow density ρ_snow [kg/m³] of the snowpack, delegating to the process's density scheme.

source
Terrarium.snow_depth — Function
snow_depth(i, j, grid, fields, ::AbstractSnow)

Compute or retrieve the snow layer depth d_snow [m].

source
Terrarium.snow_domain — Method
snow_domain(::Oceananigans.Grids.AbstractGrid)

Return the spatial discretization of the snow domain of grid, or nothing if the snowpack is not vertically resolved. Grids which are not land grids never resolve a snow domain.

source
Terrarium.snow_energy — Function
snow_energy(i, j, grid, fields, ::AbstractSnow)

Retrieve the depth-integrated (column) snow internal energy Ū_snow [J/m²] relative to ice at 0°C.

source
Terrarium.snow_meltwater_flux — Method
snow_meltwater_flux(
    i,
    j,
    grid,
    fields,
    snow::SingleLayerSnow
)

Snow meltwater outflow M_r (m/s SWE) at grid cell i, j, the meltwater_flux auxiliary: the outflow at the current liquid fraction under explicit integration (see compute_meltwater_flux!), and the drainage of the last implicit step otherwise.

source
Terrarium.snow_thermal_interface — Method
snow_thermal_interface(
    i,
    j,
    grid,
    fields,
    snow::Terrarium.AbstractSnow,
    constants::PhysicalConstants
) -> Tuple{Any, Any, Any}

Return the conduction target (Tsnow, κsnow, dsnow) for the snow-covered fraction: the snow's own (bulk) temperature, its thermal conductivity recovered from the density scheme, and its depth floored at min_snow_conduction_thickness. Without snow (snow === nothing), returns a placeholders with κsnow = 0 such that the snow conductive heat flux reduces to zero.

source
Terrarium.snow_water_equivalent — Function
snow_water_equivalent(i, j, grid, fields, ::AbstractSnow)

Retrieve the snow water equivalent (SWE) W (m) — the total water substance (ice + retained liquid).

source
Terrarium.snowfall — Method
snowfall(i, j, grid, fields, ::AbstractAtmosphere{NF, <:RainSnow})

Retrieve or compute the frozen precipitation (snowfall) at the current time step.

source
Terrarium.soil_composition — Function
soil_composition(i, j, k, grid, fields, ::AbstractStratigraphy, args...)

Return a SoilComposition describing the full material composition of the soil volume at index i, j, k for the given stratigraphy parameterization.

source
Terrarium.soil_composition — Method
soil_composition(
    i,
    j,
    k,
    grid,
    fields,
    strat,
    hydrology,
    bgc
)

Construct a SoilComposition object summarizing the material composition of the soil volume at the given indices i, j, k on grid.

source
Terrarium.soil_horizon — Method
soil_horizon(
    i,
    j,
    k,
    grid,
    fields,
    strat::SoilStratigraphy{NF, N, Horizons} where {N, Horizons<:NTuple{N, Terrarium.AbstractSoilHorizon{NF}}}
) where NF

Retrieve the soil horizon for the soil volume at index i, j, k. The last soil horizon in strat is assumed to extend to the bottom of the vertical column regardless of its associated thickness. Note that, since SoilStratigraphy uses namespaces for the state variables of each horizon, any methods defined on AbstractSoilHorizon types should be passed the namespace, e.g:

horizon = soil_horizon(i, j, k, grid, fields, strat)
texture = soil_texture(i, j, grid, getproperty(fields, nameof(horizon)), horizon)
source
Terrarium.soil_matrix — Function
soil_matrix(i, j, grid, fields, ::AbstractSoilHorizon, args...)
soil_matrix(i, j, k, grid, fields, ::AbstractStratigraphy, args...)

Return the solid matrix of the soil at index i, j, k for the given stratigraphy parameterization.

source
Terrarium.soil_matrix — Method
soil_matrix(
    i,
    j,
    k,
    grid,
    fields,
    strat::Terrarium.AbstractStratigraphy,
    bgc::Terrarium.AbstractSoilBiogeochemistry
) -> MineralOrganic

Compute and return the soil solid matrix at index i, j, k on grid. The default implementation assumes a simple MineralOrganic parameterization of the solid material.

source
Terrarium.soil_moisture_limiting_factor — Method
soil_moisture_limiting_factor(
    grid,
    clock,
    fields,
    ::FieldCapacityLimitedPAW
) -> Field{LX, LY, LZ, O, G, I, D, T, B, Oceananigans.Fields.FieldStatus{Float64}} where {LX, LY, LZ, O, G, I, D, T, B}

Field constructor for the soil moisture limiting factor. Returns a derived Field that calculates the integral of W(z) * r(z) where W is the water availability coefficient and r is the root fraction.

source
Terrarium.soil_surface_water_flux — Function
soil_surface_water_flux(
    i,
    j,
    grid,
    fields,
    canopy_interception::Terrarium.AbstractCanopyInterception
)
soil_surface_water_flux(
    i,
    j,
    grid,
    fields,
    canopy_interception::Terrarium.AbstractCanopyInterception,
    snow::Union{Nothing, Terrarium.AbstractSnow}
)

Meltwater flux [m/s] reaching the soil surface, accounting for the snowpack. Without snow this is just the rainfall reaching the ground; with snow the snow-covered fraction f_snow intercepts rain into the snowpack, so only the bare-ground fraction (1 − f_snow)·rain_ground reaches the soil directly, plus the snow meltwater outflow M draining from the snowpack base.

source
Terrarium.soil_texture — Function
soil_texture(i, j, grid, fields, ::AbstractSoilHorizon, args...)
soil_texture(i, j, k, grid, fields, ::AbstractStratigraphy, args...)

Return the texture of the soil at index i, j, k for the given stratigraphy parameterization.

source
Terrarium.soil_texture — Method
soil_texture(
    i,
    j,
    k,
    grid,
    fields,
    strat::SoilStratigraphy{NF, N, Horizons} where {N, Horizons<:NTuple{N, Terrarium.AbstractSoilHorizon{NF}}}
) where NF

Retrieve the soil texture of the soil volume at index i, j, k in the given stratigraphy strat.

source
Terrarium.solve! — Function
solve!(out, indices, grid, fields, objective_func!::ObjectiveFunction, solver, args...; kwargs...)

Solve the nonlinear problem defined by objective_func! for its target field at the given indices, mutating out in place. The objective returns the residual F(x) whose root is sought; on return, the target field holds the converged estimate and the method returns the root (and, for some solvers, the number of iterations performed). Dispatches on the concrete solver type, e.g. RootSolver, NewtonSolver or FixedPointSolver.

source
Terrarium.solve! — Method
solve!(target, operator::DiagonalOperator, rhs, Δt, args...)

Solve the system of operator for target with right-hand side rhs, target = rhs / D pointwise.

source
Terrarium.solve_skin_temperature! — Method
solve_skin_temperature!(
    out,
    i,
    j,
    grid,
    fields,
    skinT::ImplicitSkinTemperature,
    seb::Terrarium.AbstractSurfaceEnergyBalance,
    args...
)

Run a full nonlinear solve to determine the skin_temperature at grid cell i, j that solves the surface energy balance.

source
Terrarium.solve_surface_energy_balance! — Method
solve_surface_energy_balance!(
    state,
    grid,
    seb::SurfaceEnergyBalance{NF, SkinTemperature, RadiativeFluxes, TurbulentFluxes, GroundHeatFlux, Albedo} where {SkinTemperature<:Terrarium.AbstractSkinTemperature{NF}, RadiativeFluxes<:Terrarium.AbstractRadiativeFluxes{NF}, TurbulentFluxes<:Terrarium.AbstractTurbulentFluxes{NF}, GroundHeatFlux<:Terrarium.AbstractGroundHeatFlux{NF}, Albedo<:Terrarium.AbstractAlbedo{NF}},
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere
) where NF
solve_surface_energy_balance!(
    state,
    grid,
    seb::SurfaceEnergyBalance{NF, SkinTemperature, RadiativeFluxes, TurbulentFluxes, GroundHeatFlux, Albedo} where {SkinTemperature<:Terrarium.AbstractSkinTemperature{NF}, RadiativeFluxes<:Terrarium.AbstractRadiativeFluxes{NF}, TurbulentFluxes<:Terrarium.AbstractTurbulentFluxes{NF}, GroundHeatFlux<:Terrarium.AbstractGroundHeatFlux{NF}, Albedo<:Terrarium.AbstractAlbedo{NF}},
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    hydrology::Union{Nothing, Terrarium.AbstractSurfaceHydrology}
) where NF
solve_surface_energy_balance!(
    state,
    grid,
    seb::SurfaceEnergyBalance{NF, SkinTemperature, RadiativeFluxes, TurbulentFluxes, GroundHeatFlux, Albedo} where {SkinTemperature<:Terrarium.AbstractSkinTemperature{NF}, RadiativeFluxes<:Terrarium.AbstractRadiativeFluxes{NF}, TurbulentFluxes<:Terrarium.AbstractTurbulentFluxes{NF}, GroundHeatFlux<:Terrarium.AbstractGroundHeatFlux{NF}, Albedo<:Terrarium.AbstractAlbedo{NF}},
    constants::PhysicalConstants,
    atmos::Terrarium.AbstractAtmosphere,
    hydrology::Union{Nothing, Terrarium.AbstractSurfaceHydrology},
    snow::Union{Nothing, Terrarium.AbstractSnow},
    args...
) where NF

Solve the surface energy balance for skin temperature on grid based on the current atmospheric and surface hydrology state.

source
Terrarium.specific_heat_capacity_moist_air — Method
specific_heat_capacity_moist_air(c::ThermodynamicConstants, q)

Compute the isobaric specific heat capacity [J/(kg*K)] of moist air as a function of the total specific humidity q [kg/kg]. Wrapper around cp_m.

source
Terrarium.specific_humidity — Method
specific_humidity(i, j, grid, fields, ::PrescribedAtmosphere{PR, IR, <:SpecificHumidity})

Retrieve or compute the specific_humidity at the current time step.

source
Terrarium.specific_humidity_difference — Method
specific_humidity_difference(
    c::ThermodynamicConstants{NF},
    p,
    q_air,
    T
) where NF

Computes the difference in specific humidity between a saturated surface at temperature T [°C] and the atmosphere, defined by its specific humidity q_air [kg/kg] and pressure p [Pa].

source
Terrarium.specific_moisture_capacity — Method
specific_moisture_capacity(swrc::SWRC, ψ, θsat)

Specific moisture capacity ∂θ/∂ψ (1/m) of the soil water retention curve swrc at the matric potential ψ (m) for the saturated water content θsat, from the derivative provided by FreezeCurves.jl, in the number type of ψ; zero for saturated conditions.

julia> swrc = VanGenuchten(α = 2.0, n = 2.0);

julia> Terrarium.specific_moisture_capacity(swrc, 0.0, 0.4)
0.0

julia> Terrarium.specific_moisture_capacity(swrc, -0.5, 0.4) ≈ swrc(Terrarium.FreezeCurves.derivative, -0.5; θsat = 0.4)
true
source
Terrarium.stefan_boltzmann — Method
stefan_boltzmann(c::UniversalConstants, T, ϵ)

Stefan-Boltzmann law $M = \epsilon \sigma T^4$ where T is the surface temperature in Kelvin and ϵ is the emissivity and σ is the Stefan-Boltzmann constant.

source
Terrarium.surface_excess_water — Function
surface_excess_water(i, j, k, grid, fields, ::AbstractSoilHydrology)

Retrieve the current saturation level of water + ice in the pore space.

source
Terrarium.temperature_to_energy! — Method
temperature_to_energy!(
    out,
    i,
    j,
    grid,
    fields,
    ::SnowEnergyTemperatureClosure,
    snow::SingleLayerSnow,
    constants::PhysicalConstants
)

Compute the depth-integrated snow energy from a prescribed temperature at grid cell i, j.

source
Terrarium.tendency — Method
tendency(var)

Creates an AuxiliaryVariable for the tendency of a prognostic variable with the given name, dimensions, and physical units. This constructor is primarily used internally by other constructors and does not usually need to be called by implementations of variables.

source
Terrarium.tendency_fields — Method
tendency_fields(state, components...)

Retrieves all Fields from state corresponding to tendencies defined on the given components.

source
Terrarium.timestamp — Method
timestamp(::Type{TT}, reftime, Δt)

Convert the time delta Δt to a suitable timestamp of type TT relative to reftime. If TT is a TimeType (i.e. Date or DateTime), then this method returns reftime + Δt.

source
Terrarium.timestep! — Function
timestep!(integrator::ModelIntegrator, timestepper::AbstractTimeStepper, Δt)

Advance prognostic variables of the integrator model by one time step based on the current state, or by Δt units of time.

source
Terrarium.timestep! — Method
timestep!(integrator::ModelIntegrator, timestepper::AbstractIMEX, Δt)

Advance the model by one IMEX step of size Δt using an AbstractIMEX timestepper:

  1. update_cache! of the implicit sub-stepper for the Implicit variables, while their fields still hold uⁿ;
  2. the explicit sub-stepper's explicit_step! for all prognostic variables, which evaluates the tendencies itself; for implicitly routed variables, these hold only the explicit terms (see timestepping(state, ::Val)), so the step gives u⁺ = uⁿ + Δt G_exp, the right-hand side of the implicit system, where Δt G_exp = u⁺ - uⁿ is the explicit increment of the partner (e.g. evaluated at tⁿ for ForwardEuler);
  3. implicit_step! of the implicit sub-stepper for the implicit variables;
  4. closure!, followed by a single clock tick.
source
Terrarium.timestep! — Method
timestep!(integrator::ModelIntegrator, timestepper::AbstractTimeStepper, Δt)

Advance the model forward by one timestep of size Δt using a single timestepper, which integrates all prognostic variables. Dispatches on the timestepper's timestepping trait (Explicit/Implicit) to timestep!(integrator, timestepper, ::Timestepping, Δt).

source
Terrarium.timestep! — Method
timestep!(integrator::ModelIntegrator, timestepper::AbstractTimeStepper, ::Timestepping, Δt)

Trait-dispatched single-timestepper step: forward the prognostic variable names to the scheme's timestep!(integrator, timestepper, Δt, names) method and advance the clock once for the whole step.

source
Terrarium.timestep! — Method
timestep!(integrator::ModelIntegrator; finalize)

Advance the model forward by one timestep with optional timestep size Δt. If finalize = true, compute_auxiliary! is called after the time step in order to update the values of auxiliary/diagnostic variables.

source
Terrarium.timestepping — Method
timestepping(timestepper::Optional{AbstractTimeStepper}, state::StateVariables, ::Val{name})

Return the Timestepping class with which the prognostic variable name of state is integrated by timestepper, for process methods that receive the model's timestepper. A single timestepper uses its own class (see timestepping(timestepper)), an AbstractIMEX the per-variable class in its IMEXCache (see timestepping(state, ::Val)), and nothing (e.g. standalone process evaluation) gives Explicit(). Type stable.

source
Terrarium.timestepping — Method
timestepping(timestepper::AbstractTimeStepper)::Timestepping

Return the Timestepping trait (Explicit or Implicit) of the given timestepper. Every concrete timestepper must define this trait (e.g. timestepping(::ForwardEuler) = Explicit()); there is no default so that a new scheme declares its class explicitly. It is used, among other things, to route each sub-stepper of an AbstractIMEX to its slice of the IMEXCache.

timestepping(var::AbstractVariable, model::AbstractModel, timestepper::AbstractTimeStepper)::Timestepping

Return the Timestepping class with which the prognostic variable var of model is integrated under timestepper. Defaults to Explicit() for all variables; specialize this method (typically on an AbstractIMEX timestepper together with particular variable and/or model types) to route selected variables to the implicit sub-stepper.

source
Terrarium.timestepping — Method
timestepping(state::StateVariables, ::Val{name})
timestepping(state::StateVariables, var::AbstractVariable{name})

Return the resolved Timestepping class (Explicit or Implicit) of the prognostic variable name in state. Under an AbstractIMEX timestepper the class is read from the IMEXCache type parameter in state.timestepper_cache; for any other cache every variable is Explicit(), as are names that are not top-level prognostic variables (including variables in namespaces, which an IMEX does not route).

The lookup is resolved at compile time (type stable), so the trait can be passed to process methods (e.g. compute_tendencies!) that dispatch on it.

source
Terrarium.transpiration_conductance — Method
transpiration_conductance(
    ::PALADYNCanopyEvapotranspiration{NF},
    rₐ,
    g_stm
) where NF

Compute the transpiration vapor conductance [m/s] from aerodynamic resistance rₐ and stomatal conductance g_stm. The transpiration flux is this conductance times the humidity gradient.

source
Terrarium.update_cache! — Method
update_cache!(cache::AbstractTimeStepperCache, integrator::ModelIntegrator, Δt, names::Tuple)

Update the timestepper cache from the state of integrator for the variables in names, at the start of a step (before the explicit step, while the prognostic fields still hold uⁿ). Timesteppers that retain beginning-of-step state implement this on their cache type (e.g. BackwardEulerCache stores a copy of uⁿ). The default is a no-op.

source
Terrarium.update_cache! — Method
update_cache!(
    cache::Terrarium.BackwardEulerCache,
    integrator::ModelIntegrator,
    Δt,
    names::Tuple
)

Store uⁿ of each variable in names in previous_state of the BackwardEulerCache. Called by the AbstractIMEX driver before the explicit step overwrites the fields with u⁺.

source
Terrarium.update_inputs! — Function

Update input variables from the given input sources. The scope corresponds to the path of namespace names from the root namespace to state and is used to match namespaced input sources to their target variables; see varpath.

source
Terrarium.update_inputs! — Method
update_inputs!(inputs, grid, clock, fields, ::InputSource)

Updates the values of the input variables stored in inputs from the given input source, called at every time step. The grid and the full model state fields (read-only) are provided so that sources may compute their inputs from the grid geometry or other state variables. Namespace routing is handled by the caller (see [InputSources]). Default implementation returns nothing.

source
Terrarium.uses_reactant — Method
uses_reactant(_)

Return true when Reactant is loaded, false otherwise.

Note, that ReactantCore.within_compile is not used because it doesn't work properly when KA kernels aren't raised.

source
Terrarium.validate_timestepper — Method
validate_timestepper(imex::AbstractIMEX)

Host-side validation of an AbstractIMEX: the sub-steppers must be given in the order IMEX(explicit, implicit) (checked via their timestepping traits), and each must accept its role via validate_timestepper(sub_stepper, imex).

source
Terrarium.validate_timestepper — Method
validate_timestepper(timestepper::AbstractTimeStepper)
validate_timestepper(timestepper::AbstractTimeStepper, imex::AbstractIMEX)

Host-side validation of a timestepper configuration, called from initialize before any cache is allocated. The one-argument form validates timestepper alone (a no-op by default); the two-argument form validates it as a sub-stepper of imex and throws an ArgumentError for unsupported roles (a no-op by default). Not exported.

source
Terrarium.vapor_pressure_deficit — Method
vapor_pressure_deficit(c, T, pres, q_air)

Computes the vapor pressure deficit for an air parcel at temperature T [°C] with pressure pres [Pa] and specific humidity q_air [kg/kg]. Assumes that air parcel is over water when T > 0°C and over ice when T < 0°C. Wrapper around vapor_pressure_deficit.

source
Terrarium.var — Function
var(name, dims; ...)
var(name, dims, units; eltype)

Convenience constructor for Variable. A variable normally states the domain it lives on by wrapping its VarDims in a VarDomain, e.g. var(:temperature, Ground(XYZ())) or var(:snow_temperature, Snow(XY())).

Bare dimensions, e.g. var(:u, XY()), declare the variable without a domain. This is for models discretized on a plain AbstractGrid, where there is only one discretization and naming a domain would say nothing. Prefer stating the domain in any model which runs on an AbstractLandGrid: there the domain is a real choice, and a reader of the declaration should not have to infer it.

source
Terrarium.vardims — Method
vardims(
    ::Oceananigans.Fields.AbstractField{LX, LY, Nothing}
)

Infer the appropriate VarDims from the given Field.

This infers the dimensions of an externally supplied field, e.g. one wrapped by an InputSource, and returns only XY or XYZ. It is deliberately not the inverse of the Field constructor: a field created from a Top or Bottom variable reports XY, because recovering the Coordinate would mean inferring intent from the field's indices. Where the domain or the coordinate matters, read the variable's declared VarLocation instead.

source
Terrarium.variable_grid — Method
variable_grid(grid, loc)

Return the spatial discretization on which a variable at loc is allocated.

A domain which the model does not resolve vertically still has variables: a single-layer snowpack has a snow water equivalent, a big-leaf canopy has a temperature. Those variables carry no vertical dimension, so they are allocated on the shared horizontal discretization, which is the ground domain's. A variable which is vertically resolved (XYZ) cannot be placed on a domain with no vertical discretization, and asking for one is a configuration error.

A grid which is not an AbstractLandGrid has a single discretization and no notion of domains, so the variable's domain is ignored and the grid is returned unchanged.

source
Terrarium.variables — Function
variables(model::AbstractModel)
variables(process::AbstractProcess)

Return a Tuple of AbstractVariables (i.e. PrognosticVariable, AuxiliaryVariable, etc.) defined by the model or process.

source
Terrarium.variables — Method
variables(::InputSource) -> Tuple{}

Returns a tuple of Symbols corresponding to variable names supported by this InputSource.

source
Terrarium.varloc — Method
varloc(source)

Retrieve the VarLocation of the variable this input source provides, and its constituent VarDims and VarDomain. The dimensions are inferred from the source data; the domain is given when the source is constructed and must match the variable it feeds.

source
Terrarium.varname — Method
varname(source::InputSource)

Returns the name of the input variable provided by this source, i.e. the last entry of its varpath.

source
Terrarium.varname — Method
varname(::SoilEnergyTemperatureClosure) -> Symbol

Name of the variable returned by the SoilEnergyTemperatureClosure (varname interface for closures): temperature. The closure also diagnoses liquid_water_fraction, but the temperature is its primary variable, in which the implicit heat operator of internal_energy is solved (see BackwardEuler).

source
Terrarium.varname — Method
varname(::Terrarium.AbstractVariable{name})

Retrieve the name of the given variable or closure. For closure relations, varname should return the name of the variable returned by the closure relation.

source
Terrarium.varpath — Method
varpath(name::Symbol)
varpath(path::Pair)
varpath(path::Tuple{Vararg{Symbol}})

Normalize the given variable name into a path of the form (namespace_1, ..., namespace_N, varname). Plain Symbol names correspond to variables in the root namespace, i.e. the path (varname,). Namespaced variables can be specified either as Pairs, e.g. :ns1 => :ns2 => :varname, or directly as a tuple of Symbols, e.g. (:ns1, :ns2, :varname).

source
Terrarium.vegetation_area_fraction — Function
vegetation_area_fraction(i, j, grid, fields, ::AbstractVegetationDynamics)

Return the fraction of the grid cell i, j covered by vegetation of any type.

source
Terrarium.volumetric_fractions — Method
volumetric_fractions(soil::SoilComposition) -> NamedTuple

Calculates the volumetric fractions of all constituents in the given soil volume and returns them as a named tuple of the form (; water, ice, air, solids...), where solids corresponds to the volumetric fractions defined by the solid phase soil.solid.

source
Terrarium.volumetric_fractions — Method
volumetric_fractions(
    solid::MineralOrganic{NF},
    solid_frac::NF
) where NF -> NamedTuple{(:organic, :mineral), <:Tuple{Any, Any}}

Compute the volumetric fractions of the solid phase scaled by the overall solid fraction of the soil solid_frac.

source
Terrarium.water_outflow_timescale — Method
water_outflow_timescale(
    state,
    grid,
    hydrology::SoilHydrology{NF, RichardsEq, SaturationClosure, SoilHydraulics} where {SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:(Terrarium.AbstractSoilHydraulics{NF})},
    soil::Terrarium.AbstractSoil,
    constants::PhysicalConstants,
    evtr::Union{Nothing, Terrarium.AbstractEvapotranspiration},
    timestepping::Timestepping
) where NF

Return the minimum over all cells of the explicit water outflow timescale (compute_water_outflow_timescale) of a Richards-equation hydrology: the time in which the explicit terms of the saturation tendency, evaluated at the current state, would drain a cell to its residual saturation. timestepping is the resolved Timestepping class of saturation_water_ice, which selects the explicit terms as in compute_tendencies!.

source
Terrarium.water_table — Function
water_table(i, j, k, grid, fields, ::AbstractSoilHydrology)

Compute or retrieve the current water table level relative to the surface.

source
Terrarium.windspeed — Method
windspeed(
    i,
    j,
    grid,
    fields,
    atmos::Terrarium.AbstractAtmosphere{NF, PR, IR, HD, Windspeed, AD} where AD<:Terrarium.AbstractAerodynamics{NF}
) where {NF, PR, IR, HD}

Retrieve or compute the windspeed at the current time step.

source
Terrarium.with_scope — Method
with_scope(path, var)

Wrap the given variable var in nested Namespaces according to the path, where path is the namespace scope (i.e. the sequence of enclosing namespace names, excluding the variable's own name). An empty path returns var unwrapped.

source
Terrarium.with_soil_horizon — Method
with_soil_horizon(
    func,
    i,
    j,
    k,
    grid,
    fields,
    strat::SoilStratigraphy,
    args...;
    kwargs...
)

Convenience method that invokes func(i, j, grid, horizon_fields, horizon, args...; kwargs...) where horizon is the soil horizon returned by soil_horizon and horizon_fields is getproperty(fields, nameof(horizon)).

source
Core.Type — Method
(::Type{Model})(grid::AbstractGrid; kwargs...) where {Model <: AbstractModel}

Convenience constructor for all AbstractModel types that accepts grid as a positional argument.

source
Oceananigans.Fields.Field — Type
Field(
    grid::AbstractGrid,
    loc::VarLocation,
    boundary_conditions = nothing,
    args...;
    kwargs...
)

Auxiliary constructor for an Oceananigans Field on grid at the given Terrarium variable location and boundary conditions. Additional arguments are passed directly to the Field constructor.

VarLocation determines both where the field is allocated and what shape it has: its VarDomain selects the domain discretization via variable_grid, and its VarDims give the Oceananigans location and, for variables declared at a single point such as Top or Bottom, the indices which restrict the field to that point.

Note that the Field is allocated on the domain discretization rather than on the land grid itself, so that field.grid names the domain the field lives on and Oceananigans' own grid methods, many of which dispatch on concrete grid types, apply to it unchanged.

source
Oceananigans.Fields.Field — Method
Field(ring_field, grid; domain)

Converts a RingGrids.Field to an Oceananigans Field using the given ColumnRingGrid. Only masked grid points are copied to the Oceananigans field. For 2D RingGrids fields, returns a 2D Oceananigans field. For 3D fields, returns a 3D field.

source
Oceananigans.OutputReaders.FieldTimeSeries — Type
FieldTimeSeries(
    grid::AbstractGrid,
    loc::VarLocation,
    times=eltype(grid)[];
    kwargs...
)

Construct a FieldTimeSeries on the domain discretization of grid selected by loc, with the given times. Additional keyword arguments (e.g. time_indexing = Cyclical() for a periodically repeating climatology) are forwarded to the Oceananigans FieldTimeSeries constructor.

source
Oceananigans.OutputReaders.FieldTimeSeries — Method
FieldTimeSeries(ring_field, grid, times; domain, kwargs...)

Converts a RingGrids.Field whose last dimension is time to an Oceananigans FieldTimeSeries on the given ColumnRingGrid, one snapshot per entry of times. Only masked grid points are copied. A 2D RingGrids field (horizontal × time) yields a 2D series, a 3D field (horizontal × vertical × time) a 3D series. Additional keyword arguments (e.g. time_indexing = Cyclical()) are forwarded to the FieldTimeSeries constructor.

source
RingGrids.Field — Method
Field(field, grid; fill_value)

Converts the given Oceananigans Field to a RingGrids.Field with a ring grid matching that of the given ColumnRingGrid.

source
Terrarium.AbstractAerodynamics — Type
abstract type AbstractAerodynamics{NF}

Base type for aerodynamic parameterizations that compute the bulk drag coefficient for turbulent heat and moisture exchange between the land surface and atmosphere.

source
Terrarium.AbstractAtmosphere — Type
abstract type AbstractAtmosphere{NF, PR<:Terrarium.AbstractPrecipitation, IR<:Terrarium.AbstractIncomingRadiation, HM<:Terrarium.AbstractHumidity, WS<:Terrarium.AbstractWind, AD<:Terrarium.AbstractAerodynamics{NF}} <: Terrarium.AbstractProcess{NF}

Base type for representations of the atmosphere that provide meterological state variables such as air temperature and pressure, humidity, precipitation, incoming solar radiation, gas concentrations, wind speed, and near-surface aerodynamics.

source
Terrarium.AbstractClosureRelation — Type
abstract type AbstractClosureRelation

Base type for prognostic variable closure relations for differential equations of the form:

\[\frac{\partial g(u)}{\partial t} = F(u)\]

where F represents the RHS tendency as a function of the state variable u, and g(u) is a closure or constitutive relation that maps u to the physical units matching the tendency. Common examples in soil hydrothermal modeling are temperature-enthalpy and saturation-pressure relations.

source
Terrarium.AbstractCoupledProcesses — Type
abstract type AbstractCoupledProcesses{NF} <: Terrarium.AbstractProcess{NF}

Base type for AbstractProces implementations that define a coupling interface for (typically two or more) sub-processes.

source
Terrarium.AbstractEnergyClosure — Type
abstract type AbstractEnergyClosure <: Terrarium.AbstractClosureRelation

Base type for closure relations between internal energy and temperature in a material volume.

source
Terrarium.AbstractFieldInitializer — Type

Base type for reusable initializers of a single Field. Implementations should provide a dispatch of initialize!(field, grid, init::AbstractFieldInitializer). The default evaluates init as a callable at the node coordinates of field, i.e. init(coords...), via set!.

A field initializer is accepted everywhere a set!-compatible value is: as the default of an input variable, as an entry of the initializers keyword argument of initialize, or as a parameter of a model AbstractInitializer. In the latter case it may declare @param fields, which are then exposed as model parameters.

source
Terrarium.AbstractGroundHeatFlux — Type

Base type for ground heat flux schemes, i.e. schemes that determine the energy flux G across the top of the ground (soil) column. All fluxes are positive upward.

source
Terrarium.AbstractHumidity — Type
abstract type AbstractHumidity

Base type for representations of near-surface atmospheric humidity. Subtypes define which form of humidity (e.g. specific or relative humidity) is used as input.

source
Terrarium.AbstractIMEX — Type
abstract type AbstractIMEX{NF} <: Terrarium.AbstractTimeStepper{NF}

Base type for implicit-explicit (IMEX) time steppers, which combine an explicit and an implicit sub-stepper. The explicit sub-stepper applies the explicit tendency terms of all prognostic variables; variables of timestepping class Implicit are then advanced by the implicit sub-stepper (see implicit_step!), while those of class Explicit are fully integrated by the explicit stage.

Concrete subtypes (e.g. IMEX) must provide the sub-steppers via explicit_timestepper and implicit_timestepper; the remaining behavior is defined here.

source
Terrarium.AbstractIncomingRadiation — Type
abstract type AbstractIncomingRadiation

Base type for representations of downwelling (incoming) radiation. Subtypes define which spectral components are provided as inputs (e.g. split into shortwave and longwave).

source
Terrarium.AbstractInitializer — Type

Base type for model initializers. Implementations should provide a dispatch of the initialize!(state, model::M, init::I) method where M corresponds to the model type and I to the initializer. Initializers may additionally implement variables to declare input variables for their (possibly spatially varying) parameters; these are collected by variables(model) alongside the process variables.

source
Terrarium.AbstractLandGrid — Type

Base type for land grids, i.e. grids which collect the spatial discretizations of all vertical domains (ground, snow, canopy) of a land model. AbstractLandGrids are the grid types stored by AbstractModels; they are constructed from an ordinary Oceananigans AbstractGrid via create_land_grid. LandGrid is the only implementation.

Land grids wrap the per-domain spatial discretizations and forward the AbstractGrid interface to the ground domain; implementations need only define ground_domain.

source
Terrarium.AbstractLinearOperator — Type
abstract type AbstractLinearOperator

Base type for the linearized operator of a model's implicitly integrated prognostic variables. An operator owns its working state (coefficient fields and linear solver), is filled by linearize!, and is solved by solve! in each solver iteration. Operators of several variables either compose per-variable operators (e.g. SplitOperator) or couple them. They are allocated by implicit_operator at initialize and stored in the timestepper's cache (e.g. BackwardEulerCache).

source
Terrarium.AbstractModel — Type
abstract type AbstractModel{NF, Grid<:Oceananigans.Grids.AbstractGrid}

Base type for all Terrarium "models". Models are standalone representations of a system that consist of

(i) a spatial grid characterizing the model domain, (ii) zero or more AbstractProcesses defining the dynamics, and (iii) an AbstractInitializer responsible for defining the initial state of the model.

Implementations of AbstractModel are required to implement, at minimum, three methods:

  • variables which declares the state variables requried by the model,
  • compute_auxiliary! which is responsible for computing all auxiliary (non-prognostic) variables,
  • compute_tendencies! which is responsible for computing the tendencies of all prognostic variables.

Note that a default implementation of variables is provided which automatically collects all variables declared by AbstractProcesses defined as fields (properties) of structs that subtype AbstractModel.

source
Terrarium.AbstractPlantAvailableWater — Type
abstract type AbstractPlantAvailableWater{NF} <: Terrarium.AbstractProcess{NF}

Base type for processes that comptue the plant available water fraction in each soil layer.

source
Terrarium.AbstractPrecipitation — Type
abstract type AbstractPrecipitation

Base type for representations of atmospheric precipitation. Subtypes define which variables describe the precipitation input (e.g. rain and snow as separate fields).

source
Terrarium.AbstractProcess — Type
abstract type AbstractProcess{NF}

Base type for all "processes". Implementations of AbstractProcess define equations, state variables, and parameterizations which characterize the dynamics of a system at for any given transient state. Note that processes should be largely agnostic to the details regarding spatial and temporal discretization of the model; i.e. they should not require specification of a specific grid or time stepping scheme but rather should be able to operate on any given set of Fields and parameters representing the state of a model at any point in time. Note that process types may also wrap/orchestrate one or more other process types.

source
Terrarium.AbstractSnow — Type
abstract type AbstractSnow{NF} <: Terrarium.AbstractCoupledProcesses{NF}

Base type for coupled snow processes. Implementations should typically couple an energy balance and a mass (water equivalent) balance for a snowpack overlying the ground surface. Snow is modeled as its own coupled process (a sibling of soil), reusing the medium-agnostic FreeWater enthalpy relations for the energy↔temperature closure (the same closure used for the soil; see Soil energy balance).

source
Terrarium.AbstractSoil — Type
abstract type AbstractSoil{NF} <: Terrarium.AbstractCoupledProcesses{NF}

Base type for coupled soil processes.

source
Terrarium.AbstractSoilHorizon — Type
abstract type AbstractSoilHorizon{NF, name}

Base type for soil "horizons", i.e. vertical segments of soil with homogeneous soil properties and a user-defined name.

source
Terrarium.AbstractSoilHydraulics — Type
abstract type AbstractSoilHydraulics{NF, RC<:SWRC, UnsatK<:Terrarium.AbstractUnsatK}

Base type for soil hydraulic properties and parameterization schemes.

source
Terrarium.AbstractSoilHydrology — Type
abstract type AbstractSoilHydrology{NF} <: Terrarium.AbstractProcess{NF}

Base type for soil hydrology implementations. Subtypes should define state variables for saturation_water_ice, hydraulic_conductivity, liquid_water_fraction, and the current water_table level, along with any other implementation-specific state variables.

source
Terrarium.AbstractSoilThermodynamics — Type
abstract type AbstractSoilThermodynamics{NF} <: Terrarium.AbstractThermodynamics{NF}

Base type for soil energy balance process implementations. Subtypes should define state variables for soil temperature, internal_energy, and any other relevant thermal properties or state variables. Soil energy balances evolve the soil internal energy and therefore subtype AbstractThermodynamics.

source
Terrarium.AbstractSoilWaterClosure — Type
abstract type AbstractSoilWaterClosure <: Terrarium.AbstractClosureRelation

Base type for closure relations between water saturation and potential in soil volumes.

source
Terrarium.AbstractThermodynamics — Type
abstract type AbstractThermodynamics{NF} <: Terrarium.AbstractProcess{NF}

Base type for energy balance process implementations that evolve the internal energy of a solid or porous material medium.

source
Terrarium.AbstractVegetation — Type
abstract type AbstractVegetation{NF} <: Terrarium.AbstractCoupledProcesses{NF}

Base type for coupled vegetation (carbon) processes.

source
Terrarium.AbstractWind — Type
abstract type AbstractWind

Base type for representations of wind input fields. The target input variable is windspeed but subtypes may define different input formulations (e.g. u/v component velocities).

source
Terrarium.Atmosphere — Type
struct Atmosphere <: Terrarium.VarDomain

The near-surface atmosphere: the domain of atmospheric forcing variables, i.e. quantities a land model reads rather than computes, such as air temperature, wind, humidity, precipitation, and downwelling radiation. Atmosphere is intended for forcing variables only. Like Surface, Atmosphere carries no vertical discretization, so its variables must be declared as Atmosphere(XY()); Atmosphere(XYZ()) raises an error.

source
Terrarium.AuxiliaryVariable — Type
struct AuxiliaryVariable{name, VL<:Terrarium.VarLocation, UT<:Unitful.Units, Var<:Terrarium.Variable{name, VL, UT}, BT<:IntervalSets.AbstractInterval, FC} <: Terrarium.AbstractProcessVariable{name, VL, UT}

Represents an auxiliary (a.k.a "diagnostic") state variable with the given name and spatial dims. Auxiliary variables are those which are diagnosed directly or indirectly from the values of one or more prognostic variables.

source
Terrarium.BackwardEuler — Type
struct BackwardEuler{NF, S<:Terrarium.AbstractImplicitSolver} <: Terrarium.AbstractTimeStepper{NF}

First-order implicit (backward) Euler timestepper for use as the implicit sub-stepper of an IMEX timestepper, e.g. IMEX(ForwardEuler(NF), BackwardEuler(NF)). For each prognostic variable routed to it (see timestepping), the implicit step solves

uⁿ⁺¹ = u⁺ + Δt G_imp(uⁿ⁺¹),    u⁺ = uⁿ + Δt G_exp,

where G_imp is the implicitly treated tendency and u⁺ the result of the explicit partner's step for the explicitly treated terms (G_exp = G_exp(uⁿ) for ForwardEuler). The system is solved by solver (an AbstractImplicitSolver); the linearized operator of all routed variables is provided by the model (see implicit_operator). BackwardEuler has no time step size of its own: the IMEX takes Δt from its explicit partner (see default_dt).

Properties:

  • solver::Terrarium.AbstractImplicitSolver: Solver for the implicit system
source
Terrarium.BackwardEuler — Method
BackwardEuler(
    ::Type{NF};
    solver::Terrarium.AbstractImplicitSolver
) where NF -> BackwardEuler{<:Any, Picard}

Construct a BackwardEuler timestepper with numeric type NF and implicit solver.

source
Terrarium.BackwardEulerCache — Type
struct BackwardEulerCache{NF, US, Operator<:AbstractLinearOperator, Workspaces<:NamedTuple} <: Terrarium.AbstractTimeStepperCache{NF}

Cache for the BackwardEuler timestepper. previous_state and workspaces are NamedTuples keyed by the names of the prognostic variables routed to the implicit sub-stepper: previous_state holds uⁿ of each variable (stored by update_cache!), and workspaces holds the ImplicitSolverWorkspace of each variable (right-hand side, explicit stage, and non-final Iteration label). The target of the label is the closure variable (as given by varname of the closure) if the variable has a closure, and the variable itself otherwise. operator holds the AbstractLinearOperator of all routed variables, as returned by implicit_operator(model, state, names) (e.g. a SplitOperator of one TridiagonalOperator per variable).

Properties:

  • previous_state::Any: Copy of the state uⁿ at the beginning of the step for each implicitly routed prognostic variable, stored by update_cache!

  • operator::AbstractLinearOperator: Linearized implicit operator of all implicitly routed prognostic variables

  • workspaces::NamedTuple: ImplicitSolverWorkspace of each implicitly routed prognostic variable

source
Terrarium.BareGroundEvaporation — Type
BareGroundEvaporation{NF, GR} <: AbstractEvapotranspiration

Evaporation scheme for bare ground that calculates the humidity flux as

\[E = \beta \frac{\Delta q}{r_a}\]

where Δq is the specific humidity difference, rₐ is aerodynamic resistance, and β is an evaporation limiting factor.

source
Terrarium.Bottom — Type
Bottom(x = Center(), y = Center(), z = Face())

Dimensions for a variable defined at a single point at the bottom of a domain's vertical axis, such as a basal flux. The vertical index is resolved with firstindex, so a field declared this way is restricted to k = 1.

See also Top.

source
Terrarium.Canopy — Type
struct Canopy <: Terrarium.VarDomain

The canopy domain, i.e. the vegetation layer. A grid which does not discretize the canopy vertically (a big-leaf scheme) still carries its 2D variables.

source
Terrarium.ColumnGrid — Type

Alias for an Oceananigans RectilinearGrid representing a set of laterally independent vertical columns with dimensions (x, y, z) where x (Periodic) is the column dimension, y = 1 is constant (Flat), and z is the vertical axis with Bounded topology. The x-dimension is somewhat arbitrairly assigned a Periodic topology to reflect the fact that it has no well defined spatial extent.

source
Terrarium.ColumnGrid — Method
ColumnGrid(arch, ::Type{NF}, vertical_coordinate)
ColumnGrid(
    arch,
    ::Type{NF},
    vertical_coordinate,
    num_columns
)

Creates a ColumnGrid from the given architecture, numeric type NF, and vertical_coordinate, which may be any VerticalCoordinate: a vector of cell interfaces, such as the one returned by UniformSpacing, or a discretization such as the one returned by ExponentialSpacing. The num_columns determines the number of laterally independent columns initialized on the grid.

source
Terrarium.ColumnRingGrid — Type
struct ColumnRingGrid{NF, Arch, RingGrid<:RingGrids.AbstractGrid, RectGrid<:Oceananigans.Grids.RectilinearGrid, Mask<:AbstractArray} <: Oceananigans.Grids.YFlatGrid{NF, Oceananigans.Grids.Periodic, Oceananigans.Grids.Bounded, Arch, Nothing}

Represents a global (spherical) grid of independent, vertical columns where the spatial discretization in the horizontal direction is defined by a RingGrids.AbstractGrid.

source
Terrarium.ConstantAerodynamics — Type
struct ConstantAerodynamics{NF} <: Terrarium.AbstractAerodynamics{NF}

Dummy implementation of aerodynamics that simply returns constant values for all drag coefficients.

source
Terrarium.ConstantAlbedo — Type
struct ConstantAlbedo{NF} <: Terrarium.AbstractAlbedo{NF}

Properties:

  • albedo::Any: Surface albedo, i.e. ratio of outgoing to incoming shortwave radiation

  • emissivity::Any: Surface emissivity, i.e. fraction of thermal radiation emitted from the surface

source
Terrarium.ConstantEvaporationResistanceFactor — Type
struct ConstantEvaporationResistanceFactor{NF} <: Terrarium.AbstractGroundEvaporationResistanceFactor

Represents a spatiotemporally constant ground evaporation resistance factor.

Note that this factor does not limit ground evaporation by the soil water supply: with a factor greater than zero, the ground evaporates at the same fraction of its potential rate regardless of how dry the soil is. It is therefore only suitable where soil water is not limiting; use SoilMoistureResistanceFactor otherwise.

source
Terrarium.ConstantSaturation — Type
struct ConstantSaturation{NF, S} <: Terrarium.AbstractInitializer{NF}

Initializer for soil water/ice that sets the saturation profile of each column to the value of the initial_saturation input variable, whose default is sat. See QuasiThermalSteadyState for the accepted forms of the default.

Properties:

  • sat::Any: Initial water/ice saturation (-)
source
Terrarium.ConstantSnowAlbedo — Type
struct ConstantSnowAlbedo{NF} <: Terrarium.AbstractSnowAlbedo{NF}

Basic constant albedo scheme for snow that treats both albedo and emissivity as both spatially and temporally constants. The default values are for freshly fallen snow, taken from [17].

source
Terrarium.ConstantSnowDensity — Type
struct ConstantSnowDensity{NF} <: Terrarium.AbstractSnowDensity{NF}

Constant, spatially homogeneous bulk snow density ρ_snow. This is the default (and currently only) snow density scheme for SingleLayerSnow. Default bulk snow density follows [17].

Properties:

  • density::Any: Bulk snow density ρ_snow

References

  • [17] Westermann et al., Geoscientific Model Development (2016)
source
Terrarium.ConstantSnowHydraulics — Type
struct ConstantSnowHydraulics{NF} <: Terrarium.AbstractSnowHydraulics{NF}

Constant, spatially homogeneous snow hydraulic properties: a saturated hydraulic conductivity K_sat, a capillary retention L_c, and a drainage timescale τ_m, setting the meltwater outflow (see compute_meltwater_outflow). Default values follow [5].

Properties:

  • saturated_conductivity::Any: Hydraulic conductivity at saturation

  • capillary_retention::Any: Capillary retention L_c: liquid fraction held against gravity before meltwater drains

  • drainage_timescale::Any: Drainage timescale τ_m of the liquid water in excess of the capillary retention, limiting the outflow to the water stored in the pack

References

  • [5] Tarboton, Chowdhury and Jackson (1994)
source
Terrarium.ConstantSoilCarbonDensity — Type
struct ConstantSoilCarbonDensity{NF} <: Terrarium.AbstractSoilBiogeochemistry{NF}

Naive implementation of soil biogeochemistry that just assumes there to be a constant organic content in all soil layers.

Properties:

  • ρ_soc::Any: Soil organic carbon density

  • ρ_org::Any: Pure organic matter density

source
Terrarium.ConstantSoilHorizon — Type
struct ConstantSoilHorizon{NF, name, Porosity<:Terrarium.AbstractSoilPorosity{NF}} <: Terrarium.AbstractSoilHorizon{NF, name}

Represents an arbitrary soil horizon whose properties (texture and porosity) are assumed to be constant across both space and time.

source
Terrarium.ConstantSoilHydraulics — Type
struct ConstantSoilHydraulics{NF, RC, UnsatK<:Terrarium.AbstractUnsatK{NF}} <: Terrarium.AbstractSoilHydraulics{NF, RC, UnsatK}

Represents a simple case where soil hydraulic properties are given as constant values. This is mostly provided just for testing, although it may be useful in certain cases where direct measurements of hydraulic properites are available.

Properties:

  • swrc::Any: Soil water retention curve

  • unsat_hydraulic_cond::Terrarium.AbstractUnsatK: Unsaturated hydraulic conductivity formulation; defaults to the formulation matching swrc (see default_unsat_hydraulic_cond)

  • saturated_conductivity::Any: Hydraulic conductivity at saturation

  • field_capacity::Any: Constant field capacity

  • wilting_point::Any: Constant wilting point

  • residual_saturation::Any: Residual (minimum) saturation level

  • minimum_moisture_capacity::Any = 1.0e-5: Lower bound (1/m) of the specific moisture capacity ∂θ/∂ψ on the diagonal of the implicit Richards solve (implicit time stepping only)

source
Terrarium.ConstantSoilPorosity — Type
struct ConstantSoilPorosity{NF} <: Terrarium.AbstractSoilPorosity{NF}

Parameterization of soil porosity that simply specifies constant values for the mineral and organic components.

source
Terrarium.ConstantSoilTemperature — Type
struct ConstantSoilTemperature{NF, T0} <: Terrarium.AbstractInitializer{NF}

Initializer for soil/ground temperature that sets the temperature profile of each column to the value of the initial_surface_temperature input variable, whose default is T₀.

T₀ may be a number, a function of the horizontal node coordinates, an array, a Field, or an AbstractFieldInitializer. It is re-applied as the default of the input variable at every initialization and can be overridden by an InputSource named initial_surface_temperature.

Properties:

  • T₀::Any: Initial surface temperature (°C)
source
Terrarium.ConstantSoilTemperature — Method
ConstantSoilTemperature(
    ::Type{NF};
    T₀
) where NF -> ConstantSoilTemperature

Creates a constant soil temperature initializer with the given surface temperature T₀ (°C).

source
Terrarium.Coordinate — Type
struct Coordinate{V, L}

Helper type used for specifying a single point or cross-section in space along the X, Y, or Z axis. If val = nothing, the coordinate is undefined or integrated over the extent of the axis.

source
Terrarium.DiagnosedGroundHeatFlux — Type
struct DiagnosedGroundHeatFlux{NF} <: Terrarium.AbstractGroundHeatFlux{NF}

Ground heat flux G diagnosed from the rest of the surface energy balance. With all fluxes positive upward (aligned with +z), the energy arriving at the skin from below must balance the radiative and turbulent losses above, so the atmosphere-side demand is the residual G = R_net + H_s + H_l.

How that demand is realized depends on the skin temperature scheme: PrescribedSkinTemperature does not calculate G as a conductive flux and stores the demand, whereas ImplicitSkinTemperature stores the explicit conductive flux 2κ_g (T_g - T_s) / Δz_g evaluated at the current skin temperature, which coincides with the demand only at convergence.

source
Terrarium.DiagnosedRadiativeFluxes — Type
struct DiagnosedRadiativeFluxes{NF} <: Terrarium.AbstractRadiativeFluxes{NF}

Computes outgoing shortwave and longwave radiation according to separately specified schemes for the albedo, skin temperature, and atmospheric inputs.

source
Terrarium.DiagnosedTurbulentFluxes — Type
struct DiagnosedTurbulentFluxes{NF} <: Terrarium.AbstractTurbulentFluxes{NF}

Represents the standard case where the turbulent (sensible and latent) heat fluxes are diagnosed from atmosphere and soil conditions.

source
Terrarium.DiagnosticAlbedo — Type
struct DiagnosticAlbedo{NF} <: Terrarium.AbstractAlbedo{NF}

Diagnosed surface albedo and emissivity. The values are computed in compute_auxiliary! as an area-weighted blend of bare ground, vegetation, and snow, α = (1 − f_snow)·(1 − f_veg)·α_bg + (1 − f_snow)·f_veg·α_veg + f_snow·α_snow (and likewise for emissivity), where f_veg is the vegetated area fraction of the optional vegetation component and f_snow the snow-covered area fraction of the optional snow component passed to compute_auxiliary!. Snow-covered bare and vegetated areas are assumed to share the same snow albedo and emissivity. Without a vegetation or snow component (nothing), the corresponding fraction is zero.

Properties:

  • background_albedo::Any: Snow- and vegetation-free (background) albedo of bare ground

  • background_emissivity::Any: Snow- and vegetation-free (background) emissivity of bare ground

source
Terrarium.DiagonalOperator — Type
struct DiagonalOperator{Diagonal} <: AbstractLinearOperator

Diagonal AbstractLinearOperator for implicit terms without spatial coupling, e.g. the meltwater outflow of a single-layer snowpack. Each row of the system reads D ϕ = rhs, with the lagged diagonal D in diagonal, so that solve! is a pointwise division. The diagonal field is allocated at the location of the field the system is solved for.

julia> grid = ColumnGrid(CPU(), Float64, UniformSpacing(Δz = 0.1, N = 4));

julia> operator = DiagonalOperator(Field{Center, Center, Nothing}(ground_domain(grid)));

julia> size(operator.diagonal)
(1, 1, 1)

Properties:

  • diagonal::Any: Lagged diagonal D, at the location of the field it is solved for
source
Terrarium.DirectSurfaceRunoff — Type
struct DirectSurfaceRunoff{NF} <: Terrarium.AbstractSurfaceRunoff{NF}

Simple surface runoff scheme that computes runoff as

\[R = P + D - I\]

where P is precipitation reaching the ground, D is drainage from accumualted excess water at the surface, and I is infiltration into the soil.

Properties:

  • τ_r: Surface water removal timescale
source
Terrarium.ERA5LandForcings — Type
struct ERA5LandForcings <: Terrarium.AbstractLandAsset

One year of ERA5-Land hourly meterological variables regridded to approximately 1° x 1° resolution (72 Gaussian rings).

VariableDescriptionUnits
t2m2 metre air temperatureK
d2m2 metre dewpoint temperatureK
tpTotal precipitationm
sfSnowfall (water equivalent)m
spSurface pressurePa
ssrdSurface solar (shortwave) radiation downwardsJ/m²
strdSurface thermal (longwave) radiation downwardsJ/m²
u1010 metre eastward (U) wind componentm/s
v1010 metre northward (V) wind componentm/s
source
Terrarium.ERA5LandInvariants — Type
struct ERA5LandInvariants <: Terrarium.AbstractLandAsset

Time-invariant spatial fields from ERA5-Land at the native 0.1° x 0.1° resolution.

VariableDescriptionUnits
cvhHigh vegetation coverfraction (0–1)
lsmLand-sea mask (fraction of land)fraction (0–1)
tvlType of low vegetationcategorical index
cvlLow vegetation coverfraction (0–1)
zSurface geopotential (orography × g)m²/s²
sltSoil typecategorical index
dlLake total depthm
clLake coverfraction (0–1)
si1010 metre wind speedm/s
tvhType of high vegetationcategorical index
source
Terrarium.ERA5LandLeafAreaIndex — Type
struct ERA5LandLeafAreaIndex{grid} <: Terrarium.AbstractLandAsset

Leaf area index daily climatology for 1980-2010 from ERA5-Land at the native 0.1° x 0.1° resolution.

VariableDescriptionUnits
lai_lvLeaf area index, low vegetationm²/m²
lai_hvLeaf area index, high vegetationm²/m²
source
Terrarium.FieldBCs — Type

Alias for a NamedTuple of FieldBC types where the keys correspond to field/variable names.

source
Terrarium.FieldCapacityLimitedPAW — Type
struct FieldCapacityLimitedPAW{NF} <: Terrarium.AbstractPlantAvailableWater{NF}

Implementation of vegetation water availability (a.k.a "plant available water") that computes the wilting fraction

\[W_i = \min\left(\frac{\theta_{\text{w},i} - \theta_{\text{wp},i}}{\theta_{\text{fc},i} - \theta_{\text{wp},i}} , 1\right)\]

where $\theta_{\text{w},i}$ is the volumetric water content of the $i$'th soil layer, $\theta_{\text{fc},i}$ is the "field capacity", and $\theta_{\text{wp},i}$ is the "wilting point". The water availability

Properties:

source
Terrarium.FieldInputSource — Type
struct FieldInputSource{NF, name, VL<:Terrarium.VarLocation, FS<:(Oceananigans.Fields.AbstractField{LX, LY, LZ, G, NF} where {LX, LY, LZ, G}), UT} <: InputSource{NF, name}

Input source that defines input state variables with the given names which can then be directly modified by the user.

source
Terrarium.FieldTimeSeriesInputSource — Type
struct FieldTimeSeriesInputSource{NF, name, VL<:Terrarium.VarLocation, FTS<:(FieldTimeSeries{LX, LY, LZ, TI, K, I, D, G, NF} where {LX, LY, LZ, TI, K, I, D, G}), TT, UT} <: InputSource{NF, name}

Input source that reads input fields from pre-specified Oceananigans FieldTimeSeries.

source
Terrarium.FixedPointSolver — Type
struct FixedPointSolver{NF, R}

Fixed-point (Picard) iteration solver. Repeatedly applies the update g(x) = x - F(x), where F is the residual returned by the ObjectiveFunction, optionally under-relaxed via a RelaxationFactor, until the change in the iterate falls below tolerance or max_iterations is reached.

Properties:

  • tolerance: Numerical tolerance of the fixed point iteration

  • relax: Relaxation scheme

  • max_iterations: Maximum number of iterations to run

source
Terrarium.FractionalSnowCover — Type
struct FractionalSnowCover{NF} <: Terrarium.AbstractSnowCover{NF}

Simple fractional snow cover parameterization f_snow = W_snow/(W_snow + W_ref) where W_snow is the current snow water equivalent (SWE) within any given finite area and W_ref is the reference SWE at which the area would be expected to be 50% covered. The function is smooth and differentiable, with f_snow → 0 as W_snow → 0 and f_snow → 1 as W_snow → ∞.

Default SWE level for half_coverage is set to 0.01 m following [16].

Properties:

  • half_coverage::Any: Reference snow water equivalent level W_ref

References

  • [16] Douville et al., Climate Dynamics (1995)
source
Terrarium.Ground — Type
struct Ground <: Terrarium.VarDomain

The ground (soil) domain: the vertically resolved subsurface column. This is the domain on which a land grid's shared horizontal discretization is defined.

source
Terrarium.Heun — Type
struct Heun{NF} <: Terrarium.AbstractTimeStepper{NF}

Simple forward 2nd order Heun / improved Euler time stepping scheme.

source
Terrarium.HeunCache — Type
struct HeunCache{NF, P, T, NS} <: Terrarium.AbstractTimeStepperCache{NF}

Cache for the Heun scheme, holding copies of the prognostic state u₀ and the predictor tendencies ∂u∂t₀ (Heun steps in-place on state, so only these two are needed). The cache mirrors the namespace tree of the state: namespaces holds a sub-HeunCache per namespace so that namespaced prognostic variables are staged (saved/restored/averaged) consistently with how explicit_stage! recurses into namespaces.

source
Terrarium.IMEX — Type
struct IMEX{NF, E<:Terrarium.AbstractTimeStepper{NF}, I<:Terrarium.AbstractTimeStepper{NF}} <: AbstractIMEX{NF}

Implicit-explicit (IMEX) time stepper that integrates each prognostic variable according to its timestepping class: variables of class Explicit are stepped by explicit alone, and those of class Implicit receive the explicit step for their explicit terms followed by an implicit_step! of implicit (sequential operator splitting). Any explicit timestepper that implements explicit_step!, e.g. ForwardEuler or Heun, can be the explicit partner; the splitting makes the scheme first order in either case.

Each variable's class is resolved from timestepping(var, model, imex), which defaults to Explicit(). To integrate variables implicitly, specialize timestepping on the variable and/or model types together with the IMEX timestepper. The resolved classes are stored in the IMEXCache type parameter and used to route variables at each step.

Properties:

  • explicit::Terrarium.AbstractTimeStepper: Sub-stepper for prognostic variables of class Explicit (must have timestepping(explicit) === Explicit())

  • implicit::Terrarium.AbstractTimeStepper: Sub-stepper for prognostic variables of class Implicit (must have timestepping(implicit) === Implicit())

source
Terrarium.IMEX — Method
IMEX(explicit, implicit)
IMEX(; explicit, implicit)

Construct an IMEX time stepper from an explicit and an implicit sub-stepper (with the same numeric type NF). Which variables are integrated implicitly is set by specializing timestepping.

source
Terrarium.IMEXCache — Type
struct IMEXCache{classes, NF, EC<:Terrarium.AbstractTimeStepperCache{NF}, IC<:Terrarium.AbstractTimeStepperCache{NF}} <: Terrarium.AbstractTimeStepperCache{NF}

Cache for an AbstractIMEX time stepper. Holds each sub-stepper's cache; the resolved classes are the leading type parameter classes (a tuple of Explicit/Implicit instances in prognostic-variable order), so that routing is type stable.

Properties:

  • explicit::Terrarium.AbstractTimeStepperCache: Cache for the explicit sub-stepper

  • implicit::Terrarium.AbstractTimeStepperCache: Cache for the implicit sub-stepper

source
Terrarium.Implicit — Type
struct Implicit <: Timestepping

Timestepping trait marking implicit integration. It is the trait of implicit timesteppers and, under an AbstractIMEX, of prognostic variables routed to the implicit sub-stepper.

source
Terrarium.ImplicitSkinTemperature — Type
struct ImplicitSkinTemperature{NF, Solver} <: Terrarium.AbstractSkinTemperature{NF}

Scheme for an implicit skin temperature $T_s$ satisfying:

\[R_{\text{net}}(T_s) + H_s(T_s) + H_l(T_s) - (1 - f_{\text{snow}})\, G(T_s, T_g) - f_{\text{snow}}\, S(T_s, T_{\text{snow}}) = 0\]

where $R_{\text{net}}$ is the net radiation budget, $H_s$ is the sensible heat flux, $H_l$ is the latent heat flux from sublimation and evapotranspiration, $G$ is the conductive flux from the skin into the snow-free ground ($T_g$ its temperature), $S$ is the conductive flux from the skin into the top of the snowpack over the snow-covered fraction ($T_{\text{snow}}$ its temperature), and $f_{\text{snow}}$ is the snow-covered area fraction ($f_{\text{snow}} = 0$ and $S$ absent without snow). $G$ and $S$ are each computed from their own unblended conduction target (see ground_thermal_interface and snow_thermal_interface).

Properties:

  • κₛ: Assumed thermal conductivity at the surface

  • solver: Numerical solver for the implicit skin temperature

source
Terrarium.ImplicitSolverWorkspace — Type
struct ImplicitSolverWorkspace{I<:Terrarium.Iteration, R, E}

Per-variable working data of an implicit step: the right-hand side rhs of the linear system, the explicit_stage (the explicit increment Δt G_exp on entry to implicit_step!, from which the solver forms u⁺ = u⁰ + Δt G_exp at the initial iterate u⁰), and the non-final Iteration label iteration of the variable. Allocated by the implicit timestepper (see BackwardEulerCache). Not exported.

Properties:

  • rhs::Any: Right-hand side of the linear system

  • explicit_stage::Any: Explicit increment Δt G_exp on entry to the step, and the explicit stage u⁺ once the solver has formed it

  • iteration::Terrarium.Iteration: Non-final iteration label of the variable, naming the variable and the target field of its linear system

source
Terrarium.InputSource — Type
abstract type InputSource{NF, name}

Base type for input data sources. Implementations of InputSource are free to load data from any arbitrary backend. They expect an initialize!(inputs, grid, clock, fields, ::InputSource) that is called once at model initialization and an update_inputs!(inputs, grid, clock, fields, ::InputSource) method that is called at every time step, where inputs are the input Fields to be written, grid is the model grid, clock the simulation clock, and fields the full (read-only) model state. Both default to doing nothing. Implementations should additionally provide a constructor as a dispatch of InputSource. Namespace routing (scope) is handled by the enclosing [InputSources] container.

The type argument NF corresponds to the numeric type of the input data, name to its name that's also used in its variables definition.

source
Terrarium.InputSource — Method
InputSource(
    grid::Oceananigans.Grids.AbstractGrid{NF},
    field::FS;
    name,
    domain::Union{Nothing, Terrarium.VarDomain},
    units
) where {NF, FS<:(Oceananigans.Fields.AbstractField{LX, LY, LZ, G, NF} where {LX, LY, LZ, G})}

Create a FieldInputSource with the given grid and input variable fields. Use it for static input fields. The name can either be a plain Symbol or a namespaced path; see varpath.

The spatial dimensions are inferred from field. The domain defaults to Surface, which is where most forcing data lives; give it explicitly for a source feeding a variable on another domain. It must match the VarDomain that variable is declared with, since a variable declared on two different domains is a conflict rather than a merge, and is reported as one.

source
Terrarium.InputSource — Method
InputSource(
    grid::ColumnRingGrid{NF},
    ring_field::RingGrids.AbstractField;
    name,
    domain::Union{Nothing, Terrarium.VarDomain},
    units
) where NF

Convenience function to create a FieldInputSource from a RingGrids.Field. Converts the RingGrids field to an Oceananigans field and then creates the input source.

source
Terrarium.InputVariable — Type
struct InputVariable{name, VL<:Terrarium.VarLocation, UT<:Unitful.Units, Var<:Terrarium.Variable{name, VL, UT}, BT<:IntervalSets.AbstractInterval, Def} <: Terrarium.AbstractProcessVariable{name, VL, UT}

Represents a spatially varying input (e.g. forcing) variable with the given name and spatial dims. Input variables can also be made to vary in time through the use of InputSources.

The default is applied once, when the input Field is constructed, via set!(field, default). It may be nothing (zero), a number, or any other value accepted by set!: a function of the node coordinates, an array, a Field, or an AbstractFieldInitializer.

source
Terrarium.InverseQuadratic — Type
struct InverseQuadratic <: Terrarium.AbstractBulkWeighting

The inverse quadratic (or "quadratic parallel") bulk weighting formula for thermal conductivity ([40]):

\[k = \left[\sum_{i=1}^N θᵢ\sqrt{kᵢ}\right]^2\]

References

  • [40] Cosenza et al., European Journal of Soil Science (2003)
source
Terrarium.Iteration — Type
Iteration{name, target, final}(number)

Identifies one iteration of an implicit solver for the prognostic variable name, whose linear system is solved for the field target (the closure variable, e.g. temperature for internal_energy; defaults to name). final is true in the solver's last iteration. All three are type parameters, so hooks dispatch on them. number is the 1-based iteration index, kept for debugging only.

julia> iteration = Terrarium.Iteration(:internal_energy; target = :temperature)
Terrarium.Iteration{:internal_energy, :temperature, false}(1)
source
Terrarium.LUEPhotosynthesis — Type
struct LUEPhotosynthesis{NF} <: Terrarium.AbstractPhotosynthesis{NF}

Photosynthesis implementation from PALADYN [21] for C3 PFTs following the mechanistic approach of [22]. Computes instantaneous photosynthetic rates as differential equations that are integrated over arbitrary timesteps by the timestepper.

Authors: Maha Badri and Matteo Willeit

Properties:

  • τ25::Any: Rubisco specificity factor at 25°C. Ratio of carboxylation to oxygenation rates.

  • Kc25::Any: Michaelis-Menten constant for CO₂ at 25°C. PALADYN value for needleleaf trees.

  • Ko25::Any: Michaelis-Menten constant for O₂ at 25°C. PALADYN value for needleleaf trees.

  • q10_τ::Any: Q10 temperature sensitivity for τ. Controls temperature dependence of specificity.

  • q10_Kc::Any: Q10 temperature sensitivity for Kc. Controls temperature dependence of CO₂ affinity.

  • q10_Ko::Any: Q10 temperature sensitivity for Ko. Controls temperature dependence of O₂ affinity.

  • α_leaf::Any: Leaf albedo in PAR range

  • α_a::Any: Fraction of PAR assimilated at ecosystem level, relative to leaf level

  • α_C3::Any: Intrinsic quantum efficiency of CO2 uptake in C3 plants

  • leaf_respiration_fraction::Any: Leaf (dark) respiration as a fraction of the maximum carboxylation capacity Vc_max for C3 plants, [22, Eq. (10)]

  • cq::Any: Conversion factor for solar radiation at 550 nm from J/m² to mol/m²

  • T_CO2_high::Any: Upper temperature threshold for CO₂/O₂ specificity factor. Above this, photosynthesis rapidly declines. PFT-specific, needleleaf tree value.

  • T_CO2_low::Any: Lower temperature threshold for CO₂/O₂ specificity factor. Below this, photosynthesis rapidly declines. PFT-specific, needleleaf tree value.

  • T_photos_high::Any: Upper temperature threshold for light-limited photosynthesis rate. Peak photosynthesis capacity. PFT-specific, needleleaf tree value.

  • T_photos_low::Any: Lower temperature threshold for light-limited photosynthesis rate. Minimum for photosynthesis. PFT-specific, needleleaf tree value.

  • θ_r::Any: Root of quadratic mean shape parameter. Controls smoothness of interpolation between light and RuBisCO limitations (0.7 for smooth, 0.5 for arithmetic mean).

References

  • [22] Haxeltine & Prentice, Global Biogeochemical Cycles (1996)
  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.LandGrid — Type
struct LandGrid{NF, TX, TY, TZ, Arch, GroundGrid, SnowGrid, CanopyGrid} <: Terrarium.AbstractLandGrid{NF, TX, TY, TZ, Arch}

The spatial discretization of a land model, consisting of one grid per vertical domain: ground (soil), snow, and canopy. All three domains share the same horizontal discretization and differ only in their vertical discretization. Domains which are not resolved vertically by the model (e.g. a single-layer snow scheme or a big-leaf canopy) are represented by nothing.

LandGrid is the only implementation of AbstractLandGrid and is normally constructed implicitly by the model constructors via create_land_grid rather than directly by the user.

Properties:

  • ground::Any: Spatial discretization of the ground (soil) domain; also the grid on which Fields are defined by default.

  • snow::Any: Spatial discretization of the snow domain, or nothing when the snowpack is not vertically resolved.

  • canopy::Any: Spatial discretization of the canopy domain, or nothing when the canopy is not vertically resolved.

source
Terrarium.LandGrid — Method
LandGrid(ground; snow, canopy)

Construct a LandGrid on the spatial discretization ground with optional snow and canopy domain grids. The domain grids must all share the same horizontal discretization and architecture; pass nothing (the default) for domains which are not vertically resolved.

source
Terrarium.LandModel — Type
mutable struct LandModel{NF, GridType<:Terrarium.AbstractLandGrid{NF}, Vegetation<:Union{Nothing, Terrarium.AbstractVegetation{NF}}, Soil<:Terrarium.AbstractSoil{NF}, Snow<:Union{Nothing, Terrarium.AbstractSnow{NF}}, SEB<:Terrarium.AbstractSurfaceEnergyBalance, Hydrology<:Terrarium.AbstractSurfaceHydrology, Atmosphere<:Terrarium.AbstractAtmosphere, Initializer<:Terrarium.AbstractInitializer, Timestepper<:Terrarium.AbstractTimeStepper{NF}} <: Terrarium.AbstractLandModel{NF, GridType}

Fully-coupled land model integrating atmosphere, surface energy balance, surface hydrology, vegetation, and soil processes.

Properties:

  • grid::Terrarium.AbstractLandGrid: Spatial discretization

  • vegetation::Union{Nothing, Terrarium.AbstractVegetation{NF}} where NF: Vegetation processes

  • soil::Terrarium.AbstractSoil: Soil processes

  • snow::Union{Nothing, Terrarium.AbstractSnow{NF}} where NF: Snow processes

  • surface_energy_balance::Terrarium.AbstractSurfaceEnergyBalance: Surface energy balance

  • surface_hydrology::Terrarium.AbstractSurfaceHydrology: Surface hydrology scheme

  • atmosphere::Terrarium.AbstractAtmosphere: Near-surface atmospheric conditions

  • constants::PhysicalConstants: Physical constants

  • initializer::Terrarium.AbstractInitializer: State variable initializer

  • timestepper::Terrarium.AbstractTimeStepper: Time stepper: a single AbstractTimeStepper (e.g. ForwardEuler, Heun) or an IMEX (default)

source
Terrarium.LatitudinalClimatology — Type
struct LatitudinalClimatology{NF} <: Terrarium.AbstractFieldInitializer

Latitude-dependent surface temperature climatology (°C):

T(φ) = T_equator - |ΔT sin φ|

where φ is the latitude in degrees. Supported on a ColumnRingGrid, where it is evaluated on the host at the latitude of each active column, and on a LatitudeLongitudeGrid, where it is evaluated at the latitude of each node.

Properties:

  • T_equator::Any: Mean annual surface temperature at the equator (°C)

  • ΔT::Any: Temperature difference between the equator and the poles (°C)

source
Terrarium.LongShortWaveRadiation — Type
struct LongShortWaveRadiation <: Terrarium.AbstractIncomingRadiation

Incoming radiation parameterization in which downwelling shortwave [W/m²] and longwave [W/m²] radiation are provided as separate input fields, along with daytime length [hr].

source
Terrarium.MaterialConstants — Type
struct MaterialConstants{NF}

Material constants for water, ice, and carbon used in soil energy, hydrology, and vegetation process implementations.

julia> show(MaterialConstants(Float64))
MaterialConstants{Float64}(1000.0, 916.7, 0.012, 28.9647)

Properties:

  • density_water = 1000.0: Density of water in kg/m^3

  • density_ice = 916.7: Density of ice in kg/m^3

  • atomic_weight_carbon = 0.012: Atomic mass of carbon in kgC/mol

  • molecular_weight_dry_air = 28.9647: Molecular weight of dry air in g/mol

source
Terrarium.MedlynStomatalConductance — Type
struct MedlynStomatalConductance{NF} <: Terrarium.AbstractStomatalConductance{NF}

Stomatal conductance following the optimal stomatal conductance model of [24], in the corrected form of [25], which supplies the water/CO₂ diffusivity ratio. The canopy scaling of the minimum conductance and the PFT-specific parameter values follow [21], whose g₁ are in turn those of [26]. Note that PALADYN keeps the diffusivity ratio in λc (its Eq. 71) rather than in the conductance (Eq. 68); this implementation uses the Medlyn convention for both.

Authors: Maha Badri and Matteo Willeit

Properties:

  • g₁::Any: Parameter in optimal stomatal conductance formulation representing the quasi-linear relationship between conductance and net assimilation, [26]. PFT specific.

  • g_min::Any: Minimum stomatal conductance parameter

  • diffusivity_ratio_water_co2::Any = 1.6: Diffusivity ratio of water to CO₂

References

  • [26] Lin et al., Nature Climate Change (2015)
  • [24] Medlyn et al., Global Change Biology (2011)
  • [25] Medlyn et al., Global Change Biology (2012)
  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.MineralOrganic — Type
struct MineralOrganic{NF} <: Terrarium.AbstractSoilMatrix{NF}

Soil matrix consisting of a simple, homogeneous mixture of mineral and organic material.

Properties:

  • texture::SoilTexture: Mineral soil texture

  • organic::Any: Organic soil fraction

source
Terrarium.MineralOrganic — Method
MineralOrganic(; texture, organic)

Validating keyword constructor for MineralOrganic; enforces that organic lies in the unit interval.

source
Terrarium.ModelIntegrator — Type
struct ModelIntegrator{NF, Arch<:Oceananigans.Architectures.AbstractArchitecture, Grid<:Oceananigans.Grids.AbstractGrid, TimeStepper<:Terrarium.AbstractTimeStepper, Model<:Terrarium.AbstractModel, StateVars<:Terrarium.AbstractStateVariables, ClockType<:Clock, Inits<:NamedTuple, Inputs<:InputSources, InitialTime} <: Oceananigans.AbstractModel{TimeStepper, Arch}

Represents a "integrator" for a simulation of a given model. ModelIntegrator consists of a clock, a model, and an initialized StateVariables data structure, as well as any relevant inputs provided by a corresponding InputProvider. The ModelIntegrator implements the Oceananigans.AbstractModel interface and can thus be treated as a "model" in Oceananigans Simulations and output reading/writing utilities.

source
Terrarium.Namespace — Type
struct Namespace{name, Vars}

Represents a new variable namespace, typically from a subcomponent of the model.

source
Terrarium.NewtonSolver — Type
struct NewtonSolver{NF, iterations}

Newton root-finder that always performs a fixed number of iterations, with the iteration count carried in the type so that the iteration is a compile-time constant and the loop unrolls into straight-line code.

Unlike RootSolver and FixedPointSolver there is no convergence test and hence no data-dependent loop bound. That matters in two places:

  • Reactant: a convergence-tested loop lowers to an scf.while with a dynamic trip count, which the StableHLO raise pass cannot lift. An unrolled loop raises cleanly.
  • Reverse-mode AD: a fixed trip count avoids a dynamically-sized tape.

TODO: In the future, Reactant should just use the regular solvers.

source
Terrarium.NewtonSolver — Method
NewtonSolver(
    ::Type{NF};
    iterations::Int64
) where NF -> Terrarium.NewtonSolver{T, 5} where T

Construct a NewtonSolver performing exactly iterations Newton steps.

source
Terrarium.NoCanopyInterception — Type
struct NoCanopyInterception{NF} <: Terrarium.AbstractCanopyInterception{NF}

No-op canopy interception that routes all rainfall directly to the ground (open sky). This is necessary since downstream processes consume rainfall_ground rather than the rainfall directly; this no-op implementation allows for a unified interface.

source
Terrarium.NoFlow — Type
struct NoFlow <: Terrarium.AbstractVerticalFlow

Represents a hydrology scheme where soil water is immobile.

source
Terrarium.ObjectiveFunction — Type
struct ObjectiveFunction{target, F, DF}

Represents an objective function for nonlinear solvers. The name target refers to the output Field which should updated on each iteration. The objective function should have the signature

func(out, indices..., grid, fields, func_args...; func_kwargs...)

where indices are the grid indices passed to solve! and directly return the scalar residual. If an analytical derivative is provided via dfunc, it should follow the same signature as func and return the derivative of the residual with respect to the target.

source
Terrarium.PALADYNAutotrophicRespiration — Type
struct PALADYNAutotrophicRespiration{NF} <: Terrarium.AbstractAutotrophicRespiration{NF}

Autotrophic respiration implementation from [21].

Authors: Maha Badri and Matteo Willeit

Properties:

  • cn_sapwood::Any: Carbon-to-nitrogen mass ratio of sapwood (kgC/kgN)

  • cn_root::Any: Carbon-to-nitrogen mass ratio of fine roots (kgC/kgN)

  • aws::Any: Ratio of total to respiring stem carbon, [27]. PFT specific.

  • resp10::Any: Tissue respiration rate at 10 °C per unit tissue nitrogen (kgC/kgN/day), as in [21]

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
  • [27] Cox, Hadley Centre Technical Note (2001)
source
Terrarium.PALADYNCanopyEvapotranspiration — Type
struct PALADYNCanopyEvapotranspiration{NF, GR<:Terrarium.AbstractGroundEvaporationResistanceFactor} <: Terrarium.AbstractEvapotranspiration{NF}

Canopy evapotranspiration scheme from PALADYN ([21, Eq. (5)]) that includes a canopy evaporation term based on the saturation fraction of canopy water defined by the canopy hydrology scheme.

\[E_{\text{ground}} = \beta \frac{\Delta q}{r_a + r_e}\]

\[E_{\text{can}} = f_{\text{can}} \frac{\Delta q}{r_a}\]

\[T_{\text{can}} = \frac{\Delta q}{r_a + r_s}\]

Properties:

  • C_can: Drag coefficient for the transfer of heat and water between the ground and canopy

  • ground_resistance: Parameterization for ground resistance to evaporation/sublimation

References

  • [21] Willeit and Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.PALADYNCanopyInterception — Type
struct PALADYNCanopyInterception{NF} <: Terrarium.AbstractCanopyInterception{NF}

Canopy interception and storage implementation following PALADYN ([21]) considering only liquid water (no snow).

Properties:

  • α_int: Canopy water interception factor for tree PFTs

  • k_ext: Extinction coefficient for radiation through vegetation

  • W_can_max: Canopy interception capacity parameter, [33]

  • τ_w: Canopy water removal timescale

References

  • [33] Verseghy et al., International Journal of Climatology (1993)
  • [21] Willeit and Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.PALADYNCarbonDynamics — Type
struct PALADYNCarbonDynamics{NF} <: Terrarium.AbstractVegetationCarbonDynamics{NF}

Vegetation carbon dynamics implementation following [21] but considering only the sum of the vegetation carbon pools. The subsequent splitting into Cleaf, Cstem, C_root is not implemented for now.

Authors: Maha Badri

Properties:

  • γL::Any: Leaf turnover rate ([29]). PFT specific.

  • γR::Any: Root turnover rate. PFT specific.

  • γS::Any: Stem turnover rate modified from [30]. PFT specific.

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
  • [27] Cox, Hadley Centre Technical Note (2001)
  • [30] Clark et al., Geoscientific Model Development (2011)
  • [29] Kattge et al., Global Change Biology (2011)
source
Terrarium.PALADYNPhenology — Type
struct PALADYNPhenology{NF} <: Terrarium.AbstractPhenology{NF}

Prognostic, growing-degree-day (GDD) based vegetation phenology following the cold-deciduous scheme of [21] and [31].

The instantaneous leaf area index is LAI = ϕ·LAI_b, where LAI_b is the balanced (annual-maximum) leaf area index and ϕ is the phenology factor. For a cold-deciduous PFT, ϕ ramps up linearly with accumulated growing degree days above a base temperature T_gdd_base at a rate set by gdd_crit [21, Eq. (83)], holds at 1 once fully leafed out, and declines linearly during senescence as air temperature falls from T_gdd_base to T_gdd_base − T_senescence_range.

Unlike the discrete daily accumulation of the original scheme in PALADYN, the growing degree days are integrated as a prognostic state variable, so no history of past inputs needs to be stored. To recover a periodic seasonal cycle without a discrete annual reset (which would violate the continuous-time design), a cold-season relaxation term drains the accumulator with timescale gdd_relaxation_time whenever air temperature is below T_gdd_base.

The deciduous/evergreen distinction, set in PALADYN by the coldest-month temperature, is represented here by the prescribed f_deciduous fraction: ϕ = f_deciduous·ϕ_deciduous + (1 − f_deciduous), so an evergreen PFT (f_deciduous = 0) has ϕ = 1 (and LAI = LAI_b) independent of temperature.

Authors: Maha Badri and Matteo Willeit

Properties:

  • T_gdd_base::Any: Base temperature for growing-degree-day accumulation and senescence onset

  • gdd_crit::Any: Critical growing-degree-day sum for full leaf-out

  • T_senescence_range::Any: Air-temperature range below T_gdd_base over which leaves fully senesce

  • gdd_relaxation_time::Any: Cold-season relaxation timescale for the continuous growing-degree-day reset

  • f_deciduous::Any: Deciduous fraction (0 = evergreen, 1 = fully deciduous); prescribed per PFT via the coldest-month-temperature criterion

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
  • [31] Sitch et al., Global Change Biology (2003)
source
Terrarium.PALADYNVegetationDynamics — Type
struct PALADYNVegetationDynamics{NF} <: Terrarium.AbstractVegetationDynamics{NF}

Vegetation dynamics implementation following [21] for a single PFT based on the Lotka–Volterra approach.

Authors: Maha Badri

Properties:

  • ν_seed::Any: Vegetation seed fraction

  • γv_min::Any: Minimum vegetation disturbance rate

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
source
Terrarium.PhysicalConstants — Type
struct PhysicalConstants{NF}

Top-level container for all physical constants used in Terrarium. Groups three sub-structs by category:

Construction

julia> show(PhysicalConstants())
PhysicalConstants{Float64}(ThermodynamicConstants{Float64}(1004.5, 2070.0, 4181.0, 1859.0, 333550.0, 2.5008e6, 2.83435e6, 273.16, 273.15, 273.16, 611.657, 287.05, 461.52), MaterialConstants{Float64}(1000.0, 916.7, 0.012, 28.9647), UniversalConstants{Float64}(9.80665, 5.6704e-8, 0.4))

To override individual constants, pass a customised sub-struct:

julia> tc = ThermodynamicConstants(Float64; temperature_reference = 273.15);

julia> c = PhysicalConstants(Float64; thermodynamics = tc);

julia> c.thermodynamics.temperature_reference
273.15

Properties:

  • thermodynamics

  • material

  • universal

source
Terrarium.Picard — Type
struct Picard <: Terrarium.AbstractImplicitSolver

Picard (fixed-point) solver for the implicit system of a timestepper such as BackwardEuler. Each iteration linearizes the implicit operator of a prognostic variable at the latest iterate (linearize!), solves the linear system for the closure variable (e.g. temperature) with solve!, which dispatches on the AbstractLinearOperator (e.g. a batched tridiagonal solve for a TridiagonalOperator), updates the conserved variable conservatively (implicit_update!), and re-evaluates the closure (implicit_closure!). The solver is generic over the operator; the process-specific parts are the hooks, which the model forwards to the process that owns the variable.

The iteration is a fixed-point iteration uⁿ⁺¹ᵐ⁺¹ = g(uⁿ⁺¹ᵐ) on the nonlinear system of the implicit step, where g(v) is the solution of the linear system with the coefficients evaluated (lagged) at v, starting from uⁿ⁺¹⁰ = uⁿ; a fixed point u = g(u) solves the nonlinear system. A single iteration (iterations = 1) is the linearly implicit scheme used by most land surface models [2]. The default of two iterations substantially reduces the lagged-coefficient error near freezing fronts and is the minimum recommended for the modified Picard iteration of the Richards equation [3].

Properties:

  • iterations::Int64: Number of Picard iterations (linearizations and linear solves) per implicit step

References

  • [3] Celia et al., Water Resources Research 26, 1483–1496 (1990)
  • [2] Bonan, Climate Change and Terrestrial Ecosystem Modeling, Cambridge University Press (2019)
source
Terrarium.Picard — Method
Picard(::Type{NF}; iterations::Int64) where NF -> Picard

Construct a Picard solver. NF is accepted for consistency with other timestepping constructors; the solver holds no floating-point parameters. iterations must be at least one.

julia> Picard(Float32).iterations
2

julia> Picard(Float32; iterations = 3).iterations
3
source
Terrarium.PiecewiseLinearInitialSoilTemperature — Type
struct PiecewiseLinearInitialSoilTemperature{NF, N}

Represents a piecewise linear temperature initializer specified from the given knots.

initializer = PiecewiseLinearInitialSoilTemperature(
    0.0u"m" => 5.0, # always in °C!
    0.5u"m" => 2.0,
    1.0u"m" => 1.0,
    10.0u"m" => 1.5,
    ...
)

Properties:

  • knots::NTuple{N, NF} where {NF, N}
source
Terrarium.PlantTraits — Type
struct PlantTraits{NF}

Plant-specific parameters for a single functional type. This is a temporary, partial construct that will be soon be replaced will full support for PFTs and other trait parameterizations.

source
Terrarium.PowerLawSnowThermalConductivity — Type
struct PowerLawSnowThermalConductivity{NF} <: Terrarium.AbstractSnowThermalConductivity{NF}

Power law parameterization for snow thermal conductivity as a function of density following [18, Eq. (34)].

Properties:

  • conductivity_coefficient::Any: Coefficient a in the thermal conductivity power law κ = a·(ρ_snow/ρ_w)^b

  • conductivity_exponent::Any: Exponent b in the thermal conductivity power law κ = a·(ρ_snow/ρ_w)^b

References

  • [18] Yen et al. 1981
source
Terrarium.PrescribedAtmosphere — Type
struct PrescribedAtmosphere{NF, tracernames, Precip<:Terrarium.AbstractPrecipitation, IncomingRad<:Terrarium.AbstractIncomingRadiation, Humidity<:Terrarium.AbstractHumidity, Wind<:Terrarium.AbstractWind, Aerodynamics<:Terrarium.AbstractAerodynamics, Gases<:Tuple{Vararg{TracerGas{NF}}}} <: Terrarium.AbstractAtmosphere{NF, Precip, IncomingRad, Humidity, Wind, Aerodynamics}

Represents prescribed atmospheric conditions given by the following input variables: - Air temperature - Humidity - Atmospheric pressure - Windspeed - Precipitation - Solar radiation - Zero or more tracer gases (defaults to CO2 only)

Precpitation and solar radiation are specified according to specialized subtypes which dictate the form of the input data; for precipitation, this defaults to RainSnow, i.e. rain- and snowfall given as separate inputs, while for solar radiation, the default is LongShortWaveRadiation which partitions downwelling radiation into the common short- and long wave lengths representing solar and thermal (infrared) radiation.

source
Terrarium.PrescribedGroundHeatFlux — Type
struct PrescribedGroundHeatFlux{NF} <: Terrarium.AbstractGroundHeatFlux{NF}

Ground heat flux G supplied externally as an input variable, for example assembled by a coupler from the atmosphere-side surface energy budget. Nothing is computed: compute_ground_heat_flux! is a no-op, so whatever was written into the ground_heat_flux is passed on directly the ground (soil) top boundary condition. The same positive-upward convention applies as for DiagnosedGroundHeatFlux.

Note that with all four surface fluxes prescribed, the residual identity G = R_net + H_s + H_l is not enforced by construction; it is the caller's responsibility to supply a consistent set.

source
Terrarium.PrescribedRadiativeFluxes — Type
struct PrescribedRadiativeFluxes{NF} <: Terrarium.AbstractRadiativeFluxes{NF}

Represents the simplest scheme for the radiative budget where outgoing shortwave and longwave radiation are given as input variables. Net radiation is diagnosed by summing all radiative fluxes:

\[R_{\text{net}} = S_{\uparrow} - S_{\downarrow} + L_{\uparrow} - L_{\downarrow}\]

source
Terrarium.PrescribedSkinTemperature — Type
struct PrescribedSkinTemperature{NF} <: Terrarium.AbstractSkinTemperature{NF}

Simple scheme for prescribed skin temperatures from input variables.

Properties:

  • κₛ: Assumed thermal conductivity at the surface
source
Terrarium.PrescribedSoilHorizon — Type
struct PrescribedSoilHorizon{NF, name, Porosity<:Terrarium.AbstractSoilPorosity{NF}} <: Terrarium.AbstractSoilHorizon{NF, name}

Represents an arbitrary soil horizon whose properties (texture and porosity) are prescribed via input Fields and can therefore vary across space and (less commonly) time.

source
Terrarium.PrescribedSurfaceEnergyBalance — Type
PrescribedSurfaceEnergyBalance{NF, Albedo}

Type alias for a SurfaceEnergyBalance in which all four surface energy fluxes, i.e. the skin temperature, the radiative fluxes, the turbulent fluxes, and the ground heat flux, are supplied externally as input variables. This is the configuration used when an external coupler owns the atmosphere-land interface and Terrarium should not re-close the surface energy budget itself.

The albedo is deliberately left free: with prescribed radiative fluxes it only feeds a computation that is itself prescribed, so it is inert.

Warning

With all fluxes prescribed, the residual identity G = R_net + H_s + H_l is not enforced by construction. It is the caller's responsibility to supply a mutually consistent set of fluxes.

source
Terrarium.PrescribedTurbulentFluxes — Type
struct PrescribedTurbulentFluxes{NF} <: Terrarium.AbstractTurbulentFluxes{NF}

Represents the simplest case where the turbulent (sensible and latent) heat fluxes are prescribed via input variables.

source
Terrarium.PrescribedVegetation — Type
struct PrescribedVegetation{NF, Photosynthesis, StomatalConductance, RootDistribution, PAW} <: Terrarium.AbstractVegetation{NF}

Coupled vegetation process representing natural vegetation with a prescribed leaf area index. Unlike PrognosticVegetation, in which the vegetation carbon pool and the leaf area evolve in time, the leaf area index here is the input variable leaf_area_index (m²/m², e.g. an observed or reanalysis climatology). It drives the carbon uptake by photosynthesis, stomatal conductance, and the associated water/energy exchange, but there is no phenology, prognostic carbon-pool, or vegetation-dynamics component and no autotrophic respiration; compute_tendencies! is a no-op. Plant functional-type parameters (including the maximum leaf area index used to derive the vegetated area fraction) are supplied through the traits component.

Properties:

  • photosynthesis::Any: Photosynthesis scheme

  • stomatal_conductance::Any: Stomatal conductance scheme

  • root_distribution::Any: Plant vertical root distribution

  • plant_available_water::Any: Plant available water determining soil moisture stress

  • traits::PlantTraits: Plant physical traits

source
Terrarium.PrognosticVariable — Type
struct PrognosticVariable{name, VL<:Terrarium.VarLocation, UT<:Unitful.Units, Var<:Terrarium.Variable{name, VL, UT}, CL<:Union{Nothing, Terrarium.AbstractClosureRelation}, TV<:Union{Nothing, Terrarium.AuxiliaryVariable}, BT<:IntervalSets.AbstractInterval} <: Terrarium.AbstractProcessVariable{name, VL, UT}

Represents a prognostic state variable with the given name and spatial dims. Prognostic variables are those which are integrated by the timestepper and fully define the state of the system at any given point in (simulation) time. From a computational perspective, they can be seen as the "roots" of the computational graph for update_state!/timestep!. Prognostic variables generally should not be modified by any code not belonging to the timestepper or user. They automatically define a tendency (auxiliary) variable which is used to hold the value of their instantaneous time derivative computed by compute_tendencies!.

source
Terrarium.PrognosticVegetation — Type
struct PrognosticVegetation{NF, Photosynthesis<:Terrarium.AbstractPhotosynthesis{NF}, StomatalConductance<:Terrarium.AbstractStomatalConductance{NF}, AutotrophicRespiration<:Terrarium.AbstractAutotrophicRespiration{NF}, Phenology<:Terrarium.AbstractPhenology{NF}, CarbonDynamics<:Terrarium.AbstractVegetationCarbonDynamics{NF}, VegetationDynamics<:Union{Nothing, Terrarium.AbstractVegetationDynamics}, RootDistribution<:Union{Nothing, Terrarium.AbstractRootDistribution}, PAW<:Union{Nothing, Terrarium.AbstractPlantAvailableWater}} <: Terrarium.AbstractVegetation{NF}

Coupled process type representing natural vegetation with prognostic carbon cycle processes: the vegetation carbon pool, phenology, and (optionally) the vegetated area fraction evolve in time and drive the leaf area index, photosynthesis, stomatal conductance, and autotrophic respiration. See PrescribedVegetation for vegetation with a prescribed leaf area index instead.

Formerly named VegetationCarbonCycle; that name remains available as a deprecated alias.

source
Terrarium.ProgressReporter — Type
struct ProgressReporter{Progress<:ProgressMeter.Progress}

Simple callable struct wrapper around ProgressMeter.Progress intended to be used in an Oceananigans Callback.

simulation.callbacks[:progress] = Callback(ProgressReporter(nsteps), schedule)

The callback can be created directly via ProgressCallback,

simulation.callbacks[:progress] = ProgressCallback(nsteps)
source
Terrarium.QuadraticSnowThermalConductivity — Type
struct QuadraticSnowThermalConductivity{NF} <: Terrarium.AbstractSnowThermalConductivity{NF}

Piecewise quadratic snow thermal conductivity parameterization of [19]. Default conductivity of ice from [20].

Properties:

  • func_hi::Terrarium.QuadraticFunction

  • func_lo::Terrarium.QuadraticFunction

  • threshold::Any

  • κ_max::Any

References

  • [19] Sturm et al., Journal of Glaciology (1997)
  • [20] Weller & Schwerdtfeger, Journal of Glaciology (1971)
source
Terrarium.QuasiThermalSteadyState — Type
struct QuasiThermalSteadyState{NF, T0, QG} <: Terrarium.AbstractInitializer{NF}

Initializer that sets soil/ground temperature to a thermal quasi-steady state based on the given surface temperature, geothermal heat flux, and bulk (constant) thermal conductivity:

T(z) = T₀ - Qgeo / k_eff * z

with depth z ≤ 0 (m). Note that this is not a true thermal steady state, which would require iterative calculation of the thermal conductivity from the soil properties and initial temperature profile.

The surface temperature and the geothermal heat flux are declared as the input variables initial_surface_temperature (°C) and geothermal_heat_flux (W/m²) with defaults T₀ and Qgeo. The latter is the same variable read by the GeothermalHeatFlux bottom boundary condition, so that the initial profile and the boundary condition are consistent. Each default may be a number, a function of the horizontal node coordinates, an array, a Field, or an AbstractFieldInitializer. Defaults are re-applied at every initialization, so that changes to parameters take effect, and can be overridden by an InputSource of the same name (with matching units).

Properties:

  • T₀::Any: Initial surface temperature (°C)

  • Qgeo::Any: Geothermal heat flux (W/m²)

  • k_eff::Any: Bulk thermal conductivity (W/m/K)

source
Terrarium.QuasiThermalSteadyState — Method
QuasiThermalSteadyState(
    ::Type{NF};
    T₀,
    Qgeo,
    k_eff
) where NF -> QuasiThermalSteadyState

Creates a quasi-steady-state soil temperature initializer with surface temperature T₀ (°C), geothermal heat flux Qgeo (W/m²), and bulk thermal conductivity k_eff (W/m/K).

source
Terrarium.RainSnow — Type
struct RainSnow <: Terrarium.AbstractPrecipitation

Precipitation parameterization in which liquid rainfall [m/s] and frozen snowfall [m/s] are provided as separate input fields.

source
Terrarium.RichardsEq — Type
RichardsEq{PS} <: AbstractVerticalFlow

SoilHydrology flow operator implementing the mixed saturation-pressure form of the Richardson-Richards equation.

State variables defined by the Richards' formulation of SoilHydrology:

  • saturation_water_ice: saturation level of water and ice in the pore space.
  • hydraulic_conductivity: hydraulic conductivity at cell centers (m/s).
  • water_table`: elevation of the water table (m).
  • liquid_water_fraction: fraction of unfrozen liquid water in the pore space (dimensionless).
  • water_flux: Darcy flux (m/s, positive upward) through the cell faces that moved the water in the step (see compute_water_flux).

Excess water that reaches the soil surface is routed to the surface_excess_water pool defined by AbstractSurfaceRunoff process (see adjust_saturation_profile!), if passed as a dependency. For standalone soil hydrology with no surface runoff, surface excess water is discarded.

See also SoilSaturationPressureClosure and AbstractSoilHydraulics for details regarding the closure relating saturation and pressure head.

source
Terrarium.RootSolver — Type
struct RootSolver{NF, M, S, Tolerance<:RootSolvers.AbstractTolerance{NF}}

Wrapper for RootSolvers.jl root-finding methods.

source
Terrarium.Saturation — Type
struct Saturation{T} <: Terrarium.AbstractWaterContent

Marker type indicating that the wrapped value is the saturation of the pore space with water and ice (-), i.e. the volumetric water and ice content divided by the porosity.

Properties:

  • value::Any: Saturation of the pore space with water and ice (-)
source
Terrarium.SaturationWaterTable — Type
struct SaturationWaterTable{NF, S, D} <: Terrarium.AbstractInitializer{NF}

Simple initialization scheme for soil/ground saturation that sets the initial water table at the given depth and the water content in all layers in the vadose (unsaturated) zone to a constant value.

The vadose zone water content is given as a Saturation or as a VolumetricWaterContent; plain (unwrapped) values are interpreted as saturation. Volumetric water content is converted to saturation by dividing by the soil porosity at each grid cell (and capped at full saturation). The wrapped value is declared as the input variable vadose_zone_saturation, which therefore holds either the saturation (-) or the volumetric water content (m³/m³) as indicated by the marker type, and the water table depth as water_table_depth (m), with defaults taken from the corresponding properties. See QuasiThermalSteadyState for the accepted forms of the defaults.

julia> init = SaturationWaterTable(Float32; vadose_zone_saturation = VolumetricWaterContent(0.2f0));

julia> init.vadose_zone_saturation
VolumetricWaterContent{Float32}(0.2f0)

Properties:

  • vadose_zone_saturation::Any: Water content in the vadose zone above the water table, as Saturation, VolumetricWaterContent, or a plain saturation value

  • water_table_depth::Any: Depth of the water table below the surface (m)

source
Terrarium.SingleLayerSnow — Type
struct SingleLayerSnow{NF, Cover, Density, Conductivity, Hydraulics, Albedo, Closure} <: Terrarium.AbstractSnow{NF}

Simple single-layer snow scheme (loosely based on the Utah Energy Balance model, [5]). The snowpack is represented as a single lumped layer with a bulk density ρ_snow supplied by a snow-density scheme (constant by default), from which the thermal properties follow. The prognostic state is the depth-integrated (column) internal energy snow_energy Ū_snow [J/m²] and the snow_water_equivalent W_snow [m]; snow depth, cover fraction, and thermal conductivity are diagnosed from these and the bulk density.

Properties:

  • cover: Snow areal coverage parameterization

  • density: Bulk snow density parameterization

  • thermal_conductivity: Snow thermal conductivity parameterization

  • hydraulic_properties: Snow hydraulic properties

  • albedo: Snow albedo parameterization

  • closure: Snow energy-temperature closure

References

  • [5] Tarboton, Chowdhury and Jackson (1994)
source
Terrarium.Snow — Type
struct Snow <: Terrarium.VarDomain

The snow domain, i.e. the snowpack above the ground surface. A grid which does not discretize the snowpack vertically (a single-layer scheme) still carries its 2D variables.

source
Terrarium.SnowEnergyTemperatureClosure — Type
struct SnowEnergyTemperatureClosure <: Terrarium.AbstractEnergyClosure

Energy–temperature closure for snow volumes. For SingleLayerSnow, the depth-averaged snow temperature T_snow (°C) and liquid water fraction θ_liq are recovered from the depth-integrated internal energy Ū_snow (J/m²) using the medium-agnostic FreeWater enthalpy relations, treating the bulk snowpack as an ice-water-air mixture. The internal energy is defined as:

\[U(T) = T_{ ext{snow}} \times C(T) - \rho_{snow} L_{sl} (1 - F(T))\]

with C(T) the temperature-dependent volumetric heat capacity of the snowpack (J/m³/K), ρ_snow L_sl = ρ_w L_sl θ the volumetric latent heat of fusion (J/m³), and F(T) = θ_liq/θ the fraction of the total (liquid water + ice) volumetric water content that is liquid.

source
Terrarium.SnowModel — Type
mutable struct SnowModel{NF, GridType<:Oceananigans.Grids.AbstractGrid, Snow<:Terrarium.AbstractSnow, Atmosphere<:Terrarium.AbstractAtmosphere, Initializer<:Terrarium.AbstractInitializer, Timestepper<:Terrarium.AbstractTimeStepper} <: Terrarium.AbstractSnowModel{NF, GridType}

Minimal standalone model of a single-layer snowpack, intended for unit and differentiability testing. Couples an AbstractSnow process with a prescribed atmosphere providing precipitation and air temperature. The surface and basal heat fluxes (snow_surface_heat_flux, snow_basal_heat_flux) and the sublimation rate are prescribed input fields; in a coupled land model these are supplied by the surface energy balance and the snow→soil conduction. Like the snow state, these fluxes are grid-cell means, i.e. already scaled by the snow cover fraction f (f·S at the top and f·Q_base at the base in the coupled model).

Properties:

  • grid::Oceananigans.Grids.AbstractGrid: Spatial grid type

  • snow::Terrarium.AbstractSnow: Snow processes

  • atmosphere::Terrarium.AbstractAtmosphere: Near-surface atmospheric conditions

  • constants::PhysicalConstants: Physical constants

  • initializer::Terrarium.AbstractInitializer: State variable initializer

  • timestepper::Terrarium.AbstractTimeStepper: Time stepper: a single AbstractTimeStepper (e.g. ForwardEuler, Heun) or an IMEX

source
Terrarium.SoilCarbonTransport — Type
struct SoilCarbonTransport{NF}

Soil Carbon Transport component with Bioturbation (Diffusion) and Advection terms for the Soil Carbon Model.

source
Terrarium.SoilComposition — Type
struct SoilComposition{NF, Solid<:Terrarium.AbstractSoilMatrix{NF}}

Represents the material composition of an elementary volume of soil. The volume is decomposed into the key constitutents of water, ice, air, and a mixture of organic and mineral solid material.

Properties:

  • porosity: Natural porosity or void space of the soil

  • saturation: Fraction of the soil pores occupied by water or ice

  • liquid: Liquid (unfrozen) fraction of pore water

  • solid: Parameterization of the solid phase (matrix) of the soil

source
Terrarium.SoilComposition — Method
SoilComposition(; porosity, saturation, liquid, solid)

Validating keyword constructor for SoilVolume; enforces that porosity, saturation, and liquid lie in the unit interval.

source
Terrarium.SoilEnergyTemperatureClosure — Type
struct SoilEnergyTemperatureClosure <: Terrarium.AbstractEnergyClosure

Defines the constitutive relationship between the the internal energy and temperature of a soil volume, i.e.

\[U(T) = T\times C(T) - \rho_w L_{sl} \theta (1 - F(T))\]

where T is temperature (°C), C(T) is the temperature-dependent heat capacity (J/m³/K), ρw L{sl} θ is the volumetric latent heat of fusion (J/m³), and F(T) = θ_w/θ is the constitutive relation between T and the unfrozen fraction of pore water with θ the sum of the volumetric fractions of water and ice. Note that, under this formulation, zero energy corresponds to 0°C with no ice, i.e. all pore water fully thawed.

The closure relation is defined as being a mapping from the conserved quantity (energy) to the continuous quantity (temperature), i.e. the inverse of U(T).

source
Terrarium.SoilEnergyWaterCarbon — Type
struct SoilEnergyWaterCarbon{NF, Stratigraphy<:Terrarium.AbstractStratigraphy{NF}, Energy<:Terrarium.AbstractSoilThermodynamics{NF}, Hydrology<:Terrarium.AbstractSoilHydrology{NF}, Biogeochemistry<:Terrarium.AbstractSoilBiogeochemistry{NF}} <: Terrarium.AbstractSoil{NF}

Coupled process type that encapsulates the coupling of soil energy, water, and carbon dynamics. The stratigraphy parameterization determines how the vertical layering of the soil is parameterized.

source
Terrarium.SoilHeatCapacities — Type
struct SoilHeatCapacities{NF}

Properties:

  • water::Any: Volumetric heat capacity of water

  • ice::Any: Volumetric heat capacity of ice

  • air::Any: Volumetric heat capacity of air

  • mineral::Any: Volumetric heat capacity of mineral soil

  • organic::Any: Volumetric heat capacity of organic soil

source
Terrarium.SoilHydraulicsSURFEX — Type
struct SoilHydraulicsSURFEX{NF, RC, UnsatK<:Terrarium.AbstractUnsatK{NF}} <: Terrarium.AbstractSoilHydraulics{NF, RC, UnsatK}

Soil hydraulics parameterization that includes the SURFEX [6, Eq. (28-29)] formulation of field capacity and wilting point as a function of soil texture.

Properties:

  • swrc::Any: Soil water retention curve

  • unsat_hydraulic_cond::Terrarium.AbstractUnsatK: Unsaturated hydraulic conductivity formulation; defaults to the formulation matching swrc (see default_unsat_hydraulic_cond)

  • saturated_conductivity::Any: Hydraulic conductivity at saturation

  • wilting_point_effect::Any: Linear coefficient of wilting point adjustment due to clay content

  • field_capacity_effect::Any: Linear coefficient of field capacity adjustment due to clay content

  • field_capacity_exp::Any: Exponent of field capacity adjustment due to clay content

  • field_capacity_min::Any: Minimum field capacity at 0% clay content

  • residual_saturation::Any: Residual (minimum) saturation level

  • minimum_moisture_capacity::Any = 1.0e-5: Lower bound (1/m) of the specific moisture capacity ∂θ/∂ψ on the diagonal of the implicit Richards solve (implicit time stepping only)

References

  • [6] Noilhan & Mahfouf, Global and Planetary Change (1996)
source
Terrarium.SoilHydrology — Type
struct SoilHydrology{NF, VerticalFlow<:Terrarium.AbstractVerticalFlow, SaturationClosure<:Terrarium.AbstractSoilWaterClosure, SoilHydraulics<:Terrarium.AbstractSoilHydraulics{NF}, VWCForcing<:Union{Nothing, Oceananigans.Forcings.ContinuousForcing{LX, LY, LZ, P} where {P, LX, LY, LZ}, Oceananigans.Forcings.DiscreteForcing}} <: Terrarium.AbstractSoilHydrology{NF}

Properties:

  • vertical_flow::Terrarium.AbstractVerticalFlow: Soil water vertical flow operator

  • closure::Terrarium.AbstractSoilWaterClosure: Closure relation for the soil hydrology state

  • hydraulic_properties::Terrarium.AbstractSoilHydraulics: Soil hydraulic properties parameterization

  • vwc_forcing::Union{Nothing, Oceananigans.Forcings.ContinuousForcing{LX, LY, LZ, P} where {P, LX, LY, LZ}, Oceananigans.Forcings.DiscreteForcing}: Forcing for soil moisture (volumetric water content)

source
Terrarium.SoilInitializer — Type
struct SoilInitializer{NF, EnergyInit<:Terrarium.AbstractInitializer{NF}, HydrologyInit<:Terrarium.AbstractInitializer{NF}, BGCInit<:Terrarium.AbstractInitializer{NF}} <: Terrarium.AbstractInitializer{NF}

Initializer for coupled soil energy/hydrology/biogeochemistry models.

source
Terrarium.SoilModel — Type
mutable struct SoilModel{NF, GridType<:Oceananigans.Grids.AbstractGrid, Soil<:Terrarium.AbstractSoil, Initializer<:Terrarium.AbstractInitializer, Timestepper<:Terrarium.AbstractTimeStepper} <: Terrarium.AbstractSoilModel{NF, GridType}

General implementation of a 1D column model of soil energy, water, and carbon transport.

Properties:

  • grid::Oceananigans.Grids.AbstractGrid: Spatial grid type

  • soil::Terrarium.AbstractSoil: Soil processes

  • constants::PhysicalConstants: Physical constants

  • initializer::Terrarium.AbstractInitializer: State variable initializer

  • timestepper::Terrarium.AbstractTimeStepper: Time stepper: a single AbstractTimeStepper (e.g. ForwardEuler, Heun) or an IMEX; defaults to IMEX for Richards flow and ForwardEuler otherwise

source
Terrarium.SoilMoistureResistanceFactor — Type
struct SoilMoistureResistanceFactor{NF} <: Terrarium.AbstractGroundEvaporationResistanceFactor

Implements the soil moisture limiting resistance factor of [35],

β = ¼ (1 − cos(π x))²,  x = clamp((θ₁ − θ_res) / (θ_fc − θ_res), 0, 1)

where θ₁ is the liquid water content of the uppermost soil layer, θ_fc the field capacity, and θ_res the residual water content. The factor vanishes at and below the residual water content and equals one at and above field capacity. With θ_res = 0, this is the original formulation of Lee and Pielke, x = θ₁ / θ_fc.

References

  • [35] Lee and Pielke, Journal of Applied Meteorology (1992)
source
Terrarium.SoilPorositySURFEX — Type
struct SoilPorositySURFEX{NF} <: Terrarium.AbstractSoilPorosity{NF}

SURFEX parameterization of mineral soil porosity [6, Eq. (27)].

References

  • [6] Noilhan & Mahfouf, Global and Planetary Change (1996)
source
Terrarium.SoilSaturationPressureClosure — Type
struct SoilSaturationPressureClosure <: Terrarium.AbstractSoilWaterClosure

Represents a closure relating saturation of water/ice in soil pores to a corresponding pressure (or hydraulic) head. Note that here "pressure head" is defined to be synonymous with hydraulic head, i.e. including all both elevation and hydrostatic pressure contributions. This relation is typically described by soil property-dependent soil-water retention curve (SWRC) which is here defined in implementations of AbstractSoilHydraulics.

source
Terrarium.SoilStratigraphy — Type
struct SoilStratigraphy{NF, N, Horizons<:NTuple{N, Terrarium.AbstractSoilHorizon{NF}}} <: Terrarium.AbstractStratigraphy{NF}

Represents a soil stratigraphy as a stack of named soil horizons. Each soil horizon is assumed to have internally homogeneous soil properties. The number of horizons and their respective names are defined by the user.

Properties:

  • horizons::NTuple{N, Terrarium.AbstractSoilHorizon{NF}} where {NF, N}: Named tuple of soil horizons ordered from top to bottom
source
Terrarium.SoilThermalConductivities — Type
struct SoilThermalConductivities{NF}

Properties:

  • water::Any: Thermal conductivity of water

  • ice::Any: Thermal conductivity of ice

  • air::Any: Thermal conductivity of air

  • quartz::Any: Thermal conductivity of quartz (sand) mineral grains

  • mineral::Any: Thermal conductivity of non-quartz (silt/clay) mineral grains

  • organic::Any: Thermal conductivity of organic soil constituents

Default values from [41].

References

  • [41] Hillel, Academic Press (1982)
source
Terrarium.SoilThermalProperties — Type
struct SoilThermalProperties{NF, FC, CondWeight, Cond}

Thermal properties of the soil: constituent thermal conductivities and heat capacities, the bulk conductivity weighting, and the freeze curve of the energy–temperature closure.

Properties:

  • conductivities::Any: Thermal conductivities for all constituents

  • conductivity_weighting::Any: Method for computing bulk thermal conductivity from constituents

  • heat_capacities::SoilHeatCapacities: Thermal conductivities for all constituents

  • freezecurve::Any: Freezing characteristic curve needed for energy-temperature closure

source
Terrarium.SoilThermodynamics — Type
struct SoilThermodynamics{NF, EnergyClosure<:Terrarium.AbstractEnergyClosure, ThermalProps<:SoilThermalProperties{NF}} <: Terrarium.AbstractSoilThermodynamics{NF}

Soil thermal dynamics with freezing and thawing of pore water. The internal energy U evolves by vertical heat conduction and advection of sensible heat by the vertical water flux j_w (m/s, positive upward):

∂U/∂t = ∂z(κ ∂z T) - ∂z(C_w T j_w),

with temperature T (°C), thermal conductivity κ (W/m/K), and volumetric heat capacity of liquid water C_w (J/m³/K). The closure relates temperature and internal energy, $U(T,\phi)$, with additional parameters $\phi$ set by the model configuration.

Properties:

  • closure::Terrarium.AbstractEnergyClosure: Closure relating energy and temperature

  • thermal_properties::SoilThermalProperties: Soil thermal properties

source
Terrarium.SpecificHumidity — Type
struct SpecificHumidity <: Terrarium.AbstractHumidity

Humidity parameterization in which the near-surface specific humidity [kg/kg] is provided directly as an input field.

source
Terrarium.SplitOperator — Type
struct SplitOperator{Operators<:NamedTuple} <: AbstractLinearOperator

Composite AbstractLinearOperator for operator splitting: operators holds per-variable operators keyed by prognostic variable name, in solve order. The model sets this order in implicit_operator; e.g. SoilModel and LandModel solve saturation_water_ice before internal_energy. Solvers apply their single-variable iteration to each component in turn (see Picard). Not exported.

julia> grid = ColumnGrid(CPU(), Float64, UniformSpacing(Δz = 0.1, N = 4));

julia> operator = Terrarium.SplitOperator((b = TridiagonalOperator(ground_domain(grid)), a = TridiagonalOperator(ground_domain(grid))));

julia> keys(operator.operators)
(:b, :a)

Properties:

  • operators::NamedTuple: Per-variable operators, keyed by prognostic variable name, in the order in which they are applied
source
Terrarium.StateVariables — Type
mutable struct StateVariables{NF, prognames, closurenames, auxnames, inputnames, nsnames, ProgFields, TendFields, AuxFields, InputFields, Namespaces, Cache, ClockType} <: Terrarium.AbstractStateVariables

Container type for all Fields corresponding to state variables defined by a model. StateVariables partitions the fields into three categories: prognostic, tendencies, and auxiliary. Prognostic variables are those which characterize the state of the system and are assigned tendencies to be integrated by the timestepper. Auxiliary fields are additional state variables derived from the prognostic state variables but which are conditionally independent of their values at the previous time step given the current prognostic state. It is worth noting that tendencies are also treated internally as auxiliary variables; however, they are assigned their own category here since they need to be handled separately by the timestepping scheme.

source
Terrarium.StateVariables — Method
StateVariables(
    process::Terrarium.AbstractProcess{NF},
    grid::Oceananigans.Grids.AbstractGrid{NF};
    ...
) where NF
StateVariables(
    process::Terrarium.AbstractProcess{NF},
    grid::Oceananigans.Grids.AbstractGrid{NF},
    params;
    clock,
    input_variables,
    timestepper,
    boundary_conditions,
    initializers,
    fields
) where NF

Initialize a StateVariables data structure containing Fields defined on the given grid for all variables defined by process. Any predefined boundary_conditions and fields will be passed through to initialize for each variable.

The grid may be either a land grid or an ordinary spatial discretization; fields are allocated on whichever is given. AbstractLandGrids resolve variables' VarDomains to a their respective vertical discretization; on an ordinary grid the domain is ignored.

source
Terrarium.StateVariables — Method
StateVariables(
    vars::Terrarium.Variables,
    grid::Oceananigans.Grids.AbstractGrid{NF};
    clock::Clock,
    timestepper,
    model,
    boundary_conditions,
    initializers,
    fields
) where NF -> StateVariables{NF, <:Any, <:Any, <:Any, <:Any, <:Any, ProgFields, TendFields, AuxFields, InputFields, <:Any, Cache, Clock{Float64, Float64, Float64, Int64, Int64}} where {NF, ProgFields<:Tuple, TendFields<:Tuple, AuxFields<:Tuple, InputFields<:Tuple, Cache<:Terrarium.EmptyCache}

Initialize a StateVariables data structure containing Fields defined on the given grid for all variables in vars. Any predefined boundary_conditions and fields will be passed through to initialize for each variable. The timestepper's cache is allocated via initialize(timestepper, state, progvars).

The grid may be either a land grid or an ordinary spatial discretization; fields are allocated on whichever is given. Only an AbstractLandGrid resolves a variable's VarDomain to a per-domain discretization; on an ordinary grid the domain is ignored.

source
Terrarium.StateVariables — Method
StateVariables(
    model::Terrarium.AbstractModel{NF};
    ...
) where NF -> StateVariables
StateVariables(
    model::Terrarium.AbstractModel{NF},
    params;
    clock,
    input_variables,
    boundary_conditions,
    initializers,
    fields
) where NF -> StateVariables

Initialize a StateVariables data structure containing Fields for all variables defined by model defined on its associated grid. The clock specifies the initial simulation time and is mutated on each time step. User-specified boundary_conditions and initializers can be provided as NamedTuples with keys corresponding to the names of state variables to which they should be applied. If the state variables are defined within namespaces, the given NamedTuple must follow the same structure. The fields argument allows for manual preconstruction of Fields for the named state variables. The time stepper cache is allocated from the model's timestepper.

source
Terrarium.StaticExponentialRootDistribution — Type
struct StaticExponentialRootDistribution{NF} <: Terrarium.AbstractRootDistribution{NF}

Static vegetation root distribution implementation in [21] based on the scheme proposed by [32]. The continuous density of the root distribution is modeled as

\[\frac{\partial R}{\partial z} = \frac{1}{2} \left[ a \exp(a z) + b \exp(b z) \right]\]

which is then integrated over the soil column and normalized to sum to unity. Note that this is effectively the average of two exponential distributions with rates a and b, both with units m⁻¹. The resulting CDF of this distribution determines the root distribution.

Properties:

  • a: First empirical rate parameter for root distribution

  • b: Second empirical rate parameter for root distribution

References

  • [21] Willeit & Ganopolski, Geoscientific Model Development (2016)
  • [32] Zeng, Journal of Hydrometeorology (2001)
source
Terrarium.Surface — Type
struct Surface <: Terrarium.VarDomain

The land-atmosphere interface. Unlike Ground, Snow, and Canopy, the surface is not a vertical domain: its physical position depends on the surface tile, being the top of the soil column over bare ground, the top of the snowpack under snow, and the canopy where there is vegetation. Surface variables therefore never carry a vertical dimension and must be declared as Surface(XY()); Surface(XYZ()) raises an error.

source
Terrarium.SurfaceEnergyBalance — Type
struct SurfaceEnergyBalance{NF, SkinTemperature<:Terrarium.AbstractSkinTemperature{NF}, RadiativeFluxes<:Terrarium.AbstractRadiativeFluxes{NF}, TurbulentFluxes<:Terrarium.AbstractTurbulentFluxes{NF}, GroundHeatFlux<:Terrarium.AbstractGroundHeatFlux{NF}, Albedo<:Terrarium.AbstractAlbedo{NF}} <: Terrarium.AbstractSurfaceEnergyBalance{NF}

Standard implementation of the surface energy balance (SEB) that computes the radiative, turbulent, and ground energy fluxes at the surface. The SEB is also responsible for defining and solving the so-called skin temperature (effective emission temperature of the land surface) as well as the albedo.

Each flux group is an exchangeable sub-process with (at least) a Prescribed and a Diagnosed implementation, so that any subset of the surface fluxes may be supplied externally. Note that the type parameters are declared in the same order as the fields.

source
Terrarium.SurfaceEnergyBalance — Method
SurfaceEnergyBalance(
    ::Type{NF};
    radiative_fluxes::Terrarium.AbstractRadiativeFluxes,
    turbulent_fluxes::Terrarium.AbstractTurbulentFluxes,
    skin_temperature::Terrarium.AbstractSkinTemperature,
    ground_heat_flux::Terrarium.AbstractGroundHeatFlux,
    albedo::Terrarium.AbstractAlbedo
) where NF -> SurfaceEnergyBalance

Construct a SurfaceEnergyBalance with number format NF. The defaults reproduce the standalone land model configuration: an implicitly solved skin temperature with all surface fluxes diagnosed internally.

Not every combination of skin_temperature and ground_heat_flux is valid; the supported pairs are documented on the surface energy balance documentation page.

source
Terrarium.SurfaceEnergyModel — Type
mutable struct SurfaceEnergyModel{NF, GridType<:Oceananigans.Grids.AbstractGrid{NF}, SEB<:Terrarium.AbstractSurfaceEnergyBalance, Atmosphere<:Terrarium.AbstractAtmosphere, Initializer<:Terrarium.AbstractInitializer, Timestepper<:Terrarium.AbstractTimeStepper{NF}} <: Terrarium.AbstractSurfaceEnergyModel{NF, GridType}

Simple model wrapper for the SurfaceEnergyBalance that couples it with an AbstractAtmosphere to provide meteorological inputs. This model type is mostly intended for testing but could also be used for simple energy balance calculations from prescribed meteorological and ground temperature conditions.

source
Terrarium.SurfaceHydrology — Type
struct SurfaceHydrology{NF, CanopyInterception<:Terrarium.AbstractCanopyInterception{NF}, Evapotranspiration<:Terrarium.AbstractEvapotranspiration{NF}, SurfaceRunoff<:Terrarium.AbstractSurfaceRunoff{NF}} <: Terrarium.AbstractSurfaceHydrology{NF}

Default representation of coupled surface hydrology processes including canopy rain/snow interception, evapotranspiration, and surface runoff.

Properties:

  • canopy_interception: Canopy hydrology scheme

  • evapotranspiration: Canopy evapotranspiration scheme

  • surface_runoff: Surface runoff scheme

source
Terrarium.ThermodynamicConstants — Type
struct ThermodynamicConstants{NF} <: Thermodynamics.Parameters.AbstractThermodynamicsParameters{NF}

Thermodynamic and atmospheric constants used in surface energy, turbulent flux, and vegetation process implementations. Subtypes AbstractThermodynamicsParameters so that it integrates directly with Thermodynamics.jl.

julia> show(ThermodynamicConstants(Float64))
ThermodynamicConstants{Float64}(1004.5, 2070.0, 4181.0, 1859.0, 333550.0, 2.5008e6, 2.83435e6, 273.16, 273.15, 273.16, 611.657, 287.05, 461.52)

Properties:

  • specific_heat_capacity_dry_air = 1004.5: Isobaric specific heat capacity of dry air at standard pressure and 0°C in J/(m^3*K)

  • specific_heat_capacity_ice = 2070.0: Isobaric specific heat capacity of ice at standard pressure and 0°C in J/(m^3*K)

  • specific_heat_capacity_liquid_water = 4181.0: Isobaric specific heat capacity of liquid water at standard pressure and 0°C in J/(m^3*K)

  • specific_heat_capacity_water_vapor = 1859.0: Isobaric specific heat capacity of water vapor at standard pressure and 0°C in J/(m^3*K)

  • latent_heat_fusion = 333550.0: Specific latent heat of fusion of water in J/kg at 0°C

  • latent_heat_vaporization = 2.5008e6: Specific latent heat of vaporization of water in J/kg at 0°C

  • latent_heat_sublimation = latent_heat_fusion + latent_heat_vaporization: Specific latent heat of sublimation of water in J/kg at 0°C

  • temperature_reference = 273.16: Reference temperature (0°C in Kelvin)

  • temperature_water_freeze = 273.15: Freezing temperature of water in Kelvin

  • temperature_water_triple_point = 273.16: Triple point temperature of water in Kelvin

  • pressure_water_triple_point = 611.657: Triple point pressure of water in Pa

  • gas_constant_dry_air = 287.05: Specific gas constant of dry air in J/(kg*K)

  • gas_constant_water_vapor = 461.52: Specific gas constant of water vapor in J/(kg*K)

source
Terrarium.Top — Type
Top(x = Center(), y = Center(), z = Face())

Dimensions for a variable defined at a single point at the top of a domain's vertical axis, such as a surface flux. The vertical index is resolved with lastindex, so a field declared this way is restricted to one k: Nz + 1 at Face (the default, appropriate for fluxes across the interface) and Nz at Center (the uppermost cell).

See also Bottom.

source
Terrarium.TridiagonalOperator — Type
struct TridiagonalOperator{Solver, DiagonalCoefficient, FaceDiffusivity, FaceVelocity} <: AbstractLinearOperator

Batched vertical tridiagonal AbstractLinearOperator for implicit vertical diffusion and, optionally, first-order upwind advection, with one system per column. Row k of the system for the closure variable ϕ reads

C_k ϕ_k - Δt [∂z(κ ∂z ϕ)]_k + Δt [∂z(u ϕ_up)]_k - Δt L_k ϕ_k = rhs_k,

the finite-volume discretization of a backward Euler step of C ∂ϕ/∂t = ∂z(κ ∂z ϕ) - ∂z(u ϕ) (see the derivation of the coefficients in Tridiagonal operator), with the lagged capacity C in diagonal_coefficient (e.g. the apparent heat capacity, or ∂θ/∂ψ for Richards flow), the lagged face conductivity κ in face_conductivity (thermal or hydraulic conductivity), the optional advective face velocity u in face_velocity, and the optional linear coefficient L (compute_implicit_linear_coefficient). u is in units of capacity times velocity, so that u ϕ_up is the advective flux; e.g. u = C_w j_w (W/m²/K) for the heat carried by the vertical water flux j_w (m/s), with C_w the volumetric heat capacity of water. ϕ_up is the value in the upwind cell of the face, which keeps the system an M-matrix for any u. face_velocity is nothing for operators without advection, and the advective terms then vanish by dispatch (compute_implicit_face_velocity). Diffusive fluxes and advective inflow through the two boundary faces of the column are masked and enter through the right-hand side; advective outflow through the boundary faces (upwind value of the boundary cell itself) is part of the operator, so a boundary cell cannot lose more than its content.

Properties:

  • tridiagonal_solver::Any: Batched tridiagonal solver with ImplicitDiffusion*Diagonal marker coefficients

  • diagonal_coefficient::Any: Lagged capacity C (Center, Center, Center)

  • face_conductivity::Any: Lagged face conductivity κ (Center, Center, Face)

  • face_velocity::Any: Lagged advective face velocity u (Center, Center, Face), or nothing without advection

source
Terrarium.TridiagonalOperator — Method
TridiagonalOperator(
    grid::Oceananigans.Grids.AbstractGrid;
    advection::Bool
)

Allocate a TridiagonalOperator on grid, typically ground_domain(get_grid(model)). With advection = true, also allocate a face_velocity field; otherwise it is nothing.

julia> grid = ColumnGrid(CPU(), Float64, UniformSpacing(Δz = 0.1, N = 4));

julia> operator = TridiagonalOperator(ground_domain(grid));

julia> size(operator.diagonal_coefficient)
(1, 1, 4)

julia> isnothing(operator.face_velocity)
true

julia> size(TridiagonalOperator(ground_domain(grid); advection = true).face_velocity)
(1, 1, 5)
source
Terrarium.UniversalConstants — Type
struct UniversalConstants{NF}

Universal physical constants used in surface energy and turbulent flux process implementations.

julia> show(UniversalConstants(Float64))
UniversalConstants{Float64}(9.80665, 5.6704e-8, 0.4)

Properties:

  • gravitational_acceleration = 9.80665: Gravitational constant in m/s^2

  • stefan_boltzmann_constant = 5.6704e-8: Stefan-Boltzmann constant in J/(sm^2K^4)

  • von_karman_constant = 0.4: von Kármán constant

source
Terrarium.UnsatKBrooksCorey — Type
struct UnsatKBrooksCorey{NF} <: Terrarium.AbstractUnsatK{NF}

Unsaturated hydraulic conductivity of the Brooks–Corey model, extended with an ice impedance factor:

K = I_ice K_sat S^(3 + 2/λ)

where S = θw / θsat is the liquid water saturation, λ is the pore size distribution index of the BrooksCorey retention curve, and I_ice is the Terrarium.ice_impedance_factor of [9].

Brooks and Corey [10] define the power law on the effective saturation (θw − θres) / (θsat − θres). Terrarium evaluates the retention curve with the residual water content of the BrooksCorey curve itself, which is zero by default, and in that case the effective saturation reduces to S. A nonzero residual water content of the retention curve is not yet accounted for here; the residual_saturation of the hydraulic properties is only a numerical lower bound on the saturation.

The power law and its exponent 3 + 2/λ were derived by [10] from their retention curve, using the pore size distribution model of Burdine. [11] obtained the same law, written as S^(2b + 3) with b = 1/λ, and [12] tabulated b by soil texture; in this form, it is the conductivity of SURFEX/ISBA [13]. The exponent λ is taken from the retention curve so that the two cannot be configured inconsistently; this formulation can therefore only be combined with a BrooksCorey retention curve.

References

  • [10] Brooks & Corey, Hydrology Papers, Colorado State University (1964)
  • [11] Campbell, Soil Science (1974)
  • [12] Clapp & Hornberger, Water Resources Research (1978)
  • [13] Boone et al., Journal of Applied Meteorology (2000)
  • [9] Westermann et al., Geoscientific Model Development (2023)
source
Terrarium.UnsatKLinear — Type
struct UnsatKLinear{NF} <: Terrarium.AbstractUnsatK{NF}

Simple formulation of hydraulic conductivity as a linear function of the liquid water saturated fraction, i.e. soil.water / (soil.water + soil.ice + soil.air).

source
Terrarium.UnsatKVanGenuchten — Type
struct UnsatKVanGenuchten{NF} <: Terrarium.AbstractUnsatK{NF}

Formulation of hydraulic conductivity as a function of saturated hydraulic conductivity K_sat and volumetric fractions, assumed to include those of water, ice, and air, following the van Genuchten formulation [8] extended with an ice impedance factor [9].

References

  • [8] Van Genuchten, Soil Science Society of America Journal (1980)
  • [9] Westermann et al., Geoscientific Model Development (2023)
source
Terrarium.VarDims — Type
struct VarDims{LX, LY, LZ}

Indicator type describing the location on which a variable should be instantiated on an Oceananigans grid. The fields x, y, and z should be one of: Center() or Face() for variables that should be discretized on grid cell centers or faces along each axis, Coordinate for variables that are defined at a single point along an axis, or nothing for variables that represented quantities integrated over a domain.

source
Terrarium.VarDomain — Type
abstract type VarDomain

Marker type for state variable spatial domains; currently, five domains are considered: Ground, Snow, Canopy, Surface, and Atmosphere.

The first three are vertical domains, each of which a land grid may discretize in its own right. Surface instead represents the land-atmosphere interface, whose physical position depends on the surface tile (the top of the soil column over bare ground, the top of the snowpack under snow, the canopy where there is vegetation). A variable declared on Surface therefore never carries a vertical dimension and must always be 2D (XY).

Atmosphere is likewise not a vertical domain; it is the domain of the atmospheric forcings a land model reads rather than computes.

A variable need not state a domain at all; see VarLocation.

source
Terrarium.VarLocation — Type
struct VarLocation{Dims, Domain}

Represents the "location" of an abstract variable, i.e. both the spatial domain and its dimensionality.

The domain may be nothing, which declares a variable as domain-agnostic: it makes no claim about where the variable lives, so it is compatible with any domain and adopts whichever one another declaration of the same variable states. This is the default for an InputSource, which generally cannot know the domain of the variable it feeds, and it is also the natural choice for a model discretized on a plain AbstractGrid, which has only one discretization.

On an AbstractLandGrid a variable which is still domainless once all declarations are merged is allocated on the ground domain. That is unambiguous for a 2D variable, since every domain shares the same horizontal discretization, but a variable with a vertical extent or position also warns; see domain_matters.

source
Terrarium.VarPath — Type
VarPath

Type alias for namespaced variable paths of the form (namespace_1, ..., namespace_N, varname). Used to specify the location of variables in nested namespaces.

source
Terrarium.Variable — Type
struct Variable{name, VL, UT} <: Terrarium.AbstractVariable{name, VL, UT}

Represents metadata for a generic state variable with the given name and spatial loc.

source
Terrarium.Variables — Type
struct Variables

Container for abstract state variable definitions. Automatically collates and merges all variables and namespaces passed into the constructor. Uses OrderedDicts internally to avoid NamedTuple type explosion during initialization (each merge in a foldl creates a new distinct type), converting to NamedTuples only at the final StateVariables construction step.

source
Terrarium.VegetationModel — Type
mutable struct VegetationModel{NF, Vegetation<:Terrarium.AbstractVegetation{NF}, Atmosphere<:(Terrarium.AbstractAtmosphere{NF, PR, IR, HM, WS, AD} where {PR<:Terrarium.AbstractPrecipitation, IR<:Terrarium.AbstractIncomingRadiation, HM<:Terrarium.AbstractHumidity, WS<:Terrarium.AbstractWind, AD<:Terrarium.AbstractAerodynamics{NF}}), GridType<:Oceananigans.Grids.AbstractGrid, Initializer<:Terrarium.AbstractInitializer, Timestepper<:Terrarium.AbstractTimeStepper} <: Terrarium.AbstractVegetationModel{NF, GridType}

Model for natural (unmanaged) vegetation processes for a single plant functional type (PFT). Multiple PFTs can be later handled with a TiledVegetationModel type that composes multiple VegetationModels with different parameters for each PFT.

Properties:

  • grid::Oceananigans.Grids.AbstractGrid: Spatial grid type

  • atmosphere::Terrarium.AbstractAtmosphere: Atmospheric input configuration

  • vegetation::Terrarium.AbstractVegetation: Vegetation processes

  • constants::PhysicalConstants: Physical constants

  • initializer::Terrarium.AbstractInitializer: State variable initializer

  • timestepper::Terrarium.AbstractTimeStepper: Time stepper: a single AbstractTimeStepper (e.g. ForwardEuler, Heun) or an IMEX

source
Terrarium.VerticallySlicedField — Type

Alias for a Field restricted to a single vertical index, i.e. one declared at the Top or Bottom of a domain. Such a field carries a Center or Face vertical location, so it is not distinguishable from a fully resolved (XYZ) field by its location parameters alone; the indices type parameter is what separates the two.

source
Terrarium.VolumetricWaterContent — Type
struct VolumetricWaterContent{T} <: Terrarium.AbstractWaterContent

Marker type indicating that the wrapped value is the volumetric water and ice content (m³/m³), i.e. the volume of water and ice per unit volume of soil. It is converted to saturation by dividing by the porosity of the soil.

Properties:

  • value::Any: Volumetric water and ice content (m³/m³)
source
Terrarium.WeightedAverage — Type
struct WeightedAverage <: Terrarium.AbstractBulkWeighting

Simple weighted average formula for computing bulk quantities:

\[\bar{x} = \sum_{i=1}^N \theta_i x_i\]

source
Terrarium.WindVelocity — Type
struct WindVelocity <: Terrarium.AbstractWind

Represents a windspeed given as u (east-west) and v (south-north) velocity components.

source
Terrarium.Windspeed — Type
struct Windspeed <: Terrarium.AbstractWind

Represents a windspeed as direct input/forcing variable.

source
Terrarium.XY — Type
XY(x = Center(), y = Center(), z = nothing)

Dimensions for a variable with no vertical extent, i.e. one assigned a 2D (lateral only) field on its associated grid. This covers both genuinely two-dimensional quantities and those integrated or averaged over a domain's vertical extent.

source
Terrarium.XYZ — Type
XYZ(x = Center(), y = Center(), z = Center())

Dimensions for a variable which is resolved over a domain's full vertical extent, i.e. one assigned a 3D field on its associated grid.

source
Terrarium.FieldBC — Type

Alias for union type of FieldBoundaryConditions or a named tuple of BoundaryConditions with keys corresponding to boundary locations (i.e. top, bottom, etc.)

source
Terrarium.Optional — Type

Alias for Union{Nothing, T} indicating that an argument or field of type T is optional and can be replaced with nothing.

source
Terrarium.VerticalCoordinate — Type

The vertical coordinates accepted by Terrarium's grid constructors: either a vector (or range) of cell interfaces, such as the one returned by UniformSpacing, or one of the Oceananigans discretizations which determine their own number of cells, such as the one returned by ExponentialSpacing.

Note that a coordinate given as a Tuple of endpoints, which Oceananigans also accepts, does not determine the number of layers and so cannot be used here.

source