User Guide

Installation and usage

Installation

First, download and install Julia: https://julialang.org/downloads/. If you like you can also install julia-vscode.org to get a complete IDE. Both these steps are nicely summarized by https://techytok.com/julia-vscode/. ALternatively, you can also follow the official documentation of the VS Code Julia: https://www.julia-vscode.org/docs/dev/gettingstarted/#Installation-and-Configuration-1.

To install LWFBrook90.jl open a Julia REPL, enter the Pkg REPL by pressing ] and add the package:

(@v1.7) pkg> add LWFBrook90
(@v1.7) pkg> status

Dependencies of LWFBrook90.jl should automatically be installed. After that hit Ctrl-C to quit the Pkg REPL and return to the default Julia REPL. Now the installation can be tested with a single line using LWFBrook90; run_example().

Usage

Check out a step-by-step guide for a simulation in section Example Script 01

The steps in a typical simulation script are:

  • load the package using LWFBrook90
  • read input data model = loadSPAC()
    • optional arguments in loadSPAC() can be used to define model parameters (-> type ?loadSPAC to see documentation)
  • pre-process model for simulation simulation = setup(model)
  • compute simulation simulate!(simulation)
  • post-process and plot simulation results

LWFBrook90.jl outputs quantities in daily resolution. Monthly or yearly quantities can be derived in the post processing. ~~For performance reasons, e.g. for Bayesian parameter estimation, computation of these additional quantities can also be deactivated during simulation, and they could be calculated in a post-processing step from the state vector.~~

Input data

Overview of input data

To run a simulation following input files are expected in a single folder

  • soil_horizons.csv - containing the hydraulic parameters of the different soil horizons
  • param.csv - containing scalar model parameters
  • meteoveg.csv - containing daily values of meteorologic variables [and stand properties]
  • meteoiso.csv - containing isotopic signatures of aggregate precipitation samples
  • initial_conditions.csv - containing initial conditions of scalar state variables
  • soil_discretization.csv - containing the initial conditions of the soil water status in the form of the soil matric potential (kPa) and the initial isotopic signatures (vector state variables); parameters of relative root density distributions defined for the soil domain; as well as the definition of the numerical discretization of the soil domain (nodes with upper and lower limits).
  • meteo_storm_durations.csv - containing parameters of sub-daily storm/precipitation event patterns for each month

Of these only the CSV files for the parameters soil_horizons.csv and param.csv and the forcings meteoveg.csv, meteoiso.csv are absolutely needed. The remaing can be provided by the user as arguments to loadSPAC() in the Julia script:

  • soil_discretizations.csv: not needed if Δz_thickness_m, root_distribution, and IC_soil provided.
  • initial_conditions.csv: not needed if IC_scalar provided.
  • meteo_storm_durations.csv: not needed if storm_durations_h provided.
  • meteoveg.csv: columns with vegetation parameters are not needed if loadSPAC(canopy_evolution = ...) is provided.

The structure of the input CSV's is illustrated by the example input data sets isoBEA2010-18-* or DAV2020-bare-minimum or DAV2020-full located in the folder examples/, as well as below in this documentation. Please follow these examples closely when generating your own input files, including the exact column names and header lines containing the units.

For convenience, input CSV files can be generated from a script that sets up a simulation with the R package LWFBrook90R (v0.4.3). Instead of running the simulation with run_LWFB90(), the same arguments can be used to generate the input files for LWFBrook90.jl using the R function provided in the file generate_LWFBrook90jl_Input.R. Note that the input file meteoiso.csv needs to be generated separately and the files containing the initial conditions (initial_conditions.csv and soil_discretization.csv) also need to be extended manually with the isotope values (see structure of these input files below).

To load input data and prepare a simulation follow the instructions in section Example Script 01 or alternatively use the sample script main_with_isotopes.jl. NOTE: these will be replaced with Jupyter-notebooks generated with Literate.jl.

In case you're unfamiliar with Julia, there are various ways to run a script such as main.jl: One possibility is to open the Julia REPL and run the script using include(“main.jl”). Alternatively, the editor VS Code in combination with the Julia extension (julia-vscode.org), provides a complete IDE for programming in Julia.

