Checks that the initial and final water and nitrogen balances are equal
(or NA) for each USM, using pre-computed simulation data from
sim_rds — see run_simulations to produce it. If
there are discrepancies, it logs a warning with the details of the issue
and stops with an error listing the affected USMs.
balance_closure_test(
sim_rds,
output_dir = NULL,
usms = NULL,
parallel = FALSE,
cores = NA,
verbose = 1L
)path to an .rds file containing pre-computed
simulation data, including the balance variables — see
run_simulations's vars argument. The USMs to test
are the names of this list, optionally restricted by usms
directory where balance error details
(balance_errors_details.csv) will be written, if any. If NULL
(default), details are not exported
character vector of USMs to restrict the test to. If NULL
(default), all USMs found in sim_rds are tested
Boolean. Is the computation to be done in parallel ?
Number of cores to use for parallel computation
Integer. Logging verbosity level: 0 = silent, 1 = info, 2 = debug
Invisibly, the internal test object. Called for its side
effects: logging a summary of the test, exporting detailed balance
errors to output_dir (if defined), and stopping with an error if any
USM failed the test.
if (FALSE) { # \dontrun{
balance_closure_test(
sim_rds = "/path/to/simulations.rds",
output_dir = "/path/to/output_dir",
parallel = TRUE,
cores = 4
)
} # }