if ( requireNamespace("deSolve") ) {
# Get the mean-field approximation to the arid vegetation model
arid <- ca_library("aridvege")
mod <- ca_library("aridvege")
init <- generate_initmat(mod, rep(1, 3)/3, nrow = 100, ncol = 100)
times <- seq(0, 128)
out <- run_meanfield(mod, init, times)
# This uses the default plot method in deSolve
plot(out)
# A different model and way to specifiy initial conditions.
coralmod <- ca_library("coralreef")
init <- c(ALGAE = 0.2, CORAL = 0.5, BARE = 0.3)
times <- 10^seq(0, 4, length.out = 64)
out <- run_meanfield(coralmod, init, times, method = "lsoda")
plot(out, ylim = c(0, 1))
}
Run the code above in your browser using DataLab