Structure of input data

soil_horizons.csv: (when using Mualem-VanGenuchten parametrization of the soil retention curve):

HorizonNrUpper_mLower_mths_volFracthr_volFracalpha_perMeternpar_ksat_mmDaytort_gravel_volFrac
-mmvolume fraction (-)volume fraction (-)perMeter-mm per day-volume fraction (-)
10-0.040.71490.0691147.889191.0512324864.678394.670370.01
2-0.04-0.080.668730.0691274.886021.0510512881.486414.478280.175
3-0.08-0.20.65610.0691215.927211.0510610516.61664.501620.175
4-0.2-0.450.601590.069795.204011.050993438.062754.344890.175
5-0.45-0.750.523310.069352.368251.05097450.358024.291220.01
6-0.75-1.10.564720.069570.681681.051111488.209585.148180.01
7-1.1-1.20.467430.069164.5641.0510367.978460.010.95

meteoveg.csv: contains time dependent parameters (meterologic variables and vegetation parameters):

datesglobrad_MJDayM2tmax_degCtmin_degCvappres_kPawindspeed_msprec_mmDaydensef_percentheight_percentlai_percentsai_percent
YYYY-MM-DDMJ/Day/m2degree Cdegree CkPam per smm per daypercentpercentpercentpercent
2010-01-013.451.85-6.390.422.870.210010060100
2010-01-027.26-6.98-14.090.193.6010010060100
2010-01-035.21-1.84-13.020.121.86010010060100
.................................
2018-12-296.498.150.30.280.1010010060100
2018-12-302.833.38-1.610.390.1010010060100
2018-12-314.626.34-0.940.550.10.410010060100

If meteoveg.csv does not contain columns for DENSEF, HEIGHT, LAI, SAI, the parametrization of these should be provided to the function loadSPAC().

meteoiso.csv: contains time dependent isotopic signatures of precipiation. (Note that the dates contain the end dates of the collection interval of cumulative isotope samples. The values are backward interpolated with piecewise constants. The first row containng the NA is assumed to be the start date of the first collection interval.):

datesdelta18O_permildelta2H_permil
YYYY-MM-DDpermilpermil
2010-01-01NANA
2010-02-01-15.9-118
2010-03-01-14.5-107
.........
2021-09-30-13.8-97.67
2021-10-14-10.7-69.1
2021-10-28-9.13-58.4

meteo_storm_durations.csv:

monthaverage_storm_duration_h
### Typical average durations of a single storm event for each month –––-NA
January4
Februrary4
March4
April4
May4
June4
July4
August4
September4
October4
November4
December4

initial_conditions.csv:

param_idamountu_delta18O_init_permilu_delta2H_init_permil
### Initial conditions (of vector states) –––-NANANA
u_GWAT_init_mm1-13-95
u_INTS_init_mm0-13-95
u_INTR_init_mm0-13-95
u_SNOW_init_mm0-13-95
u_CC_init_MJ_per_m20NANA
u_SNOWLQ_init_mm0NANA

soil_discretization.csv contains the initial conditions of the soil water status, root density distributions, and the definition of the numerical discretization of the soil domain (nodes with upper and lower limits):

Upper_mLower_mRootden_uAux_PSIM_init_kPau_delta18O_init_permilu_delta2H_init_permil
mm-kPapermilpermil
0-0.040.02868-6.3-13-95
-0.04-0.080.02539-6.3-13-95
-0.08-0.20.02-6.3-13-95
-0.2-0.450.01159-6.3-10-70
-0.45-0.750.00507-6.3-10-70
-0.75-1.10.00191-6.3-10-70
-1.1-1.20.00092-6.3-10-70

param.csv contains scalar model parameters:

