Skip to content

Commit

Permalink
Extend Vcmax to support SpaceVaryingInput
Browse files Browse the repository at this point in the history
  • Loading branch information
imreddyTeja committed Aug 30, 2024
1 parent 0decb8b commit 1b89316
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 38 deletions.
7 changes: 6 additions & 1 deletion experiments/benchmarks/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,12 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
g1 = FT(141) # Wang et al: 141 sqrt(Pa) for Medlyn model; Natan used 300.

#Photosynthesis model
Vcmax25 = FT(9e-5) # from Yujie's paper 4.5e-5 , Natan used 9e-5
Vcmax25 = SpaceVaryingInput(
"/net/sampo/data1/ClimaArtifacts/artifacts/clm_data/vegetation_properties_map.nc",
"vcmx25",
surface_space;
regridder_type,
)

# Plant Hydraulics and general plant parameters
SAI = FT(0.0) # m2/m2
Expand Down
8 changes: 7 additions & 1 deletion experiments/long_runs/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,13 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
g1 = FT(141) # Wang et al: 141 sqrt(Pa) for Medlyn model; Natan used 300.

#Photosynthesis model
Vcmax25 = FT(9e-5) # from Yujie's paper 4.5e-5 , Natan used 9e-5
Vcmax25 = SpaceVaryingInput(
"/net/sampo/data1/ClimaArtifacts/artifacts/clm_data/vegetation_properties_map.nc",
"vcmx25",
surface_space;
regridder_type,
file_reader_kwargs = (; preprocess_func = (x) -> x / 1_000_000),
)

# Plant Hydraulics and general plant parameters
SAI = FT(0.0) # m2/m2
Expand Down
14 changes: 8 additions & 6 deletions ext/CreateParametersExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,19 @@ end

"""
function FarquharParameters(
FT,
FT,
mechanism::AbstractPhotosynthesisMechanism;
Vcmax25 = FT(5e-5),
kwargs... # For individual parameter overrides
)
function FarquharParameters(
toml_dict::CP.AbstractTOMLDict,
toml_dict::CP.AbstractTOMLDict,
mechanism::AbstractPhotosynthesisMechanism;
Vcmax25 = FT(5e-5),
kwargs... # For individual parameter overrides
)
Constructors for the FarquharParameters struct. Two variants:
1. Pass in the float-type and retrieve parameter values from the default TOML dict.
2. Pass in a TOML dictionary to retrieve parameter values.Possible calls:
Expand Down Expand Up @@ -166,7 +166,9 @@ function FarquharParameters(
parameters = CP.get_parameter_values(toml_dict, name_map, "Land")
FT = CP.float_type(toml_dict)
MECH = typeof(mechanism)
return FarquharParameters{FT, MECH}(;
Vcmax25 = FT.(Vcmax25)
VC = typeof(Vcmax25)
return FarquharParameters{FT, MECH, VC}(;
mechanism,
Vcmax25,
parameters...,
Expand All @@ -181,7 +183,7 @@ end
)
function OptimalityFarquharParameters(
toml_dict::CP.AbstractTOMLDict,
toml_dict::CP.AbstractTOMLDict,
kwargs... # For individual parameter overrides
)
Expand Down Expand Up @@ -260,7 +262,7 @@ end
EnergyHydrologyParameters has two constructors: float-type and toml dict based.
Additional parameters must be added manually: ν, ν_ss_om, ν_ss_quartz, ν_ss_gravel, hydrology_cm, K_sat, S_s, and θ_r
All parameters can be manually overriden via keyword arguments. Note, however,
that certain parameters must have the same type (e.g, if a field is
that certain parameters must have the same type (e.g, if a field is
supplied for porosity, it must be supplied for all other parameters
defined in the interior of the domain). Some parameters are defined only
on the surface of the domain (e.g albedo), while other are defined everywhere
Expand Down
88 changes: 64 additions & 24 deletions src/standalone/Vegetation/photosynthesis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,24 @@ struct C4 <: AbstractPhotosynthesisMechanism end

abstract type AbstractPhotosynthesisModel{FT} <: AbstractCanopyComponent{FT} end
"""
FarquharParameters{FT<:AbstractFloat, MECH <: AbstractPhotosynthesisMechanism}
FarquharParameters{
FT<:AbstractFloat,
MECH <: AbstractPhotosynthesisMechanism,
VCMAX <: Union{FT, ClimaCore.Fields.Field}
}
The required parameters for the Farquhar photosynthesis model.
$(DocStringExtensions.FIELDS)
"""
Base.@kwdef struct FarquharParameters{
FT <: AbstractFloat,
MECH <: AbstractPhotosynthesisMechanism,
VCMAX <: Union{FT, ClimaCore.Fields.Field},
}
"Vcmax at 25 °C (mol CO2/m^2/s)"
Vcmax25::FT
# Vcmax25::Union{FT, ClimaCore.Fields.Field{FT, ClimaCore.Spaces.AbstractSpace}}
Vcmax25::VCMAX

"Γstar at 25 °C (mol/mol)"
Γstar25::FT
"Michaelis-Menten parameter for CO2 at 25 °C (mol/mol)"
Expand Down Expand Up @@ -93,26 +100,24 @@ function photosynthesis_at_a_point_Farquhar(
c_co2,
medlyn_factor,
R,
parameters,
Vcmax25,
Γstar25,
ΔHJmax,
ΔHVcmax,
ΔHΓstar,
f,
ΔHRd,
To,
θj,
ϕ,
mechanism,
oi,
Kc25,
Ko25,
ΔHkc,
ΔHko,
)
(;
Vcmax25,
Γstar25,
ΔHJmax,
ΔHVcmax,
ΔHΓstar,
f,
ΔHRd,
To,
θj,
ϕ,
mechanism,
oi,
Kc25,
Ko25,
ΔHkc,
ΔHko,
) = parameters

Jmax = max_electron_transport(Vcmax25, ΔHJmax, T, To, R)
J = electron_transport(APAR, Jmax, θj, ϕ)
Vcmax = compute_Vcmax(Vcmax25, T, To, R, ΔHVcmax)
Expand All @@ -123,6 +128,7 @@ function photosynthesis_at_a_point_Farquhar(
Ko = MM_Ko(Ko25, ΔHko, T, To, R)
Ac = rubisco_assimilation(mechanism, Vcmax, ci, Γstar, Kc, Ko, oi)
return net_photosynthesis(Ac, Aj, Rd, β)

end

"""
Expand Down Expand Up @@ -156,8 +162,27 @@ function update_photosynthesis!(
c_co2,
R,
)
(; Vcmax25, f, ΔHRd, To) = model.parameters

