Modeling Setaria tundra

Modeling Setaria tundra 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.4.0 • Viewed 17 times • Downloaded 0 times • Run 0 times
Download the 'Modeling Setaria tundra' modelDownload this modelEmbed this model

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


Comments and Questions

Test (Question)

This is a test

Posted 8 days ago

Click to Run Model

;~~~~~~~~~~~~ These are globals
breed [Mosquitos Mosquito]
breed [Reindeers Reindeer]

extensions [
  csv
  time
]

globals [
  grass-growth-rate          ; the rate at which grass gows
  grass-density              ; the density of patches that is vegetation
  grass-probability          ; the probability that grass has not been overgrazed
  grass-regrowth-rate        ; the rate at which grass grows back
  grass-energy               ; amount of energy grass provides
  reproductive-energy        ; amount of energy needed for reproduction
  new-turtle                 ; spawn a new turtle
  herd-size                  ; the size of a herd
  initial-energy             ; We assume each reindeer will live for 12 years (365 ticks * 12 years = 4380)
  mortality-rate             ; the rate at which reindeer die
  risky-reindeer             ; the rate at which reindeer will explore
  cluster-center             ; this is the center of the blue water body
  mosquito-start
  reindeer-density           ; This is how many reindeer can occupy any one patch at a given time
  snow-density
  wise-one                   ; oldest reindeer

  patch-radius               ; This is the radius of the lakes
  elevation                  ; this is the elevation of the terrain
  elevation-max              ; This is the maximum elevation of the terrain in the model


  current-date               ; This is the current date of the tick
  current-month              ; This is the current month of the date of the tick, useful for categorizing meterological seasons
  time-series                ; This is if user uploads a .csv file with the first column being a datetime (YYYY-MM-DD) and the second column is temperature in degrees Celcius (must have 1 row of headers)

  temperature                ; This is the daily temperature for the simulation
  index                      ; This is to keep track of the list in the time-series

  rainy-days                ; This is to track how many consecutive days of rain there has been
  cold-warm-days            ; This is to track how many consecutive warm days above 0 C there have been


]

patches-own

[
  grass-amount              ; This is how much units of grass there is, 1 unit of grass can feed 1 turtle


]

;~~~~~~~~~~~~These are turtle properties
Reindeers-own
[
  energy               ; enrgy of the turtle
  hunger               ; minimum amount of grass need to be eaten for turtle survival
  age                  ; the age of turtles in ticks
  reproductiveness     ; the reproductive ability for turtles, based on age and body condition
  infected?            ; if this is true, the turtle is infected
  immunity-remaining   ; how many weeks of immunity the turtle has left
  flockmates           ; agentsset of nearby turtles
  nearest-neighbor     ; closest flockmate
  immune?              ; if this is true a turtle is immune
  recovered?           ; if this is true a turtle has recovered
  sick-time            ; when a turtle became sick
  dead?                ; when true, a turtle is dead
  larvae-count         ; how many larvae are in each reindeer


]

Mosquitos-own
[
 age                 ; age of mosquito (22-76 ticks, days), adult after 20 ticks
 infected            ; infected with m.f.
 infected?
 blood-meal          ; cumulative count of blood for oviposit



]

to clear-run

  clear-all
end 

to setup

  clear-output
  clear-all
  reset-ticks

  ifelse file-option? [

  ;set current-time time:create "2010-01-01"
    setup-file
  ][
    set current-date time:create Date_opt
  ]

  setup-patches
  setup-reindeer
  setup-mosquitos

  set cold-warm-days 0
  set rainy-days 0
end 

; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is to setup the world

to setup-file

  set time-series csv:from-file File-name

  let start-date first item 1 time-series
  let end-date first item (length time-series - 1) time-series

  set current-date start-date

  set index 1
end 

to setup-patches


  resize-world 0 world-size 0 world-size                     ; set up world size. This is in m. 1 patch is 100 m x 100 m


  ask patches [
    ifelse random-float 1.0 < 0.2              ; Adjust the probability (0.2 in this case) for green patches
    [ set pcolor green
    set grass-amount 5]
    [ set pcolor brown
    set grass-amount 0]
  ]

  create-blue-clusters                          ; Create irregular-shaped clusters of blue patches
end 

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~ This is to set up a water body ~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

to create-blue-clusters

