Preparation

Initialisation for spwb() function:

## Package 'medfate' [ver. 4.0.0]
# Soil
examplesoil <- soil(defaultSoilParams(n = 4))

# Load example plot plant data
data(exampleforest)

# Prepare input for 'Cochard' transpiration mode
control <- defaultControl("Cochard")

# Create input for spwb
x <- forest2spwbInput(exampleforest,examplesoil,SpParamsMED, control)

Sureau network input

Create Cochard network (similar) for each of the three plant cohort in x. This returns a list with three elements:

## [1] 3

You can inspect the structure of the network for the first object using:

network <- cn[[1]]
str(network)
## List of 40
##  $ params                     :List of 27
##   ..$ TPhase_gmin      : num 37.5
##   ..$ Q10_1_gmin       : num 1.2
##   ..$ Q10_2_gmin       : num 4.8
##   ..$ Gsw_AC_slope     : num 6.24
##   ..$ gCrown0          : num 150
##   ..$ fTRBToLeaf       : num 0.8
##   ..$ C_SApoInit       : num 2e-05
##   ..$ C_LApoInit       : num 1e-05
##   ..$ k_SLApoInit      : num 8
##   ..$ k_CSApoInit      : num 1.34
##   ..$ k_RCApoInit      : num [1:4] 2.3828 0.48335 0.04257 0.00742
##   ..$ slope_gs         : num 30
##   ..$ P50_gs           : num -1.2
##   ..$ gmin20           : num 3.09
##   ..$ gsMax            : num 285
##   ..$ gmin_S           : num 3.09
##   ..$ gsNight          : num 14.2
##   ..$ VCleaf_P50       : num -4.46
##   ..$ VCleaf_slope     : num 45.9
##   ..$ VCstem_P50       : num -4.46
##   ..$ VCstem_slope     : num 45.9
##   ..$ VCroot_P50       : num -4.46
##   ..$ VCroot_slope     : num 45.9
##   ..$ PiFullTurgor_Leaf: num -1.59
##   ..$ epsilonSym_Leaf  : num 8.92
##   ..$ PiFullTurgor_Stem: num -2.01
##   ..$ epsilonSym_Stem  : num 13.3
##  $ LAI                        : num 0.849
##  $ Psi_LApo                   : num -0.033
##  $ Psi_LSym                   : num -0.033
##  $ Psi_RCApo                  : num -0.033
##  $ Psi_SApo                   : num -0.033
##  $ Psi_SSym                   : num -0.033
##  $ Psi_SApo_cav               : num 0
##  $ Psi_LApo_cav               : num 0
##  $ PsiSoil                    : num [1:4] -0.033 -0.033 -0.033 -0.033
##  $ PLC_Stem                   : num 0
##  $ PLC_Leaf                   : num 0
##  $ C_SApo                     : num 2e-05
##  $ C_LApo                     : num 1e-05
##  $ C_SSym                     : num 1239
##  $ C_LSym                     : num 1798
##  $ k_SLApo                    : num 8
##  $ k_CSApo                    : num 1.34
##  $ k_SSym                     : num 0.26
##  $ k_LSym                     : num 8
##  $ k_RSApo                    : num [1:4] 0.8575 0.35519 0.04126 0.00738
##  $ k_SoilToStem               : num [1:4] 0.85749 0.35519 0.04126 0.00738
##  $ k_Soil                     : num [1:4] 362138 50273 6359 2081
##  $ k_Plant                    : num 0.747
##  $ Q_SApo_sat_mmol_perLeafArea: num 316823
##  $ Q_LApo_sat_mmol_perLeafArea: num 10298
##  $ Q_SSym_sat_mmol_perLeafArea: num 26192
##  $ Q_LSym_sat_mmol_perLeafArea: num 18916
##  $ Einst                      : num 0
##  $ Elim                       : num 0
##  $ Elim_SL                    : num NA
##  $ Elim_SH                    : num NA
##  $ Emin_L                     : num 0
##  $ Emin_L_SL                  : num NA
##  $ Emin_L_SH                  : num NA
##  $ Emin_S                     : num 0
##  $ Diag_nwhile_cavit          : int NA
##  $ Diag_deltaRegulMax         : int NA
##  $ Diag_deltaPLCMax           : int NA
##  $ Diag_timeStepInSeconds     : int NA

Call to semi_implicit_integration()

If we modify the values of Elim, Emin_L or Emin_S, then a call to semi_implicit_integration() should update the water potentials according to these flows. The water potentials prior to the call are:

network$Psi_LApo
## [1] -0.033
network$Psi_LSym
## [1] -0.033
network$Psi_SApo
## [1] -0.033
network$Psi_SSym
## [1] -0.033

We now set the options and time step size:

opt <- c("Lsym" = 1.0, "Ssym" = 1.0, 
         "Eord" = 1.0, "Lcav" = 1.0, "Scav" = 1.0,
         "CLapo" = 1.0, "CTapo" = 1.0)

# Number of small steps per hour sub-steps
nsmalltimesteps <- c(2, 4, 8, 16)

# Seconds of the small time step (four sub-steps per hour)
dt <- 3600.0 / nsmalltimesteps[2] 

We also specify the flows and call semi_implicit_integration():

network$Elim <- 0.1
network$Emin_L <- 0.01
network$Emin_S <- 0.01

semi_implicit_integration(network, dt, opt)

The function modifies the network object, whose water potentials are now:

network$Psi_LApo
## [1] -0.033
network$Psi_LSym
## [1] -0.04649922
network$Psi_SApo
## [1] -0.033
network$Psi_SSym
## [1] -0.03962152