- NPZ model()
- Tracer_Model()
- Salinity_Model()
- SFG()
- Filterfeeders()
- car_cap()
- Extinction()
- InitialCond()
- boundary_cond()
- Read_Runfile()
- select_model()
- select_scheme()
- Read_Parms()
- Transp_1C()
- Transp_4C()
- Transp_28C()
- irradiation()
- water_temperature()
- load_packages()
- post_proc()
- statevars()
- Png()
- DemoColors()
- LL2RD()
- RD2LL()
- load_packages()
- Shiny_*()
The model functions are located as R scripts in the subdirectory Rfunctions. The name of the script corresponds to the name of the function.
NPZ model()
Function describing the processes of the NPZ model. The function is called by the main model (Demo_Main.R) when the Type in the is “NPZ”. The NPZ model contains 9 state variables (DIN, Phyto, Zoo, Det, Bot_Det, Oys, Mus, Coc and MPB). In the model the formulation for primary production, zooplankton dynamics, mineralization of detritus in the water column and in the bottom is given. For the dynamics of shellfish (oysters, mussels and cockles), a call to the function SFG() is made. For the exchange of the pelagic state variables between the compartments, a call to the appropriate transport functions (Transp_1C(), Transp_4C() or Transp_28C()) is made.
Tracer_Model()
This function describes the tracer model. The function is called by the main model (Demo_Main.R) when the Type (set in Runfile*.txt) is “Tracer”. The tracer model describes the dynamics of a tracer. It is possible to give the tracer a first-order decay rate (value of parameter r in the parameter file > 0). If the value of parameter r in the parameter file = 0, the tracer is inert.
Salinity_Model()
This function describes the salinity model. The function is called by the main model (Demo_Main.R) when the Type (set in Runfile*.txt) is “Salinity”. The salinity model describes the dynamics of salinity. In the model, salinity is only influenced by transport, salinity in the North Sea (assumed to be constant 30 ppt) and the discharge of freshwater through Krammersluizen
SFG()
This function calculates the physiology of the shellfish species (Mus, Oys and Coc) based on a Scope-For-Growth formulation. First, the individual clearance rate is calculated based on the size (gAFDW) of the shellfish and the species specific parameters. From that the filtration rates of the food (phytoplankton, zooplankton and detritus) is calculated. Ingestion and assimilation rates are calculated using the food preference (or feeding efficiency) for the different food sources. The respiration is composed of basal respiration and cost for growth. Growth is calculated from the difference between the assimilation and respiration. All rates are expressed as mmol N m-2 d-1 and returned to the model. This SFG() function is called by the function “NPZ_Model()” and replaces the more simple function “Filterfeeders()”.
Filterfeeders()
This is simple function for the physiology of shellfish species (Mus, Oys and Coc). Grazing rate of phytoplankton, zooplankton and detritus is calculated from the maximum clearance rate and the carrying capacity. Growth is calculated from the difference between grazing rate and the sum of faeces production, pseudo-faeces production, excretion and respiration. This function can be called from the function “NPZ_Model()”. An alternative for this function is the function “SFG.R”, which gives a better representation of physiology.
car_cap()
This function calculates the carrying capacity parameters for each year in the simulation where modeloutput is available before February 15th (julday 45) and after November 15th (julday 319). The following parameters are calculated:
- PP [gC m-2 yr-1]: yearly primary production, calculated from the mean DINuptake multiplied by 365
- Chla [mg Chla m-3]: average phytoplankton concentration over the year.
- PT [d]: production time in days is the ratio between the average chlorophyll-a concentration (in units of gC m-2) and the yearly primary production.
- RT [d]: average residence time of the water in the compartment is derived from the tracer study.
- CT [d]: average clearance time is calculated from the water depth [m] divided by the average clearance rate [m3 m-2 d-1] over the year.
- CR [-]: clearance ratio is calculated from the average clearance time (CT) divided by the average residence time (RT);
- GR [-]: grazing ratio is calculated from the average clearance time (CT) divided by the average production time (PT)
Extinction()
Function to calculate extinction coefficient (k_{d}
, [d-1]) as a function of time. The function is described in Los & Wijsman (2007). Extinction is influenced by background extinction, extinction by humus in freshwater fraction (Salinity), algae (self shading), particulate organic Carbon (POC) and inorganic particles (SS). At present extinction due to algae and POC is neglected. Extinction due to inorganic particles is calculated as a function of the monthly averaged suspended solid concentration in the Oosterschelde (Cosine function).
InitialCond()
This function sets the initial conditions of the state variables for the model run. The initial conditions can be read either from a text file (Init_manual = T) or from a previous model run (Init_manual = F). In the first case, the initial conditions are read from a *.txt file located in the subdirectory “./InitialCond/”. For each state variable the starting concentration is set. Initial conditions have the same value for all compartments. State variables for shellfish are converted from g FW to mmol N m-2. In the case that the initial conditions are read from the results of a previous model run the values of the state variables are read from the file "init_*.rds" in the subdirectory "./ModelOutput/".
boundary_cond()
This function calculates the boundary conditions for the model. There are boundary conditions for the North Sea, the Krammersluizen and Bergse Diepsluis. For the NPZ model, boundary conditions are based on measurements included the water quality data (specified in the runfile). The measurements from location WALCHRN2 are used for the boundary conditions at the North Sea boundary; the measurements from location STEENBGN are used for the boundary conditions at Krammersluizen and the measurements at location OESTDM are used for boundary conditions at Berse diepsluis. Boundary conditions can be based on yearly varying measurements (RealForcing = T) or on average, seasonal varying conditions (RealForcing = F). It is assumed that the discharge rates at the Krammersluizen and Bergse Diepsluis are constant (units of m3 s-1). The results are stored as approxfun() functions which allows for linear interpolation between two data points in the model.
Read_Runfile()
This function reads the specific runfile from the directory “./Runfiles/”. The parameters set in the runfile (Type, Scheme, RefDate, outtimes, Prog_bar, Parfile, RealForcing, WQfile, Init_manual, Init_file, Init_model, Lightfile and Tempfile) are returned as a list and are available for the model run.
select_model()
Function to choose the selected type of model (NPZ, Salinity or Tracer).
select_scheme()
Function to select the transport function for a scheme ("0D","4Comp","28Comp"). In this function also the freshwater discharge from the Krammersluizen is defined.
Read_Parms()
This function reads the model parameters from the text (*.txt) file located in the subdirectory “./Parameters/”. The name of the parameter file is defined in the runfile.
Transp_1C()
This function describes the exchange rates of water between the compartments and with the North Sea for the 0D model. In this case, only exchange with the North Sea is defined in m3 d-1, since the model has only one compartment.
Transp_4C()
This function describes the exchange rates of water between the compartments and with the North Sea for the model with the four compartments. All exchange rates are defined in m3 d-1. The exchange rates are calculated in the tracer study.
Transp_28C()
This function describes the exchange rates of water between the compartments and with the North Sea for the model with the 28 compartments. All exchange rates are defined in m3 d-1. The exchange rates are calculated in the tracer study.
irradiation()
Function to read irradiation data from the KNMI file (*.rds). Data are returned as an approxfun().
water_temperature()
Function to read data with water temperatures from the file with water temperature data (*.rds). Data are returned as an approxfun().
load_packages()
Function to load the R-packages needed for the model.
post_proc()
Function with post-processing of the data. Data with model results are stored in the subdirectory “./Modeloutput/”. For the NPZ model, a number of carrying capacity parameters (PP, Chla, PT, RT, CT, CR, and GR) are calculated using the function car_cap(). The modelresults are stored as "out_*.rds", the information of the model simulation is stored as "run_*.rds", the carrying capacity parameters are stored as "agg_*.rds", the model output variables are stored as "var_*.rds" and values of the state variables at the end of the simulation are stored as "init_*.rds". The last file can be used to generate initial conditions for a new model simulation.
statevars()
Function to produce an array with the state variables of a modelrun. Input is the modeltype.
Png()
Function to save a figure as *.png file in the subdirectory "./Figures/".
DemoColors()
Color palettes for the figures and the Shiny app.
LL2RD()
Function to convert spatial data points from WGS84 to RD. Input is a dataframe with the latitude and longitude in decimal degrees. Output is a dataframe with the x and y coordinates in RD.
RD2LL()
Function to convert spatial data points from RD to WGS84. Input is a dataframe with the x and y coordinates in RD. Output is a dataframe with the latitude and longitude in decimal degrees.
load_packages()
Function to loads the R-packages needed for the model.
Shiny_*()
Specific functions used by the shiny function.