ifelse patch-sizes = "small" [
    set patch-radius world-size * 0.05
  ][
  ifelse patch-sizes = "medium" [
    set patch-radius world-size * 0.15
  ][
    set patch-radius world-size * 0.3
  ]]

  repeat patches-amt [
    set cluster-center patch random-xcor random-ycor
    ask cluster-center [
      set pcolor blue
      ask patches in-radius patch-radius [ set pcolor blue ]
    ]
  ]



; Define mosquito-start patches at the edge of blue patches
  let edge-patches patches with [
    pcolor = blue and any? neighbors with [pcolor != blue]
  ]

  ifelse any? edge-patches [
    set mosquito-start edge-patches
  ][
    user-message "No suitable mosquito start patches found"
  ]
end 



;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~ This is to set up the reindeer;~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

to setup-reindeer

  let non-blue-patches patches with [pcolor != blue] ; consider only non-blue patches
  ; Set initial positions closer together near the nearest non-blue patch
  let p one-of non-blue-patches

  create-Reindeers Reindeer-pop [
    set shape "reindeer"
    set size 1.5
    set color 33
    set age 0
    set energy initial-energy
    set immune? false
    set dead? false
    set energy 300
    set infected? false
    set larvae-count 0

    if random-float 1 < initial-infected-rate [
     set infected? true
     set larvae-count larvae-count + 1
     set color violet
    ]

    set reindeer-density 5
    move-to p ; this is the initial point
    let i 0
    let q patch-ahead random-float (herd-spread * Reindeer-pop)
    while [ i < reindeer-density] [
      rt random 360 ;cw: we were missing random turns so it was only doing random distance below
      set q patch-ahead random-float (herd-spread * Reindeer-pop)  ;cw: copied this inside the while so q is a new patch each loop of the while, also changed to * reindeer to match herd-movement
      if q != nobody and [pcolor] of q != blue and [pcolor] of q != white and [count Reindeers-here] of q < reindeer-density [
        move-to q
        set i reindeer-density ;cw: if they move, break the while
      ]
      set i i + 1
    ]
    ;cw: optional check to more fully scatter over-crowded reindeer (or increase reindeer-density above)
    if count Reindeers-here > reindeer-density [
      move-to one-of patches with [pcolor != blue and pcolor != white and count Reindeers-here < reindeer-density]
    ]
  ]
end 

;~~~~~~~~~~~~~~~~~~~ This is to set up mosquitos

to setup-mosquitos

  create-Mosquitos Mosquitos-pop[
    set shape "mosquito"
    set size 0.45
    set color white
    set age 0
    ;set age random-float max-age
    set blood-meal 0
    let initial-patch one-of mosquito-start ;patches with [pcolor = blue]
    move-to initial-patch
  ]
end 
;~~~~~~~~~~~~~~~~~~~ This is to set up mosquitos





;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   ++++    +++   ++  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  +       +   +  ++  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  +   ++  +   +  ++  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  +    +  +   +      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   ++++    +++   ++  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

to go

  ;;;;;;;;;;;;;;; PATCHES STUFF ;;;;;;;;;;;;;;;
  grow-grass
  eat-grass
  herd-movement

  ;;;;;;;;;;;;;;; REINDEER STUFF ;;;;;;;;;;;;;;;
  if reindeer-life-cycle? [
    reproduce
    age-and-die
  ]

  infect-reindeer

  ;;;;;;;;;;;;;;; MOSQUITO STUFF ;;;;;;;;;;;;;;;
  mosquito-age
  mosquito-move
  mosquito-bite
  mosquito-reproduce-die


  ;;;;;;;;;;;;;;; TEMP STUFF (FROM FILE OPTION) ;;;;;;;;;;;;;;;

  ifelse file-option? [

    if index < length time-series [
      set temperature last item index time-series
      set current-date first item index time-series
    ]
    set index index + 1

    if index > length time-series [
      user-message "The simulation has reached the end of your file points"
      stop
    ]

  ][

    temp

      ifelse temperature > 0 [set cold-warm-days cold-warm-days + 1] [set cold-warm-days 0]
      set current-date time:plus current-date 1 "days"
  ]

   ;;;;;;;;;;;;;;; RAIN STUFF ;;;;;;;;;;;;;;;

  if climate-on? [precipitation]

  tick
end 

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

