Forest Dynamic Model - Chisholm & Pacala 2010

No preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.3.0 • Viewed 39 times • Downloaded 6 times • Run 0 times
Download the 'Forest Dynamic Model - Chisholm & Pacala 2010' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Info tab cannot be displayed because of an encoding error

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

extensions [table csv]
globals [index meta-sp meta-time meta-a0  meta-j2 meta-a meta-set2 extinct-species number-of-meta-trees a initial-meta-richness random-number2 number time num j x-cor y-cor N richness a0 n-speciation local-set local-di-set local-off-set set-species-who-di set-species-who-off sp hist-frq rel-hist-frq s local-set0 remove-set richness-counts species-who-di di-locx di-locy species-who-off set1-species-who-off meta-set effective-meta-cmmunity-size number-of-local-trees item-x meta-set-new meta-sp-count sp-count j1 i1 k1 j2 i2 k2 meta-richness-counts meta-richness local-richness-counts local-richness hist-frq-meta rel-hist-frq-meta hist-frq-local rel-hist-frq-local habitat hist-frq-meta0 rel-hist-frq-meta0 hist-frq-local0 rel-hist-frq-local0 extinct-species-meta]
breed [meta-trees meta-tree]
breed [trees tree]
meta-trees-own [meta-species n-speciation-no]
trees-own [species h]
circles-own []
breed [circles a-circle]
patches-own[elevation niche]

to setup2
  clear-all
  set meta-richness-counts map count table:values table:group-agents meta-trees [ meta-species ]
  set meta-richness length meta-richness-counts
  set n-speciation 0
  set meta-set[]
  set meta-sp 0
  set JM (w1 + 1) * (w1 + 1)
  resize-world 0 (w1 + w2 + 20) 0 (w1 + w2 + 20)
  if (Hubbell-2001-Wright-Fisher? = true) [
    set speciation-rate theta / (2 * JM)
    set effective-meta-cmmunity-size JM]
  if (Moran? = true) [
    set speciation-rate theta / JM
    set effective-meta-cmmunity-size JM ^ 2 / 2]
  if (Etinne-Alonso-Hubbell?) [
    set speciation-rate theta / (theta + JM - 1)
    set effective-meta-cmmunity-size JM * (JM - 1) / 2]
  ;if (file-exists? "parent-species-speciation-species-time.csv")
  ;[
    ;carefully
    ;[file-delete "parent-species-speciation-species-time.csv"]
    ;[print error-message]
  ;]
  ;file-open "parent-species-speciation-species-time.csv"
  ;file-close
  ;if (file-exists? "Meta-Community-extinction-species-time.csv")
  ;[
    ;carefully
    ;[file-delete "Meta-Community-extinction-species-time.csv"]
    ;[print error-message]
  ;]
  ;file-open "Meta-Community-extinction-species-time.csv"
  ;file-close
  species-gen1
  ask patches with [count meta-trees-here > 0] [
    set niche 1 + random K
    set pcolor 5 * niche
  ]
  set hist-frq-meta sort-by > map count table:values table:group-agents meta-trees [ meta-species ]
  set rel-hist-frq-meta map [ i -> i / JM ] hist-frq-meta
  set hist-frq-meta0 sort-by > map count table:values table:group-agents meta-trees-on patches with [niche = 1 AND count meta-trees-here > 0] [ meta-species ]
  set rel-hist-frq-meta0 map [ i -> i / count patches with [niche = 1 AND count meta-trees-here > 0] ] hist-frq-meta0
  set meta-time 0
  set meta-a0 1
  set n-speciation 0
  set extinct-species-meta 0
  set meta-j2 2
  set meta-a JM
  set a JL
  set sp 0
  set JL (w2 + 1) * (w2 + 1)
  if (Immigration-number? = True) [
    set theta2 immigration-rate * JL / (1 - immigration-rate) ]
  species-gen2
  ask patches with [count trees-here > 0] [
    set niche 1 + random K
    set pcolor 5 * niche
  ]
  set extinct-species 0
  set hist-frq-local sort-by > map count table:values table:group-agents trees [ species ]
  set rel-hist-frq-local map [ i -> i / JL ] hist-frq-local
  set hist-frq-local0 sort-by > map count table:values table:group-agents trees-on patches with [niche = 1 AND count trees-here > 0] [ species ]
  set rel-hist-frq-local0 map [ i -> i / count patches with [niche = 1 AND count trees-here > 0] ] hist-frq-local0
  ;if (file-exists? "Local-Extinction-Species-Extinction-Time.csv")
  ;[
    ;carefully
    ;[file-delete "Local-Extinction-Species-Extinction-Time.csv"]
    ;[print error-message]
  ;]
  ;file-open "Local-Extinction-Species-Extinction-Time.csv"
  ;file-close
  create-channel
  reset-ticks
end 

