disease propagatiion model

disease propagatiion model preview image

1 collaborator

Tags

covid19 

Tagged by Bernhard Diermaier about 4 years ago

disease control 

Tagged by Bernhard Diermaier about 4 years ago

humans carry disease 

Tagged by Bernhard Diermaier about 4 years ago

infectious disease model 

Tagged by Bernhard Diermaier about 4 years ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 6.1.1 • Viewed 263 times • Downloaded 11 times • Run 0 times
Download the 'disease propagatiion model' 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

globals [          ;; definition of global variables
  day_counter      ;; counter
  bodycount        ;; counter for agents dying from disease
  new_infections   ;; counter for daily new infections
  new_sick         ;; counter for daily new sick agents
  new_recovered        ;; counter for daily new recovered agents
  new_h2h
  new_e2h
  new_bodycount
  total_h2h
  total_e2h
]

patches-own [       ;; definition of patch-related variables
  contamination?    ;; patch contaminated w/ virus: true/false
  cont_timer        ;; counter for duration of patch contamination
]

turtles-own [      ;; definition of agent-related variables
  age              ;; age of agent; random 0...90
  status           ;; health status of agent: healthy...infected...sick...recovered
  mortality        ;; mortality rate by age in case of infection
  daily_mortality  ;; daily mortality over duration of acute stadium
  inc_timer        ;; counter for duration of infection
  sick_timer       ;; counter for duration of acute stadium
  infectuous_timer ;; counter for duration if infectivity before acute stadium
  immune_timer     ;; counter for duration of immunity after sickness
  infectuous?      ;; agent infectuous?? true/false
  quarantine?      ;; sick agent under quarantine? true/false
]