to grow-grass ; grass grows on dirt patches at a constant rate

  ; Within 14 ticks, theres a threshold for 5 reindeer grazing
  ; Grass will regrow

  set grass-regrowth-rate 0.0025


  ask patches with [pcolor = brown] [

    if random-float 1 < grass-regrowth-rate [
      set pcolor green
      set grass-amount 5
      ; later I want to add a variation on green depending on grass-amount
      ;Last visited by reindeer over a certain amount of time, will regrow. Healthier grass patch after an amount of time
    ]

  ]
end 



;~~~~~ ++ ++      ++++++++  ++++++++   +++++      ++++  ++++       ++++++++  ++++++++  ++ ++    ~~~~~~~~~~
;~~~~~ +++  ++    ++           ++      ++  ++      ++   ++  ++     ++        ++        ++   ++  ~~~~~~~~~~
;~~~~~ ++  ++     ++           ++      ++   ++     ++   ++    ++   ++        ++        ++  ++   ~~~~~~~~~~
;~~~~~ +++        ++++         ++      ++    ++    ++   ++     ++  ++++      ++++      +++      ~~~~~~~~~~
;~~~~~ ++ ++      ++           ++      ++     ++   ++   ++     ++  ++        ++        ++ ++    ~~~~~~~~~~
;~~~~~ ++   ++    ++           ++      ++      ++  ++   ++    ++   ++        ++        ++   ++  ~~~~~~~~~~
;~~~~~ ++     ++  ++           ++      ++       ++ ++   ++  ++     ++        ++        ++    ++ ~~~~~~~~~~
;~~~~~ ++     ++  ++++++++  ++++++++   ++        ++++   ++++       ++++++++  ++++++++  ++    ++ ~~~~~~~~~~

to butcher
  ask n-of butcher-amt Reindeers [die]
  print (word "You have butchered " butcher-amt " reindeer")
end 

to eat-grass
  ask reindeers [
    if pcolor = green and grass-amount > 0 [
      set energy energy + 10
      ask patch-here [
        set grass-amount grass-amount - 1
        if grass-amount = 0 [
          set pcolor brown
        ]
      ]
    ]
  ]
end 

to reproduce
  ;

  ask Reindeers with [energy > 150 and random-float 1 < reproduction-rate] [
    let nearby-Reindeers other Reindeers in-radius vision
    let parent-Reindeers min-one-of nearby-Reindeers with [self != myself] [distance myself]
    if parent-Reindeers != nobody [
      hatch-reindeers 1 [
        let mean-x mean [xcor] of nearby-Reindeers
        let mean-y mean [ycor] of nearby-Reindeers
        setxy mean-x mean-y
        set age 1
        set energy initial-energy
      ]
      face parent-Reindeers
      fd 1
    ]
  ]
end 

to age-and-die

  ;Adult reindeer max age is 20 years. Each tick is a day (20 years is 7300 days)
  ;Reindeer become adults at 5 (Females) and 6 (Males). For now, will set for 5.

  ask Reindeers [
    set age age + 1
    set energy energy - 1
    if age > 7300 or energy <= 0 [
      die]
  ]

  if wise-one = nobody [
    set wise-one min [who] of Reindeers ; this is the minimum ID of all turtles, the turtle with the lowest identifier
    ask Reindeer wise-one [set color yellow] ]
end 

to infect-reindeer

  ask reindeers [
    if any? turtles-here with [breed = mosquitos and infected > 0] [
      if random-float 1 < 0.5 [
        set infected? true
        set larvae-count larvae-count + 1
      ]
    ]
  ]
end 


;to herd-movement-stationary
;
;  ; Ask all turtles to perform herd movement logic
;  ; Check if the turtle is a cow
;
;  ask turtles [
;
;    if shape = "cow" [
;      let all-turtles other turtles
;      let nearby-turtles all-turtles with [distance myself < vision]
;
;    ; check if turtle is on a non-frozen patch next to a water patch
;
;      let risky? false
;      let neighboring-patches patches in-radius 1 with [pcolor = blue]
;      if pcolor != white and any? neighboring-patches [
;        set risky? (random-float 1 < risky-reindeer)
;    ]
;
;    ; move towards mean position if not risky
;    if not risky? and any? nearby-turtles [
;      let mean-x mean [xcor] of nearby-turtles
;      let mean-y mean [ycor] of nearby-turtles
;      let mean-position patch mean-x mean-y
;
;      let dispersion-factor herd-spread * Reindeer-pop
;      let max-dispersion round(vision * 0.5)
;      let min-dispersion round(vision * 0.25)
;      let radius random-float (max-dispersion - min-dispersion) + min-dispersion
;
;      ; find all patches within radius that are not frozen or water and have fewer than 5 turtles
;      let non-frozen-patches patches with [
;          pcolor != white and
;          pcolor != blue and
;          distance myself <= radius and
;          count Reindeers-here < 5
;        ]
;
;      ; move towards a non-frozen patch if there is one, otherwise move randomly
;      ifelse any? non-frozen-patches [
;        let destination one-of non-frozen-patches
;        face destination
;        fd 1
;      ] [
;        rt random 360
;        fd 1
;      ]
;]]]
;
;end

