Skip to content

Commit

Permalink
Remove support for root_distribution as param (#812)
Browse files Browse the repository at this point in the history
Previously, rooting_depth was added as a PlayHydraulics param
to replace rootdistribution. Support for root_distribution continued,
but this caused an isbits error with broadcasting. This commit
removes support for the deprecated root_distribution param
  • Loading branch information
imreddyTeja authored Oct 3, 2024
1 parent f780e36 commit eba3ba8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 51 deletions.
5 changes: 0 additions & 5 deletions deprecated_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,3 @@

This file lists deprecated features and the recommended alternative practice

- ## `root_distribution`

The `root_distribution` in `PlantHydraulicsParameters` is replaced by `rooting_depth`.
If using a `root_distribution` function of the form P(x) = 1/d e^(z/d), then `rooting_depth`
is equivalent to d.
7 changes: 1 addition & 6 deletions src/integrated/soil_canopy_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,6 @@ function make_update_boundary_fluxes(
# Note that in `PrescribedSoil` mode, we compute the flux using K_soil = K_plant(ψ_soil)
# and K_canopy = K_plant(ψ_canopy). In `PrognosticSoil` mode here, we compute the flux using
# K_soil = K_soil(ψ_soil) and K_canopy = K_plant(ψ_canopy).
# if rooting_depth param is not nothing, use root_distribution from source
# otherwise use root_distribution from params
root_likelihood(z::FT, rd::Union{FT, Nothing}) =
!isnothing(rd) ? root_distribution(z, rd) :
model.parameters.root_distribution(z)
@. p.root_extraction =
above_ground_area_index *
PlantHydraulics.water_flux(
Expand All @@ -279,7 +274,7 @@ function make_update_boundary_fluxes(
p.canopy.hydraulics.ψ.:1,
),
) *
(root_likelihood(
(root_distribution(
z,
land.canopy.hydraulics.parameters.rooting_depth,
))
Expand Down
40 changes: 6 additions & 34 deletions src/standalone/Vegetation/PlantHydraulics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ struct PlantHydraulicsParameters{
PSAI <: PrescribedSiteAreaIndex{FT},
CP,
RP,
RDTH <: Union{FT, ClimaCore.Fields.Field, Nothing},
RDST <: Union{Function, Nothing},
RDTH <: Union{FT, ClimaCore.Fields.Field},
}
"The area index model for LAI, SAI, RAI"
ai_parameterization::PSAI
Expand All @@ -152,8 +151,6 @@ struct PlantHydraulicsParameters{
retention_model::RP
"Rooting depth parameter (m) - a characteristic depth below which 1/e of the root mass lies"
rooting_depth::RDTH
"DEPRECATED: Root distribution function P(z)"
root_distribution::RDST
end

"""
Expand All @@ -163,52 +160,32 @@ end
S_s::FT,
conductivity_model,
retention_model,
rooting_depth::Union{Nothing, FT, ClimaCore.Fields.Field} = nothing,
root_distribution::Union{Nothing, Function} = nothing, # DEPRECATED
rooting_depth::Union{FT, ClimaCore.Fields.Field},
)
Constructor for PlantHydraulicsParameters. The root_distribution parameter is deprecated.
If root_distribution and rooting_depth are both provided, root_distribution is ignored.
Constructor for PlantHydraulicsParameters.
"""
function PlantHydraulicsParameters(;
ai_parameterization::PrescribedSiteAreaIndex{FT},
ν::FT,
S_s::FT,
conductivity_model,
retention_model,
rooting_depth::Union{Nothing, FT, ClimaCore.Fields.Field} = nothing,
root_distribution::Union{Nothing, Function} = nothing, # DEPRECATED
rooting_depth::Union{Nothing, FT, ClimaCore.Fields.Field},
) where {FT}
if !isnothing(root_distribution)
if !isnothing(rooting_depth)
Base.depwarn(
"root_distribution is deprecated and will be ignored when rooting_depth is provided",
:PlantHydraulicsParameters,
)
else
Base.depwarn(
"root_distribution keyword argument is deprecated. Use rooting_depth instead.",
:PlantHydraulicsParameters,
)
end
elseif isnothing(rooting_depth)
error("rooting_depth must be provided")
end
return PlantHydraulicsParameters{
FT,
typeof(ai_parameterization),
typeof(conductivity_model),
typeof(retention_model),
typeof(rooting_depth),
typeof(root_distribution),
}(
ai_parameterization,
ν,
S_s,
conductivity_model,
retention_model,
rooting_depth,
root_distribution,
)
end

Expand Down Expand Up @@ -683,11 +660,6 @@ function root_water_flux_per_ground_area!(
n_root_layers = length(root_depths)
ψ_soil::FT = s.ψ(t)
fa .= FT(0.0)
# if rooting_depth param is not nothing, use root_distribution from source
# otherwise use root_distribution from params
root_likelihood(z::FT, rd::Union{FT, Nothing}) =
!isnothing(rd) ? root_distribution(z, rd) :
model.parameters.root_distribution(z)
@inbounds for i in 1:n_root_layers
above_ground_area_index =
getproperty(area_index, model.compartment_labels[1])
Expand All @@ -702,7 +674,7 @@ function root_water_flux_per_ground_area!(
hydraulic_conductivity(conductivity_model, ψ_soil),
hydraulic_conductivity(conductivity_model, ψ_base),
) *
root_likelihood(root_depths[i], rooting_depth) *
root_distribution(root_depths[i], rooting_depth) *
(root_depths[i + 1] - root_depths[i]) *
above_ground_area_index
else
Expand All @@ -715,7 +687,7 @@ function root_water_flux_per_ground_area!(
hydraulic_conductivity(conductivity_model, ψ_soil),
hydraulic_conductivity(conductivity_model, ψ_base),
) *
root_likelihood(root_depths[i], rooting_depth) *
root_distribution(root_depths[i], rooting_depth) *
(model.compartment_surfaces[1] - root_depths[n_root_layers]) *
above_ground_area_index
end
Expand Down
10 changes: 4 additions & 6 deletions test/standalone/Vegetation/canopy_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ import ClimaParams
g1_cases = (FT(790), fill(FT(790), domain.space.surface))
Vcmax25_cases = (FT(9e-5), fill(FT(9e-5), domain.space.surface))
mechanism_cases = (FT(1), mechanism_field)
zipped = zip(g1_cases, Vcmax25_cases, mechanism_cases)
for (g1, Vcmax25, is_c3) in zipped
rooting_cases = (FT(0.5), fill(FT(0.5), domain.space.surface))
zipped = zip(g1_cases, Vcmax25_cases, mechanism_cases, rooting_cases)
for (g1, Vcmax25, is_c3, rooting_depth) in zipped
AR_params = AutotrophicRespirationParameters(FT)
RTparams = BeerLambertParameters(FT)
photosynthesis_params = FarquharParameters(FT, is_c3; Vcmax25)
Expand Down Expand Up @@ -149,14 +150,11 @@ import ClimaParams
retention_model = PlantHydraulics.LinearRetentionCurve{FT}(a)
root_depths =
SVector{10, FT}(-(10:-1:1.0) ./ 10.0 * 2.0 .+ 0.2 / 2.0) # 1st element is the deepest root depth
function root_distribution(z::T) where {T}
return T(1.0 / 0.5) * exp(z / T(0.5)) # (1/m)
end
param_set = PlantHydraulics.PlantHydraulicsParameters(;
ai_parameterization = ai_parameterization,
ν = plant_ν,
S_s = plant_S_s,
root_distribution = root_distribution,
rooting_depth = rooting_depth,
conductivity_model = conductivity_model,
retention_model = retention_model,
)
Expand Down

0 comments on commit eba3ba8

Please sign in to comment.