run_simulation: Run the simulation for a specified number of time steps

View source: R/flume.r

run_simulationR Documentation

Run the simulation for a specified number of time steps

Description

This function begins with the current state of x, runs the model for nt steps, then returns a copy of x with the updated state and state history.

Usage

run_simulation(x, nt, reps = length(x[["networks"]]))

Arguments

x

A flume() object

nt

The number of time steps, see 'details'

reps

The number of replicate simulations to run; by default a single sim is run on a new flume; for continuing simulations, the same number of replicates will be used

Details

The time scale of flume is determiend by the combination of (a) the units of the discharge variable (assumed generally to be m^3/s) and (b) the size of the time step (which is specified with the dt parameter of the flume() function).

At each time step of length dt, the model will simulate colonisations and extinctions assuming that resource state is constant throughout the time step, and simulate resource dynamics continuously via numerical integration. Model output will include the various state variables at each time step.

For example, if discharge is in m^3/s, then the default dt = 86400 corresponds to a time step of 86400 seconds, or one day. Setting nt = 100 will run the model for 100 days.

On unix-like platforms, if multiple cores are detectable and replicate simulations are requested, then these will be run in parallel using the number of cores specified in getOption("mc.cores"). If this value is not set, then all available cores will be used by default. Override the default by setting mc.cores; for example, to disable parallel execution, run options(mc.cores = 1).

Value

A modified copy of x, with state updated with the results of the simulation.


flee-group/flume documentation built on Jan. 29, 2024, 6:44 p.m.