Virus CoronaVirus

Virus CoronaVirus preview image

1 collaborator

Default-person Ramon Barros (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.1.1 • Viewed 58 times • Downloaded 3 times • Run 0 times
Download the 'Virus CoronaVirus' 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

turtles-own
  [ sick?                ;; if true, the turtle is sick
    infected?						 ;; if true, turtle is infected
    remaining-immunity   ;; how many weeks of immunity the turtle has left
    sick-infected-time   ;; how long, in weeks, the turtle has been infectious
    age                  ;; how many weeks old the turtle is
    sick-around          ;; is there anyone sick around the turtle?
    nearest-sick         ;; the nearest sick turtle around the
    full-life            ;; how much the turtle will live
    get-sick-factor      ;; disease recovery changes with age
    reproduce-number     ;; Maximum number of sons/daughers a turtle may generate
]

globals
  [ %infected            ;; what % of the population is infectious
    %sick								 ;; what % of the population is sick
    %immune              ;; what % of the population is immune
    %dead                ;; Sickness death relative to total death (dead-sick / total-dead)
    dead-sick            ;; How many ppl died by sickness
    dead-total           ;; How many ppl died
    births               ;; How many ppl born
    lifespan             ;; the average lifespan of the turtle population
    chance-reproduce     ;; The probability of a turtle being hatched each simulation tick per turtle in the simulation
    reproduce-factor     ;; Factor of reproduction
    carrying-capacity    ;; the number of turtles that can be in the world at one time
    immunity-duration    ;; how many weeks immunity lasts
]

;; The setup is divided into four procedures

to setup
  clear-all
  setup-constants
  setup-turtles
  update-global-variables
  update-display
  reset-ticks
end 

;; We create a variable number of turtles of which 10 are infectious,
;; and distribute them randomly

to setup-turtles
  create-turtles number-people
    [ setxy random-xcor random-ycor
      set age random lifespan ;; Age is
      set full-life random-normal lifespan (10 * 52)
      while [full-life < age]
        [set age random lifespan]
      set sick-infected-time 0
      set remaining-immunity 0
      set infected? false
      update-size  ;; easier to see
      set-get-sick-factor
      set-reproduce-number
      get-healthy ]
  ask n-of 0 turtles
  [ get-infected ]
end 

to setup-constants
  set lifespan 70 * 52      ;; 70 times 52 weeks = 70 years = 3640 weeks old
  set carrying-capacity 2000
  set reproduce-factor 0.1
  set immunity-duration 9999
end 

to go
  update-chance-reproduce
  if random-float 100 < chance-new-infected
    [create-new-infected]
  if random-float 100 < chance-new-sick
    [create-new-sick]

  ask turtles [
    update-size
    set-get-sick-factor
    get-older
    move
    flee
    if infected? [ infect get-sick ]
    if sick? [ recover-or-die ]
    ifelse sick? [ infect ] [ reproduce ]
  ]
  update-global-variables
  update-display
  tick
end 

to set-get-sick-factor
  set get-sick-factor random-normal ( ((age / 52) ^ 6) * (1.78 * (10 ^ -11)) ) ( 0.5 )
end 

to get-sick ;; turtle procedure
  if sick-infected-time > 2 and random-float 100 < (chance-getting-sick * get-sick-factor);;
  	[	set infected? false
  		set sick? true
      set remaining-immunity 0]
  if sick-infected-time > duration
    [become-immune]
end 

to get-infected ;;
  	set infected? true
    set remaining-immunity 0
end 

to get-healthy ;; turtle procedure
  set sick? false
  set infected? false
  set remaining-immunity 0
  set sick-infected-time 0
end 

to become-immune ;; turtle procedure
  set sick? false
  set infected? false
  set sick-infected-time 0
  set remaining-immunity immunity-duration
end 

to update-chance-reproduce
  if count turtles > 0
    ;;[set chance-reproduce random-normal (100 * (reproduce-factor / count turtles) - (reproduce-factor / (count turtles * 10))) (count turtles / 10 ^ 4)] ;; The most ppl on the simulation, lesser is the intention of reproducing. Needs improvement
  [set chance-reproduce 1]
end 

to set-reproduce-number
  ifelse maximum-sons-by-person > 0
    [ set reproduce-number random (maximum-sons-by-person + 1) ] ;; random command excludes the number eg: random 4 generates 0, 1, 2 or 3. So I summed 1 to the variable.
  [ set reproduce-number 0 ]
end 

to create-new-infected
  create-turtles 1
  [ setxy random-xcor random-ycor
    set age random lifespan
    set full-life random-poisson lifespan
    set sick-infected-time 0
    set remaining-immunity 0
    update-size
    set-reproduce-number
    get-healthy
    get-infected
  ]
end 

to create-new-sick
  create-turtles 1
  [ setxy random-xcor random-ycor
    set age random lifespan
    set full-life random-poisson lifespan
    set sick-infected-time 0
    set remaining-immunity 0
    update-size
    set-reproduce-number
    get-healthy
    get-infected
    get-sick
  ]
end 

to flee
  if flee-from-sick?
  [
    find-sicks
    if any? sick-around
        [find-nearest-sick
          if distance nearest-sick < 2
          [ bk 3 ]]
  ]
end 

to find-sicks  ;; Find group of sick ppl next to agent.
  set sick-around other turtles in-radius 5 with [ sick? ]
end 

to find-nearest-sick ;; People Flee from nearest sick in the simulation
  set nearest-sick min-one-of sick-around [distance myself]
end 


;;Turtle counting variables are advanced.

to get-older ;; turtle procedure
  ;; Turtles die of old age once their age exceeds the
  ;; lifespan (set at 50 years in this model).
  set age age + 1
  if age > full-life
    [ set dead-total dead-total + 1
      die ]
  if immune? [ set remaining-immunity remaining-immunity - 1 ]
  if infected? [ set sick-infected-time sick-infected-time + 1 ]
  if sick? [ set sick-infected-time sick-infected-time + 1 ]
end 

;; Turtles move about at random.

to move ;; turtle procedure
  ifelse sick-can-move?
    [ rt random 100
      lt random 100
      ifelse age < (50 * 52)
        [ fd 1.0 ]
        [ fd 0.5 ]
    ]
    [ rt random 100
      lt random 100
      if sick? = false
        [ifelse age < (50 * 52)
          [ fd 1.0 ]
          [ fd 0.5 ]
  ]]
end 

;; If a turtle is sick, it infects other turtles on the same patch.
;; Immune turtles don't get sick.

to infect ;; turtle procedure
  ask other turtles-here with [ not infected? and not immune? and not sick? ]
    [ if random-float 100 < infectiousness
      [ get-infected ] ]
end 

;; Once the turtle has been sick long enough, it
;; either recovers (and becomes immune) or it dies.

to recover-or-die ;; turtle procedure
  if sick-infected-time > duration               ;; If the turtle has survived past the virus' duration, then
    [ ifelse random-float 100 < chance-recover   ;; either recover or die
      [ become-immune ]
      [ set dead-total dead-total + 1
        set dead-sick dead-sick + 1
        die ] ]
end 

;; If there are less turtles than the carrying-capacity
;; then turtles can reproduce.

to reproduce
  if age > (18 * 52) and age < (55 * 52)
    [ if count turtles < carrying-capacity and random-float 100 < chance-reproduce and reproduce-number > 0
      [ set reproduce-number reproduce-number - 1
        set births births + 1
        hatch 1
        [ set age 1
          set full-life random-normal lifespan (25 * 52)
          set-reproduce-number
          update-size
          set-get-sick-factor
          lt 45 fd 1
          get-healthy ] ]
  ]
end 

to update-size
  set size ((age / lifespan) * 1.5) + 0.5
end 

to update-global-variables
  if count turtles > 0
  [ set %infected ((count turtles with [ infected? ] + count turtles with [sick?]) / count turtles) * 100
    set %immune (count turtles with [ immune? ] / count turtles) * 100
    set %sick (count turtles with [sick?] / count turtles) * 100
    if dead-total > 0
      [ set %dead (dead-sick / dead-total) * number-people ]
  ]
end 

to update-display
  ask turtles
    [ if shape != turtle-shape [ set shape turtle-shape ]
      set color ifelse-value infected? [orange] ifelse-value sick? [ red ] [ ifelse-value immune? [ grey ] [ green ] ]
      if age > (55 * 52)
      [set shape "old"]
  ]
end 

to-report immune?
  report remaining-immunity > 0
end 

to startup
  setup-constants ;; so that carrying-capacity can be used as upper bound of number-people slider
end 


; Copyright 1998 Uri Wilensky.
; See Info tab for full copyright and license.

There is only one version of this model, created 5 months ago by Ramon Barros.

Attached files

File Type Description Last updated
Virus CoronaVirus.png preview Preview for 'Virus CoronaVirus' 5 months ago, by Ramon Barros Download

This model does not have any ancestors.

This model does not have any descendants.