param_idx
### Isotope transport parameters –––-NA
### TODO42.000
### TODO242.000
VXYLEM_mm20
DISPERSIVITY_mm40
### Meteorologic site parameters –––-NA
LAT_DEG46.70052
ESLOPE_DEG18.26
ASPECT_DEG225
ALB0.2
ALBSN0.5
C10.25
C20.5
C30.2
WNDRAT0.3
FETCH5000
Z0W0.005
ZW2
### Canopy parameters –––-NA
MAXLAI2.9299999
DENSEF_baseline_1
SAI_baseline_1
AGE_baseline_yrs200
HEIGHT_baseline_m23.0
LWIDTH0.1
Z0G0.00325
Z0S0.001
LPC4
CZS0.13
CZR0.05
HS1
HR10
ZMINH2
RHOTP2
NN2.5
### Interception parameters –––-NA
FRINTLAI0.06
FSINTLAI0.04
FRINTSAI0.06
FSINTSAI0.04
CINTRL0.15
CINTRS0.15
CINTSL0.6
CINTSS0.6
RSTEMP-0.5
### Snowpack parameters –––-NA
MELFAC1.5
CCFAC0.3
LAIMLT0.2
SAIMLT0.5
GRDMLT0.35
MAXLQF0.05
KSNVP0.3
SNODEN0.3
### Leaf evaporation parameters (affecting PE) –––-NA
GLMAX0.0053
GLMIN0.0003
CR0.5
RM1000
R5100
CVPD2
TL0
T110
T230
TH40
### Plant parameters (affecting soil-water supply) –––-NA
MXKPL8
MXRTLN3000
INITRLEN12
INITRDEP0.25
RGRORATE0.03
RGROPER30
FXYLEM0.5
PSICR-2
RTRAD0.35
NOOUTF1
### Soil parameters –––-NA
IDEPTH_m0.040
QDEPTH_m0.0
RSSA100
RSSB1
INFEXP0
BYPAR0
QFPAR1
QFFC0
IMPERV0
DSLOPE0
LENGTH_SLOPE200
DRAIN1
GSC0
GSP0
### Numerical solver parameters –––-NA
DTIMAX0.5
DSWMAX0.05
DPSIMAX0.0005

Calibration data (calibration not yet implemented)

Roadmap to include calibration data intends include of:

  • Throughfall amounts (for parametrisation of interception)
  • Soil moisture (volumetric water content, θ)
  • Soil matric potential (ψ)

as well as

  • Isotopic composition of soil water (δ_soil)
  • Isotopic composition of xylem water (δ_xylem)

Below the example structure of data sets for psi.csv contains the soil matric potential (ψ) of different sensor series or as site average:

datesdepth_cmdepthnominalcmpsi_kPaseries
YYYY-MM-DDcmcmkPaSITEAVG
2022-08-301515-5.77SITEAVG
2022-08-30200150-2.87SITEAVG
2022-08-30300150-0.10SITEAVG
2022-08-305050-1.98SITEAVG
2022-08-318080-0.13SITEAVG
2022-08-311515-7.53SITEAVG
2022-08-31200150-2.95SITEAVG
2022-08-31300150-0.10SITEAVG
2021-06-175050-3.00SITEAVG
2021-06-178080-0.17SITEAVG
...............

theta.csv contains the soil moisture (volumetric water content, θ):

datesdepth_mtheta_m3m3
YYYY-MM-DDmm3/m3
2020-12-230.150.24
2020-12-230.500.32
2020-12-230.800.30
2020-12-240.150.24
2020-12-240.500.32
.........

delta_soil.csv contains the isotopic signature of soil water:

datesdepth_mdelta18O_permildelta2h_permil
YYYY-MM-DDcmpermilpermil
2020-07-070-5.89-35.96
2020-07-0715-8.75-57.99
2020-07-0750-8.81-59.12
2020-07-0780-9.72-65.41
2020-07-210-5.83-29.54
2020-07-2115-8.73-53.58
2020-07-2150-9.31-58.47
2020-07-2180-10.14-64.71
............

delta_xylem.csv contains the isotopic signature of xylem water:

datesspeciestreeIDdelta18O_permildelta2H_permil
YYYY-MM-DD--permilpermil
2021-08-03Beech271-8.416-72.562
2021-08-03Beech3518-8.946-76.543
2021-08-03Beech3519-8.484-72.523
2021-08-17Beech271-8.378-76.044
2021-08-17Beech3518-8.769-76.036
2021-08-17Beech3519-8.135-70.475
...............