From 7dd59a4e0f41c2541c2f48f212c17072ab1c8f5f Mon Sep 17 00:00:00 2001 From: Julia Sloan Date: Wed, 13 Nov 2024 12:03:41 -0800 Subject: [PATCH] use @ConstantValue throughout repo --- src/standalone/Snow/Snow.jl | 11 +++++------ .../Soil/Biogeochemistry/Biogeochemistry.jl | 3 +-- src/standalone/Soil/energy_hydrology.jl | 3 +-- src/standalone/Soil/retention_models.jl | 1 - src/standalone/Vegetation/Canopy.jl | 3 +-- src/standalone/Vegetation/PlantHydraulics.jl | 4 ---- src/standalone/Vegetation/autotrophic_respiration.jl | 8 +++----- src/standalone/Vegetation/optimality_farquhar.jl | 3 +-- src/standalone/Vegetation/photosynthesis.jl | 3 +-- src/standalone/Vegetation/radiation.jl | 6 +++--- .../Vegetation/solar_induced_fluorescence.jl | 5 ++--- 11 files changed, 18 insertions(+), 32 deletions(-) diff --git a/src/standalone/Snow/Snow.jl b/src/standalone/Snow/Snow.jl index 54cd915ecc..0262c1d88b 100644 --- a/src/standalone/Snow/Snow.jl +++ b/src/standalone/Snow/Snow.jl @@ -51,7 +51,7 @@ A struct for storing parameters of the `SnowModel`. Note that in our current implementation of runoff, a physical timescale is required and computed using Ksat and the depth of the snow. For shallow snowpacks, this will fall below the timestep -of the model. For that reason, we pass the timestep of the model as +of the model. For that reason, we pass the timestep of the model as a parameter, and take the larger of the timestep and the physical timescale as the value used in the model. Future implementations will revisit this. $(DocStringExtensions.FIELDS) @@ -124,8 +124,7 @@ function SnowParameters{FT}( earth_param_set, ) end - -Base.broadcastable(ps::SnowParameters) = tuple(ps) +@ConstantValue SnowParameters """ struct SnowModel{ @@ -327,9 +326,9 @@ end """ clip_total_snow_energy_flux(U, S, total_energy_flux, total_water_flux, Δt) -A helper function which clips the total energy flux such that -snow energy per unit ground area U will not become positive, and -which ensures that if the snow water equivalent S goes to zero in a step, +A helper function which clips the total energy flux such that +snow energy per unit ground area U will not become positive, and +which ensures that if the snow water equivalent S goes to zero in a step, U will too. """ function clip_total_snow_energy_flux( diff --git a/src/standalone/Soil/Biogeochemistry/Biogeochemistry.jl b/src/standalone/Soil/Biogeochemistry/Biogeochemistry.jl index c7211e8e81..a691c9d9ba 100644 --- a/src/standalone/Soil/Biogeochemistry/Biogeochemistry.jl +++ b/src/standalone/Soil/Biogeochemistry/Biogeochemistry.jl @@ -65,6 +65,7 @@ Base.@kwdef struct SoilCO2ModelParameters{FT <: AbstractFloat, PSE} "Physical constants used Clima-wide" earth_param_set::PSE end +@ConstantValue SoilCO2ModelParameters """ AbstractSoilBiogeochemistryModel{FT} <: ClimaLand.AbstractExpModel{FT} @@ -555,8 +556,6 @@ function ClimaLand.get_drivers(model::SoilCO2Model) return (model.drivers.atmos, model.drivers.soc) end -Base.broadcastable(ps::SoilCO2ModelParameters) = tuple(ps) - include("./co2_parameterizations.jl") end # module diff --git a/src/standalone/Soil/energy_hydrology.jl b/src/standalone/Soil/energy_hydrology.jl index d459f80d46..5ffc54b69f 100644 --- a/src/standalone/Soil/energy_hydrology.jl +++ b/src/standalone/Soil/energy_hydrology.jl @@ -83,8 +83,7 @@ Base.@kwdef struct EnergyHydrologyParameters{ "Physical constants and clima-wide parameters" earth_param_set::PSE end - -Base.broadcastable(ps::EnergyHydrologyParameters) = tuple(ps) +@ConstantValue EnergyHydrologyParameters """ EnergyHydrology <: AbstractSoilModel diff --git a/src/standalone/Soil/retention_models.jl b/src/standalone/Soil/retention_models.jl index e2674785c6..80a79da99d 100644 --- a/src/standalone/Soil/retention_models.jl +++ b/src/standalone/Soil/retention_models.jl @@ -15,7 +15,6 @@ To add a new parameterization, methods are required for: - hydraulic_conductivity. """ abstract type AbstractSoilHydrologyClosure{FT <: AbstractFloat} end -Base.broadcastable(x::AbstractSoilHydrologyClosure) = tuple(x) """ vanGenuchten{FT} <: AbstractSoilHydrologyClosure{FT} diff --git a/src/standalone/Vegetation/Canopy.jl b/src/standalone/Vegetation/Canopy.jl index 91a6d173c4..21761d11ee 100644 --- a/src/standalone/Vegetation/Canopy.jl +++ b/src/standalone/Vegetation/Canopy.jl @@ -123,6 +123,7 @@ struct CanopyModel{FT, AR, RM, PM, SM, PHM, EM, SIFM, B, PS, D} <: "Canopy model domain" domain::D end +@ConstantValue CanopyModel """ CanopyModel{FT}(; @@ -706,6 +707,4 @@ function ClimaLand.get_drivers(model::CanopyModel) ) end include("./canopy_boundary_fluxes.jl") -#Make the canopy model broadcastable -Base.broadcastable(C::CanopyModel) = tuple(C) end diff --git a/src/standalone/Vegetation/PlantHydraulics.jl b/src/standalone/Vegetation/PlantHydraulics.jl index 5debce2bca..73d4d60223 100644 --- a/src/standalone/Vegetation/PlantHydraulics.jl +++ b/src/standalone/Vegetation/PlantHydraulics.jl @@ -407,7 +407,6 @@ An abstract type for the plant hydraulics conductivity model. """ abstract type AbstractConductivityModel{FT <: AbstractFloat} end -Base.broadcastable(x::AbstractConductivityModel) = tuple(x) """ AbstractRetentionModel{FT <: AbstractFloat} @@ -415,9 +414,6 @@ An abstract type for the plant retention curve model. """ abstract type AbstractRetentionModel{FT <: AbstractFloat} end -Base.broadcastable(x::AbstractRetentionModel) = tuple(x) - - """ Weibull{FT} <: AbstractConductivityModel{FT} diff --git a/src/standalone/Vegetation/autotrophic_respiration.jl b/src/standalone/Vegetation/autotrophic_respiration.jl index b4435847dd..e69fb97140 100644 --- a/src/standalone/Vegetation/autotrophic_respiration.jl +++ b/src/standalone/Vegetation/autotrophic_respiration.jl @@ -6,7 +6,7 @@ abstract type AbstractAutotrophicRespirationModel{FT} <: """ AutotrophicRespirationParameters{FT<:AbstractFloat} -The required parameters for the autrophic respiration model, which is based +The required parameters for the autrophic respiration model, which is based off of the JULES model. Clark, D. B., et al. "The Joint UK Land Environment Simulator (JULES), model description–Part 2: carbon fluxes and vegetation dynamics." Geoscientific Model Development 4.3 (2011): 701-722. $(DocStringExtensions.FIELDS) @@ -25,11 +25,11 @@ Base.@kwdef struct AutotrophicRespirationParameters{FT <: AbstractFloat} "Relative contribution or Rgrowth (-)" Rel::FT end - +@ConstantValue AutotrophicRespirationParameters Base.eltype(::AutotrophicRespirationParameters{FT}) where {FT} = FT """ - AutotrophicRespirationModel{FT, ARP <: AutotrophicRespirationParameters{FT},} <: AbstractAutotrophicRespirationModel{FT} + AutotrophicRespirationModel{FT, ARP <: AutotrophicRespirationParameters{FT},} <: AbstractAutotrophicRespirationModel{FT} The JULES autotrophic respiration model. @@ -98,5 +98,3 @@ function compute_autrophic_respiration( Ra = Rpm + Rg return Ra * (1 - exp(-K * LAI * Ω)) / (K * Ω) # adjust to canopy level end - -Base.broadcastable(model::AutotrophicRespirationModel) = tuple(model) # this is so that @. does not broadcast on Ref(canopy.autotrophic_respiration) diff --git a/src/standalone/Vegetation/optimality_farquhar.jl b/src/standalone/Vegetation/optimality_farquhar.jl index ee8228b8fa..3354abbde4 100644 --- a/src/standalone/Vegetation/optimality_farquhar.jl +++ b/src/standalone/Vegetation/optimality_farquhar.jl @@ -49,7 +49,7 @@ Base.@kwdef struct OptimalityFarquharParameters{ "Constant describing cost of maintaining electron transport (unitless)" c::FT end - +@ConstantValue OptimalityFarquharParameters Base.eltype(::OptimalityFarquharParameters{FT}) where {FT} = FT """ @@ -156,4 +156,3 @@ function update_photosynthesis!( @. Rd = dark_respiration(Vcmax25, β, f, ΔHRd, T, To, R) @. An = net_photosynthesis(Ac, Aj, Rd, β) end -Base.broadcastable(m::OptimalityFarquharParameters) = tuple(m) diff --git a/src/standalone/Vegetation/photosynthesis.jl b/src/standalone/Vegetation/photosynthesis.jl index 8d220f3c12..2a3806953e 100644 --- a/src/standalone/Vegetation/photosynthesis.jl +++ b/src/standalone/Vegetation/photosynthesis.jl @@ -54,7 +54,7 @@ Base.@kwdef struct FarquharParameters{ "Photosynthesis mechanism: 1.0 indicates C3, 0.0 indicates C4" is_c3::MECH end - +@ConstantValue FarquharParameters Base.eltype(::FarquharParameters{FT}) where {FT} = FT struct FarquharModel{FT, FP <: FarquharParameters{FT}} <: @@ -193,6 +193,5 @@ function update_photosynthesis!( ) Vcmax25field .= Vcmax25 end -Base.broadcastable(m::FarquharParameters) = tuple(m) include("./optimality_farquhar.jl") diff --git a/src/standalone/Vegetation/radiation.jl b/src/standalone/Vegetation/radiation.jl index 9405d5fc22..97a2d89e00 100644 --- a/src/standalone/Vegetation/radiation.jl +++ b/src/standalone/Vegetation/radiation.jl @@ -23,7 +23,7 @@ struct ConstantGFunction{F <: Union{AbstractFloat, ClimaCore.Fields.Field}} <: end # Make the ConstantGFunction broadcastable -Base.broadcastable(G::ConstantGFunction) = tuple(G) +@ConstantValue ConstantGFunction """ CLMGFunction @@ -38,7 +38,7 @@ struct CLMGFunction{F <: Union{AbstractFloat, ClimaCore.Fields.Field}} <: end # Make the CLMGFunction broadcastable -Base.broadcastable(G::CLMGFunction) = tuple(G) +@ConstantValue CLMGFunction """ BeerLambertParameters{FT <: AbstractFloat} @@ -176,7 +176,7 @@ function compute_NIR!( end # Make radiation models broadcastable -Base.broadcastable(RT::AbstractRadiationModel) = tuple(RT) +@ConstantValue AbstractRadiationModel ClimaLand.name(model::AbstractRadiationModel) = :radiative_transfer ClimaLand.auxiliary_vars(model::Union{BeerLambertModel, TwoStreamModel}) = diff --git a/src/standalone/Vegetation/solar_induced_fluorescence.jl b/src/standalone/Vegetation/solar_induced_fluorescence.jl index c7910c353b..09dc1f8b38 100644 --- a/src/standalone/Vegetation/solar_induced_fluorescence.jl +++ b/src/standalone/Vegetation/solar_induced_fluorescence.jl @@ -5,7 +5,7 @@ abstract type AbstractSIFModel{FT} <: AbstractCanopyComponent{FT} end """ SIFParameters{FT<:AbstractFloat} -The required parameters for the SIF parameterisation +The required parameters for the SIF parameterisation Lee et al, 2015. Global Change Biology 21, 3469-3477, doi:10.1111/gcb.12948. $(DocStringExtensions.FIELDS) """ @@ -29,7 +29,7 @@ $(DocStringExtensions.FIELDS) "Intercept of line relating leaf-level fluorescence to spectrometer-observed fluorescence as a function of Vcmax 25. Lee et al 2015." kappa_p2::FT = FT(7.85) end - +@ConstantValue SIFParameters Base.eltype(::SIFParameters{FT}) where {FT} = FT struct Lee2015SIFModel{FT, SP <: SIFParameters{FT}} <: AbstractSIFModel{FT} @@ -92,7 +92,6 @@ function update_SIF!( ) end -Base.broadcastable(m::SIFParameters) = tuple(m) function compute_SIF_at_a_point( APAR::FT, Tc::FT,