Skip to content

Commit

Permalink
use @constantvalue throughout repo
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasloan25 committed Nov 13, 2024
1 parent f164f7e commit 7dd59a4
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 32 deletions.
11 changes: 5 additions & 6 deletions src/standalone/Snow/Snow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -124,8 +124,7 @@ function SnowParameters{FT}(
earth_param_set,
)
end

Base.broadcastable(ps::SnowParameters) = tuple(ps)
@ConstantValue SnowParameters

"""
struct SnowModel{
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions src/standalone/Soil/Biogeochemistry/Biogeochemistry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
3 changes: 1 addition & 2 deletions src/standalone/Soil/energy_hydrology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/standalone/Soil/retention_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
3 changes: 1 addition & 2 deletions src/standalone/Vegetation/Canopy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}(;
Expand Down Expand Up @@ -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
4 changes: 0 additions & 4 deletions src/standalone/Vegetation/PlantHydraulics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -407,17 +407,13 @@ An abstract type for the plant hydraulics conductivity model.
"""
abstract type AbstractConductivityModel{FT <: AbstractFloat} end

Base.broadcastable(x::AbstractConductivityModel) = tuple(x)
"""
AbstractRetentionModel{FT <: AbstractFloat}
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}
Expand Down
8 changes: 3 additions & 5 deletions src/standalone/Vegetation/autotrophic_respiration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
Expand Down Expand Up @@ -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)
3 changes: 1 addition & 2 deletions src/standalone/Vegetation/optimality_farquhar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""
Expand Down Expand Up @@ -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)
3 changes: 1 addition & 2 deletions src/standalone/Vegetation/photosynthesis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}} <:
Expand Down Expand Up @@ -193,6 +193,5 @@ function update_photosynthesis!(
)
Vcmax25field .= Vcmax25
end
Base.broadcastable(m::FarquharParameters) = tuple(m)

include("./optimality_farquhar.jl")
6 changes: 3 additions & 3 deletions src/standalone/Vegetation/radiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand Down Expand Up @@ -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}) =
Expand Down
5 changes: 2 additions & 3 deletions src/standalone/Vegetation/solar_induced_fluorescence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
"""
Expand All @@ -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}
Expand Down Expand Up @@ -92,7 +92,6 @@ function update_SIF!(
)
end

Base.broadcastable(m::SIFParameters) = tuple(m)
function compute_SIF_at_a_point(
APAR::FT,
Tc::FT,
Expand Down

0 comments on commit 7dd59a4

Please sign in to comment.