Model description

The system

This is a pet model on a bark beetle population feeding on trees. It is be a bark beetly proliferation with one beetle generation each year and forest regrowth. Only trees older than a certain age are susceptible for bark beetles, thus young forest is "immune".

States

The world is represented as a grid of cells with possible status: forest, young forest and no-forest. For each cell the number of beetles is recorded. Each time step a new set of states is created.

Processes

The system is reduced to the following processes:

Run the model

To run the model some function arguments need to be specified. The number of time steps to be simulated (n_time) is thenumber of years to be simulated. The size of the world needs to be chosen large enough to see the pattern but small enough for your computer. Function argument world_size is the edge length of the world.

Forest parameters are the age until a forest stand is considered to be young and thus unsusceptible to beetles (young_forest) and he time until regrowth starts (regrowth).

Beetle parameters are the carrying capacity of a cell (K) and the rate parameter for the exponential dispersal kernel (dispPar). How strong beetles reproduce can also be adjusted (beetle_reproduction).

Other function arguments help to plot the output directly, set colors and determin if the output should be saved.

library(pets)
beetles_simulate(n_steps=10, world_size=100, dispPar=20, plot_flag=TRUE, col_forest=c("brown", "green", "darkgreen"), col_beetle=c("white", "blue"),  regrowth=1, sleep=0.3, K=10, young_forest=3, beetle_reproduction=0.7, write_out = TRUE)

Figure 1: Simulation with plot_flag = TRUE.

Plot maps

The simulation output can be plotted also individually by time step and map of interest. If you want to plot only the forest map, you can use the following code, which loads the simulation results first:

res <- load_results()
col_forest=c("brown", "green", "darkgreen")
image(as.matrix(res$forests[[7]]), col=col_forest, asp=1, axes=F) 
legend(0,1, legend=c("no forest", "young forest", "susceptible forest"), col=col_forest,  pch=16, pt.cex = 0.7)

Figure 2: Forest map for time step 7. Brown: no-forest, green: yound forest, dark green: susceptible forest.

Animation as GIF

Create a GIF file to visulize the simulation output.

require(animation)

ani.options(ani.width=3*230, ani.height=230) 
saveGIF(beetles_simulate(n_steps=40, world_size=150, dispPar=20, plot_flag=TRUE, col_forest=c("brown", "green", "darkgreen"), col_beetle=c("white", "blue"),  regrowth=1, sleep=0, K=10, young_forest = 3), movie.name = "animation.gif", img.name = "Rplot", convert = "convert", clean = TRUE)


KIT-IfGG/pets documentation built on May 28, 2019, 12:56 p.m.