knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
is_windows <- .Platform$OS.type == "windows"

The workflow below describes all the steps required for:

  1. Running it from within R by using the command line (cmd) and

  2. Importing and Analysing the HYDRUS1D results within R.

Install R Package

# Enable this universe
options(repos = c(
  kwbr = 'https://kwb-r.r-universe.dev',
  CRAN = 'https://cloud.r-project.org'))
# Install R package
install.packages('kwb.hydrus1d')

Define Paths

paths_list <- list(
  exe_dir = system.file("extdata/model", package = "kwb.hydrus1d"),
  model_name = "test",
  model_dir = "<exe_dir>/<model_name>",
  atmosphere = "<model_dir>/ATMOSPH.IN",
  a_level = "<model_dir>/A_LEVEL.out",
  t_level = "<model_dir>/T_LEVEL.out",
  runinf = "<model_dir>/Run_Inf.out",
  solute_id = 1L,
  solute = "<model_dir>/solute<solute_id>.out"
)

paths <- kwb.utils::resolve(paths_list)

Run Model

exe_path <- kwb.hydrus1d::check_hydrus_exe(dir = paths$exe_dir,
                                           skip_preinstalled = TRUE)
kwb.hydrus1d::run_model(exe_path = exe_path,
                        model_path = paths$model_dir)

Read Results

a_level <- kwb.hydrus1d::read_alevel(paths$a_level)
a_level

t_level <- kwb.hydrus1d::read_tlevel(paths$t_level)
t_level

runinf <- kwb.hydrus1d::read_runinf(paths$runinf)
runinf

solute <- kwb.hydrus1d::read_solute(paths$solute)
solute


KWB-R/kwb.hydrus1d documentation built on Nov. 21, 2022, 4:54 a.m.