to species-gen1
  set k1 -1
  while [k1 < w1 ] [
    set k1 k1 + 1
    set i1 -1
    while [i1 < w1 ] [
      set i1 i1 + 1
      create-meta-trees 1 [
        setxy k1 i1
        set shape "circle"
        set size 1
        set num random-float 1
        set j1 j1 + 1
        if-else (num < (theta / (theta + j1 - 1 ))) [
          set meta-sp meta-sp + 1
          set meta-species meta-sp
          set color 0.5 * meta-species
        ]
        [
          set meta-species [meta-species] of one-of other meta-trees
          set meta-sp meta-sp
          set color 0.5 * meta-species
        ]
        ;file-open "Metacommunityset.csv"
        ;file-print (meta-species)
        ;file-close
      ]
    ]
  ]
  set initial-meta-richness meta-sp
end 

to species-gen2
  set k2 -1
  while [k2 < w2 ] [
    set k2 k2 + 1
    set i2 max-pxcor + 1
    while [i2 <= max-pxcor + 1 AND i2 >= max-pxcor - w2 + 1] [
      set i2 i2 - 1
      create-trees 1 [
        set h s + 1
        setxy k2 i2
        set shape "circle"
        set size 1
        set num random-float 1
        set j2 j2 + 1
        if-else (num < (theta2 / (theta2 + j2 - 1 ))) [
          set sp sp + 1
          set species sp
          set color 5 * species + 2
        ]
        [
          set species [species] of one-of other trees
          set sp sp
          set color 5 * species + 2
        ]
      ]
    ]
  ]
  set local-richness sp
end 

to go2
  forest-die-regenerate2
  count-down
  speciation
  set hist-frq-meta sort-by > map count table:values table:group-agents meta-trees [ meta-species ]
  set rel-hist-frq-meta map [ i -> i / JM ] hist-frq-meta
  set hist-frq-meta0 sort-by > map count table:values table:group-agents meta-trees-on patches with [niche = 1 AND count meta-trees-here > 0] [ meta-species ]
  set rel-hist-frq-meta0 map [ i -> i / count patches with [niche = 1 AND count meta-trees-here > 0] ] hist-frq-meta0
  update-plots
  if (graphic? = true) [
    plot-genetic-tree-Meta-Community
    update-plot1
    update-plot4
  ]
  forest-die-regenerate3
  set hist-frq-local sort-by > map count table:values table:group-agents trees [ species ]
  set rel-hist-frq-local map [ i -> i / JL ] hist-frq-local
  set hist-frq-local0 sort-by > map count table:values table:group-agents trees-on patches with [niche = 1 AND count trees-here > 0] [ species ]
  set rel-hist-frq-local0 map [ i -> i / count patches with [niche = 1 AND count trees-here > 0] ] hist-frq-local0
  if (graphic? = true) [
    plot-genetic-tree-Local-Community
    update-plot2
    update-plot3
  ]
  update-plots
  tick
end 

to forest-die-regenerate2
  set N count meta-trees
  set meta-richness-counts map count table:values table:group-agents meta-trees [ meta-species ]
  set meta-richness length meta-richness-counts
  ask one-of meta-trees [
    set x-cor xcor
    set y-cor ycor
    set habitat [niche] of patch x-cor y-cor
    set meta-species meta-species
    let meta-species0 meta-species
    set number-of-meta-trees count meta-trees with [meta-species = meta-species0]
    if (number-of-meta-trees = 1)[
      set extinct-species-meta extinct-species-meta + 1
      ;file-open "Meta-Community-extinction-species-time.csv"
      ;file-write (meta-species)
      ;file-write (ticks)
      ;file-print ""
      ;file-close
    ]
    die
  ]
  set random-number2 random-float 1
  if (random-number2 > speciation-rate)[
    ask one-of meta-trees-on patches with [niche = habitat] [
      hatch 1
      setxy x-cor y-cor
    ]
  ]
end 

to count-down
  set time time + 1
end 

to speciation
  if  (random-number2 <= speciation-rate) [
    set n-speciation n-speciation + 1
    set meta-sp meta-sp + 1
    ask one-of meta-trees [
      let parent-of-speciation meta-species
      hatch 1
      set n-speciation-no n-speciation
      set meta-j2 meta-j2 + 1
      set meta-species meta-sp
      set color  0.5 * (a0 + 1 + meta-j2)
      setxy x-cor y-cor
      ;file-open "parent-species-speciation-species-time.csv"
      ;file-write (parent-of-speciation)
      ;file-write (meta-species)
      ;file-write (ticks)
      ;file-print ""
      ;file-close
    ]
  ]
end 

