Title: | R Interface for the Last Official Release of Hydrus1D (V4.17.0140) for Windows |
---|---|
Description: | R Interface for the Last Official Release of Hydrus1D (v4.17.0140) for Windows. |
Authors: | Michael Rustler [aut, cre] , Hauke Sonnenberg [ctb] , FlexTreat [fnd], Kompetenzzentrum Wasser Berlin gGmbH (KWB) [cph] |
Maintainer: | Michael Rustler <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.0.9000 |
Built: | 2024-11-08 02:56:50 UTC |
Source: | https://github.com/KWB-R/kwb.hydrus1d |
Check HYDRUS Executable and download if needed
check_hydrus_exe( dir = file.path(system.file(package = "kwb.hydrus1d"), "extdata/hydrus1d"), skip_preinstalled = FALSE )
check_hydrus_exe( dir = file.path(system.file(package = "kwb.hydrus1d"), "extdata/hydrus1d"), skip_preinstalled = FALSE )
dir |
target directory (default: file.path(system.file(package = "kwb.hydrus1d"), "extdata/hydrus1d"), in case compliant HYDRUS1D version is not available, executable will be downloaded from https://github.com/mrustl/hydrus1d/archive/refs/tags/v4.17.0140.zip |
skip_preinstalled |
if TRUE checking of preinstalled HYDRUS-1D will be skipped and executable will be downloaded, otherwise not (the default) |
path to preinstalled HYDRUS-1D executable (if compliant and parameter skip_preinstalled == FALSE), otherwise path to downloaded HYDRUS-1D
check_hydrus_exe(skip_preinstalled = FALSE) check_hydrus_exe(skip_preinstalled = TRUE)
check_hydrus_exe(skip_preinstalled = FALSE) check_hydrus_exe(skip_preinstalled = TRUE)
Defaults for Atmosphere
defaults_atmosphere( Prec = 0L, rSoil = 0L, rRoot = 0L, hCritA = 100000L, rB = 0L, hB = 0L, ht = 0L, tTop = 0L, tBot = 0L, Ampl = 0L, cTop = 0L, cBot = 0L, RootDepth = 0L )
defaults_atmosphere( Prec = 0L, rSoil = 0L, rRoot = 0L, hCritA = 100000L, rB = 0L, hB = 0L, ht = 0L, tTop = 0L, tBot = 0L, Ampl = 0L, cTop = 0L, cBot = 0L, RootDepth = 0L )
Prec |
Precipitation (default: 0) |
rSoil |
Evaporation (default: 0) |
rRoot |
Transpiration (default: 0) |
hCritA |
(default: 100000) |
rB |
rB (default: 0) |
hB |
hB (default: 0) |
ht |
ht (default: 0) |
tTop |
tTop (default: 0) |
tBot |
tBot (default: 0) |
Ampl |
Ampl (default: 0) |
cTop |
concentration of solute 1 at top (default: 0) |
cBot |
concentration of solute 1 at bottom (default: 0) |
RootDepth |
root depth (default: 0) |
tibble with defaults for atmospheric parameters
defaults_atmosphere()
defaults_atmosphere()
Get Atmosphere Headers
get_atmosphere_headers()
get_atmosphere_headers()
vector with atmosphere headers for "ATMOSPH.in"
get_atmosphere_headers()
get_atmosphere_headers()
Helper Function: Get Metadata of Outputs ('A_LEVEL.out', 'T_LEVEL.out')
get_output_meta(output)
get_output_meta(output)
output |
imported output as retrieved by |
returns metainformation list with sublists "general" and "units" of imported 'A_LEVEL.out' or 'T_LEVEL.out' file
test_file <- function(x) system.file("extdata/model/test", x, package = "kwb.hydrus1d") alevel <- read_alevel(path = test_file("A_LEVEL.out")) get_output_meta(alevel) tlevel <- read_tlevel(path = test_file("T_LEVEL.out")) get_output_meta(tlevel)
test_file <- function(x) system.file("extdata/model/test", x, package = "kwb.hydrus1d") alevel <- read_alevel(path = test_file("A_LEVEL.out")) get_output_meta(alevel) tlevel <- read_tlevel(path = test_file("T_LEVEL.out")) get_output_meta(tlevel)
Helper function: get units list from meta general
get_units_list(meta_general)
get_units_list(meta_general)
meta_general |
as retrieved by |
list with elements unit_L, unit_T and unit_M
path_tlevel <- system.file("extdata/model/test/T_LEVEL.out", package = "kwb.hydrus1d") content <- readLines(path_tlevel) content_general <- content[3:5] cat(content_general) meta_general <- read_meta_general(content_general) get_units_list(meta_general)
path_tlevel <- system.file("extdata/model/test/T_LEVEL.out", package = "kwb.hydrus1d") content <- readLines(path_tlevel) content_general <- content[3:5] cat(content_general) meta_general <- read_meta_general(content_general) get_units_list(meta_general)
Prepare Atmosphere Input
prepare_atmosphere_input(inputs, defaults = defaults_atmosphere())
prepare_atmosphere_input(inputs, defaults = defaults_atmosphere())
inputs |
tibble or data.frame with user defined inputs for parameters
defined in |
defaults |
defaults for undefined parameters. Default:
|
tibble with atmosphere values
inputs <- tibble::tibble(tAtm = 1:10, Prec = 10, rSoil = 0.4) prepare_atmosphere_input(inputs)
inputs <- tibble::tibble(tAtm = 1:10, Prec = 10, rSoil = 0.4) prepare_atmosphere_input(inputs)
A-level information is printed each time a time-dependent boundary condition is specified. The information is directed to output file A_LEVEL.OUT.
read_alevel(path, dbg = FALSE)
read_alevel(path, dbg = FALSE)
path |
full path to A_LEVEL.out file |
dbg |
show debug messages (default: FALSE) |
imports A_LEVEL out with tidy column names and saves metainformation in attributes 'meta_general' and 'meta_units'
Time, t, at current time-level [T]
Cumulative potential surface flux [L] (infiltration/evaporation: -/+)
Cumulative potential transpiration [L]
Cumulative value of the actual surface flux [L] (infiltration/evaporation: -/+) [-]
Cumulative value of the actual transpiration [L]
Cumulative value of the bottom boundary flux [L] (inflow/outflow: +/-)
Pressure head at the soil surface [L]
Mean value of the pressure head in the soil root zone for which Beta(n)>0 [L]
Pressure head at the bottom of the soil profile [L]
A-level number (current variable boundary condition number) [-]
https://www.pc-progress.com/Downloads/Pgm_Hydrus1D/HYDRUS1D-4.17.pdf#page=277
path_alevel <- system.file("extdata/model/test/A_LEVEL.out", package = "kwb.hydrus1d") alevel <- read_alevel(path = path_alevel) alevel
path_alevel <- system.file("extdata/model/test/A_LEVEL.out", package = "kwb.hydrus1d") alevel <- read_alevel(path = path_alevel) alevel
Helper Function: Read Meta General
read_meta_general(content_general)
read_meta_general(content_general)
content_general |
lines with content general (see example) |
tibble with columns description, modelstart_datetime and unit L,T,M
path_tlevel <- system.file("extdata/model/test/T_LEVEL.out", package = "kwb.hydrus1d") content <- readLines(path_tlevel) content_general <- content[3:5] cat(content_general) read_meta_general(content_general)
path_tlevel <- system.file("extdata/model/test/T_LEVEL.out", package = "kwb.hydrus1d") content <- readLines(path_tlevel) content_general <- content[3:5] cat(content_general) read_meta_general(content_general)
Contains time and iteration information
read_runinf(path, dbg = FALSE)
read_runinf(path, dbg = FALSE)
path |
full path to Run_Inf.out file |
dbg |
show debug messages (default: FALSE) |
imports Run_Inf.out with tidy column names and saves metainformation in attributes 'meta_general' and 'meta_units'
Time-level (current time-step number) [-]
Time, t, at current time-level [T]
Time step, delta t [T]
Number of iterations necessary for solution of the water flow equation [-]
Number of iterations necessary for solution of the solute transport equation [-]
Cumulative number of iterations [-]
Code for the boundary condition at the soil surface
Code for the boundary condition at the bottom of the soil profile
Information whether or not the numerical convergence was achieved at the current time-level
Maximum local Peclet number [-]
Maximum local Courant number [-]
https://www.pc-progress.com/Downloads/Pgm_Hydrus1D/HYDRUS1D-4.17.pdf#page=272
path_runinf <- system.file("extdata/model/test/Run_Inf.out", package = "kwb.hydrus1d") runinf <- read_runinf(path = path_runinf) runinf
path_runinf <- system.file("extdata/model/test/Run_Inf.out", package = "kwb.hydrus1d") runinf <- read_runinf(path = path_runinf) runinf
Reads Solute output
read_solute( path = system.file("extdata/model/test/solute1.out", package = "kwb.hydrus1d"), dbg = FALSE )
read_solute( path = system.file("extdata/model/test/solute1.out", package = "kwb.hydrus1d"), dbg = FALSE )
path |
full path to solute_id.out file (default: system.file("extdata/model/test/solute1.out", package = "kwb.hydrus1d")) |
dbg |
show debug messages (default: FALSE) |
imports solute_id.out with tidy column names and saves metainformation in attributes 'meta_general' and 'meta_units'
Time, t, at current time-level [T]
Actual solute flux across the soil surface [ML-2 T -1] (inflow/outflow: +/-)
Actual solute flux across the bottom of the soil profile [ML-2 T -1] (inflow/outflow: +/-)
Cumulative solute flux across the soil surface [ML-2] (inflow/outflow: +/-)
Cumulative solute flux across the bottom of the soil profile [ML-2] (inflow/outflow: +/-)
Cumulative amount of solute added to the flow region by zero-order reactions [ML-2] (negative when removed from the system)
Cumulative amount of solute removed from the flow region by first-order reactions [ML-2] (negative removed from the system).
Solute concentration at the soil surface [ML-3]
Mean solute concentration of the root zone [ML-3]
Solute concentration at the bottom of the soil profile [ML-3]
Actual root solute uptake in the root zone [ML-2 T -1] (positive when removed from the system)
Cumulative amount of solute removed from the flow region by root water uptake S [ML-2] (positive when removed from the system)
Cumulative mass transfer to either kinetic adsorption sites (type-2 adsorption sites), or to the immobile liquid region [ML-2] (inflow/outflow: +/-).
Time-level (current time-step number) [-]
Average concentration in the saturated zone [ML-3] (in the groundwater)
Solute flux in the runoff ([ML-3] * [LT-1]) [ML-2T-1]
Cumulative solute flux in the runoff ([ML-3] * [LT-1]* [T]) [ML-2]
Solute flux at the first through third observation node ([ML-3] * [LT-1]) [ML-2T-1]
cumulative solute flux at the first through third observation node ([ML-3] * [LT-1] * [T]) [ML-2]. Total solute fluxes are reported when only one solute is simulated. Only convective fluxes (for the first solute) are reported when 2 or more solutes are simulated
https://www.pc-progress.com/Downloads/Pgm_Hydrus1D/HYDRUS1D-4.17.pdf#page=273
path_solute <- system.file("extdata/model/test/solute1.out", package = "kwb.hydrus1d") solute <- read_solute(path = path_solute) solute
path_solute <- system.file("extdata/model/test/solute1.out", package = "kwb.hydrus1d") solute <- read_solute(path = path_solute) solute
Stores pressure heads and fluxes on the boundaries and in the root zone.
read_tlevel(path, dbg = FALSE)
read_tlevel(path, dbg = FALSE)
path |
full path to T_LEVEL.out file |
dbg |
show debug messages (default: FALSE) |
imports T_LEVEL out with tidy column names and saves metainformation in attributes 'meta_general' and 'meta_units'
Time, t, at current time-level [T]
Potential surface flux [LT-1] (infiltration/evaporation: -/+)
Potential transpiration rate [LT-1]
Actual surface flux [LT-1] (infiltration/evaporation: -/+)
Actual transpiration rate [LT-1]
Actual flux across the bottom of the soil profile [LT-1] (inflow/outflow +/-)
Cumulative value of the potential surface flux [L] (infiltration/evaporation: -/+)
Cumulative value of the potential transpiration rate [L]
Cumulative value of the actual surface flux [L]
Cumulative value of the actual transpiration rate [L] (infiltration/evaporation: -/+)
Cumulative value of the actual flux across the bottom of the soil profile [LT-1] (inflow/outflow +/-)
Pressure head at the soil surface [L]
Mean value of the pressure head over the region for which Beta(n) > 0 (i.e. within the root zone) [L]
Pressure head at the bottom of the soil profile [L]
Surface runoff [LT-1]
Cumulative surface runoff [L]
Volume of water in the entire flow domain [L]
Cumulative infiltration [L]
Cumulative actual evaporation [L]
Time-level (current time-step number) [-]
Cumulative mass transfer between the mobile and immobile regions for dual porosity model [L]
Thickness of snow layer, expressed as the "snow water equivalent" (the amount of water contained within the snowpack) [L]
https://www.pc-progress.com/Downloads/Pgm_Hydrus1D/HYDRUS1D-4.17.pdf#page=271
path_tlevel <- system.file("extdata/model/test/T_LEVEL.out", package = "kwb.hydrus1d") tlevel <- read_tlevel(path = path_tlevel) tlevel
path_tlevel <- system.file("extdata/model/test/T_LEVEL.out", package = "kwb.hydrus1d") tlevel <- read_tlevel(path = path_tlevel) tlevel
Run Model
run_model( exe_path = check_hydrus_exe(), model_path = system.file("extdata/model/test", package = "kwb.hydrus1d"), ... )
run_model( exe_path = check_hydrus_exe(), model_path = system.file("extdata/model/test", package = "kwb.hydrus1d"), ... )
exe_path |
path to Hydrus1D executable v4.17.040 (default: as retrieved
by |
model_path |
path to model directory (default: system.file("extdata/model/test", package = "kwb.hydrus1d")) |
... |
additional arguments passed to |
runs HYDRUS 1D model
run_model()
run_model()
Write "ATMOSPH.IN" input file
write_atmosphere( atm, MaxAL = 365, DailyVar = FALSE, SinusVar = FALSE, lLai = FALSE, lBCCycles = FALSE, lInterc = FALSE, hCritS = 0, round_digits = 2, remove_scientific = TRUE )
write_atmosphere( atm, MaxAL = 365, DailyVar = FALSE, SinusVar = FALSE, lLai = FALSE, lBCCycles = FALSE, lInterc = FALSE, hCritS = 0, round_digits = 2, remove_scientific = TRUE )
atm |
tibble of input data as defined in |
MaxAL |
Number of meteorological records |
DailyVar |
TRUE if HYDRUS-1D is to generate daily variations in evaporation and transpiration (see section 2.7.2.)., otherwise: FALSE (default: FALSE) |
SinusVar |
TRUE if HYDRUS-1D is to generate sinusoidal variations in precipitation (see section 2.7.2.), otherwise: FALSE(default: FALSE) |
lLai |
Logical variable indicating that potential evapotranspiration is to be divided into potential evaporation and potential transpiration using eq. (2.75). (default: FALSE) |
lBCCycles |
TRUE if a set of boundary conditions is to be repeated multiple times, otherwise FALSE(default: FALSE) |
lInterc |
TRUE if interception is considered using eq. (2.78), otherwise FALSE (default: FALSE) |
hCritS |
Maximum allowed pressure head at the soil surface (L). (default: 0) |
round_digits |
digits used for rounding values (default: 2) of all columns besides "tAtm" |
remove_scientific |
if TRUE scientific notation of numbers is removed, otherwise not (default: TRUE) |
Creates ATMOSPH.IN input textfile
inputs <- tibble::tibble(tAtm = 1:10, Prec = 10, rSoil = 0.4) atm <- prepare_atmosphere_input(inputs) atm atm_string <- write_atmosphere(atm = atm, MaxAL = nrow(atm)) cat(atm_string)
inputs <- tibble::tibble(tAtm = 1:10, Prec = 10, rSoil = 0.4) atm <- prepare_atmosphere_input(inputs) atm atm_string <- write_atmosphere(atm = atm, MaxAL = nrow(atm)) cat(atm_string)