(;
Vcmax25,
f,
ΔHRd,
To,
Γstar25,
ΔHJmax,
ΔHVcmax,
ΔHΓstar,
f,
ΔHRd,
To,
θj,
ϕ,
mechanism,
oi,
Kc25,
Ko25,
ΔHkc,
ΔHko,
) = model.parameters
@. Rd = dark_respiration(Vcmax25, β, f, ΔHRd, T, To, R)
@. An = photosynthesis_at_a_point_Farquhar(
T,
Expand All @@ -167,7 +192,22 @@ function update_photosynthesis!(
c_co2,
medlyn_factor,
R,
model.parameters,
Vcmax25,
Γstar25,
ΔHJmax,
ΔHVcmax,
ΔHΓstar,
f,
ΔHRd,
To,
θj,
ϕ,
mechanism,
oi,
Kc25,
Ko25,
ΔHkc,
ΔHko,
)
Vcmax25field .= Vcmax25
end
Expand Down
12 changes: 6 additions & 6 deletions test/standalone/Vegetation/canopy_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import ClimaParams
@testset "Canopy software pipes" begin
for FT in (Float32, Float64)
domain = Point(; z_sfc = FT(0.0))

Vcmax25 = fill(FT(9e-5), domain.space.surface)
AR_params = AutotrophicRespirationParameters(FT)
RTparams = BeerLambertParameters(FT)
photosynthesis_params = FarquharParameters(FT, C3())
photosynthesis_params = FarquharParameters(FT, C3(); Vcmax25 = Vcmax25)
stomatal_g_params = MedlynConductanceParameters(FT)

AR_model = AutotrophicRespirationModel{FT}(AR_params)
Expand Down Expand Up @@ -515,9 +515,9 @@ end
@testset "Canopy software pipes with energy model" begin
for FT in (Float32, Float64)
domain = Point(; z_sfc = FT(0.0))

Vcmax25 = fill(FT(9e-5), domain.space.surface)
RTparams = BeerLambertParameters(FT)
photosynthesis_params = FarquharParameters(FT, C3())
photosynthesis_params = FarquharParameters(FT, C3(); Vcmax25 = Vcmax25)
stomatal_g_params = MedlynConductanceParameters(FT)

stomatal_model = MedlynConductanceModel{FT}(stomatal_g_params)
Expand Down Expand Up @@ -765,7 +765,7 @@ end
@testset "Zero LAI;" begin
for FT in (Float32, Float64)
domain = Point(; z_sfc = FT(0.0))

Vcmax25 = fill(FT(9e-5), domain.space.surface)
BeerLambertparams = BeerLambertParameters(FT)
# TwoStreamModel parameters
Ω = FT(0.69)
Expand All @@ -787,7 +787,7 @@ end
τ_NIR_leaf,
G_Function,
)
photosynthesis_params = FarquharParameters(FT, C3())
photosynthesis_params = FarquharParameters(FT, C3(); Vcmax25 = Vcmax25)
stomatal_g_params = MedlynConductanceParameters(FT)

stomatal_model = MedlynConductanceModel{FT}(stomatal_g_params)
Expand Down

0 comments on commit 1b89316

Please sign in to comment.