to forest-die-regenerate3
  set N count trees
  count-down
  set remove-set []
  set local-richness-counts map count table:values table:group-agents trees [species]
  set local-richness length local-richness-counts
  repeat D [ask one-of trees [
    set species species
    let species0 species
    set number-of-local-trees count trees with [species = species0]
    if (number-of-local-trees = 1)[
      set extinct-species extinct-species + 1
      ;file-open "Local-Extinction-Species-Extinction-Time.csv"
      ;file-write (species0)
      ;file-write (ticks)
      ;file-print ""
      ;file-close
    ]
    set di-locx xcor
    set di-locy ycor
    set habitat [niche] of patch x-cor y-cor
    die
    ]
    let random-number3 random-float 1
    if-else (immigration-rate < random-number3) [
      ask one-of trees-on patches with [niche = habitat] [
        hatch 1
        set h  a
        setxy di-locx di-locy
      ]
    ]
    [
      replace-previous-immigrant
      move-immigrant
      immigration-through-channel
      create-trees 1 [
        set species one-of [meta-species] of meta-trees
        set h  a
        set shape "circle"
        set size 1
        setxy di-locx di-locy
      ]
    ]
  ]
end 

to update-plot1
  set-current-plot "Species Abundance Distribution Meta Community"
  set n 1
  while [n <= meta-sp] [
    create-temporary-plot-pen (word n)
    set-current-plot-pen (word n)
    set-plot-pen-color 5 * n + 4
    plotxy ticks count meta-trees with [meta-species = n]
    set n n + 1
    plot-pen-down
  ]
end 

to update-plot2
  set-current-plot "Species Abundance Distribution Local Community"
  set n 1
  while [n <= sp] [
    create-temporary-plot-pen (word n)
    set-current-plot-pen (word n)
    set-plot-pen-color 5 * n + 4
    plotxy ticks count trees with [species = n]
    set n n + 1
    plot-pen-down
  ]
end 

to plot-genetic-tree-Meta-Community
  set meta-sp-count 0
  set-current-plot "Generic-Tree Meta Community"
  while [meta-sp-count <= meta-sp] [
    create-temporary-plot-pen (word meta-sp-count)
    set-current-plot-pen (word meta-sp-count)
    set-plot-pen-color 5 * meta-sp-count + 4
    let N-sp count (meta-trees with [meta-species = meta-sp-count])
    if (N-sp > 0) [
      plotxy ticks meta-sp-count
      plot-pen-down
    ]
    set meta-sp-count meta-sp-count + 1
  ]
end 

to plot-genetic-tree-Local-Community
  set sp-count 0
  set-current-plot "Generic-Tree Local Community"
  while [sp-count <= sp] [
    create-temporary-plot-pen (word sp-count)
    set-current-plot-pen (word sp-count)
    set-plot-pen-color 5 * sp-count + 4
    let N-sp count (trees with [species = sp-count])
    if (N-sp > 0) [
      plotxy ticks sp-count
      plot-pen-down
    ]
    set sp-count sp-count + 1
  ]
end 

to create-channel
  ask patches [
    if (pxcor > w2 / 2 AND pxcor < ((w2 / 2) + 2) AND pycor > w1 AND pycor < w1 + 20) [
      set pcolor gray
    ]
  ]
end 

to immigration-through-channel
  create-circles 1 [
    set color ticks
    set heading 0
    set size 1
    setxy ((w2 + 2) / 2) (w1 + 1)
   ]
end 

to move-immigrant
  ask circles [ fd 4]
end 

to replace-previous-immigrant
  ask circles with [ycor > (w1 + 13) ] [die]
end 

to update-plot3
  set-current-plot "Relative species abundance of niches in local community"
  let n2 1
  clear-plot
  while [n2 <= K] [
    create-temporary-plot-pen (word "habitat " n2)
    set-current-plot-pen (word "habitat " n2)
    set-plot-pen-color 5 * n2 + 4
    set-plot-pen-mode 0
    set hist-frq-local0 sort-by > map count table:values table:group-agents trees-on patches with [niche = n2 AND count trees-here > 0] [ species ]
    set rel-hist-frq-local0 map [ i -> i / count patches with [niche = n2 AND count trees-here > 0] ] hist-frq-local0
    foreach (reverse sort rel-hist-frq-local0) plot
    set n2 n2 + 1
    plot-pen-down
  ]
end 

to update-plot4
  set-current-plot "Relative species abundance of niches in meta-community"
  let n3 1
  clear-plot
  while [n3 <= K] [
    create-temporary-plot-pen (word "habitat " n3)
    set-current-plot-pen (word "habitat " n3)
    set-plot-pen-color 5 * n3 + 4
    set-plot-pen-mode 0
    set hist-frq-meta0 sort-by > map count table:values table:group-agents trees-on patches with [niche = n3 AND count trees-here > 0] [ species ]
    set rel-hist-frq-meta0 map [ i -> i / count patches with [niche = n3 AND count trees-here > 0] ] hist-frq-meta0
    foreach (reverse sort rel-hist-frq-meta0) plot
    set n3 n3 + 1
    plot-pen-down
  ]
end 

; Copyright 2023 Ruwan Punchi-Manage.
; See Info tab for full copyright and license.

There are 3 versions of this model.

Uploaded by When Description Download
Ruwan Punchi-Manage 5 months ago Web version Download this version
Ruwan Punchi-Manage 5 months ago Web version Download this version
Ruwan Punchi-Manage 5 months ago Initial upload Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.