to herd-movement

  let non-frozen-patches patches with [ ;Patches that are not snow or water
    pcolor != 105
  ]

  set wise-one min [who] of Reindeers ; this is the minimum ID of all turtles, the turtle with the lowest identifier
  ask Reindeer wise-one [set color yellow]
  let dispersion-factor herd-spread * Reindeer-pop ; this is how many patches wide herded reindeer can move around in
  let herd-patches non-frozen-patches with [distance Reindeer wise-one < dispersion-factor] ;  contain a subset of non-frozen-patches that are within the specified distance from the turtle wise-one

  let lead-x [xcor] of Reindeer wise-one
  let lead-y [ycor] of Reindeer wise-one
  let lead-distance patch lead-x lead-y ; The location of wise-one will dictate movements of all turtles

  ask Reindeer wise-one [
    face one-of herd-patches in-radius vision
    if patch-ahead 1 != nobody and [pcolor] of patch-ahead 1 != blue [
      fd 1
  ]
  ]

  ask Reindeers [

    ; if the distance of the turtle to the lead-turtle is less than the dispersion factor, then it will move randomly within the "radius" of the herd
    ; However, if the distance of the turtle to the lead turtle is more than the dispersion factor, then it will move forward one towards the leader
    ; We also want to make sure there are only 5 turtles on a patch

    ifelse distance Reindeer wise-one < dispersion-factor [
      rt random 360
      if patch-ahead 1 != nobody and member? patch-ahead 1 non-frozen-patches and [count Reindeers-here] of patch-ahead 1 < 5 [ ; rename to land
        fd 1];[if count turtles-here > 5 [type "a"]]
    ][
      ; this is asking if the patch ahead the turtle satifies the following conditions. If it does it moves fd 1. If not it faces the wise-one and moves fd 1 towards them
      ;[1] That the patch is a herd-patch, meaning it is grass and not frozen
      ;[2] that there are less than 5 turtles on that patch
      face Reindeer wise-one
      ifelse patch-ahead 1 != nobody and member? patch-ahead 1 herd-patches and [count Reindeers-here] of patch-ahead 1 < 5 and [pcolor] of patch-ahead 1 != blue [
        fd 1
      ]
      [
          rt 90 - random 180
          if patch-ahead 1 != nobody and member? patch-ahead 1 non-frozen-patches and [count Reindeers-here] of patch-ahead 1 < 5 and [pcolor] of patch-ahead 1 != blue [
          fd 1 ];[if count turtles-here > 5 [type "b"]]
      ]
    ]

    if patch-here = blue [
      rt 180
      fd 1
    ]

    ;if count turtles-here > 5 [type "c"]
  ]

;    if [pcolor] of patch-here = blue [
;      print "Turtle is on a blue patch."
;      stop ]

  ; CHECK HOW MANY REINDEER PER PATCH
;  if max [count turtles-here] of patches > 5 [
;      print word ("There are more than 5 turtles on a patch:") max [count turtles-here] of patches
;  ]
end 

;~~~~~~~~~~  +++         +++     +++++     ++++++         +++++     ~~~~~~~~~~
;~~~~~~~~~~  ++  +     +  ++    ++   ++    ++            ++   ++    ~~~~~~~~~~
;~~~~~~~~~~  ++   +   +   ++   ++     ++     ++         ++     ++   ~~~~~~~~~~
;~~~~~~~~~~  ++    + +    ++  ++       ++        ++    ++       ++  ~~~~~~~~~~
;~~~~~~~~~~  ++     +     ++  ++       ++          ++  ++       ++  ~~~~~~~~~~
;~~~~~~~~~~  ++           ++   ++     ++          ++    ++     ++   ~~~~~~~~~~
;~~~~~~~~~~  ++           ++    ++   ++         ++       ++   +++   ~~~~~~~~~~
;~~~~~~~~~~  ++           ++     +++++     ++++++         +++++ ++  ~~~~~~~~~~

