\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{natbib}
\usepackage{authblk}
\usepackage{hyperref}

%\VignetteIndexEntry{Hydrological processes and plant drought stress}
%\VignettePackage{medfate}

\title{Hydrological processes and plant drought stress}
\author[1,2]{Miquel De Cáceres}
\affil[1]{Centre Tecnològic Forestal de Catalunya. Ctra. St. Llorenç de Morunys km 2, 25280, Solsona, Catalonia, Spain}
\affil[2]{CREAF, Cerdanyola del Vallès, 08193, Spain}

\begin{document}
\SweaveOpts{concordance=TRUE}

\maketitle
\tableofcontents

<<echo=FALSE>>=
options(width=67)
library(medfate)
@
\section{Introduction}
\subsection{Processes and model functions}
Hydrological processes and drought stress are fundamental for the simulation models included in the \texttt{medfate} package. Hydrological processes can be divided into local and landscape processes. By local water processes we refer to the soil water balance of forest stands. Processes affecting soil water content include rainfall, canopy interception, infiltration and runoff, percolation and deep drainage, soil evaporation and plant transpiration. In \texttt{medfate}, the soil water balance of a forest is primarily used to predict drought stress for living plants in it. Soil water balance can be studied for a single forest stand using function \texttt{swb()} or for multiple stands distributed spatially using function \texttt{swbpoints()} or \texttt{swbgrid()}. When input data is in form of forest continuously described over a landscape, the \texttt{medfate} package allows studying local soil water balance in combination with water discharge from one cell to the other (a landscape hydrological process). This is done using function \texttt{swbgrid()}.

\subsection{Potential applications}
Functions \texttt{swb()} and \texttt{swbpoints()} may be used to:
\begin{itemize}
\item{Monitor temporal variation in soil water content in particular stands (for example to estimate mushroom yield).}
\item{Monitor temporal variation of plant drought stress in particular stands.}
\item{Monitor temporal variation of fuel moisture in particular stands.}
\end{itemize}
Function \texttt{swbgrid()} may be used to:
\begin{itemize}
\item{Determine areas where particular plant species have high vulnerability to suffer from drought stress.}
\item{Partition the total rainfall in given area among: (1) water evaporated from canopy interception or bare soil evaporation; (2) water transpired by plants; (3) water exported via runoff or deep drainage into the water table and river streams.}
\end{itemize}

\section{Model overview}
\subsection{Design principles}
When only local hydrological processes are considered soil water balance is calculated on a daily step basis for the input forest stand and for the period corresponding to input weather data. Soil water balance follows the design principles of SIERRA (Mouillot et al., 2001; Ruffault et al., 2014, 2013) and BILJOU (Granier et al., 2007, 1999), although some features are taken from other models. The model only has one spatial dimension (vertical) and divides the stand into plant cohorts of different species, height and contribution of leaf area index(LAI) of the stand. If potential evapotranspiration is given as input, the model determines maximum transpiration implements Granier et al. (1999) empirical relationship between the LAI of the stand and the ratio Tmax/PET (maximum transpiration over potential evapotranspiration). Alternatively, the model can calculate Penman-Monteith combined evapotranspiration equation taking into account the canopy (stomatal) resistance as well as aerodynamic resistance. Actual plant transpiration of each plant cohort depends on the radiation energy absorbed by it and on transpirational regulation. Two regulation models are implemented. In the first one transpiration depends on the current soil moisture levels. The second transpiration model uses Sperry \& Love (2015) supply-loss hydraulic theory to determine stomatal regulation and actual transpiration. 

When lateral water transport is also considered the total water input of the stand depends on precipitation but also on the water balance of cells of its upper microwatershed, as done in SIERRA (Mouillot et al., 2001). 
\subsection{Soil description}
The soil of the stand is described using three layers (topsoil: 0 – 30 cm; subsoil: from 30 cm to soil depth ($Z_{soil}$); rocky layer: from soil depth to a maximum depth $Z_{rocksoil}$). Soil texture (i.e. percent of sand, silt and clay), bulk density and rock fragment content can differ between soil layers. Specifying a rocky layer is important because Mediterranean plants may extend their roots into cracks existing in the parent rock (Ruffault et al., 2013). The soil depth attribute ($Z_{soil}$) refers to the sum of topsoil and subsoil layers (thus, subsoil may not exist in very shallow soils). 

Relative soil moisture content is tracked at each layer $s$ using the pair of coupled state variables:
\begin{itemize}
\item{$\Psi_s$, the soil water potential (in kPa).}
\item{$W = \theta(\Psi_s)/ \theta_{fc,s}$, the proportion of volumetric soil moisture in relation to field capacity $\theta_{fc,s}$}
\end{itemize}
Following Reynolds et al. (2000), volumetric soil moisture $\theta(\Psi_s)$ corresponding to a given water potential $\Psi_s$ is calculated using the pedotransfer functions of Saxton et al. (1986):
\begin{equation}
\theta(\Psi_s) = (-\Psi_s/A_s)^{(1/B_s)}
\end{equation}
where
$A_s = 100 \cdot e^{(- 4.396 - 0.0715 \cdot P_{clay,s} - 0.0004880\cdot P_{sand,s}^2 - 0.00004285 \cdot P_{sand,s}^2 \cdot P_{clay,s})}$
and $B = - 3.140 - 0.00222 \cdot P_{clay,s}^2 - 0.00003484 \cdot P_{sand,s}^2 \cdot P_{clay,s}$. Here $P_{clay,s}$ and $P_{sand,s}$ are the percentage of clay and sand, respectively. Soil water holding capacity (in mm) in soil layer $s$ is defined as the volumetric water content at field capacity:
\begin{equation}
V_s = d_s\cdot ((100-P_{rocks,s})/100)\cdot\theta_{fc,s}
\end{equation}
where $d_s$ is the depth of the soil layer (in mm) and $P_{rocks,s}$ is the percentage of rock fragments. The following code shows the properties of a soil initialized using default values for texture, bulk density, rock fragment content and soil depth:

<<echo=FALSE>>=
s = soil(defaultSoilParams())
print(s)
@

\subsection{Vegetation description}

Vegetation is described using a set of plant cohorts. Each plant cohort $i$ is defined by the following characteristics:
\begin{itemize}
\item{$SP_i$: Species identity.}
\item{$H_i$: Height (in cm).}
\item{$CR_i$: Crown ratio (i.e. the ratio between crown length and total height).}
\item{$v_{i,s}$: The proportion of fine roots in each soil layer $s$.}
\item{$LAI_i$: (Maximum) leaf area index (one-side leaf area of plants in the cohort per surface area of the stand).}
\end{itemize}
All vegetation characteristics except are assumed to stay constant during water balance simulations. Only LAI values are adjusted for phenology (see below). Functions \texttt{swbInput} and \texttt{forest2swbInput} are used to build input for the soil water balance model.

\subsection{Meteorological input}
Weather input data must include variables calculated at the \textbf{daily} scale. The variables required depend on the potential evapotranspiration (PET) mode. The following input variables are required when PET is directly given: 
\begin{itemize}
\item{\texttt{DOY}: Day of the year.}
\item{\texttt{Precipitation}: Precipitation (in $L/m^2 = mm$ of water).}
\item{\texttt{MeanTemperature}: Mean temperature (in $^{\circ} \mathrm{C}$).}
\item{\texttt{PET}: Potential evapotranspiration (in $L/m^2 = mm$ of water).}
\end{itemize}
The following input variables are required if PET has to be calculated internally: 
\begin{itemize}
\item{\texttt{DOY}: Day of the year.}
\item{\texttt{Precipitation}: Precipitation (in $L/m^2 = mm$ of water).}
\item{\texttt{MeanTemperature}: Mean temperature (in $^{\circ} \mathrm{C}$).}
\item{\texttt{MinTemperature}: Minimum temperature (in $^{\circ} \mathrm{C}$).}
\item{\texttt{MaxTemperature}: Maximum temperature (in $^{\circ} \mathrm{C}$).}
\item{\texttt{MinRelativeHumidity}: Minimum relative humidity (in percent).}
\item{\texttt{MaxRelativeHumidity}: Maximum relative humidity (in percent).}
\item{\texttt{Radiation}: Solar radiation after accounting for clouds (in $MJ/m^2$).}
\item{\texttt{WindSpeed}: Wind speed (in $m/s$).}
\end{itemize}

