Unified Forest Dynamic Model
No preview image
Model was written in NetLogo 6.3.0
•
Viewed 149 times
•
Downloaded 14 times
•
Run 0 times
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 neighbor-patch species0 neighbor-tree conspecifics species2 neighboring-tree specs time-spent-list abundance-list mean-time-spent mean-life-comm data extinct-species-meta] breed [meta-trees meta-tree] breed [trees tree] meta-trees-own [meta-species n-speciation-no species-trait time-system] trees-own [species h species-trait time-system] circles-own [] breed [circles a-circle] patches-own[occupied dis-patch] to setup2 clear-all ask patches [ set pcolor black set occupied 0 ] 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 data [] 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 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 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 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 ;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 let random-patch one-of patches with [pycor <= w1 AND pycor >= 0 AND pxcor >= 0 AND pxcor <= w1 AND occupied = 0] create-meta-trees 1 [ setxy [pxcor] of random-patch [pycor] of random-patch set shape "circle" set size 1 set num random-float 1 set j1 j1 + 1 set species-trait random 2 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 ] ask patches [ if-else (count turtles-here > 0) [ set occupied 1 ] [ set occupied 0 ] ] 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] [ let random-patch one-of patches with [pycor <= max-pycor AND pycor > max-pycor - w2 - 1 AND pxcor >= 0 AND pxcor <= w2 AND occupied = 0] set i2 i2 - 1 create-trees 1 [ set h s + 1 setxy [pxcor] of random-patch [pycor] of random-patch set shape "circle" set size 1 set num random-float 1 set j2 j2 + 1 set species-trait random 2 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 ] ] ask patches [ if-else (count turtles-here > 0)[ set occupied 1 ] [ set occupied 0 ] ] ] ] set local-richness sp end to go2 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 forest-die-regenerate2 ask patches [ if-else (count turtles-here > 0) [ set occupied 1 ] [ set occupied 0 ] ] count-down 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 neut-death-birth let disturbance-rate random-float 1 if (disturbance-rate-per-year <= disturbance-rate) [ tree-falls-gaps ] forest-die4 forest-regenerate4 if-else (graphics? = true) [ update-plot1 update-plots plot-genetic-tree-Meta-Community update-plots update-plot2 update-plots plot-genetic-tree-Local-Community update-plots ] [ ] if (count trees <= Disturbance-Size) [ stop ] time-spent-system update-plot9 update-plot10 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-rate) [ ask one-of meta-trees [ hatch 1 setxy x-cor y-cor ] ] [ speciation ] 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 time-system time-system + 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-die4 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 if-else (intra-specific-competition? = true) [ ask one-of trees [ set species species set 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 conspecifics count trees in-radius crowd-radius with [species = species0] if (conspecifics >= conspecific-crowd) [ set di-locx xcor set di-locy ycor die ] ] ] [ ] end to forest-regenerate4 if (conspecifics >= conspecific-crowd) [ if-else (limited-dispersal? = false) [ ask one-of trees with [species != species0] [ set time-system time-system + 1 hatch 1 set h a setxy di-locx di-locy ] ] [ ask patches with [pxcor = di-locx AND pycor = di-locy] [set neighbor-tree one-of trees in-radius dispersal-radius ] ask neighbor-tree [ hatch 1 setxy di-locx di-locy ] ] ] end to tree-falls-gaps if (Disturbance-Size = 1) [ let disturbance-patch one-of patches with [count trees-here >= 1 AND dis-patch = 0 AND pycor <= max-pycor - 1 AND pycor > max-pycor - w2 AND pxcor >= 1 AND pxcor <= w2 - 1] ask disturbance-patch [ set dis-patch 1 ] ask trees-on disturbance-patch [ die ] ask disturbance-patch [ set occupied 0 ] if (Disturbance-Size > 1) [ repeat Disturbance-Size - 1 [ ask disturbance-patch [ let neighboring-patch one-of neighbors with [occupied = 1 AND pycor <= max-pycor AND pycor > max-pycor - w2 - 1 AND pxcor >= 0 AND pxcor <= w2] ask neighboring-patch [ ask trees-here [ die ] set dis-patch 1 set occupied 0 ] ] ] ] if-else (light-sensitivity = true) [ repeat Disturbance-Size [ let non-empty-patch one-of patches with [count trees-here > 1 AND pycor <= max-pycor AND pycor > max-pycor - w2 - 1 AND pxcor >= 0 AND pxcor <= w2] let empty-patch one-of patches with [count trees-here = 0 AND dis-patch = 1 AND pycor <= max-pycor AND pycor > max-pycor - w2 - 1 AND pxcor >= 0 AND pxcor <= w2] ask empty-patch [ set neighboring-tree one-of trees with [species-trait = 1] in-radius dispersal-radius if-else (neighboring-tree = true) [ ask neighboring-tree [ hatch 1 [ ;set time-system time-system + 1 setxy [pxcor] of empty-patch [pycor] of empty-patch ] ] ] [ set neighboring-tree one-of trees in-radius dispersal-radius ask neighboring-tree [ hatch 1 [ setxy [pxcor] of empty-patch [pycor] of empty-patch ] ] ] set dis-patch 0 set occupied 1 ] ] ] [repeat Disturbance-Size [ let non-empty-patch one-of patches with [count trees-here > 1 AND pycor <= max-pycor AND pycor > max-pycor - w2 - 1 AND pxcor >= 0 AND pxcor <= w2] let empty-patch one-of patches with [count trees-here = 0 AND dis-patch = 1 AND pycor <= max-pycor AND pycor > max-pycor - w2 - 1 AND pxcor >= 0 AND pxcor <= w2] ask one-of trees [ hatch 1 [ setxy [pxcor] of empty-patch [pycor] of empty-patch ] ] ask empty-patch [ set dis-patch 0 set occupied 1 ] ] ] ] end to neut-death-birth let rando-patch one-of patches with [pycor <= max-pycor AND pycor > max-pycor - w2 - 1 AND pxcor >= 0 AND pxcor <= w2] ask trees-on rando-patch [ die ] let random-number4 random-float 1 if-else (random-number4 > immigration-rate) [ ask one-of trees [ hatch 1 setxy [pxcor] of rando-patch [pycor] of rando-patch ] ] [ set species2 one-of [meta-species] of meta-trees replace-previous-immigrant move-immigrant immigration-through-channel create-trees 1 [ set species species2 set h a set shape "circle" set size 1 setxy [pxcor] of rando-patch [pycor] of rando-patch ] ] 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 time-spent-system ask trees [set time-system time-system + 1] ask meta-trees [set time-system time-system + 1] set specs 0 set time-spent-list [] set abundance-list [] set mean-time-spent [] set mean-life-comm [] set data [] while [specs <= max [species] of trees] [ let time-spent-list0 sum [time-system] of trees with [species = specs] let abundance count trees with [species = specs] set time-spent-list fput time-spent-list0 time-spent-list if (abundance > 0) [ set abundance-list fput abundance abundance-list let mean-time-spent0 time-spent-list0 / abundance set mean-time-spent fput mean-time-spent0 mean-time-spent let data0 (list mean-time-spent0 abundance) set data fput data0 data let mean-life-community mean [time-system] of trees set mean-life-comm n-values 300 [i -> mean-life-community] ] set specs specs + 1 ] end to update-plot9 set-current-plot "Average Life Time Vs. Abundance (Y vs. X)" clear-plot create-temporary-plot-pen (word "pen-0") set-current-plot-pen "pen-0" set-plot-pen-mode 2 foreach data [[pt1] -> plotxy item 1 pt1 item 0 pt1] update-plots end to update-plot10 set-current-plot "Average Life Time Vs. Abundance (Y vs. X)" create-temporary-plot-pen (word "pen-1") set-current-plot-pen "pen-1" set-plot-pen-mode 0 foreach (mean-life-comm) plot update-plots end ; Copyright 2023b Ruwan Punchi-Manage. ; See Info tab for full copyright and license.
There are 2 versions of this model.
Attached files
No files
This model does not have any ancestors.
This model does not have any descendants.