diffusion {simecol}R Documentation

A Random Walk Particle Diffusion Model

Description

simecol example: This is a random walk (basic particle diffusion) model.

Usage

data(diffusion)

Format

An S4 object according to the rwalkModel specification. The object contains the following slots:

main
A function with the movement rules for the particles.
parms
A list with the following components:
ninds
number of simulated particles,
speed
speed of the particles,
area
vector with 4 elements giving the coordinates (left, bottom, right, top) of the coordinate system.
times
Simulation time (discrete time steps, by-argument ignored).
init
Data frame holding the start properties (Cartesian coordinates x and y and movement angle a) of the particles.

Details

To see all details, please have a look into the implementation.

See Also

sim, parms, init, times.

Examples

  ## Not run: 
    data(diffusion)
    ## (1) basic example
    plot(sim(diffusion))
    ## show "grid of environmental conditions"
    image(inputs(diffusion))
    
    ## (2) scenario
    ##     with homogeneous environment (no "refuge" in the middle)
    no_refuge <- diffusion # Cloning of the whole model object
    inputs(no_refuge) <- matrix(1, 100, 100)
    plot(sim(no_refuge))
    
    ## (3) example of using an observer function
    observer(diffusion) <- function(state, ...) {
      ## numerical output to the screen
      cat("mean x=", mean(state$x),
          ", mean y=", mean(state$y),
          ", sd   x=", sd(state$x),
          ", sd   y=", sd(state$y), "\n")
      # animation
      par(mfrow=c(2,2))
      plot(state$x, state$y, xlab="x", ylab="y", pch=16, col="red", xlim=c(0, 100))
      hist(state$y)
      hist(state$x)
      # default case: return the state --> iteration stores it in "out"
      init
    }

    sim(diffusion)
    
    ## (4) remove the observer
    observer(diffusion) <- NULL
    diffusion <- sim(diffusion)
    
  ## End(Not run)

[Package simecol version 0.6-1 Index]