\subsection{Process scheduling}
Every day water balance is calculated as follows. The model first updates leaf area values according to the phenology of species and calculates light extinction. After that, the model updates soil water content of soil layers in two steps: (1) it increases soil moisture due to precipitation, $P$, after accounting for canopy interception loss, $I$, surface runoff, $R$, and deep drainage, $D$; (2) it decreases water content due to bare soil evaporation, $E$, and plant transpiration, $T$. Daily variations in soil water content can be summarized as: 
  \begin{equation}
  \Delta{SWC} = P - I - R - D - E - T
  \end{equation}

When landscape hydrological processes are not considered, daily water balance simulations can be done for cells independently (i.e., the whole simulation period can be done one cell before going to the next one). When lateral water transport is also considered, however, water balance of a given day is conducted for all cells before starting the next day. Moreover, a discharge parameter table is prepared at the beginning of the simulation, cells are processed in an order determined by elevation (i.e. cells at higher elevation are processed before cells at lower elevation) and the water balance of a given target cell is influenced by surface runon, $O$, coming from those neighboring cells that are at higher elevation. Daily variations in soil water content is then summarized as: 
  \begin{equation}
  \Delta{SWC} = P + O - I - R - D - E - T
  \end{equation}

After updating soil layers, the model determines drought stress index for each plant cohort, according to whole-plant relative water conductance.

\section{Details of processes}
\subsection{Leaf phenology}
Given a base temperature ($T_{base}$), the growth degree days are zero for all those days where mean temperature $T_{mean}$ is below $T_{base}$ and start increasing when temperatures become warmer than this threshold. In other words, the function accumulates $\max(0.0, T_{mean} - T_{base})$ for all days previous to the current one. At the end of a year the cummulative value is set again to zero.
Plant species can have either evergreen or winter deciduous phenology. Evergreen plants maintain constant leaf area over the year, whereas in deciduous plants leaf-phenological status is updated daily, represented by $\phi_i$, the fraction of maximum leaf area. Leaf area index (LAI) values of deciduous plants are adjusted for leaf phenology following (Prentice et al., 1993; Sitch et al., 2003):
\begin{equation}
LAI_{i}^{\phi}=LAI_i\,\cdot\phi_i
\end{equation}
Budburst occurs when daily temperature exceeds 5ºC and $\phi_i$ increases linearly from 0 to 1 as function of the degree days above 5ºC, until a species-specific value $S_{GDD}$ is reached. In autumn, $\phi_i$ drops to 0 when average daily temperature falls again below 5ºC (Sitch et al., 2003). 

The leaf area index of the whole stand, $LAI_c^{\phi}$ is:
\begin{equation}
LAI_{stand} = \sum_{i}{LAI_{i}^{\phi}}
\end{equation}

\subsection{Light extinction}
The proportion of photosynthetic active radiation (PAR) available after removing the light intercepted by a single plant cohort $i$ of species $sp$ follows Beer-Lambert’s light extinction equation:
\begin{equation}
L^{PAR}=e^{-k_{PAR}(SP_i) \cdot LAI_{i}^{\phi}}
\end{equation}
where $k(SP_i)$ is the PAR extinction coefficient of species $SP_i$. To calculate the proportion of PAR available for a given plant cohort one must accumulate the light extinction caused by cohorts whose crown is above that of the target cohort:
\begin{equation}
L^{PAR}_i=e^{-\sum_{j}{k_{PAR}(SP_j) \cdot LAI_{j}^{\phi} \cdot p_{ij}}}
\end{equation}
Because plant cohorts may differ in height only slightly, the adjusted leaf area is multiplied by $p_{ij}$, the proportion of the crown of cohort $j$ that overtops that of cohort $i$: 
\begin{equation}
p_{ij}=\max(0,\min(1,(H_j-H_i)/(H_j-H_j \cdot b(SP_j))))
\end{equation}
where $b(SP_j)$ is the species-specific proportion of total plant height that corresponds to the crown. In other terms, cohorts whose crown is completely above that of $i$ reduce the amount of light available more strongly by than cohorts that are only slightly taller. $L^{PAR}_{ground}$, the proportion of PAR that reaches the ground, is calculated as:
\begin{equation}
L^{PAR}_{ground}=e^{-\sum_{i}{k_{PAR}(SP_i) \cdot LAI_{i}^{\phi}}}
\end{equation}

Incoming net radiation is partitioned among plant cohorts and the soil. The shortwave radiation (SWR; 400-3000 nm) energy absorbed by each plant cohort needs to be calculated to determine plant transpiration. Foliage absorbs a higher proportion of PAR than SWR; thus, the extinction coefficient is higher for PAR than for SWR. However, values for the ratio of extinction coefficients are rather constant. Following Friend et al. (1997) here it is assumed that the extinction coefficient for PAR is 1.35 times larger than that for SWR. To calculate radiation absorption, where the vertical dimension of the plot is divided into 1 m deep layers, and the SWR absorbed is calculated for each plant cohort in each layer. The fraction of radiation incident on layer $j$ that is absorbed in the same layer is:
\begin{equation}
f_j=1 - e^{-\sum_{i}{k_{SWR}(SP_i) \cdot LAI_{ij}^{\phi}}}
\end{equation}
where $LAI_{ij}^{\phi}$ is the leaf area index of cohort $i$ in layer $j$. Hence, the fraction transmitted is $(1-f_j)$. The fraction of radiation incident on layer $j$ that is absorbed by plant cohort $i$ in that layer ($f_{ij}$) is calculated from the relative contribution of each cohort to the total absorption in the layer:
\begin{equation}
f_{ij} = f_i \cdot \frac{k_{SWR}(SP_i)\cdot LAI_{ij}^{\phi}}{\sum_{h}{k_{SWR}(SP_h) \cdot LAI_{hj}^{\phi}}}
\end{equation}
The fraction of canopy radiation absorbed by a plant cohort across all layers is found by adding the fraction absorbed in each layer:
\begin{equation}
f_i = \sum_{j}{\prod_{h>j}{(1-f_h)}}
\end{equation}
where for each layer the fraction of the radiation incident in the canopy that reaches the layer is found by multiplying the transmitted fractions across the layers above it. The proportion of (shortwave) net radiation absorbed by the ground is simply:
\begin{equation}
L^{SWR}_{ground} = 1 - \sum_{j}{f_j}
\end{equation}

\subsection{Rainfall interception loss}
Rainfall interception loss, $I$, is modelled following the Gash et al. (1995) analytical interception model for sparse canopies, where rain is assumed to fall in a single event during the day. First, the amount of rainfall needed to saturate the canopy is calculated: 
\begin{equation}
P_G = - \frac{S/C}{(E/R)} \cdot \ln(1-(E/R))
\end{equation}
where $S$ is the canopy water storage capacity (in mm) –  i.e. the minimum amount of water needed to saturate the canopy –, $C$ is the canopy cover and $(E/R)$ is the ratio of evaporation rate to rainfall rate during the rainfall event. Simplifying assumptions are made to determine $(E/R)$. In De Cáceres et al. (2015) a value of 0.2 is used for all days between December and June, and a value of 0.05 is used for the remaining months (Miralles et al. 2010).