to mosquito-age


  ; Age adult mosquitos
  ask Mosquitos with [color != white] [
    set age age + 1]

  ; Mosquito larvae and pupa will grow above 5 degrees
  if temperature > 4 and temperature < 40 [
    if member? current-month [3 4 5 6 7 8 9] [
      ask mosquitos with [color = white] [
        set age age + 1
        if age >= 20 [
          set color 1 ]
      ]
    ]
  ]
  ; but half will die if temperatures hit above 40
  if temperature > 40 [
    ask n-of (0.5 * count mosquitos with [color = white]) mosquitos with [color = white] [
      die]
  ]
end 

to mosquito-move

  ;This is set up so that all mosquitos move around the water body
  ;as they are flood-water mosquitos.

  ask Mosquitos with [color != white] [
    ifelse blood-meal < blood-max [
      let r min-one-of Reindeers [distance myself]
      ifelse distance r < mosquito-vision [
        face r
        fd random-float mosquito-move-day] [
        rt random 360
        fd random-float mosquito-move-day]
    ] [
      let t min-one-of mosquito-start [distance myself]
      face t
;      print "t"
      ifelse distance t < mosquito-move-day [
        move-to t][
        fd random-float mosquito-move-day
      ]

    ]
  ]
end 

to mosquito-bite

  ; this model will follow the SIRS
  ;Susceptible
  ;Infected


 ; Only consider mosquitoes that are either healthy (color 1) or already infected (color red)
  ask Mosquitos with [color = 1 or color = red] [

; If there are reindeer on the same patch as the mosquito
    if count Reindeers-here != 0 [
      let lunch 0                                                 ; Initialize a variable 'lunch' to store that the mosquito has had a blood meal or partial blood meal
      ifelse count Reindeers-here <= mosquito-bite-day            ; If the number of reindeer on the patch is less than or equal to the number of bites a mosquito can take in a day
        [set lunch Reindeers-here]
        [set lunch n-of mosquito-bite-day Reindeers-here ]        ; if there are 50 reindeer, they will bite all 50, if 100 reindeer, they will bite random 50 if mosquito bite is 50

      set blood-meal blood-meal + (count lunch * random-float blood-meal-size)       ; Increase the mosquito's blood meal by an amount proportional to the number of reindeer bitten and a random factor of the blood-meal-size
;      if blood-meal >= blood-max [
;        print "blood!"
;        print blood-meal]

      let infected-lunch lunch with [infected? = true]           ; Create a subset of 'lunch' that includes only the reindeer that are already infected

      let i 0
      while [i < count infected-lunch] [                         ; Create a subset of 'lunch' that includes only the reindeer that are already infected
        if random-float 1 < infected-probability [               ; If a randomly generated number between 0 and 1 is less than the infected-probability
          set infected 1                                         ; can add m.f. load here (avg 3-6 per mosquito)
          set color red
          ]

        set i i + 1
      ]

      print infected-lunch


    ]


  ]
end 

to mosquito-reproduce-die


; Only reproduction happening from April to September

  if member? current-month [4 5 6 7 8 9] [

    ask mosquitos with [blood-meal >= blood-max] [
      if member? patch-here mosquito-start [
        hatch-mosquitos eggs [
          set infected 0
          set color white
          set age 0
          set blood-meal 0
        ]

;        print "babies!"]
;      print count mosquitos with [color = white]
      set blood-meal 0
    ]


; Some percentage of adult mosquitos die after reproduction
    if random-float 1 < percent-die-oviposit [
      die ]
  ]
  ]

; Mosquitoes have a short life expectancy
  ask mosquitos with [age >= max-age] [
    die]

; Mosquitos die off after september
  ask mosquitos with [color != white] [
    if member? current-month [10 11 12 1 2 3] and temperature < 1 [
      die ]
  ]
end 

