This vignette provides an overview of the basic modelling workflow
with the RPhosFate
package.
Load the package and obtain a copy of the demonstration project:
library(RPhosFate)
<- demoProject() cv_dir
Use RPhosFate()
or catchment()
to
initialise the project:
<- RPhosFate(
x cv_dir = cv_dir,
ns_dep_ovl = 25e-4,
ns_dep_cha = 0.0,
nv_tfc_inl = c(SS = 0.6, PP = 0.6),
nv_enr_rto = c(PP = 2.0),
nm_olc = matrix(c(4704255, 2795195), ncol = 2L),
df_cdt = read.table(
file.path(cv_dir, "cdt.txt"),
header = TRUE,
stringsAsFactors = FALSE
) )
firstRun()
calls all low-level interface methods for the
specified substance in the required order:
<- firstRun(x, substance = "SS") x
Snap coordinates of provided calibration gauges to the respective midpoint of the nearest channel cell if necessary and check calibration quality:
<- snapGauges(x)
x
<- calibrationQuality(x, substance = "SS", col = "SS_load") metrics
SS is calibrated by iteratively specifying better parameter values
for ns_dep_ovl
(overland deposition rate) and/or
ns_dep_cha
(channel deposition rate) as well as calling
subsequentRun()
for SS afterwards until pleased with the
metrics. By default, subsequentRun()
only calls the
transport()
low-level interface method for the specified
substance:
<- setParameter(x, ns_dep_ovl = 15e-4)
x
<- subsequentRun(x, substance = "SS")
x
<- calibrationQuality(x, substance = "SS", col = "SS_load") metrics
The autoCalibrate()
and autoCalibrate2()
methods may provide more comfortable alternatives to this process.
First, a further call to subsequentRun()
for PP is
necessary:
<- subsequentRun(x, substance = "PP")
x
<- calibrationQuality(x, substance = "PP", col = "PP_load") metrics
Same procedure as with SS apart from iteratively specifying better parameter values for the enrichment ratio:
<- setParameter(x, nv_enr_rto = c(PP = 1.4))
x
<- subsequentRun(x, substance = "PP")
x
<- calibrationQuality(x, substance = "PP", col = "PP_load") metrics
In case the only substance of interest is PP, it is possible to set
its enrichment ratio to one and directly calibrate it via
ns_dep_ovl
and/or ns_dep_cha
.
Write parameters and transport calculation order to disk:
saveState(x)
Simply load the previously saved state of the project via the
ls_ini
argument of RPhosFate()
or
catchment()
:
<- RPhosFate(
x cv_dir = cv_dir,
ls_ini = TRUE
)