The amount of water evaporated from interception, $I$ (mm), is calculated as:
\begin{eqnarray}
I = C\cdot P_G+C\cdot(E/R)\cdot(P-P_G) \: {if}\: P > P_G \\
I = C\cdot P\: {if}\: P \leq P_G
\end{eqnarray}
where $P$ is the daily gross precipitation (in mm). Net rainfall, $P_{net}$, is calculated as the difference between gross rainfall and interception loss. Although interception models are normally applied to single-canopy stands, we apply the sparse Gash model to the whole stand (including shrubs). Moreover, in our implementation stem interception is lumped with canopy interception, so that $S$ represents both. Following Watanabe \& Mizutani (1996) we estimate $S$, the canopy water storage capacity, from adjusted LAI values:
\begin{equation}
S=\sum_{i}{s(SP_i)\cdot LAI_{i}^{\phi}}
\end{equation}
where $s(SP_i)$ is the depth of water that can be retained by leaves and trunks of a  species $i$ per unit of leaf area index (mm/LAI). To estimate the stand cover, $C$, we use the complement of the percentage of PAR that reaches the ground, i.e. $C = 1 - L^{PAR}_{ground}$  (Deguchi et al., 2006). Fig. 1 below shows examples of relative throughfall, calculated according to the interception model, under different situations (see function \texttt{swb.RainInterception}). 

\subsection{Runoff}
Runoff, $R$ (in mm), is calculated using the USDA SCS curve number method, as in Boughton (1989):
\begin{equation}
R=\frac{(P_{net} - 0.2 \cdot V_{soil})^2}{(P_{net} - 0.8 \cdot V_{soil})}
\end{equation}
where $V_{soil}$ (in mm) is the overall soil water retention capacity (i.e. the sum of $V_s$ values for topsoil and subsoil).

\begin{center}
<<fig=TRUE, width=9, height=9, echo=FALSE>>==
par(mfrow=c(2,2), mar=c(5,5,5,1))
throughfallMatrixGash<-function(P = seq(1,50, by=1), Cm = seq(1,5, by=1), 
                                ER = 0.08,p=0.8) {
  m2<-P-swb.RainInterception(P,Cm[1],p,ER=ER)
  for(i in 2:length(Cm)) {
    m2<-rbind(m2,P-swb.RainInterception(P,Cm[i],p,ER=ER))
  }
  colnames(m2)<-P
  rownames(m2)<-Cm
  return(m2)
}

Cm = c(0.5,seq(1,4, by=1))
P = seq(1,50, by=1)

m2 = throughfallMatrixGash(P=P, p=0.2, Cm=Cm,ER = 0.05)
rt = sweep(m2,2,P,"/")*100
matplot(t(rt), type="l", axes=TRUE, ylab="Relative throughfall (%)", 
        xlab="Gross rainfall (mm)", xlim=c(0,length(P)), 
        lty=1:length(Cm), col="black", ylim=c(0,100))
title(main="p = 0.2 E/R = 0.05")
m2 = throughfallMatrixGash(P=P, p=0.8, Cm=Cm,ER = 0.05)
rt = sweep(m2,2,P,"/")*100
matplot(t(rt), type="l", axes=TRUE, ylab="Relative throughfall (%)", 
        xlab="Gross rainfall (mm)", xlim=c(0,length(P)), 
        lty=1:length(Cm), col="black", ylim=c(0,100))
title(main="p = 0.8 E/R = 0.05")
m2 = throughfallMatrixGash(P=P, p=0.2, Cm=Cm,ER = 0.2)
rt = sweep(m2,2,P,"/")*100
matplot(t(rt), type="l", axes=TRUE, ylab="Relative throughfall (%)", 
        xlab="Gross rainfall (mm)", xlim=c(0,length(P)), 
        lty=1:length(Cm), col="black", ylim=c(0,100))
title(main="p = 0.2 E/R = 0.2")
m2 = throughfallMatrixGash(P=P, p=0.8, Cm=Cm,ER = 0.2)
rt = sweep(m2,2,P,"/")*100
matplot(t(rt), type="l", axes=TRUE, ylab="Relative throughfall (%)", 
        xlab="Gross rainfall (mm)", xlim=c(0,length(P)), 
        lty=1:length(Cm), col="black", ylim=c(0,100))
title(main="p = 0.8 E/R = 0.2")

legend("bottomright",lty=1:length(Cm), legend=paste("S =",Cm), bty="n")
@
\end{center}
\begin{center}
\emph{Fig. 1}: Examples of canopy interception with different $S$ (canopy water storage capacity), $E/R$ (ratio between evaporation and rainfall rates) and p (throughfall coefficient; $p = 1 - C$).
\end{center}
\subsection{Infiltration and percolation}
The amount of water infiltrating into the soil is $P_{net} - R$, where $R$ is the water lost by runoff (see function \texttt{swb.SoilInfiltration}). Following Granier (1999), part of the water reaching one soil layer percolates quickly through the macropores. The remaining water is retained by the micropores refilling the current soil layer. When this soil layer reaches its field capacity the excess of water percolates to the soil layer below. The water percolating from the lowest layer is considered deep drainage, $D$. 
\begin{center}
<<fig=TRUE, width=8, height=4, echo=FALSE>>==
par(mfrow=c(1,2), mar=c(5,5,5,1))

SoilDepth = c(200,400,800,1200,1500)

#TOPSOIL LAYERS
d1 = pmin(SoilDepth, 300) #<300
#SUBSOIL LAYERS
d2 = pmax(0, pmin(SoilDepth-300,1200)) #300-1500 mm
#ROCK LAYER
d3 = 4000-(d1+d2) #From SoilDepth down to 4.0 m

TS_clay = 15
TS_sand = 25
SS_clay = 15
SS_sand = 25
RL_clay = 15
RL_sand = 25
TS_gravel = 20
SS_gravel = 40
RL_gravel = 95

Theta_FC1=soil.psi2theta(TS_clay, TS_sand, -33) #in m3/m3
Theta_FC2=soil.psi2theta(SS_clay, SS_sand, -33) #in m3/m3
Theta_FC3=soil.psi2theta(RL_clay, RL_sand, -33) #in m3/m3
pcTS_gravel = 1-(TS_gravel/100)
pcSS_gravel = 1-(SS_gravel/100)
pcRL_gravel = 1-(RL_gravel/100)
MaxVol1 = (d1*Theta_FC1*pcTS_gravel)
MaxVol2 = (d2*Theta_FC2*pcSS_gravel)
MaxVol3 = (d3*Theta_FC3*pcRL_gravel)
V = MaxVol1+MaxVol2+MaxVol3

par(mar=c(5,5,1,1), mfrow=c(1,2))
NP = seq(0,60, by=1)
plot(NP,swb.SoilInfiltration(NP, V[1]), type="l", xlim=c(0,60), ylim=c(0,60), 
     ylab="Infiltration (mm)", xlab="Net rainfall (mm)", frame=FALSE)
lines(NP,swb.SoilInfiltration(NP, V[2]), lty=2)
lines(NP,swb.SoilInfiltration(NP, V[3]), lty=3)
lines(NP,swb.SoilInfiltration(NP, V[4]), lty=4)
lines(NP,swb.SoilInfiltration(NP, V[5]), lty=5)
legend("topleft", bty="n", lty=1:5, legend=c(paste("d =", SoilDepth, "Vsoil =",round(V),"mm")))
plot(NP,NP-swb.SoilInfiltration(NP, V[1]), type="l", xlim=c(0,60), ylim=c(0,60), 
     ylab="Runoff (mm)", xlab="Net rainfall (mm)", frame=FALSE)
lines(NP,NP-swb.SoilInfiltration(NP, V[2]), lty=2)
lines(NP,NP-swb.SoilInfiltration(NP, V[3]), lty=3)
lines(NP,NP-swb.SoilInfiltration(NP, V[4]), lty=4)
lines(NP,NP-swb.SoilInfiltration(NP, V[5]), lty=5)
legend("topleft", bty="n", lty=1:5, legend=c(paste("d =", SoilDepth,"Vsoil =",round(V),"mm")))
@
\end{center}

