### 2.5.3.2. Numerical Implementation[¶](#numerical-implementation "Permalink to this headline")

Canopy energy conservation gives

(2.5.137)[¶](#equation-5-128 "Permalink to this equation")\\\[-\\overrightarrow{S}\_{v} +\\overrightarrow{L}\_{v} \\left(T\_{v} \\right)+H\_{v} \\left(T\_{v} \\right)+\\lambda E\_{v} \\left(T\_{v} \\right)=0\\\]

where \\(\\overrightarrow{S}\_{v}\\) is the solar radiation absorbed by the vegetation (section [2.4.1](https://escomp.github.io/ctsm-docs/versions/master/html/tech_note/Radiative_Fluxes/CLM50_Tech_Note_Radiative_Fluxes.html#solar-fluxes)), \\(\\overrightarrow{L}\_{v}\\) is the net longwave radiation absorbed by vegetation (section [2.4.2](https://escomp.github.io/ctsm-docs/versions/master/html/tech_note/Radiative_Fluxes/CLM50_Tech_Note_Radiative_Fluxes.html#longwave-fluxes)), and \\(H\_{v}\\) and \\(\\lambda E\_{v}\\) are the sensible and latent heat fluxes from vegetation, respectively. The term \\(\\lambda\\) is taken to be the latent heat of vaporization \\(\\lambda \_{vap}\\) ([Table 2.2.7](https://escomp.github.io/ctsm-docs/versions/master/html/tech_note/Ecosystem/CLM50_Tech_Note_Ecosystem.html#table-physical-constants)).

\\(\\overrightarrow{L}\_{v}\\), \\(H\_{v}\\), and \\(\\lambda E\_{v}\\) depend on the vegetation temperature \\(T\_{v}\\). The Newton-Raphson method for finding roots of non-linear systems of equations can be applied to iteratively solve for \\(T\_{v}\\) as

(2.5.138)[¶](#equation-5-129 "Permalink to this equation")\\\[\\Delta T\_{v} =\\frac{\\overrightarrow{S}\_{v} -\\overrightarrow{L}\_{v} -H\_{v} -\\lambda E\_{v} }{\\frac{\\partial \\overrightarrow{L}\_{v} }{\\partial T\_{v} } +\\frac{\\partial H\_{v} }{\\partial T\_{v} } +\\frac{\\partial \\lambda E\_{v} }{\\partial T\_{v} } }\\\]

where \\(\\Delta T\_{v} =T\_{v}^{n+1} -T\_{v}^{n}\\) and the subscript “n” indicates the iteration.

The partial derivatives are

(2.5.139)[¶](#equation-5-130 "Permalink to this equation")\\\[\\frac{\\partial \\overrightarrow{L}\_{v} }{\\partial T\_{v} } =4\\varepsilon \_{v} \\sigma \\left\[2-\\varepsilon \_{v} \\left(1-\\varepsilon \_{g} \\right)\\right\]T\_{v}^{3}\\\]

(2.5.140)[¶](#equation-5-131 "Permalink to this equation")\\\[\\frac{\\partial H\_{v} }{\\partial T\_{v} } =\\rho \_{atm} C\_{p} \\left(c\_{a}^{h} +c\_{g}^{h} \\right)\\frac{c\_{v}^{h} }{c\_{a}^{h} +c\_{v}^{h} +c\_{g}^{h} }\\\]

(2.5.141)[¶](#equation-5-132 "Permalink to this equation")\\\[\\frac{\\partial \\lambda E\_{v} }{\\partial T\_{v} } =\\lambda \\rho \_{atm} \\left(c\_{a}^{w} +c\_{g}^{w} \\right)\\frac{c\_{v}^{w} }{c\_{a}^{w} +c\_{v}^{w} +c\_{g}^{w} } \\frac{dq\_{sat}^{T\_{v} } }{dT\_{v} } .\\\]

The partial derivatives \\(\\frac{\\partial r\_{ah} }{\\partial T\_{v} }\\) and \\(\\frac{\\partial r\_{aw} }{\\partial T\_{v} }\\), which cannot be determined analytically, are ignored for \\(\\frac{\\partial H\_{v} }{\\partial T\_{v} }\\) and \\(\\frac{\\partial \\lambda E\_{v} }{\\partial T\_{v} }\\). However, if \\(\\zeta\\) changes sign more than four times during the temperature iteration, \\(\\zeta =-0.01\\). This helps prevent “flip-flopping” between stable and unstable conditions. The total water vapor flux \\(E\_{v}\\), transpiration flux \\(E\_{v}^{t}\\), and sensible heat flux \\(H\_{v}\\) are updated for changes in leaf temperature as

(2.5.142)[¶](#equation-5-133 "Permalink to this equation")\\\[E\_{v} =-\\rho \_{atm} \\left\[c\_{a}^{w} q\_{atm} +c\_{g}^{w} q\_{g} -\\left(c\_{a}^{w} +c\_{g}^{w} \\right)\\left(q\_{sat}^{T\_{v} } +\\frac{dq\_{sat}^{T\_{v} } }{dT\_{v} } \\Delta T\_{v} \\right)\\right\]\\frac{c\_{v}^{w} }{c\_{a}^{w} +c\_{v}^{w} +c\_{g}^{w} }\\\]

(2.5.143)[¶](#equation-5-134 "Permalink to this equation")\\\[E\_{v}^{t} =-r\_{dry} ^{{'} {'} } \\rho \_{atm} \\left\[c\_{a}^{w} q\_{atm} +c\_{g}^{w} q\_{g} -\\left(c\_{a}^{w} +c\_{g}^{w} \\right)\\left(q\_{sat}^{T\_{v} } +\\frac{dq\_{sat}^{T\_{v} } }{dT\_{v} } \\Delta T\_{v} \\right)\\right\]\\frac{c\_{v}^{h} }{c\_{a}^{w} +c\_{v}^{w} +c\_{g}^{w} }\\\]

(2.5.144)[¶](#equation-5-135 "Permalink to this equation")\\\[H\_{v} =-\\rho \_{atm} C\_{p} \\left\[c\_{a}^{h} \\theta \_{atm} +c\_{g}^{h} T\_{g} -\\left(c\_{a}^{h} +c\_{g}^{h} \\right)\\left(T\_{v} +\\Delta T\_{v} \\right)\\right\]\\frac{c\_{v}^{h} }{c\_{a}^{h} +c\_{v}^{h} +c\_{g}^{h} } .\\\]

The numerical solution for vegetation temperature and the fluxes of momentum, sensible heat, and water vapor flux from vegetated surfaces proceeds as follows:

1.  Initial values for canopy air temperature and specific humidity are obtained from
    
    (2.5.145)[¶](#equation-5-136 "Permalink to this equation")\\\[T\_{s} =\\frac{T\_{g} +\\theta \_{atm} }{2}\\\]
    
    (2.5.146)[¶](#equation-5-137 "Permalink to this equation")\\\[q\_{s} =\\frac{q\_{g} +q\_{atm} }{2} .\\\]
    
2.  An initial guess for the wind speed \\(V\_{a}\\) is obtained from [(2.5.24)](#equation-5-24) assuming an initial convective velocity \\(U\_{c} =0\\) m s\-1 for stable conditions (\\(\\theta \_{v,\\, atm} -\\theta \_{v,\\, s} \\ge 0\\) as evaluated from [(2.5.50)](#equation-5-50) ) and \\(U\_{c} =0.5\\) for unstable conditions (\\(\\theta \_{v,\\, atm} -\\theta \_{v,\\, s} <0\\)).
    
3.  An initial guess for the Monin-Obukhov length \\(L\\) is obtained from the bulk Richardson number using equations [(2.5.46)](#equation-5-46) and [(2.5.48)](#equation-5-48).
    
4.  Iteration proceeds on the following system of equations:
    
5.  Friction velocity \\(u\_{\*}\\) ([(2.5.32)](#equation-5-32), [(2.5.33)](#equation-5-33), [(2.5.34)](#equation-5-34), [(2.5.35)](#equation-5-35))
    
6.  Ratio \\(\\frac{\\theta \_{\*} }{\\theta \_{atm} -\\theta \_{s} }\\) ([(2.5.37)](#equation-5-37), [(2.5.38)](#equation-5-38), [(2.5.39)](#equation-5-39), [(2.5.40)](#equation-5-40))
    
7.  Ratio \\(\\frac{q\_{\*} }{q\_{atm} -q\_{s} }\\) ([(2.5.41)](#equation-5-41), [(2.5.42)](#equation-5-42), [(2.5.43)](#equation-5-43), [(2.5.44)](#equation-5-44))
    
8.  Aerodynamic resistances \\(r\_{am}\\), \\(r\_{ah}\\), and \\(r\_{aw}\\) ([(2.5.55)](#equation-5-55), [(2.5.56)](#equation-5-56), [(2.5.57)](#equation-5-57))
    
9.  Magnitude of the wind velocity incident on the leaves \\(U\_{av}\\) ([(2.5.120)](#equation-5-117) )
    
10.  Leaf boundary layer resistance \\(r\_{b}\\) ([(2.5.145)](#equation-5-136) )
    
11.  Aerodynamic resistances \\(r\_{ah} ^{{'} }\\) and \\(r\_{aw} ^{{'} }\\) )
    
12.  Sunlit and shaded stomatal resistances \\(r\_{s}^{sun}\\) and \\(r\_{s}^{sha}\\) (Chapter [2.9](https://escomp.github.io/ctsm-docs/versions/master/html/tech_note/Photosynthesis/CLM50_Tech_Note_Photosynthesis.html#rst-stomatal-resistance-and-photosynthesis))
    
13.  Sensible heat conductances \\(c\_{a}^{h}\\), \\(c\_{g}^{h}\\), and \\(c\_{v}^{h}\\) ([(2.5.97)](#equation-5-94), [(2.5.98)](#equation-5-95), [(2.5.99)](#equation-5-96))
    
14.  Latent heat conductances \\(c\_{a}^{w}\\), \\(c\_{v}^{w}\\), and \\(c\_{g}^{w}\\) ([(2.5.111)](#equation-5-108), [(2.5.112)](#equation-5-109), [(2.5.113)](#equation-5-110))
    
15.  Sensible heat flux from vegetation \\(H\_{v}\\) ([(2.5.100)](#equation-5-97) )
    
16.  Latent heat flux from vegetation \\(\\lambda E\_{v}\\) ([(2.5.104)](#equation-5-101) )
    
17.  If the latent heat flux has changed sign from the latent heat flux computed at the previous iteration (\\(\\lambda E\_{v} ^{n+1} \\times \\lambda E\_{v} ^{n} <0\\)), the latent heat flux is constrained to be 10% of the computed value. The difference between the constrained and computed value (\\(\\Delta \_{1} =0.1\\lambda E\_{v} ^{n+1} -\\lambda E\_{v} ^{n+1}\\) ) is added to the sensible heat flux later.
    
18.  Change in vegetation temperature \\(\\Delta T\_{v}\\) ([(2.5.138)](#equation-5-129) ) and update the vegetation temperature as \\(T\_{v}^{n+1} =T\_{v}^{n} +\\Delta T\_{v}\\). \\(T\_{v}\\) is constrained to change by no more than 1°K in one iteration. If this limit is exceeded, the energy error is
    
    (2.5.147)[¶](#equation-5-138 "Permalink to this equation")\\\[\\Delta \_{2} =\\overrightarrow{S}\_{v} -\\overrightarrow{L}\_{v} -\\frac{\\partial \\overrightarrow{L}\_{v} }{\\partial T\_{v} } \\Delta T\_{v} -H\_{v} -\\frac{\\partial H\_{v} }{\\partial T\_{v} } \\Delta T\_{v} -\\lambda E\_{v} -\\frac{\\partial \\lambda E\_{v} }{\\partial T\_{v} } \\Delta T\_{v}\\\]
    

where \\(\\Delta T\_{v} =1{\\rm \\; or\\; }-1\\). The error \\(\\Delta \_{2}\\) is added to the sensible heat flux later.

1.  Water vapor flux \\(E\_{v}\\) ([(2.5.142)](#equation-5-133) )
    
2.  Transpiration \\(E\_{v}^{t}\\) ([(2.5.143)](#equation-5-134) if \\(\\beta\_{t} >0\\), otherwise \\(E\_{v}^{t} =0\\))
    
3.  The water vapor flux \\(E\_{v}\\) is constrained to be less than or equal to the sum of transpiration \\(E\_{v}^{t}\\) and the water available from wetted leaves and stems \\({W\_{can} \\mathord{\\left/ {\\vphantom {W\_{can} \\Delta t}} \\right.} \\Delta t}\\). The energy error due to this constraint is
    
    (2.5.148)[¶](#equation-5-139 "Permalink to this equation")\\\[\\Delta \_{3} =\\max \\left(0,\\, E\_{v} -E\_{v}^{t} -\\frac{W\_{can} }{\\Delta t} \\right).\\\]
    

The error \\(\\lambda \\Delta \_{3}\\) is added to the sensible heat flux later.

1.  Sensible heat flux \\(H\_{v}\\) ([(2.5.144)](#equation-5-135) ). The three energy error terms, \\(\\Delta \_{1}\\), \\(\\Delta \_{2}\\), and \\(\\lambda \\Delta \_{3}\\) are also added to the sensible heat flux.
    
2.  The saturated vapor pressure \\(e\_{i}\\) (Chapter [2.9](https://escomp.github.io/ctsm-docs/versions/master/html/tech_note/Photosynthesis/CLM50_Tech_Note_Photosynthesis.html#rst-stomatal-resistance-and-photosynthesis)), saturated specific humidity \\(q\_{sat}^{T\_{v} }\\) and its derivative \\(\\frac{dq\_{sat}^{T\_{v} } }{dT\_{v} }\\) at the leaf surface (section [2.5.5](#saturation-vapor-pressure)), are re-evaluated based on the new \\(T\_{v}\\).
    
3.  Canopy air temperature \\(T\_{s}\\) ([(2.5.96)](#equation-5-93) )
    
4.  Canopy air specific humidity \\(q\_{s}\\) ([(2.5.110)](#equation-5-107) )
    
5.  Temperature difference \\(\\theta \_{atm} -\\theta \_{s}\\)
    
6.  Specific humidity difference \\(q\_{atm} -q\_{s}\\)
    
7.  Potential temperature scale \\(\\theta \_{\*} =\\frac{\\theta \_{\*} }{\\theta \_{atm} -\\theta \_{s} } \\left(\\theta \_{atm} -\\theta \_{s} \\right)\\) where \\(\\frac{\\theta \_{\*} }{\\theta \_{atm} -\\theta \_{s} }\\) was calculated earlier in the iteration #. Humidity scale \\(q\_{\*} =\\frac{q\_{\*} }{q\_{atm} -q\_{s} } \\left(q\_{atm} -q\_{s} \\right)\\) where \\(\\frac{q\_{\*} }{q\_{atm} -q\_{s} }\\) was calculated earlier in the iteration #. Virtual potential temperature scale \\(\\theta \_{v\*}\\) ([(2.5.17)](#equation-5-17) )
    
8.  Wind speed including the convective velocity, \\(V\_{a}\\) ([(2.5.24)](#equation-5-24) )
    
9.  Monin-Obukhov length \\(L\\) ([(2.5.49)](#equation-5-49) )
    
10.  The iteration is stopped after two or more steps if \\(\\tilde{\\Delta }T\_{v} <0.01\\) and \\(\\left|\\lambda E\_{v}^{n+1} -\\lambda E\_{v}^{n} \\right|<0.1\\) where \\(\\tilde{\\Delta }T\_{v} =\\max \\left(\\left|T\_{v}^{n+1} -T\_{v}^{n} \\right|,\\, \\left|T\_{v}^{n} -T\_{v}^{n-1} \\right|\\right)\\), or after forty iterations have been carried out.
    
11.  Momentum fluxes \\(\\tau \_{x}\\), \\(\\tau \_{y}\\) ([(2.5.5)](#equation-5-5), [(2.5.6)](#equation-5-6))
    
12.  Sensible heat flux from ground \\(H\_{g}\\) ([(2.5.92)](#equation-5-89) )
    
13.  Water vapor flux from ground \\(E\_{g}\\) ([(2.5.105)](#equation-5-102) )
    
14.  2-m height air temperature \\(T\_{2m}\\), specific humidity \\(q\_{2m}\\), relative humidity \\(RH\_{2m}\\) ([(2.5.58)](#equation-5-58), [(2.5.59)](#equation-5-59), [(2.5.60)](#equation-5-60))
    

