Run simulation.
Usage
run_simulation(
seafloor,
fishpop,
nutrients_input = 0,
movement = "rand",
parameters,
threshold_mat = NULL,
max_i,
min_per_i,
seagrass_each = 1,
save_each = 1,
burn_in = 0,
return_burnin = TRUE,
to_disk = FALSE,
path_disk = NULL,
verbose = TRUE
)
Arguments
- seafloor
Data.frame with seafloor.
- fishpop
Data.frame with fish population.
- nutrients_input
Vector with nutrient input for each time step.
- movement
String specifying movement algorithm.
- parameters
List with all model parameters.
- threshold_mat
Matrix with reserve threshold values.
- max_i
Integer with maximum number of simulation time steps.
- min_per_i
Integer to specify minutes per i.
- seagrass_each
Integer how often (each i * x) seagrass dynamics will be simulated.
- save_each
Numeric how often data should be saved.
- burn_in
Numeric with time steps used to burn in (no fish).
- return_burnin
If FALSE, all time steps < burn_in are not saved.
- to_disk
Logical if TRUE, results are written into a text file.
- path_disk
String with path to result text file.
- verbose
Logical if TRUE, progress reports are printed.
Details
This is the main function of the simulation model. Besides running all sub-processes,
the function also includes some basic checks to make sure the model does not crash.
However, this does not ensure that all parameter values "make sense". The function
returns a mdl_rn
object, which stores the model run results and additionally
information about the model run itself.
The functions is a 'wrapper' around the following sub-processes: (i) nutrient input, (ii) seagrass growth, (iii) detritus mineralization, (iv) movement of individuals, (v) respiration of individuals, (vi) growth of individuals, (vii) mortality of individuals, (viii) diffusion of nutrients/detritus, and ix) nutrient output.
If nutrients_input
is zero (default), no nutrient input is simulated.
To simulate no nutrient output, set the nutrients_loss
parameter to zero.
The movement
argument allows to either specify random movement of individuals
('rand'
), attracted movement towards the artificial reef cells of individuals
('attr'
) or a movement behavior based on their bioenergetics ('behav'
).
If threshold_mat
equals NULL, the matrix is created automatically using a
normal distribution with pop_reserves_thres_mean
and pop_reserves_thres_sd
.
seagrass_each
allows to simulate all seagrass sub-processes only each
specified time step.
If save_each > 1
, not all iterations are saved in the final mdl_rn
object,
but only each time step specified by the argument. max_i
must be dividable by
save_each
without rest.
If burn_in > 0
, all sub-processes related to fish individuals are not simulated
before this time step is reached.
References
For a detailed model description, please see Esquivel, K.E., Hesselbarth, M.H.K., Allgeier, J.E., 2022. Mechanistic support for increased primary production around artificial reefs. Ecological Applications e2617. <https://doi.org/10.1002/eap.2617>
Examples
if (FALSE) { # \dontrun{
reef <- matrix(data = c(-1, 0, 0, 1, 1, 0, 0, -1, 0, 0),
ncol = 2, byrow = TRUE)
seafloor <- setup_seafloor(dimensions = c(50, 50), grain = 1,
reef = reef, starting_values = default_starting)
fishpop <- setup_fishpop(seafloor = seafloor,
starting_values = default_starting, parameters = default_parameters)
run_simulation(seafloor = seafloor, fishpop = fishpop, parameters = parameters,
max_i = 1000, min_per_i = 120, save_each = 10)
} # }