\begin{center}
\emph{Fig. 2}: Examples of infiltration/runoff calculation for different values of net rainfall and overall retention capacity (see function \texttt{swb.SoilInfiltration}), $V_{soil}$, calculated from different soil depths (topsoil+subsoil), $d$, and assuming that soil texture is 15\% clay and 25\% sand. Rock fragment content was 25\% and 40\% for the topsoil and subsoil, respectively.
\end{center}

\subsection{Potential evapotranspiration and Tmax}
Potential evapotranspiration ($PET$; in $mm\cdot day^{-1}$) is the amount of evaporation that would occur if a sufficient water source was available. $PET$ can be calculated externally (e.g. Penman's formula) and given as input; or it can be calculated internally using Penman-Monteith combination equation. The following subsections detail the calculations in each case.

\subsubsection{Evapotranspiration demand from input}
If $PET$ is given as input, it is assumed to represent open water evaporation potential (like in Penman's formula). Maximum canopy transpiration $T_{\max}$ will depend on the amount of transpirating surface. We take the approach of Granier et al. (1999) where $T_{\max}/PET$ is a function of $LAI_{stand}$ – the cumulative leaf area of the forest stand –, according to the experimental equation:
\begin{equation}
\frac{T_{\max}}{PET}= -0.006\,LAI_{stand}^2+0.134\,LAI_{stand}+0.036
\end{equation}
This equation has already been adopted for Mediterranean biomes (Fyllas and Troumbis, 2009; Ruffault et al., 2013). 
\begin{center}
<<fig=TRUE, width=4, height=4, echo=FALSE>>==
par(mar=c(4,4,1,1))
LAIc = seq(0,10, by=0.01)
TmaxPET = -0.006*(LAIc^2) + 0.134*LAIc + 0.036
plot(LAIc, TmaxPET, type="l", ylab="Tmax/PET", xlab="LAIstand", ylim=c(0,1))
@
\end{center}
\begin{center}
\emph{Fig. 3}: Experimental relationship between $T_{\max}/PET$ and $LAI_{stand}$.
\end{center}
When $PET$ is given as input, potential evaporation from the soil ($PE_{soil}$; in $mm\cdot day^{-1}$) is defined as the product between $PET$ and $L^{SWR}_{ground}$, the proportion of SWR absorbed by the ground:
\begin{equation}
PE_{soil} =  PET\cdot L^{SWR}_{ground}
\end{equation}

\subsubsection{Evapotranspiration demand using Penman-Monteith combination equation}
Another option is to calculate $T_{\max}$ and $PE_{soil}$ using the Penman-Monteith combination equation. To this aim, the model first determines radiation balance at the stand scale. Daily net radiation $R_n$ (in $MJ\cdot m^{-2}\cdot day^{-1}$) is calculated using:
\begin{equation}
R_n = R_s\cdot (1 - \alpha) - R_{nl}
\end{equation}
where $R_s$ is the input solar radiation (in $MJ\cdot m^{-2}\cdot day^{-1}$), $\alpha = 0.08$ accounts for surface albedo, and $R_{nl}$ is the net longwave radiation, which depends on elevation, latitude, Julian day and temperature. Net radiation is then split into that absorbed by the canopy and that absorbed by the soil (both in $MJ\cdot m^{-2}\cdot day^{-1}$):
\begin{eqnarray}
R_{n,canopy} &=& R_{n}\cdot \sum_{i}{f_i} = R_{n} \cdot (1 - L^{SWR}_{ground})\\
R_{n,soil} &=& R_{n}\cdot (1 - \sum_{i}{f_i})  = R_{n} \cdot L^{SWR}_{ground}
\end{eqnarray}
Daily maximum canopy transpiration ($T_{\max}$; in $mm\cdot day^{-1}$) is calculated using the Penman-Monteith combination equation:
\begin{equation}
T_{\max} = \frac{1}{\lambda} \cdot \frac{\Delta \cdot R_{n,canopy} + D \cdot (\rho \cdot C_p/r_a)}{\Delta + \gamma \cdot (1 + r_s/r_a)}
\end{equation}
where  $D$ is the vapour pressure deficit (in kPa), $\Delta$  is the slope of the saturated vapor pressure (in $Pa \cdot K^{-1}$), $\gamma$ is the psychrometer constant (in $kPa\cdot K^{-1}$), $\lambda$ is the latent heat vaporization of water (in $MJ\cdot kg^{-1}$) and $C_p$ is the specific heat of air (in $MJ\cdot kg^{-1}\cdot K^{-1}$). $r_s$ is the surface resistance and $r_a$ is the aerodynamic resistance (both in $s \cdot m^{-1}$). The surface resistance describes the resistance of vapour flow through the transpiring canopy. Assuming a dense full cover vegetation, it is calculated from:
\begin{equation}
r_s = \frac{r_l}{LAI_{stand}}
\end{equation}
where $r_l$ is the leaf minimum resistance (in $s \cdot m^{-1}$). We calculate leaf minimum resistance of the stand from species-specific minimum leaf resistance values, $r_l(SP_i)$, using a LAI-weighted average of maximum conductances (hence, assuming that resistances of the different cohorts are in parallel):
\begin{equation}
r_l = \frac{LAI_{stand}}{\sum_i{(1/r_s(SP_i))\cdot LAI_{i}^{\phi}}}
\end{equation}
where $LAI_{i}^{\phi}$ is the leaf area index of the plant cohort. Substituting in the former equation leads to:
\begin{equation}
r_s = \frac{1}{\sum_i{(1/r_l(SP_i))\cdot LAI_{i}}}
\end{equation}
Potential evaporation from the soil ($PE_{soil}$; in $mm\cdot day^{-1}$) is calculated as:
\begin{equation}
PE_{soil} = \frac{1}{\lambda} \cdot \frac{\Delta \cdot R_{n,soil} + D \cdot (\rho \cdot C_p/r_a)}{\Delta + \gamma \cdot (1 + r_{soil}/r_a)}
\end{equation}
where $r_{soil}$ is the resistance of the soil surface, set to a constant value ($r_{soil} = 200$ $s\cdot m^{-1}$). For simplicity, aerodynamic resistance ($r_a$) in the soil and the canopy are both currently set to $r_a = 208.0/u$ where $u$ is the input wind speed. Improvements of this approach should include reduced wind speed at the ground level due to canopy extinction effects. 


Total potential evapotranspiration (PET; in $mm\cdot day^{-1}$) is derived for comparison with input values:
\begin{equation}
PET = PE_{soil} + T_{\max}
\end{equation}


\subsection{Maximum and actual plant transpiration}
The maximum transpiration for a given plant cohort $i$ is calculated as the portion of $T_{\max}$ defined by the fraction of total absorbed SWR that is due to cohort $i$:
\begin{equation}
T_{\max, i} = T_{canopy} \cdot \frac{f_i}{\sum_{j}{f_j}}
\end{equation}
Actual plant transpiration is calculated for each plant cohort and each soil layer separately. $T_{i,s}$ represents the transpiration made by cohort $i$ from layer $s$. In \texttt{swb} actual plant transpiration is regulated by soil moisture and water conductance through the plant. We implemented two approaches to implement hydraulic constraints. These are described in the following subsections. 

\subsubsection{Simple regulation model}
In the simple approach, transpiration of a plant cohort is a function of soil water potential and the species identity. For each plant cohort $i$ and soil layer $s$, the model first estimates the a whole-plant relative water conductance, $K_{i,s}$, which varies between 0 and 1 depending on $\Psi(SP_i)$, the potential at which conductance is 50\% of maximum for species $SP_i$, and $\Psi_s$, the water potential in layer $s$.
\begin{equation}
K_{i,s}=K_{i}(\Psi_s) = \exp \left \{\ln{(0.5)}\cdot \left[ \frac{\Psi_s}{\Psi(SP_i)} \right] ^r \right \} 
\end{equation}
where $r$ is an exponent that modulates the steepness of the decrease in relative conductance when soil potential becomes negative (by default, $r = 3$) and $\ln(0.5)$ is used to ensure that $K_{i}(\Psi(SP_i)) = 0.5$ (Fig. 4).
\begin{center}
<<fig=TRUE, width=4, height=4, echo=FALSE>>==
par(mar=c(4,4,1,1))
x = seq(-10000, 0, by=10)
plot(x/1000,exp(-0.6931472*(x/-2000)^3)*100, type="l", ylab="K (relative conductance, %)",
     xlim=c(-10.0,0), ylim=c(0,100),xlab="Y (soil potential, MPa)", frame=FALSE)
lines(x/1000, exp(-0.6931472*(x/-3000)^3)*100, lty=2)
lines(x/1000, exp(-0.6931472*(x/-4000)^3)*100, lty=3)
lines(x/1000, exp(-0.6931472*(x/-5000)^3)*100, lty=4)
legend("topleft", lty=1:4, col=c(rep("black",4)), 
       legend = paste("Ysp = ", c(-2.0,-3.0,-4.0, -5.0), "MPa"), bty="n")
abline(h=50, col="gray", lwd=2)
@
\end{center}

\begin{center}
\emph{Fig. 4}: Whole-plant relative water conductance functions for different $\Psi_{sp}$ values ($r = 3$ in all cases).
\end{center}

Actual transpiration of plant cohort $i$ from a given soil layer $s$, $T_{i,s}$, is defined as the product of (Mouillot et al., 2001): (i) the maximum transpiration of the plant cohort; (ii) the relative whole-plant conductance, $K_{i,s}$, corresponding to the species and water potential in layer $s$; (iii) the proportion of plant fine roots in layer $s$, $v_{i,s}$:
\begin{equation}
T_{i,s} =  T_{\max,i} \cdot K_{i,s} \cdot v_{i,s}
\end{equation}
The total amount of water transpired by plants, $T$, is the sum of $T_{i,s}$ values over all plant cohorts and soil layers:
\begin{equation}
T =\sum_{s}\sum_{i}{T_{i,s}}
\end{equation}
Assuming no water limitations (i.e. $K_{i,s} = 1$), we have that $T = T_{\max}$. Total stand transpiration will be lower than $T_{\max}$ if soil water potential in any layer is negative enough to cause a significant reduction in whole-plant conductance. At the plant level, the transpiration of a given plant cohort will be lower than that of others if: (1) the cohort is under the shade (it reduces $f_i$ and hence $T_{\max,i}$); (2) the cohort has a lower amount of leaf area (it reduces $f_i$ and hence $T_{\max,i}$); (3) the soil layers exploited by the cohort have more negative water potentials (it reduces $K_{i,s}$). 

\subsubsection{Supply-loss theory of plant hydraulics}
The supply-loss theory of plant hydraulics was recently presented by Sperry and Love (2015). The theory uses the physics of flow through soil and xylem to quantify how canopy water supply declines with drought and ceases by hydraulic failure. The theory can be applied to different networks representing the soil-plant continuum, but in our case the continuum is divided into two resistance elements in series, one representing the rhizosphere and the other representing the xylem. 

Each continuum element has a vulnerability curve that starts at maximum hydraulic conductance ($k_{max}$, flow rate per pressure drop) and monotonically declines as water pressure ($\Psi$) becomes more negative. Vulnerability curves form the basis of the calculations. The xylem element follows a two-parameter Weibull function as the vulnerability curve $k_x(\Psi)$:
\begin{equation}
k_x(\Psi) = k_{xmax}(SP_i)\cdot e^{-((-\Psi/{d(SP_i)})^{c(SP_i)})}
\end{equation}
where $k_{xmax}(SP_i)$ is the species-specific xylem maximum hydraulic conductance (defined as flow per leaf surface unit and per pressure drop), and $c(SP_i)$ and $d(SP_i)$ are also species-specific parameters describing the shape of the Weibull function. The rhizosphere conductance function $k_r(\Psi)$ is modeled as a van Genuchten function (van Genuchten, 1980):
\begin{eqnarray}
k_r(\Psi) &=& k_{rmax} \cdot v^{(n-1)/(2\cdot n)} \cdot ((1-v)^{(n-1)/n}-1)^2 \\
v &=& [(\alpha \Psi)^{n}+1]^{-1}
\end{eqnarray}
where $k_{rmax}$ is the maximum rhizosphere conductance, and $n$ and $\alpha$ are texture-specific parameters (see Leij et al. 1996; Carsel \& Parrish 1988).

The supply function describes the rate of water supply (i.e. flow) for transpiration ($E$) as a function of the pressure. The steady-state flow rate $E_i$ through each $i$ element of the continuum is related to the flow-induced drop in pressure across that element ($\Delta \Psi_i$) by the integral transform of the element's vulnerability curve $k_i(\Psi)$:
\begin{equation}
E_i(\Delta \Psi_i) = \int_{\Psi_{up}}^{\Psi_{down}}{k_i(\Psi) d\Psi}
\end{equation}
where $\Psi_{up}$ and $\Psi_{down}$ are the upstream and downstream water potential values, respectively. The integral transform assumes infinite discretization of the flow path. 
In the case of a single xylem element the supply function describes the flow rate as a function of canopy xylem pressure ($\Psi_{canopy}$). It is calculated by numerical integration of the Weibull function. The  supply function of the rhizosphere element relates the flow rate to the pressure inside the roots ($\Psi_{root}$). It is calculated by numerical integration of the van Genuchten function. In the network of the two elements in series (rhizosphere + xylem) the supply function has to be calculated by sequentially using the previous supply functions. The $E_i$ is identical for each element and equal to the canopy $E$. Since $\Psi_{soil}$ is known, one first inverts the supply function of the rhizosphere to find $\Psi_{root}$ and then inverts the supply function of the xylem to find $\Psi_{canopy}$. The supply function for the whole continuum contains much information. The $\Psi$ intercept at $E=0$ represents the predawn canopy sap pressure which integrates the rooted soil moisture profile. As $E$ increments from zero, the disproportionately greater drop in $\Psi_{canopy}$ results from the loss of conductance. As the soil dries the differences in flow due to soil texture become more apparent. The derivative of the whole continuum supply function, $dE/d\Psi$, represents the whole plant hydraulic conductance (i.e. the conductance at the endpoint of the continuum), and it falls towards zero for asymptotic critical values ($E_{crit}$).

The loss function specifies where the plant regulates its actual transpiration rate along the supply function. The supply function derivative ($dE/d\Psi_{canopy}$) drives the loss function. Soil drought and high demand both push the plant towards lower $dE/d\Psi_{canopy}$ values. A simple rule for a loss function is that stomata should close more as stress pushes $dE/d\Psi_{canopy}$ closer to zero. The loss function needs an input water demand $E'$. The $\Psi'$ corresponding to $E'$ (and hence the unregulated pressure drop $\Delta \Psi'$) is first determined by inverting the supply function. The derivative $dE'/d\Psi_{canopy}'$ corresponding to the demand is also calculated from the supply function. The maximum $dE/d\Psi_{canopy}$ is at the start of the curve ($dE/d\Psi_{max}$) and equals maximum soil-plant conductance. The fraction $(dE'/d\Psi_{canopy}')/(dE/d\Psi_{max})$ drops from 1 to 0 as $E'$ increases, quantifying how close the plant is pushed to the critical point of complete hydraulic failure without stomatal closure. Regulated pressure drop ($\Delta \Psi_{canopy}$) is calculated as:
\begin{equation}
\Delta \Psi = \Delta \Psi' \cdot ((dE'/d\Psi_{canopy}')/(dE/d\Psi_{max}))
\end{equation}
The regulated pressure drop is then used to determine the regulated $\Psi_{canopy}$ and, using again the supply function, find the regulated $E$ value. Due to its formulation,$\Delta \Psi$ reaches a maximum before $dE'/d\Psi_{canopy}' \simeq 0$. At this point $\Delta \Psi$ should saturate with water demand, rather than to show an unrealistic decline with further $E'$ increases. Thus, beyond this $\Delta \Psi$ saturation point the stomata are assumed to be maximally sensitive to water demand by closing sufficiently to keep $E$ and $\Psi_{canopy}$ constant.

\subsubsection{Implementation of Sperry \& Love regulation model}
Despite the obvious increase in complexity and computational time, adopting the regulation model of Sperry \& Love has the following advantages: (1) regulation of transpiration is based on a state-of-the-art knowledge of plant hydraulics; (2) regulation of transpiration is affected by both soil moisture and atmospheric demand (not only soil moisture); (3) the model allows predicting water potential value for the leaves. 

The input of regulation model of Sperry \& Love is the unregulated transpiration demand, which in the case of a plant cohort $i$ is set to:
\begin{equation}
E_i' = T_{\max,i}/LAI_{i}^{\phi} 
\end{equation}
where division by $LAI_{i}^{\phi}$ is done because hydraulic conductance parameters $k_{xmax}(SP_i)$ are assumed scaled to unit of leaf surface area. The Sperry \& Love regulation model is called once per soil layer $s$, each time using the corresponding soil water potential and soil parameters (i.e. van Genuchten function), in addition to the parameters of the vulnerability curve corresponding to the plant cohort'species. The regulation model returns a regulated plant water potential, $\Psi_{i,s}$, and the regulated transpiration per unit of leaf area, $E_{i,s}$. The amount of water transpired by any plant cohort $i$ from a soil layer $s$ is the result of scaling $E_{i,s}$ using the LAI value and the proportion of fine roots in the soil layer:
\begin{equation}
T_{i,s} = E_{i,s} \cdot LAI_i^{\Phi} \cdot v_{i,s}
\end{equation}
Like in the simple hydraulic model, the amount of water transpired by all plants of the stand, $T$, is the sum of $T_{i,s}$ values over plant cohorts and soil layers:
\begin{equation}
T =\sum_{s}\sum_{i}{T_{i,s}}
\end{equation}
Assuming no water limitations (i.e. $E_{i,s} = E_i'$), we have that $T = PT_{canopy}$. Finally, one can obtain a whole-plant relative conductance value, for comparison with the simple hydraulic model, using:
\begin{equation}
K_{i,s} = \frac{E_{i,s}}{E_i'}
\end{equation}


\subsection{Bare soil evaporation}

Evaporation from the soil surface is modeled as in Mouillot et al. (2001), who followed Ritchie (1972).  First, the model determines the time needed to evaporate the current water deficit (difference between field capacity and current moisture) in the surface soil layer:
\begin{equation}
t = \left \{ \frac{V_1\cdot(1- W_1)}{\gamma_{soil}} \right \}
\end{equation}
where $\gamma_{soil}$ is the maximum daily evaporation ($mm \cdot day^{-1}$). The calculated time is used to determine the ‘supplied’ evaporation, $S_{soil}$:
\begin{equation}
S_{soil} = \gamma_{soil} \cdot (\sqrt{t+1}-\sqrt{1})
\end{equation}
The amount of water evaporated from the soil, $E_{soil}$, is then calculated as the minimum between supply and demand (Federer, 1982), the latter being the product of PET and the proportion of light that reaches the ground (see function \texttt{swb.SoilEvaporation}): 
\begin{equation}
E_{soil} = \min(PE_{soil}, S_{soil})
\end{equation}
Finally, $E_{soil}$ is distributed along the soil profile according to an exponential decay function with an extinction coefficient $\kappa_{soil}$ (Mouillot et al., 2001).

\begin{center}
<<fig=TRUE, width=4, height=4, echo=FALSE>>==
TS_clay=10
TS_silt=65
TS_sand=25
TS_gravel=40
SS_clay=10
SS_silt=65
SS_sand = 25
SS_gravel=40
TS_macro=0.25
TS_micro = 0.75
SS_macro=0.10
SS_micro=0.90
#Rock layer is like subsoil but with 95% of rocks
RL_clay = SS_clay
RL_sand = SS_sand
RL_macro = SS_macro
RL_micro = SS_micro
RL_gravel = 95


RunEvaporation<-function(Gsoil, Ksoil, d1,d2,d3, numDays = 15){
  PET = 100 #Not limited by PET
  Lground = 1
  
  Theta_FC1=soil.psi2theta(TS_clay, TS_sand, -33) #in m3/m3
  Theta_FC2=soil.psi2theta(SS_clay, SS_sand, -33) #in m3/m3
  Theta_FC3=soil.psi2theta(RL_clay, RL_sand, -33) #in m3/m3
  pcTS_gravel = 1-(TS_gravel/100)
  pcSS_gravel = 1-(SS_gravel/100)
  pcRL_gravel = 1-(RL_gravel/100)
  MaxVol1 = (d1*Theta_FC1*pcTS_gravel)
  MaxVol2 = (d2*Theta_FC2*pcSS_gravel)
  MaxVol3 = (d3*Theta_FC3*pcRL_gravel)
  Ssoil = MaxVol1 + MaxVol2 + MaxVol3

  W1=rep(0, numDays)
  W2=rep(0, numDays)
  W3=rep(0, numDays)
  W1[1] = 1
  W2[1] = 1
  W3[1] = 1
  Esoil = rep(NA,numDays)
  EsoilCum = rep(NA,numDays)
  t = rep(NA, numDays)
  for(i in 1:numDays){
    #Evaporation from bare soil
    Esoil[i] = swb.SoilEvaporation(DEF=(MaxVol1*(1 - W1[i])), PETs = PET*Lground, Gsoil = Gsoil)
    if(i==1) EsoilCum[i] = Esoil[i]
    else EsoilCum[i] = EsoilCum[i-1]+Esoil[i]
    #Exponential decay to divide bare soil evaporation among layers
    Esoil1 = Esoil[i]*(1-exp(-Ksoil*d1))
    Esoil2 = Esoil[i]*(exp(-Ksoil*d1)-exp(-Ksoil*(d1+d2)))
    Esoil3 = Esoil[i]*(exp(-Ksoil*(d1+d2)))
    if(i<numDays){
      W1[i+1] = max(W1[i]-(Esoil1)/MaxVol1,0)
      W2[i+1] = max(min(W2[i]-(Esoil2)/MaxVol2,1),0)
      W3[i+1] = max(min(W3[i]-(Esoil3)/MaxVol3,1),0)
    }  
  }
  return(list(Esoil = Esoil, EsoilCum = EsoilCum))  
}

E11=RunEvaporation(Gsoil=1, Ksoil = 0.05, d1=300, d2=1200, d3= 2500)
E12=RunEvaporation(Gsoil=2, Ksoil = 0.05, d1=300, d2=1200, d3= 2500)
E13=RunEvaporation(Gsoil=3, Ksoil = 0.05, d1=300, d2=1200, d3= 2500)
E21=RunEvaporation(Gsoil=1, Ksoil = 0.005, d1=300, d2=1200, d3= 2500)
E22=RunEvaporation(Gsoil=2, Ksoil = 0.005, d1=300, d2=1200, d3= 2500)
E23=RunEvaporation(Gsoil=3, Ksoil = 0.005, d1=300, d2=1200, d3= 2500)


par(mar=c(4,4,1,1))
plot(x=1:length(E11$EsoilCum), y=E11$EsoilCum, ylim=c(0,15), ylab="Cummulative soil evaporation (mm)", xlab="day", type="l", axes=FALSE)
axis(1, at=1:length(E11$EsoilCum), cex.axis=0.7)
axis(2)
points(x=1:length(E11$EsoilCum), y=E11$EsoilCum, pch=1)
lines(x=1:length(E12$EsoilCum), y=E12$EsoilCum, lty=2)
points(x=1:length(E12$EsoilCum), y=E12$EsoilCum, pch=1)
lines(x=1:length(E13$EsoilCum), y=E13$EsoilCum, lty=3)
points(x=1:length(E13$EsoilCum), y=E13$EsoilCum, pch=1)
lines(x=1:length(E21$EsoilCum), y=E21$EsoilCum, lty=1)
points(x=1:length(E21$EsoilCum), y=E21$EsoilCum, pch=2)
lines(x=1:length(E22$EsoilCum), y=E22$EsoilCum, lty=2)
points(x=1:length(E22$EsoilCum), y=E22$EsoilCum, pch=2)
lines(x=1:length(E23$EsoilCum), y=E23$EsoilCum, lty=3)
points(x=1:length(E23$EsoilCum), y=E23$EsoilCum, pch=2)
legend("topleft", lty=rep(1:3,2), pch=c(1,1,1,2,2,2), legend=c("Gsoil = 1 Ksoil = 0.05", 
                                    "Gsoil = 2 Ksoil = 0.05", 
                                    "Gsoil = 3 Ksoil = 0.05",
                                    "Gsoil = 1 Ksoil = 0.005", 
                                    "Gsoil = 2 Ksoil = 0.005", 
                                    "Gsoil = 3 Ksoil = 0.005"), cex = 0.7, bty="n")
@
\end{center}
\begin{center}
\emph{Fig. 4}: Cumulative bare soil evaporation for different values of maximum evaporation rate $\gamma_{soil}$ and extinction coefficient $\kappa_{soil}$. Three soil layers (0 – 30 cm; 30 – 150 cm; 150 – 400 cm) are initialized at field capacity ($V_1 = 50 mm$; $V_2 = 201 mm$; $V_3 = 35 mm$). $PE_{soil}$ was assumed not to be limiting. When the extinction coefficient is smaller a higher proportion of the evaporated water is removed from the subsoil and less from the topsoil. This causes more water being available to calculate t in the next step.
\end{center}

\subsection{Landscape hydrological processes}
To simulate runoff from one cell to the other, the approach of Ostendorf \& Reynolds (1993) is used, as in SIERRA (Mouillot et al. 2001). Water lateral transport depends on topography only. The model determines cell neigbours following the queen rule (up to eight neighbours per cell). The proportion of water runoff of cell $i$ will be an input to a neighbouring cell $j$ is:
\begin{equation}
q_{ij} = \frac{\Delta z_{ij}/L_{ij}}{\sum_{j}{\Delta z_{ij}/L_{ij}}}
\end{equation}
if $\Delta z_{ij} = z_i - z_j > 0$, that is, if the difference in elevation between the two cells is positive (i.e. if $z_j < z_i$). Otherwise there is no discharge from $i$ to $j$, i.e. $q_{ij} = 0$. $L_{ij}$ indicates the distance between cell $i$ and $j$ (which depends on cell size and on whether the neighbouring cell $j$ is diagonal to cell $i$). The sumatory of the denominator is done only for neighbours at lower elevation, so that $\sum_{i}{qij} = 1$. 
 
The table of $q_{ij}$ values is calculated at the beginning of simulations only. Every day, cells are processed in order from higher to lower elevation. After the daily water balance of a given cell $i$, water runoff $R_i$ is divided among the neighbouring cells situated at lower elevation. The runon of a neighbour $j$, $O_j$ is updated as:
\begin{equation}
O_j = O_j + R_i \cdot q_{ij}
\end{equation}
Note that a given cell $j$ can receive water discharge from more than one neighbour. $O_j$ values are set to zero at the beginning of each day.


\section{Drought stress estimation}
\subsection{Daily plant drought stress}
Similarly to Mouillot et al. (2002), daily drought stress of a given plant cohort $i$, $DDS_i$, is defined as the complement of relative whole-plant conductance and is aggregated across soil layers using the proportion of fine roots in each layer as weights:
\begin{equation}
DDS_i=\phi_i\,\sum_{s}{(1-K_{i,s})\,v_{i,s}}
\end{equation}
Leaf-phenological status is included to prevent winter deciduous plants from suffering drought stress during winter. Daily drought stress values can be later used to define drought stress indices for larger temporal scales, as presented in the main text.

\subsection{Annual drought stress indices}
Plant drought stress for a period of interest (i.e. months, years,...) is evaluated by aggregating $DDS$ values. If the drought stress evaluation is done annually, annual drought duration can be defined as the number of drought days (NDD) with relative conductance below 50\% (i.e. DDS > 0.5). Annual drought intensity (DI) is defined for a given cohort $i$ as:
\begin{equation}
DI_i = \sum_{j}^{365}{\max{\left[\frac{0.5-DDS_{i,j}}{0.5}, 0\right]}/365}
\end{equation}
where $DDS_{i,j}$ is the drought stress of day $j$ for cohort $i$. $DI_i$ is dimensionless and ranges between 0 (relative conductance always > 50\%) and 1 (0\% relative conductance during all year). The same quantities can be evaluated at other temporal scales (i.e. months, quarters, weeks...).

\section{Parameters}
\subsection{List of soil parameters}
The following is a list of soil parameters needed to call function \texttt{soil()}, which calculates soil characteristics for \texttt{swb()}. 
\begin{itemize}
\item{$Z_{soil}$ [\texttt{SoilDepth}]: Depth corresponding to the topsoil and subsoil layers.}
\item{$Z_{rocksoil}$ [\texttt{RockSoilDepth}]: Depth corresponding to the three layers (including the rock layer).}
\item{$P_{clay}$ [\texttt{TS\_clay}, \texttt{SS\_clay}, \texttt{RL\_clay}]: Percentage of clay corresponding to the three soil layers.}
\item{$P_{sand}$ [\texttt{TS\_sand}, \texttt{SS\_sand}, \texttt{RL\_sand}]: Percentage of sand corresponding to the three soil layers.}
\item{$P_{rocks}$ [\texttt{TS\_rfc}, \texttt{SS\_rfc}, \texttt{RL\_rfc}]: Percentage of rock fragments (>2 mm) corresponding to the three soil layers.}
\item{[\texttt{TS\_macro}, \texttt{SS\_macro}, \texttt{RL\_macro}]: Percentage of macroporosity corresponding to the three soil layers. Macroporosity values can be calculated for each soil layer from its percentage of sand and bulk density, using the equations given in Stolf et al. (2011).}
\item{$\gamma_{soil}$ [\texttt{Gsoil}]: Maximum daily bare soil evaporation ($mm \cdot day^{-1}$).}
\item{$\kappa_{soil}$ [\texttt{Ksoil}]: Exponential decay coefficient for bare soil evaporation.}
\end{itemize}
Other parameters, like van Genuchten's $n$ and $\alpha$ values, are automatically derived from texture using USDA classification.

\subsection{List of species parameters}
The following is a list of species parameters needed for function \texttt{swb()}. These should be arranged in columns of a data frame where each species corresponds to a column. The column name for each parameter is indicated in square brackets.

The following parameters are needed in all calculation modes:
\begin{itemize}
\item{$b(SP_i)$ [\texttt{pBole}]: Proportion of total plant height that corresponds to the crown for plants of species $i$.}
\item{$k_{PAR}(SP_i)$ [\texttt{k}]: PAR extinction coefficient for species $i$.}
\item{$s(SP_i)$ [\texttt{g}]: Canopy storage capacity (i.e. depth of water that can be retained by leaves and branches of a species $i$) per LAI unit (in mm/LAI).}
\item{$S_{GDD}$ [\texttt{Sgdd}]: Growth degree days corresponding to leave budburst for species $i$ (in degrees Celsius).}
\end{itemize}
For the calculation of PET per plant cohort using Penman-Monteith, one additional parameter is needed:
\begin{itemize}
\item{$r_s(SP_i)$ [\texttt{RC\_min}]: Minimum surface resistance (s/m) for species $i$.}
\end{itemize}
For simple transpiration regulation model, the following parameter is needed:
\begin{itemize}
\item{$\Psi(SP_i)$ [\texttt{psiExtr}]: Soil water potential (in kPa) corresponding to 50\% of water extractive capacity for species $i$.}
\end{itemize}
For the Sperry \& Love transpiration regulation model three parameters are needed:
\begin{itemize}
\item{$k_{xmax}(SP_i)$ [\texttt{VC\_kxmax}]: Maximum hydraulic conductance per leaf area unit (mm/m2/day) for species $i$.}
\item{$c(SP_i)$ and $d(SP_i)$ [\texttt{VC\_c} and \texttt{VC\_d}]: Parameters modulating the shape of the hydraulic vulnerability curve for species $i$.}
\end{itemize}

\section{References}
\begin{itemize}
\item{Collins, D.B.G., Bras, R.L., 2007. Plant rooting strategies in water-limited ecosystems. Water Resour. Res. 43, W06407. doi:10.1029/2006WR005541}

\item{De Cáceres, M., Martínez-Vilalta, J., Coll, L., Llorens, P., Casals, P., Poyatos, R., Pausas, J.G., Brotons, L., 2015. Coupling a water balance model with forest inventory data to predict drought stress: the role of forest structural changes vs. climate changes. Agric. For. Meteorol. 213, 77–90. doi:10.1016/j.agrformet.2015.06.012}

\item{Deguchi, A., Hattori, S., Park, H.-T., 2006. The influence of seasonal changes in canopy structure on interception loss: Application of the revised Gash model. J. Hydrol. 318, 80–102. doi:10.1016/j.jhydrol.2005.06.005}

\item{Federer, C., 1982. Transpirational supply and demand: plant, soil, and atmospheric effects evaluated by simulation. Water Resour. Res. 18, 355–362.}

\item{Fyllas, N.M., Troumbis, A.Y., 2009. Simulating vegetation shifts in north-eastern Mediterranean mountain forests under climatic change scenarios. Glob. Ecol. Biogeogr. 18, 64–77. doi:10.1111/j.1466-8238.2008.00419.x}

\item{Gash, J., Lloyd, C., Lachaud, G., 1995. Estimating sparse forest rainfall interception with an analytical model. J. Hydrol. 170.}

\item{Granier, A., Bréda, N., Biron, P., Villette, S., 1999. A lumped water balance model to evaluate duration and intensity of drought constraints in forest stands. Ecol. Modell. 116, 269–283.}

\item{Granier, A., Reichstein, M., Bréda, N., Janssens, I.A., Falge, E., Ciais, P., Grünwald, T., Aubinet, M., Berbigier, P., Bernhofer, C., Buchmann, N., Facini, O., Grassi, G., Heinesch, B., Ilvesniemi, H., Keronen, P., Knohl, A., Köstner, B., Lagergren, F., Lindroth, A., Longdoz, B., Loustau, D., Mateus, J., Montagnani, L., Nys, C., Moors, E., Papale, D., Peiffer, M., Pilegaard, K., Pita, G., Pumpanen, J., Rambal, S., Rebmann, C., Rodrigues, A., Seufert, G., Tenhunen, J., Vesala, T., Wang, Q., 2007. Evidence for soil water control on carbon and water dynamics in European forests during the extremely dry year: 2003. Agric. For. Meteorol. 143, 123–145. doi:10.1016/j.agrformet.2006.12.004}

\item{Jarvis, P., McNaughton, K., 1986. Stomatal control of transpiration: Scaling Up from leaf to region. Adv. Ecol. Res. 15, 1–49.}

\item{Linacre, E.T., 1968. Estimating the net-radiation flux. Agric. Meteorol. 93, 49–63.}


\item{Miralles, D.G., Gash, J.H., Holmes, T.R.H., de Jeu, R.A.M., Dolman, A.J., 2010. Global canopy interception from satellite observations. J. Geophys. Res. 115, D16122. doi:10.1029/2009JD013530}

\item{Mouillot, F., Rambal, S., Joffre, R., 2002. Simulating climate change impacts on fire frequency and vegetation dynamics in a Mediterranean-type ecosystem. Glob. Chang. Biol. 8, 423–437.}

\item{Mouillot, F., Rambal, S., Lavorel, S., 2001. A generic process-based SImulator for meditERRanean landscApes (SIERRA): design and validation exercises. For. Ecol. Manage. 147, 75–97. doi:10.1016/S0378-1127(00)00432-1}
\item{Ostendorf, B., Reynolds, J.F., 1993. Relationships between a terrain-based hydrologic model and patch-scale vegetation patterns in an arctic tundra landscape. Landsc. Ecol. 8, 229–237. doi:10.1007/BF00125130}
\item{Prentice, I.C., Sykes, M.T., Cramer, W., 1993. A simulation model for the transient effects of climate change on forest landscapes. Ecol. Modell. 65, 51–70. doi:10.1016/0304-3800(93)90126-D}

\item{Reynolds, C.A., Jackson, T.J., Rawls, W.J., 2000. Estimating soil water-holding capacities by linking the Food and Agriculture Organization Soil map of the world with global pedon databases and continuous pedotransfer functions. Water Resour. Res. 36, 3653–3662. doi:10.1029/2000WR900130}

\item{Ritchie, J., 1972. Model for predicting evaporation from a row crop with incomplete cover. Water Resour. Res. 8, 1204–1213.}

\item{Ruffault, J., Martin-StPaul, N.K., Duffet, C., Goge, F., Mouillot, F., 2014. Projecting future drought in Mediterranean forests: bias correction of climate models matters! Theor. Appl. Climatol. 117, 113–122. doi:10.1007/s00704-013-0992-z}

\item{Ruffault, J., Martin-StPaul, N.K., Rambal, S., Mouillot, F., 2013. Differential regional responses in drought length, intensity and timing to recent climate changes in a Mediterranean forested ecosystem. Clim. Change 117, 103–117. doi:10.1007/s10584-012-0559-5}

\item{Saxton, K.E., Rawls, W.J., Romberger, J.S., Papendick, R.I., 1986. Estimating generalized soil-water characteristics from texture. Soil Sci. Soc. Am. J. 50, 1031–1036.}

\item{Schenk, H., Jackson, R., 2002. The global biogeography of roots. Ecol. Monogr. 72, 311–328.}

\item{Sitch, S., Smith, B., Prentice, I.C., Arneth, a., Bondeau, a., Cramer, W., Kaplan, J.O., Levis, S., Lucht, W., Sykes, M.T., Thonicke, K., Venevsky, S., 2003. Evaluation of ecosystem dynamics, plant geography and terrestrial carbon cycling in the LPJ dynamic global vegetation model. Glob. Chang. Biol. 9, 161–185. doi:10.1046/j.1365-2486.2003.00569.x}

\item{Sperry, J.S., Love, D.M., 2015. What plant hydraulics can tell us about responses to climate-change droughts. New Phytol. 207, 14–27. doi:10.1111/nph.13354}

\item{Stolf, R., Thurler, Á., Oliveira, O., Bacchi, S., Reichardt, K., 2011. Method to estimate soil macroporosity and microporosity based on sand content and bulk density. Rev. Bras. Ciencias do Solo 35, 447–459.}

\item{Watanabe, T., Mizutani, K., 1996. Model study on micrometeorological aspects of rainfall interception over an evergreen broad-leaved. Agric. For. Meteorol. 80, 195–214.}
\end{itemize}

\end{document}