;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Setup of playing field ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup
  clear-all
  crt population [                      ;; creation of agents
    set shape "circle"
    set color white
    set size 1
    set xcor random-xcor
    set ycor random-ycor
    set age random 90
    ifelse age >= 65 [                 ;; agents' mortality in case of infection, depending on agents' age
      set mortality 0.1
    ][
      ifelse age < 65 and age >= 35 [
        set mortality 0.01
      ][
        set mortality 0.005
      ]
    ]
    set inc_timer 0
    set status "healthy"
    set immune_timer 0
    set infectuous? false
    set quarantine? false
  ]

  ask patches [                         ;; preparation of patches on playing field
    set pcolor black
    set contamination? false
    set cont_timer 0
  ]

  set new_infections 0                 ;; global variables set to 0
  set new_sick 0
  set new_recovered 0
  set new_h2h 0
  set new_e2h 0
  set total_h2h 0
  set total_e2h 0
  set new_bodycount 0
  set bodycount 0

  ask n-of initial_infections turtles [                ;; infection of tuned in number of "patients zero"
    set status "infected"
    set color yellow
    set inc_timer round (abs (random-normal incubation_time (incubation_time * 0.5)))                  ;; incubation- sick- and infectivity-counter set to values according to sliders in GUI
    set sick_timer round (abs (random-normal sick_time (sick_time * 0.5)))
    set infectuous_timer (min (list (inc_timer) (random i_b_s)))
    set new_infections new_infections + 1
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; the procedure "go" is the actual framework of the simulation, within which different procedures of agents and patches are organized ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to go

  contain                                   ;; procedure "contain" is called (see further down)
  repeat (steps_per_round) [                ;; via the repetition according to slider "steps per round", the number of potentitial social contacts is simulated
    move                                  ;; non-quarantined agents start moving around...
    infect                                ;; ... and once in place, each of them calls the procedure "infect"
    if env_contamination? [               ;; in case "contamination" in the GUI is on, procedure "contaminate is called to carry out human-2-environment contamination events
      contaminate
    ]
  ]
  evolve                                                     ;; procedure "evolve" are called... (see further down)
  set day_counter day_counter + 1                            ;; "day" counter is increased by one
  update-plots                                               ;; plots are being updated
  set new_infections 0                                       ;; counters for daily infection data are reset
  set new_sick 0
  set new_recovered 0
  set new_h2h 0
  set new_e2h 0
  set new_bodycount 0
  if ( count turtles with [status = "infected"] = 0 ) and ( count turtles with [status = "sick"] = 0 ) [     ;; simulation is interrupted, if there are no more infected or sick agents on the playing field
    stop
  ]
  ;;contain
end 

to move
  ask turtles with [quarantine? = false] [                   ;; non-quarantined Agents move around on the playing field
    let reach random-normal mobility mobility / 3            ;; mobility range for each step via slider "mobility
    rt random 360
    while [ [pcolor] of patch-ahead reach = blue] [          ;; blue patches (cordon sanitaire around sick agents) shall be avoided
      set reach reach + 5]
    fd reach
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; agents check for human-2-human (and environment-2-human) infection events ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to infect
  ask turtles with [status = "healthy"] [                                       ;; "healthy" agents check for infectuous agents within the infection radius...
    let a count turtles in-radius infection_radius with [infectuous?]
    if random-float 1 <= (H2H_infection * a) [                                    ;; ...and check for human-to-human infection events according to infection probability and number of infected agents within infection radius
      set status "infected"
      set color yellow
      set inc_timer round (abs (random-normal incubation_time (incubation_time * 0.3)))             ;; individual incubation time...
      set sick_timer round (abs (random-normal sick_time (sick_time * 0.3)))                         ;; ... as well as individual duration of acute phase...
      set infectuous_timer (min (list (inc_timer) ceiling (1.2 * random i_b_s)))  ;; ... and the individual infectivity before outbreak of sickness are set
      set new_infections new_infections + 1
      set new_h2h new_h2h + 1
      set total_h2h total_h2h + 1
    ]
    if [contamination?] of patch-here = true and random-float 1 <= E2H_infection [                     ;; if their patch is contaminated, they check for environment-to-human infection according to the respective infection probability
      set status "infected"
      set color yellow
      set inc_timer round (abs (random-normal incubation_time (incubation_time * 0.3)))                  ;; incubation- sick- and infectivity-counter set to values according to sliders in GUI
      set sick_timer round (abs (random-normal sick_time (sick_time * 0.3)))
      set infectuous_timer (min (list (inc_timer) ceiling (1.2 * random i_b_s)))
      set new_infections new_infections + 1
      set new_e2h new_e2h + 1
      set total_e2h total_e2h + 1
    ]
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; patches check for human-2-environment contamination events ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to contaminate
  ask patches [
    if any? turtles-here with [status = "infected"] and random-float 1 <= E_contamination [      ;; contamination event according to contamination probability
      set contamination? true
      set cont_timer 1
      set pcolor grey                                                                            ;; contaminated patches are marked grey
    ]
  ]
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; agents individually check for necessity of quarantine measures ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to contain
  if containment? = true[
    ask turtles with [quarantine? = true] [    ;; in case the quarantine-marker is active, agents draw a cordon sanitaire of blue patches around themselves...
      ask patches in-radius (1.1 * infection_radius) [
        set pcolor blue
      ]
    ]
    ask turtles with [quarantine? = false] [   ;; ... and non-quarantined agents move off the blue patches
      while [ [pcolor] of patch-here = blue] [
        fd 5
      ]
    ]
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; the procedure "evolve" prepares the agents and patches for the upcoming simulation round ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to evolve
  if immunity? = false [                                           ;; time for immunity after acute phase is limited, if switch is inactive.
    ask turtles with [status = "recovered"] [
      ifelse immune_timer > 0 [
        set immune_timer immune_timer - 1
      ][
        set status "healthy"
        set color white
        set mortality mortality / 3
        set inc_timer 0
        set immune_timer 0
        set infectuous? false
        set quarantine? false
      ]
    ]
  ]
  ask turtles with [status = "sick"] [                          ;; sick agents ceck, if they die from the disease within the acute stadium (sick timer > 0)...
    ifelse sick_timer = 0 [                                  ;; if the sick timer reaches zero, the agent can switch off the cordon sanitaire (set patches back to black)...
      set_back_patches
      set status "recovered"                ;; and set their status to "recovered", which also makes them immune to new infections
      set new_recovered new_recovered + 1
      set color green
      if immunity? = false [
        set immune_timer round (abs (random-normal immunity_duration (immunity_duration * 0.2)))
      ]
      set infectuous? false
      set quarantine? false

    ][
      set sick_timer max (list (0) (sick_timer - 1))                             ;; ... but first, the sich timer counts down by one...
      if random-float 1 <= daily_mortality [                    ;; ... and in case of bad luck, switch off their cordon sanitaire...
        set_back_patches
        set bodycount bodycount + 1                            ;; ...update the body count, and die
        set new_bodycount new_bodycount + 1
        die
      ]
    ]
  ]


  ask turtles with [status = "infected"] [                      ;; first, infected agents update their infectivity status and update counters related to their course of infection
    if inc_timer <= infectuous_timer [
      set infectuous? true
      set infectuous? true
      set color orange
    ]
    if inc_timer = 0 [                                          ;; then, they check for a status update from "infected" to "sick" (the acute stadium)
      set status "sick"
      set new_sick new_sick + 1
      set color red
      set daily_mortality mortality / max (list (1) (sick_timer))
      if containment? = true [                                  ;; quarantine marker is only set "true", if "containment" switch in GUI is activated
        set quarantine? true
      ]
    ]
    if inc_timer > 0 [
      set inc_timer max (list (inc_timer - 1) (0))                  ;; counter for course of infection is updated
    ]
  ]
  ask patches with [contamination? = true] [               ;; contamination timers of each contaminated patch count down by 1...
    ifelse cont_timer > 0 [
      set cont_timer max (list (0) (cont_timer - 1))
    ][                                                     ;; in case the timer is zero, contamination is switched off and tach color is set back to black
      set contamination? false
      set pcolor black
    ]
  ]
end 

to set_back_patches
  ask patches in-radius (1.1 * infection_radius) [
    set pcolor black
  ]
end 

There is only one version of this model, created about 4 years ago by Bernhard Diermaier.

Attached files

File Type Description Last updated
disease propagatiion model.png preview Preview for 'disease propagatiion model' about 4 years ago, by Bernhard Diermaier Download

This model does not have any ancestors.

This model does not have any descendants.