Title: | Interface to VS2DH |
---|---|
Description: | Interface to the open-source model USGS model VS2DH for simulation of water and energy transport in variable-saturated porous media (for more information see: http://wwwbrr.cr.usgs.gov/projects/GW_Unsat/vs2di1.3/). |
Authors: | Michael Rustler [aut, cre] |
Maintainer: | Michael Rustler <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.0.9000 |
Built: | 2025-02-09 02:59:09 UTC |
Source: | https://github.com/KWB-R/kwb.vs2dh |
Helper function: checks whether operating system is windows or linux
checkOperatingSystem()
checkOperatingSystem()
os <- checkOperatingSystem() ### if function shell() is not available -> linux" os ### return operating system
os <- checkOperatingSystem() ### if function shell() is not available -> linux" os ### return operating system
Helper function: convert basic config to FORTRAN style
convBasic(baseConf, dbg = TRUE)
convBasic(baseConf, dbg = TRUE)
baseConf |
with basic parameterisation, i.e. conf$basic |
dbg |
If TRUE debug messages are printed on the screen (default: TRUE) |
Basic configuration in FORTRAN style
Helper function: convert string vector to numeric matrix
convertStringVectorToMatrix(values, splitSep = " ", byrow = TRUE, rows = length(values), toNumeric = TRUE)
convertStringVectorToMatrix(values, splitSep = " ", byrow = TRUE, rows = length(values), toNumeric = TRUE)
values |
character vector to be converted to matrix |
splitSep |
seperator used as split parameter in function strsplit (Default: " ") |
byrow |
If TRUE matrix is filled by rows first. Default: TRUE |
rows |
for constructing matrix: Default: length(values) |
toNumeric |
If true values will be converted to numeric, if FALSE not |
Returns matrix with nrows equals to length of values input vector
Helper function: converts string to windows path
convertToWindowsPath(path, sep = "\\/")
convertToWindowsPath(path, sep = "\\/")
path |
path string to be converted to windows path |
sep |
seperator which default: "/", which is used on unix and for R) |
unixPath <- "/usr/model/vs2dh" winPath <- convertToWindowsPath(path=unixPath) winPath
unixPath <- "/usr/model/vs2dh" winPath <- convertToWindowsPath(path=unixPath) winPath
Helper function: converting initial conditions to FORTRAN style
convInitial(iniConf, dbg = TRUE)
convInitial(iniConf, dbg = TRUE)
iniConf |
config with soils parameterisation, i.e. conf$initial |
dbg |
If TRUE debug messages are printed on the screen (default: TRUE) |
Soil configuration in FORTRAN style
Helper function: converts matrix to one string
convMatrixByRowToString(matr, colSep = " ", rowSep = "\n")
convMatrixByRowToString(matr, colSep = " ", rowSep = "\n")
matr |
matrix with character data |
colSep |
seperator used for merging data from all columns for each row (default: " ") |
rowSep |
seperator used for separating the data of different rows (default: "newline") |
One string with each row separated with rowSep
Helper function: converting recharge periods to FORTRAN style
convRecharge(rechConf, dbg = TRUE)
convRecharge(rechConf, dbg = TRUE)
rechConf |
config with recharge period parameterisation, i.e. conf$recharge |
dbg |
If TRUE debug messages are printed on the screen (default: TRUE) |
Recharge periods configuration in FORTRAN style
Helper function: converting soils structure to FORTRAN style
convSoils(conf, dbg = TRUE)
convSoils(conf, dbg = TRUE)
conf |
config with R model parameterisation, i.e. conf |
dbg |
If TRUE debug messages are printed on the screen (default: TRUE) |
Soil configuration in FORTRAN style
Helper function: Cut string by pattern
cutStringByPattern(pattern, endString = TRUE, txt)
cutStringByPattern(pattern, endString = TRUE, txt)
pattern |
pattern to be searched for in string |
endString |
if TRUE the string after the search pattern is returned, if
FALSE from the beginning until the search pattern (only evaluated if pattern
|
txt |
string or vector of strings to be searched for in string |
Returns only partial string(s) depending on the cut pattern and until the end of each string
### Path to your vs2dh model directory string = "A B C D" pattern = "B " cutStringByPattern(pattern=pattern, txt=string)
### Path to your vs2dh model directory string = "A B C D" pattern = "B " cutStringByPattern(pattern=pattern, txt=string)
Helper function: filtering lines
filterLines(pattern, patternNameCol = "txt", data, startLineOffset = 0, input, lineCol = "Line")
filterLines(pattern, patternNameCol = "txt", data, startLineOffset = 0, input, lineCol = "Line")
pattern |
pattern which lines are searched |
patternNameCol |
for pattern like "/B25" use: "txt", for para names use "paraNames", (Default: "txt") |
data |
as retrieved by prepareImport()$res |
startLineOffset |
offset of starting line: 0 (if parName is in same row as parVal, 1 if parVal is one row after parName) |
input |
as retrieved by prepareImport()$input |
lineCol |
Default "Line" |
Helper function: formatting R elments to FORTRAN style
fortranFormat(conf)
fortranFormat(conf)
conf |
as retrieved by vs2dhConfigure() |
config with prepared FORTRAN formatting style (only TRUE/FALSE values will be replaced during vs2dh.writeConfig()
Helper function: imports matrices (jtex, hvalues, tvalues)
importMatrices(prepData, dbg = TRUE)
importMatrices(prepData, dbg = TRUE)
prepData |
object as retrieved by prepareImport() |
dbg |
prints debug information on the screen |
Matrix values (always: soil, if available: initial pressure head & temperature distribution) model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") inp <- prepareImport(model.path) grid <- importMatrices(inp) #### Soil properties matrix vs2dh.plotMatrix(data = grid$jtex) #### Initial temperature distribution matrix vs2dh.plotMatrix(data = grid$tvalues)
Helper function: imports matrix values of vs2dh.dat
importMatrix(prepData, pattern = "JTEX", patternNameCol = "parNames", startLineOffset = 0, msg = "B9: Importing soil matrix...", nrow = NULL, dbg = TRUE)
importMatrix(prepData, pattern = "JTEX", patternNameCol = "parNames", startLineOffset = 0, msg = "B9: Importing soil matrix...", nrow = NULL, dbg = TRUE)
prepData |
object as retrieved by prepareImport() |
pattern |
as used in filterLines() |
patternNameCol |
as used in filterLines() |
startLineOffset |
as used in filterLines() |
msg |
message which parameter is imported. used if DBG == TRUE |
nrow |
number of rows of matrix: Default: nly |
dbg |
If TRUE prints debug information on the screen (Default: TRUE) |
Matrix values (always: soil, if available: initial pressure head & temperature distribution)
xxxxxx
importRechargePeriods(prepData)
importRechargePeriods(prepData)
prepData |
object as retrieved by prepareImport() |
Recharge periods (i.e. PART C) with naming parameter names in R style
FORTRAN parameters with always correspond to only one value
importSingleLineParas(prepData, dbg = TRUE)
importSingleLineParas(prepData, dbg = TRUE)
prepData |
object as retrieved by prepareImport() |
dbg |
prints debug information on the screen |
Single line values with naming parameter names in R style (before part C, i.e. recharge period 1 starts)
Helper function: replace a list index with a name
labeledList(inpLst, labelTxt = "id")
labeledList(inpLst, labelTxt = "id")
inpLst |
input list |
labelTxt |
user defined txt used for naming list |
Labeled list
Helper function: names of all sublists of a list returns the names of all sublists of x in the "$"-notation, e.g. list$sublist$subsublist$subsubsublist
leafValues(x, values = list())
leafValues(x, values = list())
x |
R list. |
values |
name to be used as prefix for all names found. default: "" |
leafs of sublists into one dimensional list
Writes one vector for values in multiple lines that beginn in FORTRAN "in the next line" (e.g. DELZ, DXR)
multipleLineValues(parName = "DELZ", data, patternNameCol = "parNames", startLineOffset = 1, toNumeric = TRUE)
multipleLineValues(parName = "DELZ", data, patternNameCol = "parNames", startLineOffset = 1, toNumeric = TRUE)
parName |
e.g. "PLTIM", "DELZ" or "DXR" |
data |
as retrieved by prepareImport() |
patternNameCol |
for pattern like "/B25" use: "txt", for para names use "paraNames", (Default: "txt") -> used by function: filterLines() |
startLineOffset |
offset of starting line: 0 (if parName is in same row as parVal, 1 if parVal is one row after parName), -> used by function: filterLines() |
toNumeric |
If TRUE result is converted to numeric (Default: TRUE) |
List with one vector of multiple lines values for each parameter
Helper function: node pairs
nodePairs(j, n)
nodePairs(j, n)
j |
Row of each cell |
n |
Column of each cell |
data.frame with node pairs
Helper function: selects pattern contained in different lines of a string vector (e.g. imported using readLines())
patternSelect(pattern, data)
patternSelect(pattern, data)
pattern |
index of row to be split (valid values: 1-3) |
data |
vector with strings |
data.frame with columns lines (indicating the lines where pattern was found and txt (string contained in that lines)
Helper function: prepareImport (imports and prepares input file)
prepareImport(model.path, mdb.path = system.file("extdata", "InputDescription.xls", package = "kwb.vs2dh"), dbg = TRUE)
prepareImport(model.path, mdb.path = system.file("extdata", "InputDescription.xls", package = "kwb.vs2dh"), dbg = TRUE)
model.path |
full path to folder containing vs2dh.dat |
mdb.path |
full path to the folder containing the InputDescription.xls which is used as lookup table for converting FORTRAN to R parameter names (Default: system.file("extdata", "InputDescription.xls", package = "kwb.vs2dh")) |
dbg |
if TRUE text output is printed on the screen |
Read vs2dhi.dat and does some preparations steps which are stores in a list which contains the sublists "input" (raw imported vs2dh.dat file), "inpDescription" (lookup table defined in file "mdb.path"), "res" (prepared table with parameters names and values) and "rechargePeriods" (summary of start/endlines of file "input" for each recharge period)
## Not run: model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") prepareImport(model.path) ## End(Not run)
## Not run: model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") prepareImport(model.path) ## End(Not run)
Helper function: splits header of output file with (energy, fluid) mass balance time series (balance.out)
splitHeader(row, header)
splitHeader(row, header)
row |
index of row to be split (valid values: 1-3) |
header |
first three lines of balance.out containing header |
splitted header
Configure complete vs2dh parameterisation
vs2dh.Configure(basic = vs2dh.ConfigureBasic(), soils = vs2dh.ConfigureSoils(), initial = vs2dh.ConfigureInitial(), recharge = vs2dh.ConfigureRechargePeriods())
vs2dh.Configure(basic = vs2dh.ConfigureBasic(), soils = vs2dh.ConfigureSoils(), initial = vs2dh.ConfigureInitial(), recharge = vs2dh.ConfigureRechargePeriods())
basic |
parameterisation (title, units, time, output, solver, grid, options), as retrieved by vs2dh.ConfigureBasic(), |
soils |
retrieved by vs2dh.ConfigureSoils() |
initial |
initial conditions for flow (pressure head or moisture contents and transport (temperatures), as retrieved by vs2dh.ConfigureInitial() |
recharge |
recharge periods as retrieved by vs2dh.ConfigureRechargePeriods() |
Complete vs2dh parameterisation in R style
Configure balance output file ("balance.out")
vs2dh.ConfigureBalance(mb9 = c(1:72), outputEachTimeStep = TRUE)
vs2dh.ConfigureBalance(mb9 = c(1:72), outputEachTimeStep = TRUE)
mb9 |
The index number of each mass balance component to be written to file "balance.out".(See table 7, from p. 66, in Healy (1990) |
outputEachTimeStep |
FALSE if output to file 9 ("balance.out") is desired only at selected output times rather than at each time step (default: TRUE) |
Selected components and temporal resolution for "balance.out" file
Configure basic model parameters
vs2dh.ConfigureBasic(titl = "My title", units = vs2dh.ConfigureBasicUnits(), time = vs2dh.ConfigureBasicTime(), output = vs2dh.ConfigureBasicOutput(), solver = vs2dh.ConfigureBasicSolver(), grid = vs2dh.ConfigureBasicGrid(), options = vs2dh.ConfigureBasicOptions())
vs2dh.ConfigureBasic(titl = "My title", units = vs2dh.ConfigureBasicUnits(), time = vs2dh.ConfigureBasicTime(), output = vs2dh.ConfigureBasicOutput(), solver = vs2dh.ConfigureBasicSolver(), grid = vs2dh.ConfigureBasicGrid(), options = vs2dh.ConfigureBasicOptions())
titl |
80-character problem description (formatted read, 20A4) |
units |
as retrieved by vs2dh.ConfigureBasicUnits() |
time |
as retrieved by vs2dh.ConfigureBasicTime() |
output |
as retrieved by vs2dh.ConfigureBasicTime() |
solver |
retrieved by vs2dh.ConfigureBasicSolver() |
grid |
retrieved by vs2dh.ConfigureBasicGrid() |
options |
as simulation options as retrieved by vs2dh.ConfigureBasicOptions (default: TRUE) |
Basic configuration
Configure Grid
vs2dh.ConfigureBasicGrid(nxr = 46, nly = 34, ang = 0, rad = FALSE, dx = 0.5, dy = 0.5)
vs2dh.ConfigureBasicGrid(nxr = 46, nly = 34, ang = 0, rad = FALSE, dx = 0.5, dy = 0.5)
nxr |
Number of cells in horizontal or radial direction. (default: 46) |
nly |
Number of cells in vertical direction. (default: 34) |
ang |
Angle by which grid is to be tilted (Must be between -90 and +90 degrees, ang = 0 for no tilting, see Healy (1990) for further discussion), degrees. (default: 0) |
rad |
Logical variable. TRUE if radial coordinates are used; otherwise = FALSE (default: FALSE) |
dx |
Constant value for grid spacing in horizontal or radial direction. (default: 0.5) |
dy |
Constant value for grid spacing in vertical direction. (default: 0.5) |
Grid parameterisation
Configure basic simulation options: energy transport, evaporation or evapotranspiration should be simulated? (FUNCTIONALITY NOT IMPLEMENTED YET! DO NOT CHANGE default PARAMETERISATION)
vs2dh.ConfigureBasicOptions(trans = TRUE, bcit = FALSE, etsim = FALSE)
vs2dh.ConfigureBasicOptions(trans = TRUE, bcit = FALSE, etsim = FALSE)
trans |
Should energy transport be simulated? (default: TRUE), Option FALSE currently NOT IMPLEMENTED YET!!!!!!! |
bcit |
NOT IMPLEMENTED YET!!!!!!! If TRUE evaporation is to be simulated for this simulation;if FALSE no evaporation is simulated for this simulation (default: FALSE) |
etsim |
NOT IMPLEMENTED YET!!!!!!! If TRUE evapotanspiration (plant-root extraction) is to be simulated for this simulation; if FALSE no evaporation is simulated for this simulation (default: FALSE). |
Return basic simulation options
Configure model output
vs2dh.ConfigureBasicOutput(times = vs2dh.ConfigureBasicOutputTimes(), main = vs2dh.ConfigureBasicOutputMain(), variables = TRUE, balance = vs2dh.ConfigureBalance(), obsPoints = vs2dh.ConfigureObsPoints(), boundaryFluxes = vs2dh.ConfigureBoundaryFluxes(), enhancedPrecision = FALSE)
vs2dh.ConfigureBasicOutput(times = vs2dh.ConfigureBasicOutputTimes(), main = vs2dh.ConfigureBasicOutputMain(), variables = TRUE, balance = vs2dh.ConfigureBalance(), obsPoints = vs2dh.ConfigureObsPoints(), boundaryFluxes = vs2dh.ConfigureBoundaryFluxes(), enhancedPrecision = FALSE)
times |
as retrieved by |
main |
as retrieved by |
variables |
If TRUE output of pressure heads (and temperatures if TRANS = T) to file "variables.out" is desired at selected observation times (default: TRUE) |
balance |
IF TRUE one-line mass balance summary for each time step is written to file "balance.out"; (default: TRUE) |
obsPoints |
as retrieved by vs2dh.ConfigureObsPoints(), default: no output of observation points to file "obsPoints.out" |
boundaryFluxes |
as retrieved by vs2dh.ConfigureBoundaryFluxes(), default: no output of boundary fluxes to file "boundaryFluxes.out" |
enhancedPrecision |
If TRUE results are written with enhanced precision to files9 ("variables.out") and file11 ("obsPoints.out"), (default: FALSE) |
Configuration of model output
Configure main output file ("vs2dh.out")
vs2dh.ConfigureBasicOutputMain(f6p = TRUE, thpt = TRUE, spnt = TRUE, ppnt = TRUE, hpnt = TRUE, vpnt = TRUE)
vs2dh.ConfigureBasicOutputMain(f6p = TRUE, thpt = TRUE, spnt = TRUE, ppnt = TRUE, hpnt = TRUE, vpnt = TRUE)
f6p |
If TRUE mass balance is to be written to file "vs2dt.out" for each time step; if FALSE mass balance is to be written to file "vs2dt.out" only at observation times and ends of recharge periods (default: TRUE) |
thpt |
If TRUE volumetric moisture contents are to be written to file "vs2dt.out", otherwise: FALSE (default: TRUE) |
spnt |
If TRUE saturation is written to file "vs2dt.out", otherwise: FALSE (default: TRUE) |
ppnt |
If TRUE pressure heads are written to file "vs2dt.out", otherwise: FALSE (default: TRUE) |
hpnt |
If TRUE total heads are written to file "vs2dt.out", otherwise: FALSE (default: TRUE) |
vpnt |
If TRUE velocities are written to file "vs2dt.out", otherwise: FALSE (default: TRUE) |
Output config of vs2dh.out file
Configure model output times
vs2dh.ConfigureBasicOutputTimes(pltim = seq(0, 10, 0.5), numt = 1000, enhancedPrecision = FALSE, dbg = TRUE)
vs2dh.ConfigureBasicOutputTimes(pltim = seq(0, 10, 0.5), numt = 1000, enhancedPrecision = FALSE, dbg = TRUE)
pltim |
Elapsed times at which pressure heads and temperatures are to be written to file "variables.out", and heads, temperatures, saturations, velocities, and/or moisture contents to file "vs2dt.out", T. (default: seq(0,10,0.5)) |
numt |
Maximum number of time steps. (default: 1000), will be set automatically if called from higher level function vs2dh.ConfigureBasic() |
enhancedPrecision |
if TRUE enhanced results are written with enhanced precision to files6 (vs2dh.out) & file9 (variables.out), (default: FALSE) |
dbg |
if TRUE additional information printed on screen (default: TRUE) |
Model output times
Basic solver configuration
vs2dh.ConfigureBasicSolver(cis = TRUE, cit = TRUE, numt = 1000, minit = 2, itmax = 80, eps = 1e-04, eps1 = 0.001, eps2 = 0.001, hmax = 0.7, itstop = TRUE)
vs2dh.ConfigureBasicSolver(cis = TRUE, cit = TRUE, numt = 1000, minit = 2, itmax = 80, eps = 1e-04, eps1 = 0.001, eps2 = 0.001, hmax = 0.7, itstop = TRUE)
cis |
If TRUE spatial discretisation is realised by centered-in-space differencing; if FALSE backward-in-space differencing is to be used for transport equation. (default: TRUE) |
cit |
If TRUE temporal discretisation is realised by centered-in-time differencing; if FALSE backward-in-time or fully implicit differencing is to be used. (default: TRUE) |
numt |
Maximum number of time steps.(default: 1000). (NOTE: if enhanced precision in print out to file "balance.out" and file 11 "obsPoints.out", is desired set NUMT equal to a negative number. That is, multiply actual maximum number of time steps by -1)1 |
minit |
Minimum number of iterations per time step. (default: 2) |
itmax |
Maximum number of iterations per time step. (default: 80) |
eps |
Head closure criterion for iterative solution of flow equation, L. (default: 0.0001) |
eps1 |
Temperature closure criterion for iterative solution of transport equation, C. (default: 0.001) |
eps2 |
Velocity closure criterion for outer iteration loop at each time step, L/T. (default: 0.001) |
hmax |
Relaxation parameter for iterative solution. See discussion in Lappala and others (1987) for more detail. Value is generally in the range of 0.4 to 1.2. (default: 0.7) |
itstop |
If TRUE simulation is terminated after ITMAX iterations in one time step; otherwise = F. (default: TRUE) |
Configuration of basic solver
Configure time parameters
vs2dh.ConfigureBasicTime(stim = 0, tmax = 10.1)
vs2dh.ConfigureBasicTime(stim = 0, tmax = 10.1)
stim |
Initial time (usually set to 0). (default: 0) |
tmax |
Maximum simulation time. (default: 10.1) |
Time parameters
Configure unit parameters
vs2dh.ConfigureBasicUnits(zunit = "m", tunit = "day", cunx = "J")
vs2dh.ConfigureBasicUnits(zunit = "m", tunit = "day", cunx = "J")
zunit |
Units used for length, "m" for meters. (default: "m") |
tunit |
Units used for time, "sec" for seconds, "day" for day (default: "day") |
cunx |
Units used for heat, "J" for Joules. (default: "J") |
Model units
Configure boundary conditions
vs2dh.ConfigureBoundaryCondition(jj = 5, nn = 17:26, ntx = 2, pfdum = 0.009778035, ntc = 0, cf = 10, importData = NULL, ibc = 0)
vs2dh.ConfigureBoundaryCondition(jj = 5, nn = 17:26, ntx = 2, pfdum = 0.009778035, ntc = 0, cf = 10, importData = NULL, ibc = 0)
jj |
vector with row numbers of nodes |
nn |
vector with column numbers of nodes |
ntx |
vector with node type identifier for boundary conditions. 0 (for no specified boundary (needed for resetting some nodes after initial recharge period); 1 (for specified pressure head); 2 (for specified flux per unit horizontal surface area in units of L/T); 3 (for possible seepage face); 4 (for specified total head); 5 (for evaporation, Note: is not implemented yet!); 6 (for specified volumetric flow in units of L3/T). 7 (for gravity drain). (The gravity drain boundary condition allows gravity driven vertical fow out of the domain assuming a unit vertical hydraulic gradient. Flow into the domain cannot occur.)" |
pfdum |
vector with specified head for NTX = 1 or 4 or specified flux for NTX = 2 or 6. If codes 0, 3, 5, or 7 are specified, the line should contain a dummy value for PFDUM or should be terminated after NTX by a blank and a slash (/). |
ntc |
vector with node type identifier for transport boundary conditions. 0 (for no specified boundary); 1 (for specified temperatures)" |
cf |
vector with specified temperature for NTC = 1 or NTX = 1, 2, 4, 6, or 7. Present only if TRANS = T. |
importData |
Optionally a data.frame with the colnames (jj,nn,ntx,pfdum,ntc,cf) can be used. In this case the input for the function parameters (jj,nn,ntx,pfdum,ntc,cf) will be ignored! |
ibc |
Code for reading in boundary conditions: 0 (by individual node), 1 (by row/column). (default: 0), Note: currently only option 0 is implemented |
Boundary conditions
Configure Boundary fluxes
vs2dh.ConfigureBoundaryFluxes(nodes = NULL)
vs2dh.ConfigureBoundaryFluxes(nodes = NULL)
nodes |
data.frame with columns "idbf" (id of boundary face), "bf_j" (grid row) and "bf_n" (grid column) |
Boundary fluxes parameterisation
nodes <- data.frame(idbf = c(rep(1,5), rep(2,6)), bf_j = 1:11, bf_n = rep(1,11)) vs2dh.ConfigureBoundaryFluxes(nodes = nodes)
nodes <- data.frame(idbf = c(rep(1,5), rep(2,6)), bf_j = 1:11, bf_n = rep(1,11)) vs2dh.ConfigureBoundaryFluxes(nodes = nodes)
Configure Genuchten flow parameters
vs2dh.ConfigureGenuchten(ratioKzKh = 1, satKh = 750, ss = 0, porosity = 0.39, alpha = 2.3, rmc = 0.05, beta = 5.8)
vs2dh.ConfigureGenuchten(ratioKzKh = 1, satKh = 750, ss = 0, porosity = 0.39, alpha = 2.3, rmc = 0.05, beta = 5.8)
ratioKzKh |
Ratio of hydraulic conductivity in the z-coordinate direction to that in the x-coordinate direction (Default:1) |
satKh |
Saturated hydraulic conductivity (K) at 20 C in the x-coordinate direction for class ITEX, L/T. (Default: 750 m/d) |
ss |
Specific storage (Ss), L^-1. (Default: 0) |
porosity |
Porosity (f), (Default: 0.39) |
alpha |
van Genuchten alpha. NOTE: alpha is as defined by van Genuchten (1980) and is the negative reciprocal of alpha' used in earlier versions (prior to version 3.0) of VS2DT, L., (Default: 2.3/m) |
rmc |
Residual moisture content, (Default: 0.05) |
beta |
van Genuchten parameter, beta' in Healy (1990) and Lappala and others (1987), (Default:5.8) |
Genuchten flow parameters
http://pubs.usgs.gov/circ/2003/circ1260/pdf/Circ1260.pdf p.87 for default parameterisation
Configure initial conditions
vs2dh.ConfigureInitial(flow = vs2dh.ConfigureInitialFlow(), temp = vs2dh.ConfigureInitialTemp())
vs2dh.ConfigureInitial(flow = vs2dh.ConfigureInitialFlow(), temp = vs2dh.ConfigureInitialTemp())
flow |
initial flow conditions (i.e. pressure head or saturation distribution for model domains, as retrieved by vs2dh.ConfigureInitialFlow() |
temp |
initial temperature distribution as retrieved by vs2dh.ConfigureInitialTemp() |
Initial model conditions
Configure initial head/soil moisture distribution
vs2dh.ConfigureInitialFlow(values = NA, dwtx = 3.7291667, hmin = -3.98, asPressureHeads = TRUE)
vs2dh.ConfigureInitialFlow(values = NA, dwtx = 3.7291667, hmin = -3.98, asPressureHeads = TRUE)
values |
If NA values are supplied (default): initial conditions are defined in terms of pressure head, and an equilibrium profile is specified above a free-water surface at a depth of DWTX until a pressure head of HMIN is reached. All pressure heads above this are set to HMIN. If one value is supplied: all initial conditions in terms of pressure head (if asPressureHead=TRUE) or moisture(if asPressureHead=FALSE) are set equal to value of "hvalues". |
dwtx |
Depth to free-water surface above which an equilibrium profile is computed, L. All All pressure heads above DWTX this are set to HMIN. (default: 3.7291667) |
hmin |
Minimum pressure head to limit height of equilibrium profile, L. Must be negative. (default: -3.98) matrix (with columns equal to NXR and rows equals to NLY) needs to be supplied |
asPressureHeads |
If TRUE, initial flow conditions are pressure heads, else: moisture content (default: TRUE) |
Initial flow conditions
Configure initial temperature distribution:
vs2dh.ConfigureInitialTemp(values = 10)
vs2dh.ConfigureInitialTemp(values = 10)
values |
either constant (for constant initial temperature for whole model domain, or matrix with number of rows (equals to nxr) and columns (equals to nly), with user defined initial temperature distribution (default: 10 degree C, constant temperature) |
Initial temperature distribution parameterisation
Configure Observation points
vs2dh.ConfigureObsPoints(obs_n = NULL, obs_j = NULL, outputEachTimeStep = TRUE)
vs2dh.ConfigureObsPoints(obs_n = NULL, obs_j = NULL, outputEachTimeStep = TRUE)
obs_n |
grid column "n" (if NULL no observation points will be written to file obsPoints.out) |
obs_j |
grid row "j" (if NULL no observation points will be written to file obsPoints.out) |
outputEachTimeStep |
If FALSE output to obsPoints.out is desired only at selected output times rather than at each time step (default: TRUE) |
Observation point parameterisation
Configure recharge period
vs2dh.ConfigureRechargePeriod(tper = 0.1, options = vs2dh.ConfigureRechargePeriodOptions(), solver = vs2dh.ConfigureRechargePeriodSolver(), boundary = vs2dh.ConfigureBoundaryCondition())
vs2dh.ConfigureRechargePeriod(tper = 0.1, options = vs2dh.ConfigureRechargePeriodOptions(), solver = vs2dh.ConfigureRechargePeriodSolver(), boundary = vs2dh.ConfigureBoundaryCondition())
tper |
Length of this recharge period, T. (default: 0.1) |
options |
as retrieved by vs2dh.ConfigureRechargePeriodOptions() |
solver |
as retrieved by vs2dh.ConfigureRechargePeriodSolver() |
boundary |
as retrieved by vs2dh.ConfigureBoundaryCondition() |
Recharge period
Configure recharge period options
vs2dh.ConfigureRechargePeriodOptions(prnt = FALSE, rbcit = FALSE, retsim = FALSE, seepage = vs2dh.ConfigureSeepage())
vs2dh.ConfigureRechargePeriodOptions(prnt = FALSE, rbcit = FALSE, retsim = FALSE, seepage = vs2dh.ConfigureSeepage())
prnt |
If TRUE, = T if heads, temperature, moisture contents, and/or saturations are to be printed to file "vs2dt.out" after each time step; If FALSE they are to be written to file "vs2dt.out" only at observation times and ends of recharge periods. (default: FALSE) |
rbcit |
NOT IMPLEMENTED YET!!!!!!! If TRUE evaporation is to be simulated for this recharge period;if FALSE no evaporation is simulated for this recharge period (default: FALSE) |
retsim |
NOT IMPLEMENTED YET!!!!!!! If TRUE evapotanspiration (plant-root extraction) is to be simulated for this recharge period; if FALSE no evaporation is simulated for this recharge period (default: FALSE). |
seepage |
If TRUE are to be simulated for this recharge period; seepage face not simulated for this recharge period. (default: vs2dh.ConfigureSeepage()) |
Recharge period
Configure recharge periods
vs2dh.ConfigureRechargePeriods(periods = list(vs2dh.ConfigureRechargePeriod(), vs2dh.ConfigureRechargePeriod(tper = 10)))
vs2dh.ConfigureRechargePeriods(periods = list(vs2dh.ConfigureRechargePeriod(), vs2dh.ConfigureRechargePeriod(tper = 10)))
periods |
list with one or multiple recharge periods with structure as retrieved by vs2dh.ConfigureRechargePeriod() |
List with parameterisation of recharge periods
Configure recharge period solver
vs2dh.ConfigureRechargePeriodSolver(delt = 1e-04, tmlt = 1.2, dltmx = 1, dltmin = 1e-04, tred = 0.1, dsmax = 10, sterr = 0, pond = 0)
vs2dh.ConfigureRechargePeriodSolver(delt = 1e-04, tmlt = 1.2, dltmx = 1, dltmin = 1e-04, tred = 0.1, dsmax = 10, sterr = 0, pond = 0)
delt |
Length of initial time step for this period, T. (default: 1.0E-4) |
tmlt |
Multiplier for time step length. (default: 1.2) |
dltmx |
Maximum allowed length of time step, T. (default: 1) |
dltmin |
Minimum allowed length of time step, T. (default: 1.0E-4) |
tred |
Factor by which time-step length is reduced if convergence is not obtained in ITMAX iterations. Values usually should be in the range 0.1 to 0.5. If no reduction of time-step length is desired, input a value of 0.0. (default: 0.1) |
dsmax |
Maximum allowed change in head per time step for this period, L. (default: 10) |
sterr |
Steady-state head criterion; when the maximum change in head between successive time steps is less than STERR, the program assumes that steady state has been reached for this period and advances to next recharge period, L. (default: 0) |
pond |
Maximum allowed height of ponded water for constant flux nodes. See Lappala and other (1987) for detailed discussion of POND, L. (default: 0) |
Recharge period times
Configure seepage
vs2dh.ConfigureSeepage(seepFaces = list(vs2dh.ConfigureSeepageFace(), vs2dh.ConfigureSeepageFace(j = 30:20, n = 45)))
vs2dh.ConfigureSeepage(seepFaces = list(vs2dh.ConfigureSeepageFace(), vs2dh.ConfigureSeepageFace(j = 30:20, n = 45)))
seepFaces |
list of seepage faces as retrieved by vs2dh.ConfigureSeepageFace() |
Seepage config
Configure seepage face
vs2dh.ConfigureSeepageFace(j = c(30:20), n = 2, jlast = 0)
vs2dh.ConfigureSeepageFace(j = c(30:20), n = 2, jlast = 0)
j |
Row and column of each cell on possible seepage face, in order from the lowest to the highest elevation; JJ pairs of values are required. |
n |
Column of each cell on possible seepage face, in order from the lowest to the highest elevation; JJ pairs of values are required. |
jlast |
Number of the node which initially represents the highest node of the seep; value can range from 0 (bottom of the face) up to JJ (top of the face). (default: 0) |
Seepage face
Configure soil parameters
vs2dh.ConfigureSoil(hk = vs2dh.ConfigureGenuchten(), ht = vs2dh.ConfigureTrans())
vs2dh.ConfigureSoil(hk = vs2dh.ConfigureGenuchten(), ht = vs2dh.ConfigureTrans())
hk |
flow properties |
ht |
transport properties |
(Genuchten) flow & transport parameters of soil
Configure soil grid
vs2dh.ConfigureSoilGrid(ntex = 2, grid = vs2dh.ConfigureBasicGrid(), irow = 0)
vs2dh.ConfigureSoilGrid(ntex = 2, grid = vs2dh.ConfigureBasicGrid(), irow = 0)
ntex |
number of different textual classes (default: 2) |
grid |
grid matrix as retrieved by |
irow |
Textural classes are read for each row (irow=0). This option is preferable if many |
Grid with soil indexes
Configure Soils
vs2dh.ConfigureSoils(props = list(vs2dh.ConfigureSoil(), vs2dh.ConfigureSoil(hk = vs2dh.ConfigureGenuchten(ratioKzKh = 100))), grid = vs2dh.ConfigureSoilGrid(ntex = length(props)), wus = 0.5)
vs2dh.ConfigureSoils(props = list(vs2dh.ConfigureSoil(), vs2dh.ConfigureSoil(hk = vs2dh.ConfigureGenuchten(ratioKzKh = 100))), grid = vs2dh.ConfigureSoilGrid(ntex = length(props)), wus = 0.5)
props |
Soil (flow & transport) properties as retrieved by
|
grid |
grid matrix as retrieved by |
wus |
Weighting option for intercell relative hydraulic conductivity: 1 (for full upstream weighting), 0.5 (for arithmetic mean) and 0.0 (for geometric mean), (default: 0.5) |
Configuration of soils for flow and energy transport (only hydraulic function type 1 vanGenuchten model is implemented!)
Configure soil transport parameters
vs2dh.ConfigureTrans(alphaL = 1, alphaT = 0.1, cs = 2180000, ktRmc = 129600, ktSat = 155520, cw = 4180000)
vs2dh.ConfigureTrans(alphaL = 1, alphaT = 0.1, cs = 2180000, ktRmc = 129600, ktSat = 155520, cw = 4180000)
alphaL |
Longitudinal dispersivity, L. (Default: 1 m) |
alphaT |
Transverse dispersivity, L. (Default: 0.1 m) |
cs |
Heat capacity of dry solids (Cs), Q/L3 C. (Default: 2180000.0 J/m3C) |
ktRmc |
Thermal conductivity of water sediment at residual moisture content, Q/LTC. (default: 129600.0) |
ktSat |
Thermal conductivity of water sediments at full saturation, Q/LC. (Default: 155520.0) |
cw |
Heat capacity of water (Cw), which is the product of density times specific heat of water, Q/L3 C. (default: 4180000.0) |
Soil transport parameters
http://pubs.usgs.gov/circ/2003/circ1260/pdf/Circ1260.pdf p.87 for default parameterisation
Plotting of mass balance time series
vs2dh.plotMassBalance(paras = c("TOTAL__FLOW_IN", "TOTAL__FLOW_OUT", "FLUID__STORAGE"), paraUnit = "TIMESTEP", data, mainLabel = "Flow mass balance", ...)
vs2dh.plotMassBalance(paras = c("TOTAL__FLOW_IN", "TOTAL__FLOW_OUT", "FLUID__STORAGE"), paraUnit = "TIMESTEP", data, mainLabel = "Flow mass balance", ...)
paras |
vector with at least one or multiple parameters in model results, for checking available paras run (see example: validParas). The parameter "TIME" is not allowed! |
paraUnit |
TIMESTEP RATE or |
data |
as returned by vs2di.run()$balance |
mainLabel |
a text to be written above the plot |
... |
further parameters passed to |
Temporal time series plot of mass balance variables
### Location of example vs2dh model contained in "kwb.vs2dh package" model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") res <- vs2di.run(model.path = model.path) #### Checking available parameter names for "paras": validParas <- gsub(pattern="__TOTAL|__RATE|__TIMESTEP|TIME", replacement = "", colnames(res$balance)) validParas ### Flow mass balance components (inflow, outflow, storage): vs2dh.plotMassBalance(data=res$balance) ### Only resulting flow mass balance error (per timestep): vs2dh.plotMassBalance(paras="FLUID__VOL_BAL", data = res$balance, mainLabel = "Flow mass balance error") ### Energy mass balance components (inflow, outflow, storage): vs2dh.plotMassBalance(paras=c("TOTAL__ENERGY_IN", "TOTAL__ENERGY_OUT", "ENERGY__STORAGE"), data=res$balance, mainLabel="Energy mass balance") ### Only resulting energy mass balance error (per timestep): vs2dh.plotMassBalance(paras="ENERGY__BALANCE", data = res$balance, mainLabel = "Energy mass balance error")
### Location of example vs2dh model contained in "kwb.vs2dh package" model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") res <- vs2di.run(model.path = model.path) #### Checking available parameter names for "paras": validParas <- gsub(pattern="__TOTAL|__RATE|__TIMESTEP|TIME", replacement = "", colnames(res$balance)) validParas ### Flow mass balance components (inflow, outflow, storage): vs2dh.plotMassBalance(data=res$balance) ### Only resulting flow mass balance error (per timestep): vs2dh.plotMassBalance(paras="FLUID__VOL_BAL", data = res$balance, mainLabel = "Flow mass balance error") ### Energy mass balance components (inflow, outflow, storage): vs2dh.plotMassBalance(paras=c("TOTAL__ENERGY_IN", "TOTAL__ENERGY_OUT", "ENERGY__STORAGE"), data=res$balance, mainLabel="Energy mass balance") ### Only resulting energy mass balance error (per timestep): vs2dh.plotMassBalance(paras="ENERGY__BALANCE", data = res$balance, mainLabel = "Energy mass balance error")
Plot vs2dh.plotMatrix results
vs2dh.plotMatrix(data, nodes = TRUE, maxCol = 100, ignoreZeroValues = FALSE, ...)
vs2dh.plotMatrix(data, nodes = TRUE, maxCol = 100, ignoreZeroValues = FALSE, ...)
data |
matrix as returned by vs2di.run(model.path, returnOutput=TRUE) |
nodes |
if TRUE node numbers are used as x-/y-axis; if false spatial extent |
maxCol |
maximum number of colors to be used for colorramp |
ignoreZeroValues |
if TRUE 0 values will be set to NA (Default: FALSE) |
... |
further parameters passed to |
Plot matrix values
### Location of example vs2dh model contained in "kwb.vs2dh package" model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") res <- vs2di.run(model.path = model.path) vs2dh.plotMatrix(data=res$variables$PressureHead[[1]])
### Location of example vs2dh model contained in "kwb.vs2dh package" model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") res <- vs2di.run(model.path = model.path) vs2dh.plotMatrix(data=res$variables$PressureHead[[1]])
Spatial plotting of observation point time series
vs2dh.plotObservationPoints(paras = "Temp", data, paraLabel = NULL, maxCol = 100, ...)
vs2dh.plotObservationPoints(paras = "Temp", data, paraLabel = NULL, maxCol = 100, ...)
paras |
vector with at least one of the following parameters: H_m (total head), P_m (pressure head), THETA (moisture content), SAT (saturation), TEMP (for temperature), VX (velocity in x-direction), VZ (velocity in z-direction), ET (evapotransporation) |
data |
as returned by vs2di.run() in sublist "obsPoint" |
paraLabel |
optional parameter for changing the label text of the parameters
defined in |
maxCol |
maximum number of colors to be used for colorramp |
... |
further parameters passed to |
Spatial plots of observation point time series
### Location of example vs2dh model contained in "kwb.vs2dh package" model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") res <- vs2di.run(model.path = model.path) vs2dh.plotObservationPoints (paras="TEMP", data=res$obsPoints, paraLabel="Temperature (\u00B0\ C)")
### Location of example vs2dh model contained in "kwb.vs2dh package" model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") res <- vs2di.run(model.path = model.path) vs2dh.plotObservationPoints (paras="TEMP", data=res$obsPoints, paraLabel="Temperature (\u00B0\ C)")
Plot vs2dh.plotVariables matrix time series
vs2dh.plotVariables(para = "Temp", data, ignoreBoundary = TRUE, ignoreZeroValues = TRUE, paraLabel = NULL, maxCol = 100, main = "", nodes = TRUE, ...)
vs2dh.plotVariables(para = "Temp", data, ignoreBoundary = TRUE, ignoreZeroValues = TRUE, paraLabel = NULL, maxCol = 100, main = "", nodes = TRUE, ...)
para |
either "Temp" (for temperature) or "PressureHead" |
data |
as returned by vs2di.run() in sublist "variables" |
ignoreBoundary |
should boundary nodes (first/last column/row) be ignored? Default: TRUE |
ignoreZeroValues |
if TRUE 0 values will be set to NA (Default: TRUE) |
paraLabel |
optional parameter for changing the label text of the parameter (if not used the value in "para" is used for labelling) |
maxCol |
maximum number of colors to be used for colorramp |
main |
Additional text for main label (e.g. model name) |
nodes |
if TRUE node numbers are used as x-/y-axis; if false spatial extent is derived returned in model units (currently not implemented!) |
... |
further parameters passed to |
Time series matrix plot
### Location of example vs2dh model contained in "kwb.vs2dh package" modelName <- "tutorial2" model.path <- system.file("extdata", "vs2dh_example", modelName, package = "kwb.vs2dh") res <- vs2di.run(model.path = model.path) vs2dh.plotVariables ( para = "Temp", data = res$variables, paraLabel = "Temperature (\u00B0\ C)", main = modelName) vs2dh.plotVariables (para = "PressureHead", data = res$variables, paraLabel = "Pressure head (m)", main = modelName )
### Location of example vs2dh model contained in "kwb.vs2dh package" modelName <- "tutorial2" model.path <- system.file("extdata", "vs2dh_example", modelName, package = "kwb.vs2dh") res <- vs2di.run(model.path = model.path) vs2dh.plotVariables ( para = "Temp", data = res$variables, paraLabel = "Temperature (\u00B0\ C)", main = modelName) vs2dh.plotVariables (para = "PressureHead", data = res$variables, paraLabel = "Pressure head (m)", main = modelName )
Read VS2dh model output file with fluxes at boundary faces
vs2dh.readBoundaryFluxes(model.path, fileName = "boundaryFluxes.out", dbg = TRUE)
vs2dh.readBoundaryFluxes(model.path, fileName = "boundaryFluxes.out", dbg = TRUE)
model.path |
full path to folder containing model output files |
fileName |
name of file containing fluxes at boundary faces (default: "boundaryFluxes.out") |
dbg |
if true text output |
read model results of boundary faces are imported in a R object
### Location of example vs2dh model contained in "kwb.vs2dh package" model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") vs2dh.readBoundaryFluxes(model.path)
### Location of example vs2dh model contained in "kwb.vs2dh package" model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") vs2dh.readBoundaryFluxes(model.path)
Imports the configuration from an existing vs2dh.dat file and stores it in an R list data structure as retrieved by vs2dh.Configure()
vs2dh.ReadConfig(model.path, dbg = TRUE)
vs2dh.ReadConfig(model.path, dbg = TRUE)
model.path |
Full path to the folder containing the vs2dh.dat |
dbg |
prints debug information on the screen |
Imported vs2dh configuration model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") vs2dh.ReadConfig(model.path)
Read VS2dh model output file with observation point time series
vs2dh.readObsPoints(model.path, fileName = "obsPoints.out", dbg = TRUE)
vs2dh.readObsPoints(model.path, fileName = "obsPoints.out", dbg = TRUE)
model.path |
full path to folder containing model output files |
fileName |
name of file containing observation point results (default: "obsPoints.out") |
dbg |
if true text output |
read model results at observation points aare imported in a R object
### Location of example vs2dh model contained in "kwb.vs2dh package" model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") vs2dh.readObsPoints(model.path)
### Location of example vs2dh model contained in "kwb.vs2dh package" model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") vs2dh.readObsPoints(model.path)
Read VS2dh model output file with time series of variables pressure head and temperature
vs2dh.readVariables(model.path, fileName = "variables.out", dbg = TRUE)
vs2dh.readVariables(model.path, fileName = "variables.out", dbg = TRUE)
model.path |
full path to folder containing model output files |
fileName |
name of file containing variable results (default: "variables.out") |
dbg |
if true text output |
variable model results are imported in a R object
### Location of example vs2dh model contained in "kwb.vs2dh package" model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") res <- vs2di.run(model.path = model.path) vs2dh.readVariables(model.path)
### Location of example vs2dh model contained in "kwb.vs2dh package" model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") res <- vs2di.run(model.path = model.path) vs2dh.readVariables(model.path)
Write configuration
vs2dh.writeConfig(conf)
vs2dh.writeConfig(conf)
conf |
model config as retrieved by vs2dhConfigure() |
Write vs2dh.dat in folder model.path
conf <- vs2dh.Configure() inpDat <- vs2dh.writeConfig(conf) write(inpDat, file.path(getwd(), "inp.dat"))
conf <- vs2dh.Configure() inpDat <- vs2dh.writeConfig(conf) write(inpDat, file.path(getwd(), "inp.dat"))
Create vs2dh.fil or vs2dt.fil file
vs2di.createFileDat(engine, model.path, dbg = TRUE)
vs2di.createFileDat(engine, model.path, dbg = TRUE)
engine |
model engine either 'vs2dh' or 'vs2dt' |
model.path |
full path to folder containing vs2dh.dat |
dbg |
if true text output |
Saves/Overwrites vs2dh.fil in folder model.path
### Location of example vs2dh model contained in "kwb.vs2dh package" model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") vs2di.createFileDat(engine = "vs2dh", model.path = model.path)
### Location of example vs2dh model contained in "kwb.vs2dh package" model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") vs2di.createFileDat(engine = "vs2dh", model.path = model.path)
Read VS2dh model output file with (energy, fluid) mass balance time series
vs2di.readBalance(model.path, engine, fileName = "balance.out", dbg = TRUE)
vs2di.readBalance(model.path, engine, fileName = "balance.out", dbg = TRUE)
model.path |
full path to folder containing model output files |
engine |
model engine 'vs2dh' (for flow & heat modelling) or 'vs2dt' (for flow & solute transport) (Default: no default) |
fileName |
name of file containing (energy and fluid) balance results (default: "balance.out") |
dbg |
if true text output |
balance model results are imported in a R object
### Location of kwb.vs2dh package on your computer wDir <- system.file(package = "kwb.vs2dh") model.path <- file.path(wDir, "extdata/vs2dh_example/tutorial2") res <- vs2di.run(model.path = model.path) vs2di.readBalance(model.path = model.path, engine = "vs2dh")
### Location of kwb.vs2dh package on your computer wDir <- system.file(package = "kwb.vs2dh") model.path <- file.path(wDir, "extdata/vs2dh_example/tutorial2") res <- vs2di.run(model.path = model.path) vs2di.readBalance(model.path = model.path, engine = "vs2dh")
Read main VS2dh model output file "vs2dh.out"
vs2di.readMain(model.path, engine = "vs2dh")
vs2di.readMain(model.path, engine = "vs2dh")
model.path |
full path to folder containing model output files |
engine |
model engine 'vs2dh' (for flow & heat modelling) or 'vs2dt' (for flow & solute transport) (Default: "vs2dh") |
main model results are imported in a R object
### Location of example vs2dh model contained in "kwb.vs2dh package" model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") res <- vs2di.run(model.path = model.path) vs2di.readMain(model.path = model.path, engine = "vs2dh")
### Location of example vs2dh model contained in "kwb.vs2dh package" model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") res <- vs2di.run(model.path = model.path) vs2di.readMain(model.path = model.path, engine = "vs2dh")
Run VS2dh model
vs2di.run(engine = "vs2dh", engineDirectoryWin = this_extdata_file("engine/win"), engineDirectoryLinux = this_extdata_file("engine/linux"), model.path = this_extdata_file("vs2dh_example/tutorial2"), returnOutput = TRUE, showWarnings = TRUE, openTargetDir = FALSE, dbg = TRUE)
vs2di.run(engine = "vs2dh", engineDirectoryWin = this_extdata_file("engine/win"), engineDirectoryLinux = this_extdata_file("engine/linux"), model.path = this_extdata_file("vs2dh_example/tutorial2"), returnOutput = TRUE, showWarnings = TRUE, openTargetDir = FALSE, dbg = TRUE)
engine |
model engine 'vs2dh' (for flow & heat modelling) or 'vs2dt' (for flow & solute transport) (Default: "vs2dh") |
engineDirectoryWin |
default directory on Windows OS containing vs2dh3_3.exe and vs2dt3_3.exe (Default: system.file("extdata/engine/win", package = "kwb.vs2dh")) |
engineDirectoryLinux |
default directory on Linux OS containing vs2dh3_3.exe and vs2dt3_3.exe (Default: system.file("extdata/engine/linux", package = "kwb.vs2dh")) |
model.path |
full path to folder containing vs2dh.dat (default: system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh")) |
returnOutput |
if TRUE model output files variables.out, balance.out and obsPoints.out are imported into R completely; vs2dh.out (only warnings imported) |
showWarnings |
if TRUE print warning messages during simulation on screen (default: TRUE) |
openTargetDir |
If TRUE path containing model files will be opened in explorer (Default: FALSE) |
dbg |
if true text output on screen on model run progress |
Run VS2dh model and saves model output files in folder model.path
.
If returnOutput
is TRUE the output is imported in R object
### Running model with default model.path and engine.path: model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") res <- vs2di.run(model.path = model.path)
### Running model with default model.path and engine.path: model.path <- system.file("extdata", "vs2dh_example/tutorial2", package = "kwb.vs2dh") res <- vs2di.run(model.path = model.path)
Run configuration with VS2dh model
vs2di.runConfig(conf, engine = "vs2dh", tDir = tempdir(), returnOutput = TRUE, openTargetDir = TRUE, showWarnings = TRUE, dbgRun = TRUE, dbg = TRUE)
vs2di.runConfig(conf, engine = "vs2dh", tDir = tempdir(), returnOutput = TRUE, openTargetDir = TRUE, showWarnings = TRUE, dbgRun = TRUE, dbg = TRUE)
conf |
as retrieved by vs2dh.ReadConfig (i.e. importing a working VS2DH configuration from an vs2h.dat file) or completley in R using function vs2dh.Configure() (ATTENTION: DEFAULT PARAMETERISATION FOR vs2dh.Configure() CURRENTLY YIELDS NO RUNNING VS2DH MODEL CONFIGURATION) |
engine |
model engine 'vs2dh' (for flow & heat modelling) or 'vs2dt' (for flow & solute transport) (Default: "vs2dh") |
tDir |
target directory where vs2dh model input/output files should be stored. (Default: tempdir()) |
returnOutput |
if TRUE model output files variables.out, balance.out and obsPoints.out are imported into R completely; vs2dh.out (only warnings imported) (Default: TRUE) |
openTargetDir |
If TRUE path containing model files will be opened in explorer (Default: FALSE) |
showWarnings |
if TRUE print warning messages during simulation on screen (default: TRUE) |
dbgRun |
if true text output on screen on model run progress |
dbg |
if true text output on screen on additional model run progress |
Import & write VS2dh model results in R object
## Not run: ### Testing import and writing functions with ### Folder which contains the subfolders with the different models to test: model.main.path <- system.file("extdata", "vs2dh_example", package = "kwb.vs2dh") #### Using vs2dh.dat file contained in subfolders example1, example2, tutorial1 #### for testing (i.e. ignore example3 due to long run time, but this also works!) exampleModels <- c(paste0("example", 1:2), "tutorial1") ### Create result list in R for storing model outputs for each model in a separate ### sublist res <- list() #### Loop through all example model input files & plot temperature distribution for (testModel in exampleModels) { model.path <- file.path(model.main.path, testModel) cat(sprintf("Testing model in %s\n", model.path )) cat("1.Step: importing configuration to R.....") conf <- vs2dh.ReadConfig(model.path = model.path) cat("Done!") cat("2.Step: Run vs2di.runConfig():") tDir <- file.path(tempdir(), testModel) res[[testModel]] <- vs2di.runConfig(conf = conf, tDir = tDir) cat("3.Step: Plot temperature distribution...") vs2dh.plotVariables(para = "Temp", data = res[[testModel]]$variables, main = testModel ### nice label by using model folder name ) cat("Done!") } ## End(Not run)
## Not run: ### Testing import and writing functions with ### Folder which contains the subfolders with the different models to test: model.main.path <- system.file("extdata", "vs2dh_example", package = "kwb.vs2dh") #### Using vs2dh.dat file contained in subfolders example1, example2, tutorial1 #### for testing (i.e. ignore example3 due to long run time, but this also works!) exampleModels <- c(paste0("example", 1:2), "tutorial1") ### Create result list in R for storing model outputs for each model in a separate ### sublist res <- list() #### Loop through all example model input files & plot temperature distribution for (testModel in exampleModels) { model.path <- file.path(model.main.path, testModel) cat(sprintf("Testing model in %s\n", model.path )) cat("1.Step: importing configuration to R.....") conf <- vs2dh.ReadConfig(model.path = model.path) cat("Done!") cat("2.Step: Run vs2di.runConfig():") tDir <- file.path(tempdir(), testModel) res[[testModel]] <- vs2di.runConfig(conf = conf, tDir = tDir) cat("3.Step: Plot temperature distribution...") vs2dh.plotVariables(para = "Temp", data = res[[testModel]]$variables, main = testModel ### nice label by using model folder name ) cat("Done!") } ## End(Not run)