GwRetention: Calculate groundwater retention of nutrients

View source: R/function_GwRetention.R

GwRetentionR Documentation

Calculate groundwater retention of nutrients

Description

Function to calculate nutrient load retention fractions in groundwater parts of HYPE, i.e. after root zone retention. See Details for exact definition.

Usage

GwRetention(nfrz, nfs3, gts3, gd, par, unit.area = TRUE, nutrient = "tn")

Arguments

nfrz

Data frame with two-columns. Sub-basin IDs in first column, net loads from root zone in kg/year in second column. Typically an imported HYPE map output file, HYPE output variable SL06. See Details.

nfs3

Data frame with two-columns. Sub-basin IDs in first column, net loads from soil layer 3 in kg/year in second column. Typically an imported HYPE map output file, HYPE output variable SL18. See Details.

gts3

Data frame with two-columns. Sub-basin IDs in first column, gross loads to soil layer 3 in kg/year in second column. Typically an imported HYPE map output file, HYPE output variable SL17. See Details.

gd

Data frame, with columns containing sub-basin IDs and rural household emissions, e.g. an imported 'GeoData.txt' file. See details.

par

List, HYPE parameter list, typically an imported 'par.txt' file. Must contain parameter locsoil (not case-sensitive).

unit.area

Logical, set to FALSE to calculate incoming load (leaching rates) in kg/year instead of kg/(ha year).

nutrient

Character keyword, one of the HYPE-modeled nutrient groups, for which to calculate groundwater retention. Not case-sensitive. Currently, only tn (total nitrogen) is implemented.

Details

GwRetention calculates a groundwater nutrient retention as fractions of outgoing and incoming loads using HYPE soil load variables. Incoming loads include drainage into layer 3 from the root zone (defined as soil layer 1 and 2), rural load fractions into soil (dependent on parameter locsoil), tile drainage, surface flow, and flow from layer 1 and 2. Outgoing loads include runoff from all soil layers, tile drain, and surface flow.

The retention fraction R is calculated as (see also the variable description in the HYPE online documentation):

R = 1 - \frac{OUT}{IN} = 1 - \frac{nfrz - gts3 + nfs3 + locsoil * lr}{nfrz + locsoil * lr} -

li = nfrz + locsoil * lr [kg/y]

lr = LOC_VOL * LOC_TN * 0.365 [kg/y]

, where li is incoming load to groundwater (leaching rates), lr is rural load (total from GeoData converted to kg/yr; locsoil in the formula converts it to rural load into soil layer 3), and nfrz, gts3, nfs3 are soil loads as in function arguments described above. See Examples for HYPE variable names for TN loads.

Columns SUBID, LOC_VOL, and LOC_TN must be present in gd, for a description of column contents see the GeoData file description in the HYPE online documentation. Column names are not case-sensitive.

Value

GwRetention returns a three-column data frame, containing SUBIDs, retention in groundwater as a fraction of incoming loads (if multiplied by 100, it becomes \ .

Examples

# Create dummy data
te1 <- ReadGeoData(filename = system.file("demo_model",
"GeoData.txt", package = "HYPEtools"))
te1$loc_tn <- runif(n = nrow(te1), min = 0, max = 100)
te1$loc_vol <- runif(n = nrow(te1), min = 0, max = 2)
te2 <- ReadPar(filename = system.file("demo_model",
"par.txt", package = "HYPEtools"))
te2$locsoil <- .3
# HYPE soil load (sl) variables for TN, dummy loads
GwRetention(nfrz = data.frame(SUBID = te1$SUBID, SL06 = runif(n = nrow(te1), 10, 50)), 
            gts3 = data.frame(SUBID = te1$SUBID, SL17 = runif(n = nrow(te1), 10, 50)), 
            nfs3 = data.frame(SUBID = te1$SUBID, SL18 = runif(n = nrow(te1), 10, 50)), 
            gd = te1, par = te2)


HYPEtools documentation built on Sept. 11, 2024, 8:34 p.m.