-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathCanopy.jl
More file actions
1490 lines (1323 loc) · 50.3 KB
/
Canopy.jl
File metadata and controls
1490 lines (1323 loc) · 50.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
module Canopy
import ClimaParams as CP
using DocStringExtensions
using Thermodynamics
using ClimaLand
using LazyBroadcast: lazy
using ClimaCore
using ClimaCore.MatrixFields
import ClimaCore.MatrixFields: @name, ⋅
import ClimaUtilities.TimeVaryingInputs: AbstractTimeVaryingInput
import ClimaUtilities.TimeManager: ITime, date
import LinearAlgebra: I, dot
using ClimaLand: AbstractRadiativeDrivers, AbstractAtmosphericDrivers
import ..Parameters as LP
import Insolation.Parameters as IP
using Dates
import ClimaLand:
name,
prognostic_vars,
prognostic_types,
auxiliary_vars,
auxiliary_types,
auxiliary_domain_names,
prognostic_domain_names,
initialize_prognostic,
initialize_auxiliary,
make_update_boundary_fluxes,
make_update_implicit_aux,
make_update_implicit_boundary_fluxes,
make_update_aux,
make_set_initial_cache,
make_compute_exp_tendency,
make_compute_imp_tendency,
make_compute_jacobian,
get_drivers,
get_model_callbacks,
total_liq_water_vol_per_area!,
total_energy_per_area!,
IntervalBasedCallback,
Soil,
return_momentum_fluxes,
component_temperature,
component_specific_humidity,
surface_roughness_model,
get_update_surface_temperature_function,
get_update_surface_humidity_function,
surface_displacement_height,
get_∂q_sfc∂T_function,
get_∂T_sfc∂T_function
using ClimaLand: PrescribedGroundConditions, AbstractGroundConditions
using ClimaLand.Domains: Point, Plane, SphericalSurface, get_long
export CanopyModel
include("./component_models.jl")
include("./optimal_lai.jl") # Must be before biomass.jl (defines OptimalLAIParameters used by ZhouOptimalLAIModel)
include("./biomass.jl")
include("./PlantHydraulics.jl")
using .PlantHydraulics
include("./soil_moisture_stress.jl")
include("./stomatalconductance.jl")
include("./photosynthesis.jl")
include("./photosynthesis_farquhar.jl")
include("./pmodel.jl")
include("./radiation.jl")
include("./solar_induced_fluorescence.jl")
include("./pfts.jl")
include("./canopy_energy.jl")
include("./canopy_parameterizations.jl")
using Dates
include("./autotrophic_respiration.jl")
include("./spatially_varying_parameters.jl")
include("./canopy_turbulent_fluxes.jl")
########################################################
# Convenience constructors for Canopy model components
########################################################
"""
Lee2015SIFModel{FT}(toml_dict::CP.ParamDict) where {FT}
Constructs the `Lee2015SIFModel` from the `toml_dict` using the parameters
in the `toml_dict`.
"""
function Lee2015SIFModel{FT}(toml_dict::CP.ParamDict) where {FT}
parameters = SIFParameters{FT}(;
kf = toml_dict["kf"],
kp = toml_dict["kp"],
kd_p1 = toml_dict["kd_p1"],
kd_p2 = toml_dict["kd_p2"],
min_kd = toml_dict["min_kd"],
kn_p1 = toml_dict["kn_p1"],
kn_p2 = toml_dict["kn_p2"],
kappa_p1 = toml_dict["kappa_p1"],
kappa_p2 = toml_dict["kappa_p2"],
)
return Lee2015SIFModel{FT, typeof(parameters)}(parameters)
end
## Soil Moisture Stress
"""
PiecewiseMoistureStressModel{FT}(
domain,
toml_dict::CP.ParamDict;
c::FT = toml_dict["moisture_stress_c"],
soil_params
) where {FT <: AbstractFloat}
Helper function to create `PiecewiseMoistureStressModel` by calculating field capacity (θ_high)
and wilting point (θ_low) from the soil parameters.
The low and high thresholds for the piecewise soil moisture stress function are given by
the residual soil water content and the soil porosity, respectively.
The soil parameters should be a named tuple with keys of `ν` and `θ_r`
(additional keys may be present but they will not be used). These may
be ClimaCore fields or floats, but must be consistently one or the other.
Note that unlike other Canopy components, this model is defined on the subsurface domain.
"""
function PiecewiseMoistureStressModel{FT}(
domain,
toml_dict::CP.ParamDict;
c::FT = toml_dict["moisture_stress_c"],
soil_params = Soil.soil_vangenuchten_parameters(
domain.space.subsurface,
FT,
),
) where {FT <: AbstractFloat}
if c <= 0
throw(
ArgumentError("Curvature parameter `c` must be greater than zero"),
)
end
θ_high = soil_params.ν
θ_low = soil_params.θ_r
return PiecewiseMoistureStressModel{FT}(; θ_high, θ_low, c)
end
"""
TuzetMoistureStressModel{FT}(toml_dict; sc::FT = toml_dict["moisture_stress_sc"], pc::FT = toml_dict["moisture_stress_pc"]) where{FT}
A constructor for TuzetMoistureStressModel which uses the toml_dict
values, allowing optional overrides by keyword argument.
"""
function TuzetMoistureStressModel{FT}(
toml_dict;
sc::FT = toml_dict["moisture_stress_sc"],
pc::FT = toml_dict["moisture_stress_pc"],
) where {FT}
return TuzetMoistureStressModel{FT}(; sc, pc)
end
## Autotrophic respiration models
"""
AutotrophicRespirationModel{FT}(toml_dict::CP.ParamDict,
) where {FT <: AbstractFloat}
Create a `AutotrophicRespirationModel` using `toml_dict` of type `FT`.
"""
function AutotrophicRespirationModel{FT}(
toml_dict::CP.ParamDict,
) where {FT <: AbstractFloat}
parameters = AutotrophicRespirationParameters(toml_dict)
return AutotrophicRespirationModel{FT, typeof(parameters)}(parameters)
end
## Energy models
"""
BigLeafEnergyModel{FT}(toml_dict::CP.ParamDict; ac_canopy = toml_dict["ac_canopy"]) where {FT <: AbstractFloat}
Creates a BigLeafEnergyModel using default parameters of type FT.
- ac_canopy (J m^-2 K^-1) - canopy specific heat per area
"""
function BigLeafEnergyModel{FT}(
toml_dict::CP.ParamDict;
ac_canopy::FT = toml_dict["ac_canopy"],
) where {FT <: AbstractFloat}
parameters = BigLeafEnergyParameters{FT}(ac_canopy)
return BigLeafEnergyModel{FT, typeof(parameters)}(parameters)
end
## Photosynthesis models
"""
FarquharModel{FT}(
domain;
photosynthesis_parameters = clm_photosynthesis_parameters(
domain.space.surface,
),
) where {
FT <: AbstractFloat,
MECH <: Union{FT, ClimaCore.Fields.Field},
VC <: Union{FT, ClimaCore.Fields.Field},
}
Creates a FarquharModel using default parameters of type FT.
The `photosynthesis_parameters` argument is a NamedTuple that contains
- `is_c3`: a Float or Field indicating if plants are C3 (1) or C4 (0) (unitless)
- `Vcmax25`: a Float or Field representing the maximum carboxylation rate at 25C (mol m^-2 s^-1)
By default, these parameters are set by the `clm_photosynthesis_parameters` function,
which reads in CLM data onto the surface space as ClimaUtilities SpaceVaryingInputs.
"""
function FarquharModel{FT}(
domain,
toml_dict::CP.ParamDict;
photosynthesis_parameters = clm_photosynthesis_parameters(
domain.space.surface,
),
) where {FT <: AbstractFloat}
(; is_c3, Vcmax25) = photosynthesis_parameters
parameters = FarquharParameters(toml_dict; is_c3, Vcmax25)
return FarquharModel{FT, typeof(parameters)}(parameters)
end
"""
function PModel{FT}(
domain,
toml_dict::CP.ParamDict;
is_c3 = nothing,
cstar = toml_dict["pmodel_cstar"],
β_c3 = toml_dict["pmodel_β_c3"],
β_c4 = toml_dict["pmodel_β_c4"],
temperature_dep_yield = true,
ϕ0_c3 = toml_dict["pmodel_ϕ0_c3"],
ϕ0_c4 = toml_dict["pmodel_ϕ0_c4"],
ϕa0_c3 = toml_dict["pmodel_ϕa0_c3"],
ϕa1_c3 = toml_dict["pmodel_ϕa1_c3"],
ϕa2_c3 = toml_dict["pmodel_ϕa2_c3"],
ϕa0_c4 = toml_dict["pmodel_ϕa0_c4"],
ϕa1_c4 = toml_dict["pmodel_ϕa1_c4"],
ϕa2_c4 = toml_dict["pmodel_ϕa2_c4"],
α = toml_dict["pmodel_α"],
) where {FT <: AbstractFloat}
Constructs a P-model (an optimality model for photosynthesis) using default parameters.
If `is_c3` is not provided, the constructor uses the spatial `c3_fraction` field from
the CLM artifact when available, and otherwise falls back to the dominant-pathway flag.
The following default parameters (from the TOML file) are used:
- cstar = 0.41 (unitless) - 4 * dA/dJmax, assumed to be a constant marginal cost (Wang 2017, Stocker 2020)
- β_c3 = 146 (unitless) - Unit cost ratio of Vcmax to transpiration for C3 plants (Stocker 2020)
- β_c4 = 146/9 ≈ 16.222 (unitless) - Unit cost ratio of Vcmax to transpiration for C4 plants (pyrealm)
- ϕ0_c3 = 0.052 (unitless) - constant intrinsic quantum yield. Skillman (2008)
- ϕ0_c4 = 0.057 (unitless) - constant intrinsic quantum yield. Skillman (2008)
- ϕa0_c3 = 0.044 (unitless) - constant term in quadratic intrinsic quantum yield (pyrealm/Bernacchi et al., 2003)
- ϕa1_c3 = 0.00275 (K^-1) - first order term in quadratic intrinsic quantum yield (pyrealm/Bernacchi et al., 2003)
- ϕa2_c3 = -0.0000425 (K^-2) - second order term in quadratic intrinsic quantum yield (pyrealm/Bernacchi et al., 2003)
- ϕa0_c4 = -0.008 (unitless) - constant term in quadratic intrinsic quantum yield (pyrealm/Cai and Prentice, 2020)
- ϕa1_c4 = 0.00375 (K^-1) - first order term in quadratic intrinsic quantum yield (pyrealm/Cai and Prentice, 2020)
- ϕa2_c4 = -0.000058 (K^-2) - second order term in quadratic intrinsic quantum yield (pyrealm/Cai and Prentice, 2020)
- α = 0.933 (unitless) - 1 - 1/T where T is the timescale of Vcmax, Jmax acclimation. Here T = 15 days. (Mengoli 2022)
"""
function PModel{FT}(
domain,
toml_dict::CP.ParamDict;
is_c3 = nothing,
cstar = toml_dict["pmodel_cstar"],
β_c3 = toml_dict["pmodel_β_c3"],
β_c4 = toml_dict["pmodel_β_c4"],
temperature_dep_yield = true,
ϕ0_c3 = toml_dict["pmodel_ϕ0_c3"],
ϕ0_c4 = toml_dict["pmodel_ϕ0_c4"],
ϕa0_c3 = toml_dict["pmodel_ϕa0_c3"],
ϕa1_c3 = toml_dict["pmodel_ϕa1_c3"],
ϕa2_c3 = toml_dict["pmodel_ϕa2_c3"],
ϕa0_c4 = toml_dict["pmodel_ϕa0_c4"],
ϕa1_c4 = toml_dict["pmodel_ϕa1_c4"],
ϕa2_c4 = toml_dict["pmodel_ϕa2_c4"],
α = toml_dict["pmodel_α"],
) where {FT <: AbstractFloat}
c3_fraction = if isnothing(is_c3)
photosynthesis_parameters = clm_photosynthesis_parameters(domain.space.surface)
(
hasproperty(photosynthesis_parameters, :c3_fraction) ?
photosynthesis_parameters.c3_fraction :
photosynthesis_parameters.is_c3
)
else
is_c3
end
parameters = ClimaLand.Canopy.PModelParameters(
cstar,
β_c3,
β_c4,
temperature_dep_yield,
ϕ0_c3,
ϕ0_c4,
ϕa0_c3,
ϕa1_c3,
ϕa2_c3,
ϕa0_c4,
ϕa1_c4,
ϕa2_c4,
α,
)
return PModel{FT}(c3_fraction, toml_dict, parameters)
end
## Plant hydraulics models
"""
PlantHydraulicsModel{FT}(
domain,
toml_dict::CP.ParamDict;
n_stem::Int = 0,
n_leaf::Int = 1,
h_stem::FT = FT(0),
h_leaf::FT = toml_dict["canopy_height"],
ν::FT = FT(1.44e-4),
S_s::FT = FT(1e-2 * 0.0098), # m3/m3/MPa to m3/m3/m
conductivity_model = Weibull{FT}(
K_sat = FT(7e-8),
ψ63 = FT(-4 / 0.0098),
c = FT(4),
),
retention_model = LinearRetentionCurve{FT}(a = FT(0.2 * 0.0098)),
) where {FT <: AbstractFloat}
Creates a PlantHydraulicsModel on the provided domain, using paramters from `toml_dict`.
The following default parameters are used:
- n_stem = 0 (unitless) - number of stem compartments
- n_leaf = 1 (unitless) - number of leaf compartments
- h_stem = 0 (m) - height of the stem compartment
- h_leaf = 1 (m) - height of the leaf compartment
- ν = 1.44e-4 (m3/m3) - porosity
- S_s = 1e-2 * 0.0098 (m⁻¹) - storativity
- K_sat = 7e-8 (m/s) - saturated hydraulic conductivity
- ψ63 = -4 / 0.0098 (MPa to m) - xylem percentage loss of conductivity curve parameters;
- c = 4 (unitless) - Weibull parameter;
- a = 0.2 * 0.0098 (m) - bulk modulus of elasticity;
Citation:
Holtzman, N., Wang, Y., Wood, J. D., Frankenberg, C., & Konings, A. G. (2023).
Constraining plant hydraulics with microwave radiometry in a land surface model:
Impacts of temporal resolution. Water Resources Research, 59, e2023WR035481.
https://doi.org/10.1029/2023WR035481
"""
function PlantHydraulicsModel{FT}(
domain,
toml_dict::CP.ParamDict;
n_stem::Int = 0,
n_leaf::Int = 1,
h_stem::FT = FT(0),
h_leaf::FT = toml_dict["canopy_height"],
ν::FT = toml_dict["plant_nu"],
S_s::FT = toml_dict["plant_S_s"], # m3/m3/MPa to m3/m3/m
conductivity_model = PlantHydraulics.Weibull(toml_dict),
retention_model = PlantHydraulics.LinearRetentionCurve(toml_dict),
) where {FT <: AbstractFloat}
@assert n_stem >= 0 "Stem number must be non-negative"
@assert n_leaf >= 0 "Leaf number must be non-negative"
@assert h_stem >= 0 "Stem height must be non-negative"
@assert h_leaf >= 0 "Leaf height must be non-negative"
# Construct compartment surfaces and midpoints from heights and number of compartments
zmin = FT(0)
compartment_surfaces =
FT.(
vcat(
[zmin], # surface at ground level
[h_stem * i for i in 1:n_stem], # stem compartments
[h_stem * n_stem + h_leaf * j for j in 1:n_leaf], # leaf compartments
),
)
compartment_midpoints =
FT.(
vcat(
[h_stem * (i - 1) + h_stem / 2 for i in 1:n_stem], # stem compartments
[
h_stem * n_stem + h_leaf * (j - 1) + h_leaf / 2 for
j in 1:n_leaf
], # leaf compartments
),
)
parameters = PlantHydraulics.PlantHydraulicsParameters(;
ν,
S_s,
conductivity_model,
retention_model,
)
return PlantHydraulics.PlantHydraulicsModel{FT}(;
n_stem,
n_leaf,
compartment_midpoints,
compartment_surfaces,
parameters,
)
end
"""
PrescribedBiomassModel{FT}(
domain,
LAI::AbstractTimeVaryingInput,
toml_dict::CP.ParamDict;
SAI::FT = toml_dict["SAI"],
RAI::FT = toml_dict["RAI"],
rooting_depth = clm_rooting_depth(domain.space.surface),
height = toml_dict["canopy_height"]
) where {FT <: AbstractFloat}
Creates a PrescribedBiomassModel on the provided domain, using parameters from `toml_dict`.
The required argument `LAI` should be a ClimaUtilities TimeVaryingInput for leaf area index.
The following default parameters are used:
- SAI = 0 (m2/m2) - stem area index
- RAI = 1 (m2/m2) - root area index
- height = 1m
"""
function PrescribedBiomassModel{FT}(
domain,
LAI::AbstractTimeVaryingInput,
toml_dict::CP.ParamDict;
SAI::FT = toml_dict["SAI"],
RAI::FT = toml_dict["RAI"],
rooting_depth = clm_rooting_depth(domain.space.surface),
height = toml_dict["canopy_height"],
) where {FT <: AbstractFloat}
plant_area_index = PrescribedAreaIndices{FT}(LAI, SAI, RAI)
return PrescribedBiomassModel{
FT,
typeof(plant_area_index),
typeof(rooting_depth),
typeof(height),
}(
plant_area_index,
rooting_depth,
height,
)
end
"""
ZhouOptimalLAIModel{FT}(
domain,
toml_dict::CP.ParamDict;
optimal_lai_inputs = optimal_lai_initial_conditions(domain.space.surface),
SAI::FT = toml_dict["SAI"],
RAI::FT = toml_dict["RAI"],
rooting_depth = clm_rooting_depth(domain.space.surface),
height = toml_dict["canopy_height"],
) where {FT <: AbstractFloat}
Creates a ZhouOptimalLAIModel (optimal LAI based on Zhou et al. 2025) on the provided domain,
using parameters from `toml_dict`.
The optimal LAI model computes LAI dynamically based on optimality principles, balancing
energy and water constraints. LAI is stored in `p.canopy.biomass.area_index.leaf`.
# Arguments
- `domain`: The model domain
- `toml_dict`: Parameter dictionary containing optimal LAI parameters
# Keyword Arguments
- `optimal_lai_inputs`: NamedTuple with spatially varying initial conditions (GSL, A0_annual,
precip_annual, vpd_gs, lai_init, f0). Default loads from `optimal_lai_initial_conditions`.
- `SAI`: Stem area index (m2/m2), default from toml_dict
- `RAI`: Root area index (m2/m2), default from toml_dict
- `rooting_depth`: Rooting depth (m), default from CLM data
- `height`: Canopy height (m), default spatially varying from CLM data
# Example
```julia
biomass = ZhouOptimalLAIModel{FT}(domain, toml_dict)
canopy = CanopyModel{FT}(...; biomass, ...)
```
# References
Zhou et al. (2025) "A General Model for the Seasonal to Decadal Dynamics of Leaf Area"
Global Change Biology. https://onlinelibrary.wiley.com/doi/pdf/10.1111/gcb.70125
"""
function ZhouOptimalLAIModel{FT}(
domain,
toml_dict::CP.ParamDict;
optimal_lai_inputs = optimal_lai_initial_conditions(domain.space.surface),
SAI::FT = toml_dict["SAI"],
RAI::FT = toml_dict["RAI"],
rooting_depth = clm_rooting_depth(domain.space.surface),
height = clm_canopy_height(domain.space.surface),
) where {FT <: AbstractFloat}
parameters = OptimalLAIParameters{FT}(toml_dict)
return ZhouOptimalLAIModel{FT}(
parameters,
optimal_lai_inputs;
SAI,
RAI,
rooting_depth,
height,
)
end
## Radiative transfer models
"""
TwoStreamModel{FT}(
domain,
toml_dict::CP.ParamDict;
radiation_parameters = clm_canopy_radiation_parameters(domain.space.surface),
ϵ_canopy = toml_dict["canopy_emissivity"],
K_lw = toml_dict["canopy_K_lw"],
n_layers::Int = 20,
)
Creates a Two Stream model for canopy radiative transfer on the provided domain.
Spatially-varying parameters are read in from data files in `clm_canopy_radiation_parameters`.`
In particular, this function returns a NamedTuple containing:
- `Ω`: clumping index
- `G_Function`: a G function for leaf angle distribution
- `α_PAR_leaf`, `τ_PAR_leaf`: albedo and transmissivity in the PAR band
- `α_NIR_leaf`, `τ_NIR_leaf`: albedo and transmissivity in the NIR band
Canopy emissivity and wavelength per PAR photon are currently treated
as constants; these can be passed in as Floats by kwarg.
Otherwise the default values from ClimaParams.jl are used.
The number of layers in the canopy is set by `n_layers`, which defaults to 20.
"""
function TwoStreamModel{FT}(
domain,
toml_dict::CP.ParamDict;
radiation_parameters = clm_canopy_radiation_parameters(
domain.space.surface,
),
ϵ_canopy::FT = toml_dict["canopy_emissivity"],
K_lw = toml_dict["canopy_K_lw"],
n_layers::Int = 20,
) where {FT <: AbstractFloat}
parameters = TwoStreamParameters(
toml_dict;
radiation_parameters...,
ϵ_canopy,
K_lw,
n_layers,
)
return TwoStreamModel{FT, typeof(parameters)}(parameters)
end
"""
BeerLambertModel{FT}(
domain,
toml_dict::CP.ParamDict;
radiation_parameters = clm_canopy_radiation_parameters(domain.space.surface),
ϵ_canopy::FT = toml_dict["canopy_emissivity"],
K_lw = toml_dict["canopy_K_lw"]
) where {FT <: AbstractFloat}
Creates a Beer-Lambert model for canopy radiative transfer on the provided domain.
Spatially-varying parameters are read in from data files in `clm_canopy_radiation_parameters`.`
In particular, this function returns a field for
- clumping index `Ω`
- leaf angle distribution `G_Function`
- albedo and transmissitivy in PAR and NIR bands (`α_PAR_leaf`, `τ_PAR_leaf`, `α_NIR_leaf`, `τ_NIR_leaf`)
Canopy emissivity and wavelength per PAR photon are currently treated
as constants; these can be passed in as Floats by kwarg.
Otherwise the default values from ClimaParams.jl are used.
"""
function BeerLambertModel{FT}(
domain,
toml_dict::CP.ParamDict;
radiation_parameters = clm_canopy_radiation_parameters(
domain.space.surface,
),
ϵ_canopy::FT = toml_dict["canopy_emissivity"],
K_lw = toml_dict["canopy_K_lw"],
) where {FT <: AbstractFloat}
# Filter out radiation parameters that are not needed for Beer-Lambert model
radiation_parameters = NamedTuple{
filter(
k -> k in (:α_PAR_leaf, :α_NIR_leaf, :G_Function, :Ω),
keys(radiation_parameters),
),
}(
radiation_parameters,
)
parameters = BeerLambertParameters(
toml_dict;
ϵ_canopy,
K_lw,
radiation_parameters...,
)
return BeerLambertModel{FT, typeof(parameters)}(parameters)
end
## Stomatal conductance models
"""
MedlynConductanceModel{FT}(
domain,
toml_dict::CP.ParamDict;
g0::FT = toml_dict["min_stomatal_conductance"],
g1 = clm_medlyn_g1(domain.space.surface),
) where {FT <: AbstractFloat}
Creates a `MedlynConductanceModel` using default parameters of type `FT`.
The `conductance_parameters` argument is a NamedTuple that contains
- `g1`: a Float or ClimaCore Field representing the slope parameter (PA^{1/2})
By default, this parameter is set by the `clm_medlyn_g1` function,
which reads in CLM data onto the surface space as a ClimaUtilities SpaceVaryingInput.
The following default parameter is used:
- g0 = FT(1e-4) (mol m^-2 s^-1) - minimum stomatal conductance
"""
function MedlynConductanceModel{FT}(
domain,
toml_dict::CP.ParamDict;
g1 = clm_medlyn_g1(domain.space.surface),
g0::FT = toml_dict["min_stomatal_conductance"],
) where {FT <: AbstractFloat}
parameters = MedlynConductanceParameters(toml_dict; g0, g1)
return MedlynConductanceModel{FT, typeof(parameters)}(parameters)
end
"""
PModelConductance{FT}(toml_dict;
Drel = toml_dict["Drel"],
) where {FT <: AbstractFloat}
Creates a PModelConductance using default parameters of type FT.
The following default parameter is used:
- Drel = FT(1.6) (unitless) - relative diffusivity of H2O to CO2 (Bonan Table A.3)
"""
function PModelConductance{FT}(
toml_dict::CP.ParamDict;
Drel = toml_dict["relative_diffusivity_of_water_vapor"],
) where {FT <: AbstractFloat}
cond_params = PModelConductanceParameters(Drel = Drel)
return PModelConductance{FT}(cond_params)
end
########################################################
# End component model convenience constructors
########################################################
"""
CanopyModel{FT, AR, RM, PM, SM, SMSM, PHM, EM, SIFM, B, PS, D} <: ClimaLand.AbstractImExModel{FT}
The model struct for the canopy, which contains
- the canopy model domain (a point for site-level simulations, or
an extended surface (plane/spherical surface) for regional or global simulations.
- subcomponent model type for radiative transfer. This is of type
`AbstractRadiationModel`.
- subcomponent model type for photosynthesis. This is of type
`AbstractPhotosynthesisModel` and supports `FarquharModel`, and `PModel`.
- subcomponent model type for stomatal conductance. This is of type
`AbstractStomatalConductanceModel` and supports `MedlynConductanceModel` and
`PModelConductance`. Note if `PModel` is used for photosynthesis, then you
must also use `PModelConductance` for stomatal conductance, since these two models
are derived from the same set of conditions.
- subcomponent model type for soil moisture stress. This is of type
`AbstractSoilMoistureStressModel`. Currently we support `TuzetMoistureStressModel` (default)
`PiecewiseMoistureStressModel`, and `NoMoistureStressModel` (stress factor = 1).
- subcomponent model type for plant hydraulics. This is of type
`AbstractPlantHydraulicsModel` and currently only a version which
prognostically solves Richards equation in the plant is available.
- subcomponent model type for canopy energy. This is of type
`AbstractCanopyEnergyModel` and currently we support a version where
the canopy temperature is prescribed, and one where it is solved for
prognostically.
- subcomponent model type for canopy SIF.
prognostically.
- canopy model parameters, which include parameters that are shared
between canopy model components or those needed to compute boundary
fluxes.
- The boundary conditions, which contain:
- The atmospheric conditions, which are either prescribed
(of type `PrescribedAtmosphere`) or computed via a coupled simulation
(of type `CoupledAtmosphere`).
- The radiative flux conditions, which are either prescribed
(of type `PrescribedRadiativeFluxes`) or computed via a coupled simulation
(of type `CoupledRadiativeFluxes`).
- The ground conditions, which are either prescribed or prognostic
Note that the canopy height is specified as part of the
PlantHydraulicsModel, along with the area indices of the leaves, roots, and
stems. Eventually, when plant biomass becomes a prognostic variable (by
integrating with a carbon model), some parameters specified here will be
treated differently.
$(DocStringExtensions.FIELDS)
"""
struct CanopyModel{FT, AR, RM, PM, SM, SMSM, PHM, EM, SIFM, BM, B, PSE, D} <:
ClimaLand.AbstractImExModel{FT}
"Autotrophic respiration model, a canopy component model"
autotrophic_respiration::AR
"Radiative transfer model, a canopy component model"
radiative_transfer::RM
"Photosynthesis model, a canopy component model"
photosynthesis::PM
"Stomatal conductance model, a canopy component model"
conductance::SM
"Soil moisture stress parameterization, a canopy component model"
soil_moisture_stress::SMSM
"Plant hydraulics model, a canopy component model"
hydraulics::PHM
"Energy balance model, a canopy component model"
energy::EM
"SIF model, a canopy component model"
sif::SIFM
"Biomass parameterization, a canopy component model"
biomass::BM
"Boundary Conditions"
boundary_conditions::B
"Shared parameters between component models"
earth_param_set::PSE
"Canopy model domain"
domain::D
end
"""
CanopyModel{FT}(;
autotrophic_respiration::AbstractAutotrophicRespirationModel{FT},
radiative_transfer::AbstractRadiationModel{FT},
photosynthesis::AbstractPhotosynthesisModel{FT},
conductance::AbstractStomatalConductanceModel{FT},
soil_moisture_stress::AbstractSoilMoistureStressModel{FT},
hydraulics::AbstractPlantHydraulicsModel{FT},
energy::AbstractCanopyEnergyModel{FT},
sif::AbstractSIFModel{FT},
biomass::AbstractBiomassModel{FT},
boundary_conditions::B,
earth_param_set::PSE,
domain::Union{
ClimaLand.Domains.Point,
ClimaLand.Domains.Plane,
ClimaLand.Domains.SphericalSurface,
},
energy = PrescribedCanopyTempModel{FT}(),
) where {FT, PSE}
An outer constructor for the `CanopyModel`, which makes certain
consistency checks between parameterizations.
Note that we do not currently enforce that the biomass `height` is the same
as the height used in plant hydraulics. We have:
biomass.height:
- Used for: Aerodynamic calculations (displacement height, roughness length), mass of plant
in energy equation
- Type: Can be spatially-varying (Field) or uniform (scalar)
hydraulics height = hydraulics.compartment_surfaces[end] - hydraulics.compartment_surfaces[1]
- Compartment spacing affects vertical structure of plant water
- Type: Currently always a scalar
"""
function CanopyModel{FT}(;
autotrophic_respiration::AbstractAutotrophicRespirationModel{FT},
radiative_transfer::AbstractRadiationModel{FT},
photosynthesis::AbstractPhotosynthesisModel{FT},
conductance::AbstractStomatalConductanceModel{FT},
hydraulics::AbstractPlantHydraulicsModel{FT},
soil_moisture_stress::AbstractSoilMoistureStressModel{FT},
sif::AbstractSIFModel{FT},
energy = PrescribedCanopyTempModel{FT}(),
biomass::AbstractBiomassModel{FT},
boundary_conditions::B,
earth_param_set::PSE,
domain::Union{
ClimaLand.Domains.Point,
ClimaLand.Domains.Plane,
ClimaLand.Domains.SphericalSurface,
},
) where {FT, B, PSE}
if typeof(photosynthesis) <: PModel{FT}
@assert typeof(conductance) <: PModelConductance{FT} "When using PModel for photosynthesis, you must also use PModelConductance for stomatal conductance"
end
if typeof(conductance) <: PModelConductance{FT}
@assert typeof(photosynthesis) <: PModel{FT} "When using PModelConductance for stomatal conductance, you must also use PModel for photosynthesis"
end
args = (
autotrophic_respiration,
radiative_transfer,
photosynthesis,
conductance,
soil_moisture_stress,
hydraulics,
energy,
sif,
biomass,
boundary_conditions,
earth_param_set,
domain,
)
return CanopyModel{FT, typeof.(args)...}(args...)
end
"""
function CanopyModel{FT}(
domain::Union{
ClimaLand.Domains.Point,
ClimaLand.Domains.Plane,
ClimaLand.Domains.SphericalSurface,
},
forcing::NamedTuple,
LAI::AbstractTimeVaryingInput,
toml_dict::CP.ParamDict;
prognostic_land_components = (:canopy,),
autotrophic_respiration = AutotrophicRespirationModel{FT}(toml_dict),
radiative_transfer = TwoStreamModel{FT}(domain, toml_dict),
photosynthesis = FarquharModel{FT}(domain, toml_dict),
conductance = MedlynConductanceModel{FT}(domain, toml_dict),
soil_moisture_stress = TuzetMoistureStressModel{FT}(toml_dict),
hydraulics = PlantHydraulicsModel{FT}(domain, toml_dict),
energy = BigLeafEnergyModel{FT}(toml_dict),
biomass= PrescribedBiomassModel{FT}(domain, LAI, toml_dict),
sif = Lee2015SIFModel{FT}(toml_dict),
turbulent_flux_parameterization = MoninObukhovCanopyFluxes(toml_dict, biomass.height),
) where {FT, PSE}
Creates a `CanopyModel` with the provided `domain`, `forcing`, and `toml_dict`.
Defaults are provided for each canopy component model, which can be overridden
by passing in a different instance of that type of model. Default parameters are also provided
for each canopy component, and can be changed with keyword arguments. Please see the documentation
of each component model for details on the default parameters.
The required argument `forcing` should be a NamedTuple with the following field:
- `atmos`: a `PrescribedAtmosphere` or `CoupledAtmosphere` object
- `radiation`: a `PrescribedRadiativeFluxes` or `CoupledRadiativeFluxes` object
- `ground`: a `PrescribedGroundConditions` or `PrognosticGroundConditions` object
The required argument `LAI` should be a `ClimaUtilities.TimeVaryingInputs.TimeVaryingInput`
for leaf area index.
When running the canopy model in standalone mode, set `prognostic_land_components = (:canopy,)`,
while for running integrated land models, this should be a list of the individual models.
This value of this argument must be the same across all components in the land model.
"""
function CanopyModel{FT}(
domain::Union{
ClimaLand.Domains.Point,
ClimaLand.Domains.Plane,
ClimaLand.Domains.SphericalSurface,
},
forcing::NamedTuple,
LAI::AbstractTimeVaryingInput,
toml_dict::CP.ParamDict;
prognostic_land_components = (:canopy,),
autotrophic_respiration = AutotrophicRespirationModel{FT}(toml_dict),
radiative_transfer = TwoStreamModel{FT}(domain, toml_dict),
photosynthesis = FarquharModel{FT}(domain, toml_dict),
conductance = MedlynConductanceModel{FT}(domain, toml_dict),
soil_moisture_stress = TuzetMoistureStressModel{FT}(toml_dict),
hydraulics = PlantHydraulicsModel{FT}(domain, toml_dict),
energy = BigLeafEnergyModel{FT}(toml_dict),
biomass = PrescribedBiomassModel{FT}(domain, LAI, toml_dict),
turbulent_flux_parameterization = MoninObukhovCanopyFluxes(
toml_dict,
biomass.height,
),
sif = Lee2015SIFModel{FT}(toml_dict),
) where {FT}
(; atmos, radiation, ground) = forcing
# Confirm that each spatially-varying parameter is on the correct domain
for component in [
autotrophic_respiration,
radiative_transfer,
photosynthesis,
conductance,
soil_moisture_stress,
hydraulics,
energy,
biomass,
sif,
]
# For component models without parameters, skip the check
!hasproperty(component, :parameters) && continue
@assert !(component.parameters isa ClimaCore.Fields.Field) ||
axes(component.parameters) == domain.space.surface
end
# Confirm that the LAI passed agrees with the LAI of the biomass model
@assert biomass.plant_area_index.LAI == LAI
boundary_conditions = AtmosDrivenCanopyBC(
atmos,
radiation,
ground,
turbulent_flux_parameterization,
prognostic_land_components,
)
earth_param_set = LP.LandParameters(toml_dict)
args = (
autotrophic_respiration,
radiative_transfer,
photosynthesis,
conductance,
soil_moisture_stress,
hydraulics,
energy,
sif,
biomass,
boundary_conditions,
earth_param_set,
domain,
)
return CanopyModel{FT, typeof.(args)...}(args...)
end
"""
function CanopyModel{FT}(
domain,
forcing::NamedTuple,
toml_dict::CP.ParamDict;
prognostic_land_components = (:canopy,),
biomass = ZhouOptimalLAIModel{FT}(domain, toml_dict),
...
) where {FT}
Creates a `CanopyModel` with the provided `domain`, `forcing`, and `toml_dict`,
using the optimal LAI model (ZhouOptimalLAIModel) by default.
This constructor does not require `LAI` as a positional argument, making it suitable
for use with prognostic LAI models like `ZhouOptimalLAIModel`.
Defaults are provided for each canopy component model, which can be overridden
by passing in a different instance of that type of model.
The required argument `forcing` should be a NamedTuple with the following fields:
- `atmos`: a `PrescribedAtmosphere` or `CoupledAtmosphere` object
- `radiation`: a `PrescribedRadiativeFluxes` or `CoupledRadiativeFluxes` object
- `ground`: a `PrescribedGroundConditions` or `PrognosticGroundConditions` object
When running the canopy model in standalone mode, set `prognostic_land_components = (:canopy,)`,
while for running integrated land models, this should be a list of the individual models.
"""
function CanopyModel{FT}(
domain::Union{
ClimaLand.Domains.Point,
ClimaLand.Domains.Plane,
ClimaLand.Domains.SphericalSurface,
},
forcing::NamedTuple,
toml_dict::CP.ParamDict;
prognostic_land_components = (:canopy,),
autotrophic_respiration = AutotrophicRespirationModel{FT}(toml_dict),
radiative_transfer = TwoStreamModel{FT}(domain, toml_dict),
photosynthesis = PModel{FT}(domain, toml_dict),
conductance = MedlynConductanceModel{FT}(domain, toml_dict),
soil_moisture_stress = TuzetMoistureStressModel{FT}(toml_dict),
hydraulics = PlantHydraulicsModel{FT}(domain, toml_dict),
energy = BigLeafEnergyModel{FT}(toml_dict),
biomass = ZhouOptimalLAIModel{FT}(domain, toml_dict),
turbulent_flux_parameterization = MoninObukhovCanopyFluxes(
toml_dict,
biomass.height,
),
sif = Lee2015SIFModel{FT}(toml_dict),
) where {FT}
(; atmos, radiation, ground) = forcing
# Confirm that each spatially-varying parameter is on the correct domain
for component in [
autotrophic_respiration,
radiative_transfer,
photosynthesis,
conductance,
soil_moisture_stress,
hydraulics,
energy,
biomass,
sif,
]
# For component models without parameters, skip the check
!hasproperty(component, :parameters) && continue
@assert !(component.parameters isa ClimaCore.Fields.Field) ||
axes(component.parameters) == domain.space.surface
end
boundary_conditions = AtmosDrivenCanopyBC(
atmos,
radiation,
ground,
turbulent_flux_parameterization,
prognostic_land_components,
)
earth_param_set = LP.LandParameters(toml_dict)
args = (
autotrophic_respiration,
radiative_transfer,
photosynthesis,
conductance,
soil_moisture_stress,
hydraulics,