Covid-19_with_social_distancing

Covid-19_with_social_distancing preview image

1 collaborator

Default-person Alan Mode (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.1.1 • Viewed 382 times • Downloaded 18 times • Run 0 times
Download the 'Covid-19_with_social_distancing' modelDownload this modelEmbed this model

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


WHAT IS IT?

The model is a visualization of the transmission of a virus through a human population and the potential impact of social distancing on person-to-person contagion. The model is loosely based on the Virus model of the Netlogo Models Library and a model by Anamaria Berea of the Covid-19 virus (see citations). The model provides the user with control over parameters frequently considered as factors in the development of a wide-scale (pandemic) infectious viral disease. The time scale is in DAYS reflecting the rapid spread of such a disease. The population is broadly broken into four segments: young, adult, mature, and elderly, the fractions chosen by the user. Each segment has its own chance of infection and chance of recovery.

Global factors include duration of infection (infecious but asymptomatic), duration of sickness (infectious and symptomatic), and duration of immunity following recovery. Deaths are recorded but dead agents are returned to the population.

"Social distancing" (SD) became an issue with Covid-19 and a parameter for SD effectiveness has been included. An agent has a probability of avoiding other turtles by not moving to a patch where others are located. If the agent does move to an occupied patch it may become infected based on its individual (age related) chance of becoming infected. If the agent is already infected or sick, it can infect others on the common patch.

HOW TO USE IT

Procedural notes

  • The units in the model are critical to proper use.
  • The internal time unit (tick) is 1 DAY.
  • The percentage sliders are in integer units.
  • The sum of the population percentages must equal 100 or the code stops and an error is reported in the Command Center.

--- User selected sliders (GLOBAL): number-people: 0 - 10000 (deaths are replaced, initial population is retained for run) initial-infected: 0 - 10% of number-people sd-effective: 0 - 100% effectivness of social-distancing infection-duration: asymptomatic sick DAYS (infectious) sickness-duration: symptomatic sick DAYS (infectous) immunity-duration: immune to infection DAYS

--- User selected sliders (AGE SPECIFIC): The population is divided into four groups: youth, adult, mature, and elderly. The specific age of each group is not important since the agents do not age. The duration of each agent's infection, sickness and immunity do age and change according to the parameters set by the user.

Chance of contracting illness when in contact with an infections agent is user-selected over range 0 - 100%. infection-young infection-adult infection-mature infection-elderly

Chance of recovery following sickness-duration period is user selected over range 0 - 100%. Failure to recover is death. Dead agents ARE replaced. recovery-young recovery-adult recovery-mature recovery-elderly

--- Run will stop at 1092 ticks (3 years, 1092 days)

--- The turtles in the display are color-coded as follows: gray - healthy yellow - infected red - sick green - immune

CREDITS AND REFERENCES:

Model author: V. Alan Mode, alan MODE associates, Pleasanton, CA, kk6zl@comcast.net

Corvid-19 model: Anamaria Berea, Associate Term Professor in Computational and Data Sciences, George Mason University, http://modelingcommons.org/browse/onemodel/6227#modeltabsbrowseinfo

Netlogo Virus model: Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. COPYRIGHT AND LICENSE Copyright 1998 Uri Wilensky.

Comments and Questions

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

Click to Run Model

turtles-own
  [ age                  ;; age group: Young, Auult, Mature, Elderly
    healthy?             ;; if true, not infected, sick or immune
    infected?            ;; if true, turtle is infected
    infected-time        ;; how long, in days, the turtle has been infectous
    sick?                ;; if true, the turtle is symptomatic
    sick-time            ;; how long, in days, the turtle has been symptomatic
    immune?              ;; if true, turtle is immune
    immune-time          ;; how long, in days, the turtle has been immune
    chance-infection     ;; / 100 = the probability of infection for given age
    chance-recover       ;; / 100 = the probability of recovery for given age
  ]

globals
  [ young                ;; number of young (constant set from interface % slider)
    adult                ;; number of adults
    mature               ;; number of martures
    elderly              ;; number of elderly
    initial-infected     ;; total number of initial people infected
    %infected            ;; what % of the population is infectious
    %sick                ;; what % of the population is symptomatic
    %immune              ;; what % of the population is immune
    young-sick           ;; total young getting sick
    young-deaths         ;; count of young who have died
    young-deaths%        ;; % of young who have died
    adult-sick           ;; total adults getting sick
    adult-deaths         ;; count of adults who have died
    adult-deaths%        ;; % of adults who have died
    mature-sick          ;; total mature getting sick
    mature-deaths        ;; count of mature who have died
    mature-deaths%       ;; % of mature who have died
    elderly-sick         ;; total elderly getting sick
    elderly-deaths       ;; count of elderly who have died
    elderly-deaths%      ;; % of elderly who have died
    deaths               ;; count of total deaths during run
    deaths%              ;; deaths as percent of original population
    mark                 ;; dummy for plotting year marks
  ]

to setup
  ;; check for error in setting % of population sliders
  if ( %young + %adult + %mature + %elderly) != 100 [
    print "POPULATION DISTRIBUTION ERROR"
    print %young + %adult + %mature + %elderly
    stop ]

  clear-all                      ;; The setup is divided into five procedures
    setup-constants
    init-values
    setup-turtles
    update-global-variables
    update-display
  reset-ticks
end 

to setup-constants     ;; This sets up constants of the model
  set initial-infected initial-infected% * number-people / 100

  set young %young * number-people / 100       ;; convert % to numbers
  set adult %adult * number-people / 100
  set mature %mature * number-people / 100
  set elderly %elderly * number-people / 100
end 

to init-values     ;; initialize values to 0
  set young-deaths 0
  set adult-deaths 0
  set mature-deaths 0
  set elderly-deaths 0
  set young-deaths% 0
  set adult-deaths% 0
  set mature-deaths% 0
  set elderly-deaths% 0
end 

to setup-turtles
  create-turtles young                     ;; number-people set in interface
    [ setxy random-xcor random-ycor        ;; random location
      set size .9                          ;; easier to see
      set age 10                           ;; age = Young
      get-infection                        ;; set age-dependent parameters
      get-recover
      get-healthy ]                        ;; make every turtle healthy
  create-turtles  adult                    ;; number-people set in interface
    [ setxy random-xcor random-ycor        ;; random location
      set size .9                          ;; easier to see
      set age 30                           ;; age = Adult
      get-infection                        ;; set age-dependent parameters
      get-recover
      get-healthy ]                        ;; make every turtle healthy
  create-turtles mature                    ;; number-people set in interface
    [ setxy random-xcor random-ycor        ;; random location
      set size .9                          ;; easier to see
      set age 50                           ;; age = Mature
      get-infection                        ;; set age-dependent parameters
      get-recover
      get-healthy ]                        ;; make every turtle healthy
  create-turtles elderly                   ;; number-people set in interface
    [ setxy random-xcor random-ycor        ;; random location
      set size .9                          ;; easier to see
      set age  70                            ;; age = Elderly
      get-infection                        ;; set age-dependent parameters
      get-recover
      get-healthy ]                        ;; make every turtle healthy

  ask n-of initial-infected turtles                ;; set initial number of infected
    [ get-infected ]
end 

to get-infection     ;; set each turtle's chance of infection for their age (interface)
  if age = 10 [ set chance-infection infection-young ]
  if age = 30 [ set chance-infection infection-adult ]
  if age = 50 [ set chance-infection infection-mature ]
  if age = 70 [ set chance-infection infection-elderly ]
end 

to get-recover     ;; set each turtle's chance of recovery for their age (interface)
  if age = 10 [ set chance-recover recover-young ]
  if age = 30 [ set chance-recover recover-adult ]
  if age = 50 [ set chance-recover recover-mature ]
  if age = 70 [ set chance-recover recover-elderly ]
end 

to get-healthy           ;; set healthy parameters
  set healthy? true
  set infected? false
  set infected-time 0
  set sick? false
  set sick-time 0
  set immune? false
  set immune-time 0
end 

to get-infected              ;; set infected parameters
  set healthy? false
  set infected? true
  set infected-time 0        ;; infection duration set in interface
  set sick? false
  set sick-time 0
  set immune? false
  set immune-time 0
end 

to get-sick                  ;; set sick parameters
  set healthy? false
  set infected? false
  set infected-time 0
  set sick? true
  set sick-time 0            ;; sickness duration set in interface
  if age = 10 [set young-sick young-sick + 1]   ;; collect data on sick distribution
  if age = 30 [set adult-sick adult-sick + 1]
  if age = 50 [set mature-sick mature-sick + 1]
  if age = 70 [set elderly-sick elderly-sick + 1]
  set immune? false
  set immune-time 0
end 

to get-immune             ;; set immune parameters
  set healthy? false
  set infected? false
  set infected-time 0
  set sick? false
  set sick-time 0
  set immune? true
  set immune-time 0          ;; immunity duration set in interface
end 

to go
  ask turtles
    [ get-older
    if infected-time > infection-duration [ get-sick ]
    if sick-time > sickness-duration  [ recover-or-die ]
    if immune-time > immunity-duration [ get-healthy ]
    move
    ]
  update-global-variables
  update-display

  ;; if there is no one infected or sick, introduce sick turtles to test herd immunity
  let ill count turtles with [infected?] + count turtles with [sick?]
  if ill < initial-infected [
      ask n-of (initial-infected - ill ) turtles  ;; reset initial number of infected
    [ get-infected ]
    ]

  ifelse ( ticks = 364 or ticks = 728 or ticks = 1092 )     ;; put year marker on plot
    [ set mark 10 ]
    [ set mark 0 ]

  if  ticks >= 1093  [ stop ]     ;; stop at 3 years (1092 days)
  tick
end 

to update-global-variables
  set %infected 100 * count turtles with [ infected? ] / number-people
  set %sick 100 * count turtles with [ sick? ] / number-people
  set %immune 100 * count turtles with [ immune? ] / number-people
  set young-deaths%  100 * young-deaths / young
  set adult-deaths% 100 * adult-deaths / adult
  set mature-deaths% 100 * mature-deaths / mature
  set elderly-deaths% 100 * elderly-deaths / elderly
  set deaths% 100 * deaths / number-people
end 

to update-display
  ask turtles                                      ;; set turtle to appropriate color:
    [ set color ifelse-value infected? [ yellow ]  ;;  infected = yellow
      [ ifelse-value sick? [ red ]                 ;;  sick = red
        [ ifelse-value immune? [green ] [ gray ]   ;;  immune = green
        ]                                          ;;  healthy = gray
      ]
    ]
end 

to get-older     ;;infected-time, sick-time, immune-time are increased
  if infected? [ set infected-time infected-time + 1 ]
  if sick? [ set sick-time sick-time + 1 ]
  if immune? [ set immune-time immune-time + 1 ]
end 

to move                        ;; turtles turn at random, move forward, then decide what to do
  rt random 100
  lt random 100
  ifelse not any? turtles-on patch-ahead 1 [ fd 1 ]  ;; nobody there, go ahead and move
                                                     ;; somebody there, social distancing important
    [ if random 100 > sd-effective                   ;; ignore sd, move anyway
       [ fd 1
         if any? turtles-here with [ sick? or infected? ]
                                                     ;; any infected or sick here?
          [ if any? turtles-here with [ healthy? ] [
                                                     ;; any healthy mixed with infected or sick?
                                                     ;; if so check chance of infection
            ask turtles-here with [ healthy? ] [ if random 100 < chance-infection [ get-infected ] ] ]
          ]
       ]
    ]
end 

;; Once the turtle has been sick long enough, it
;; either recovers (and becomes immune) or it dies.
;; Deaths are counted but turtle is not removed so population is retained for run.

to recover-or-die
  ifelse random 100 < chance-recover [ get-immune ]

  [ if age = 10 [ set young-deaths young-deaths + 1 ]
    if age = 30 [set adult-deaths adult-deaths + 1]
    if age = 50 [set mature-deaths mature-deaths + 1]
    if age = 70 [set elderly-deaths elderly-deaths + 1]
    set deaths deaths + 1                        ;; count death but don't remove turtle
    get-healthy                                  ;; reset turtle in population
    ]
end 

There is only one version of this model, created almost 4 years ago by Alan Mode.

Attached files

File Type Description Last updated
Covid-19_with_social_distancing.png preview Preview for 'Covid-19_with_social_distancing' almost 4 years ago, by Alan Mode Download

This model does not have any ancestors.

This model does not have any descendants.