-
Notifications
You must be signed in to change notification settings - Fork 8
/
canopy_boundary_fluxes.jl
205 lines (183 loc) · 6.03 KB
/
canopy_boundary_fluxes.jl
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
import ClimaLand:
surface_temperature,
surface_specific_humidity,
surface_evaporative_scaling,
surface_height,
surface_resistance,
displacement_height
"""
ClimaLand.displacment_height(model::CanopyModel, Y, p)
A helper function which returns the displacement height for the canopy
model.
See Cowan 1968; Brutsaert 1982, pp. 113–116; Campbell and Norman 1998, p. 71; Shuttleworth 2012, p. 343; Monteith and Unsworth 2013, p. 304.
"""
function ClimaLand.displacement_height(model::CanopyModel{FT}, Y, p) where {FT}
return FT(0.67) * model.hydraulics.compartment_surfaces[end]
end
"""
ClimaLand.surface_resistance(
model::CanopyModel{FT},
Y,
p,
t,
) where {FT}
Returns the surface resistance field of the
`CanopyModel` canopy.
"""
function ClimaLand.surface_resistance(
model::CanopyModel{FT},
Y,
p,
t,
) where {FT}
earth_param_set = model.parameters.earth_param_set
R = FT(LP.gas_constant(earth_param_set))
ρ_liq = FT(LP.ρ_cloud_liq(earth_param_set))
P_air = p.drivers.P
T_air = p.drivers.T
leaf_conductance = p.canopy.conductance.gs
canopy_conductance =
upscale_leaf_conductance.(
leaf_conductance,
p.canopy.hydraulics.area_index.leaf,
T_air,
R,
P_air,
)
return 1 ./ canopy_conductance # [s/m]
end
"""
ClimaLand.surface_temperature(model::CanopyModel, Y, p, t)
A helper function which returns the temperature for the canopy
model.
"""
function ClimaLand.surface_temperature(model::CanopyModel, Y, p, t)
return canopy_temperature(model.energy, model, Y, p, t)
end
"""
ClimaLand.surface_height(model::CanopyModel, Y, _...)
A helper function which returns the surface height for the canopy
model, which is stored in the parameter struct.
"""
function ClimaLand.surface_height(model::CanopyModel, _...)
return model.hydraulics.compartment_surfaces[1]
end
"""
ClimaLand.surface_specific_humidity(model::CanopyModel, Y, p)
A helper function which returns the surface specific humidity for the canopy
model, which is stored in the aux state.
"""
function ClimaLand.surface_specific_humidity(
model::CanopyModel,
Y,
p,
T_canopy,
ρ_canopy,
)
thermo_params =
LP.thermodynamic_parameters(model.parameters.earth_param_set)
return Thermodynamics.q_vap_saturation_generic.(
Ref(thermo_params),
T_canopy,
ρ_canopy,
Ref(Thermodynamics.Liquid()),
)
end
function make_update_boundary_fluxes(canopy::CanopyModel)
function update_boundary_fluxes!(p, Y, t)
canopy_boundary_fluxes!(p, canopy, canopy.radiation, canopy.atmos, Y, t)
end
return update_boundary_fluxes!
end
"""
canopy_boundary_fluxes!(p::NamedTuple,
canopy::CanopyModel{
FT,
<:AutotrophicRespirationModel,
<:Union{BeerLambertModel, TwoStreamModel},
<:Union{FarquharModel,OptimalityFarquharModel},
<:MedlynConductanceModel,
<:PlantHydraulicsModel,
<:Union{PrescribedCanopyTempModel,BigLeafEnergyModel}
},
radiation::PrescribedRadiativeFluxes,
atmos::PrescribedAtmosphere,
Y::ClimaCore.Fields.FieldVector,
t,
) where {FT}
Computes the boundary fluxes for the canopy prognostic
equations; updates the specific fields in the auxiliary
state `p` which hold these variables. This function is called
within the explicit tendency of the canopy model.
- `p.canopy.energy.shf`: Canopy SHF
- `p.canopy.energy.lhf`: Canopy LHF
- `p.canopy.hydraulics.fa[end]`: Transpiration
- `p.canopy.conductance.transpiration`: Transpiration (stored twice; to be addressed in a future PR)
- `p.canopy.hydraulics.fa_roots`: Root water flux
- `p.canopy.radiative_transfer.LW_n`: net long wave radiation
- `p.canopy.radiative_transfer.SW_n`: net short wave radiation
"""
function canopy_boundary_fluxes!(
p::NamedTuple,
canopy::CanopyModel{
FT,
<:AutotrophicRespirationModel,
<:Union{BeerLambertModel, TwoStreamModel},
<:Union{FarquharModel, OptimalityFarquharModel},
<:MedlynConductanceModel,
<:PlantHydraulicsModel,
<:Union{PrescribedCanopyTempModel, BigLeafEnergyModel},
},
radiation::PrescribedRadiativeFluxes,
atmos::PrescribedAtmosphere,
Y::ClimaCore.Fields.FieldVector,
t,
) where {FT}
root_water_flux = p.canopy.hydraulics.fa_roots
root_energy_flux = p.canopy.energy.fa_energy_roots
fa = p.canopy.hydraulics.fa
transpiration = p.canopy.conductance.transpiration
shf = p.canopy.energy.shf
lhf = p.canopy.energy.lhf
r_ae = p.canopy.energy.r_ae
i_end = canopy.hydraulics.n_stem + canopy.hydraulics.n_leaf
# Compute transpiration, SHF, LHF
canopy_turbulent_fluxes = turbulent_fluxes(atmos, canopy, Y, p, t)
transpiration .= canopy_turbulent_fluxes.vapor_flux
shf .= canopy_turbulent_fluxes.shf
lhf .= canopy_turbulent_fluxes.lhf
r_ae .= canopy_turbulent_fluxes.r_ae
# Transpiration is per unit ground area, not leaf area (mult by LAI)
fa.:($i_end) .= PlantHydraulics.transpiration_per_ground_area(
canopy.hydraulics.transpiration,
Y,
p,
t,
)
# Update the root flux of water per unit ground area in place
root_water_flux_per_ground_area!(
root_water_flux,
canopy.soil_driver,
canopy.hydraulics,
Y,
p,
t,
)
root_energy_flux_per_ground_area!(
root_energy_flux,
canopy.soil_driver,
canopy.energy,
Y,
p,
t,
)
canopy_radiant_energy_fluxes!(
p,
canopy.soil_driver,
canopy,
canopy.radiation,
canopy.parameters.earth_param_set,
Y,
t,
)
end