Skip to content

Commit 756f055

Browse files
committed
small fixes
- remove deprecated PModelDrivers constructor in test file - allow users to change some PModelConstants by placing them in the kwargs - add some more documentation to pmodel.jl
1 parent d3d8190 commit 756f055

File tree

2 files changed

+60
-55
lines changed

2 files changed

+60
-55
lines changed

src/standalone/Vegetation/pmodel.jl

Lines changed: 59 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -99,31 +99,56 @@ Base.broadcastable(m::PModelConstants) = tuple(m)
9999
PModelConstants(FT)
100100
101101
Creates a `PModelConstants` object with default values for the P-model constants.
102+
See Stocker et al. (2020) Table A2 and references within for more information.
102103
"""
103-
function PModelConstants(FT)
104-
return PModelConstants(
105-
R = LP.gas_constant(LP.LandParameters(FT)),
106-
Kc25 = FT(39.97),
107-
Ko25 = FT(27480),
108-
To = FT(298.15),
109-
ΔHkc = FT(79430),
110-
ΔHko = FT(36380),
111-
Drel = FT(1.6),
112-
ΔHΓstar = FT(37830),
113-
Γstar25 = FT(4.332),
114-
Ha_Vcmax = FT(71513),
115-
Hd_Vcmax = FT(200000),
116-
aS_Vcmax = FT(668.39),
117-
bS_Vcmax = FT(1.07),
118-
Ha_Jmax = FT(49884),
119-
Hd_Jmax = FT(200000),
120-
aS_Jmax = FT(659.70),
121-
bS_Jmax = FT(0.75),
122-
Mc = FT(0.0120107),
123-
oi = FT(0.2095),
124-
aRd = FT(0.1012),
125-
bRd = FT(-0.0005),
126-
fC3 = FT(0.015),
104+
function PModelConstants{FT}(;
105+
R = LP.gas_constant(LP.LandParameters(FT)),
106+
Kc25 = FT(39.97), # Pa (see note on line 38 above)
107+
Ko25 = FT(27480), # Pa (see note on line 38 above)
108+
To = FT(298.15),
109+
ΔHkc = FT(79430),
110+
ΔHko = FT(36380),
111+
Drel = FT(1.6),
112+
ΔHΓstar = FT(37830),
113+
Γstar25 = FT(4.332), # Pa (see note on line 38 above)
114+
Ha_Vcmax = FT(71513),
115+
Hd_Vcmax = FT(200000),
116+
aS_Vcmax = FT(668.39),
117+
bS_Vcmax = FT(1.07),
118+
Ha_Jmax = FT(49884),
119+
Hd_Jmax = FT(200000),
120+
aS_Jmax = FT(659.70),
121+
bS_Jmax = FT(0.75),
122+
Mc = FT(0.0120107),
123+
oi = FT(0.2095),
124+
aRd = FT(0.1012),
125+
bRd = FT(-0.0005),
126+
fC3 = FT(0.015),
127+
) where {FT <: AbstractFloat}
128+
129+
return PModelConstants{FT}(
130+
R,
131+
Kc25,
132+
Ko25,
133+
To,
134+
ΔHkc,
135+
ΔHko,
136+
Drel,
137+
ΔHΓstar,
138+
Γstar25,
139+
Ha_Vcmax,
140+
Hd_Vcmax,
141+
aS_Vcmax,
142+
bS_Vcmax,
143+
Ha_Jmax,
144+
Hd_Jmax,
145+
aS_Jmax,
146+
bS_Jmax,
147+
Mc,
148+
oi,
149+
aRd,
150+
bRd,
151+
fC3,
127152
)
128153
end
129154

@@ -132,6 +157,13 @@ end
132157
OPFT <: PModelParameters{FT},
133158
OPCT <: PModelConstants{FT}
134159
} <: AbstractPhotosynthesisModel{FT}
160+
161+
An implementation of the optimality photosynthesis model "P-model v1.0" of Stocker et al. (2020).
162+
163+
Stocker, B. D., Wang, H., Smith, N. G., Harrison, S. P., Keenan, T. F., Sandoval, D., Davis, T.,
164+
and Prentice, I. C.: P-model v1.0: an optimality-based light use efficiency model for simulating
165+
ecosystem gross primary production, Geosci. Model Dev., 13, 1545–1581,
166+
https://doi.org/10.5194/gmd-13-1545-2020, 2020.
135167
"""
136168
struct PModel{FT, OPFT <: PModelParameters{FT}, OPCT <: PModelConstants{FT}} <:
137169
AbstractPhotosynthesisModel{FT}
@@ -231,6 +263,9 @@ function compute_full_pmodel_outputs(
231263
) = constants
232264

233265
# Compute intermediate values
266+
267+
# The quantum yield ϕ0 can either be taken as a constant or computed from the temperature
268+
# dependent function. If ϕ0 is not NaN, it is used directly.
234269
ϕ0 = isnan(ϕ0) ? intrinsic_quantum_yield(T_canopy, ϕc, ϕa0, ϕa1, ϕa2) : ϕ0
235270

236271
Γstar = co2_compensation_p(T_canopy, To, P_air, R, ΔHΓstar, Γstar25)

test/standalone/Vegetation/test_pmodel.jl

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,36 +53,6 @@ function percent_difference(a, b)
5353
return abs(a - b) / abs(b) * 100
5454
end
5555

56-
"""
57-
create_pmodel_drivers(inputs::Dict{String, Any}, FT)
58-
59-
Create P-Model driver variables from test input data.
60-
Converts input data from the test CSV files into the appropriate driver structure
61-
for the P-Model, handling unit conversions and optional soil moisture stress.
62-
"""
63-
function PModelDrivers(inputs::Dict{String, Any}, FT)
64-
T_canopy = FT(inputs["tc"] + 273.15) # Convert from Celsius to Kelvin
65-
VPD = FT(inputs["vpd"])
66-
ca = FT(inputs["co2"]) * FT(1e-6) * FT(101325.0) # Convert ppm to Pa
67-
P_air = FT(get(inputs, "patm", 101325.0))
68-
69-
# Calculate I_abs directly from fapar and ppfd
70-
I_abs = FT(inputs["fapar"]) * FT(inputs["ppfd"])
71-
72-
βm =
73-
Bool(inputs["do_soilmstress"]) ?
74-
quadratic_soil_moisture_stress(FT(inputs["soilm"])) : FT(1.0)
75-
76-
return ClimaLand.Canopy.PModelDrivers(
77-
T_canopy = T_canopy,
78-
I_abs = I_abs,
79-
ca = ca,
80-
P_air = P_air,
81-
VPD = VPD,
82-
βm = βm,
83-
)
84-
end
85-
8656
"""
8757
create_pmodel_parameters(inputs::Dict{String, Any}, FT)
8858
@@ -191,7 +161,7 @@ end
191161
println("Running test case: $testcase_name with FT = $FT")
192162

193163
# prepare constants, parameters, and drivers for the current FT
194-
constants = PModelConstants(FT)
164+
constants = PModelConstants{FT}()
195165
parameters = PModelParameters(inputs, FT)
196166

197167
T_canopy = FT(inputs["tc"] + 273.15) # Convert from Celsius to Kelvin

0 commit comments

Comments
 (0)