;~~~~~~ ++++++++   ++        ++++++++   +++++  +++++   ++++++++   ++++++++  +++++++  ~~~~~~~~~~~~
;~~~~~~ ++         ++           ++      ++ ++ ++  ++   ++    ++      ++     ++       ~~~~~~~~~~~~
;~~~~~~ ++         ++           ++      ++  ++++  ++   ++    ++      ++     ++       ~~~~~~~~~~~~
;~~~~~~ ++         ++           ++      ++   ++   ++   ++    ++      ++     +++++    ~~~~~~~~~~~~
;~~~~~~ ++         ++           ++      ++        ++   ++++++++      ++     ++       ~~~~~~~~~~~~
;~~~~~~ ++         ++           ++      ++        ++   ++    ++      ++     ++       ~~~~~~~~~~~~
;~~~~~~ ++         ++           ++      ++        ++   ++    ++      ++     ++       ~~~~~~~~~~~~
;~~~~~~ ++++++++   ++++++++  ++++++++   ++        ++   ++    ++      ++     +++++++  ~~~~~~~~~~~~

to temp

  ; This is to set random temperatures for the meterological seasons of DJF, MAM, JJA, SON
  ; DJF is between -30 and 00
  ; MAM is between -05 and 05
  ; JJA is between  10 and 15
  ; SON is between  00 and 05
  set current-month time:get "month" current-date

  ifelse member? current-month [1 2 12] [
    set temperature random -30
  ][
    ifelse member? current-month [3 4 5] [
      set temperature -5 + random 5
    ][
      ifelse member? current-month [6 7 8] [
        set temperature 10 + random 15
      ][
        set temperature 0 + random 5
      ]
    ]
  ]
end 

to precipitation


; procedure to create random snow when the temperature is below 0.  for now if the month is DJF, snowfall has a probability of 30%
; if the month is MAM, snowfall has a probability of 15%
; if the month is JJA, snowfall has a 5%
; if the month is SON, snowfall has a 10%

; the snow should "disappear" after 3 consecutive days of temp over 0 degrees

  let precip-prob 0
  let precip-dens 0
  let snow-prob 0
  let snow-dens 0


  set current-month time:get "month" current-date

  ifelse member? current-month [12 1 2] [
    set precip-prob 5
    set precip-dens 0.05 * world-size
    set snow-prob 30
    set snow-dens 0.5 * world-size
  ]
  [ ifelse member? current-month [3 4 5] [
     set precip-prob 10
     set precip-dens 0.15 * world-size
     set snow-prob 15
     set snow-dens 0.3 * world-size
    ]
    [ ifelse member? current-month [6 7 8] [
      set precip-prob 30
      set precip-dens 0.40 * world-size
      set snow-prob 5
      set snow-dens 0.1 * world-size
      ]
      [ set precip-prob 15
        set precip-dens 0.25 * world-size
        set snow-prob 10
        set snow-dens 0.2 * world-size
      ]
    ]
  ]

  ask n-of snow-dens patches with [pcolor = brown or pcolor = green] [
    if temperature < 1 [
      set pcolor white]
  ]

    ; Snow melts after 3 consecutive warm days (days above 0)
  ask patches with [pcolor = white] [
    if temperature > 0 and cold-warm-days > 2 [
      set pcolor brown]
  ]
  ;Rain

  if temperature > 0 [
    ;Rain on grass or dirt
    ifelse random-float 100 < precip-prob [
      set rainy-days rainy-days + 1
      ask n-of precip-dens patches with [pcolor != blue] [
        set pcolor 104
      ]
    ][
      set rainy-days 0
    ]

    ;Expand or contract ephemeral water depending on how much it rained
    ;if it rains more than 2 consecutive days, the area will pond randomly
    ifelse rainy-days < 2 [
      ask patches with [pcolor = 104] [
        set pcolor brown
      ]
    ][
      ask patches with [pcolor = 104] [
        if any? neighbors with [pcolor = brown or pcolor = green] [
          ask one-of neighbors with [pcolor = brown or pcolor = green] [
            set pcolor 104
            ]
          ]
        ]
      ]
      ]
  ;if it rains for 5+ consecutuve days, then the permanent waterbodies will flood and expand
  if rainy-days > 4 [
    ask patches with [pcolor = green or pcolor = brown] [
      if any? neighbors with [pcolor = blue] [
        set pcolor 107]
    ]
  ]

  ; if it doesn't rain for 2 days, then the permenant water bodies that previously flooded will contract. (I will have to fix this)
  if rainy-days < 2 [
    ask patches with [pcolor = 107] [
      set pcolor brown]
  ]
end 

There is only one version of this model, created 8 days ago by Stephania Zneimer.

Attached files

File Type Description Last updated
Modeling Setaria tundra.png preview Preview for 'Modeling Setaria tundra' 8 days ago, by Stephania Zneimer Download

This model does not have any ancestors.

This model does not have any descendants.