Forest Dynamic Model-Hubbell (2001)

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 69 times • Downloaded 2 times • Run 0 times
Download the 'Forest Dynamic Model-Hubbell (2001)' 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 n-initiation-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 mutant0 n-initiation-speciation-count extinct-species-meta]
breed [meta-trees meta-tree]
breed [trees tree]
meta-trees-own [meta-species n-speciation-no n-initiation-speciation-no tau mutant]
trees-own [species h tau]
circles-own []
breed [circles a-circle]
;breed [local-trees local-tree]
patches-own[elevation]
;trees-own[local-species]
;extensions [ r ]

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 n-initiation-speciation 0
  set meta-set[]
  set meta-sp 0
  set mutant0 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-initiation-rate theta / (2 * JM)
    set effective-meta-cmmunity-size JM]
  if (Moran? = true) [
    set speciation-initiation-rate theta / JM
    set effective-meta-cmmunity-size JM ^ 2 / 2]
  if (Etinne-Alonso-Hubbell?) [
    set speciation-initiation-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
  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 meta-time 0
  set meta-a0 1
  set n-speciation 0
  set n-initiation-speciation 0
  set extinct-species 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
  set extinct-species-meta 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

  ;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-species (meta-sp + 1)
          set meta-sp meta-sp + 1
          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
  forest-die-regenerate3
  protracted-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-local sort-by > map count table:values table:group-agents trees [ species ]
  set rel-hist-frq-local map [ i -> i / JL ] hist-frq-local

  if-else (graphic? = true) [
    update-plot1
    update-plots
    plot-genetic-tree-Meta-Community
    plot-incipient-species
    update-plot2
    plot-genetic-tree-Local-Community
    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 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-else (random-number2 > speciation-initiation-rate)[
    ask one-of meta-trees [
      hatch 1
      setxy x-cor y-cor
    ]
  ]
  [speciation-initiation]
end 

to count-down
  set time time + 1
end 

to speciation-initiation
  set n-initiation-speciation n-initiation-speciation + 1
  ;set meta-sp meta-sp + 1
  set mutant0 mutant0 + 1
  ask one-of meta-trees [
    let parent-of-speciation meta-species
    hatch 1 [
      set mutant mutant0
      set n-initiation-speciation-no n-initiation-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
    ]
  ]
end 

to protracted-speciation
  ask meta-trees with [mutant != 0] [set tau tau + 1]
  ask meta-trees with [mutant != 0 AND tau = tau-protracted] [
    speciation
  ]
end 

to speciation
  set n-speciation n-speciation + 1
  set meta-sp meta-sp + 1
  ask meta-trees with [tau = tau-protracted] [
    let parent-of-speciation meta-species
    set n-speciation-no n-speciation
    set meta-j2 meta-j2 + 1
    set meta-species meta-sp
    ;set mutant 0
    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
      ;file-open "extinction-time.csv"
      ;file-write (time)
      ;file-close
    ]
    set di-locx xcor
    set di-locy ycor
    die
    ]
    let random-number3 random-float 1
    if-else (immigration-rate < random-number3) [
      ask one-of trees [
        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 plot-incipient-species
  set n-initiation-speciation-count 0
  set-current-plot "Incipient Species Meta Community"
  while [n-initiation-speciation-count <= n-initiation-speciation] [
    create-temporary-plot-pen (word n-initiation-speciation-count)
    set-current-plot-pen (word n-initiation-speciation-count)
    set-plot-pen-color 5 * n-initiation-speciation-count + 4
    let N-sp count (meta-trees with [n-initiation-speciation-no = n-initiation-speciation-count])
    if (N-sp > 0) [
      plotxy ticks n-initiation-speciation-count
      plot-pen-down
    ]
    set n-initiation-speciation-count n-initiation-speciation-count + 1
  ]
end 


; Copyright 2023 Wimansa Rajakaruna & Ruwan Punchi-Manage*.
; * Corresponding Email: spunchi@sci.pdn.ac.lk
; See Info tab for full copyright and license.

There are 3 versions of this model.

Uploaded by When Description Download
Ruwan Punchi-Manage 7 months ago Web version Download this version
Ruwan Punchi-Manage 7 months ago Web version Download this version
Ruwan Punchi-Manage 7 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.