corona

corona preview image

1 collaborator

Wei_xu Wei Xu (Author)

Tags

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

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 infectious
  cured?           ;; if true, the turtle is cured
  body-statue      ;;four value: 0 normal; 1 infected; 2 cured;
  self-protected?  ;;if true, has mask
  sick-time        ;;from infected, caculate by days, cured goto 0
  cure-time        ;;from go into hospital, caculate by days
  age              ;;use later
]

globals[
  sum-GDP                 ;;caculate the total GDP
  sum-cure-consume        ;;caculate the total consume of cure
  sum-sick                ;;caculate the total sicker
  sum-death               ;;caculate the total death
  temp-sicker             ;;caculate the sicker in every step
  hospital-patches        ;;area of hospital
  non-hospital-patches    ;;area of non-hospital
]

to setup
  clear-all

  set sum-GDP 0
  set sum-cure-consume 0
  set sum-sick 0
  set sum-death 0
  set temp-sicker 0

  ;;creat the hospital-area
  set hospital-patches patches with [abs pxcor <= 15 and abs pycor <= 15]
  ask hospital-patches [ set pcolor white ]

  ;;creat the non-hospital-area
  set non-hospital-patches patches with [abs pxcor > 15 or abs pycor > 15]
  ask non-hospital-patches [ set pcolor black ]

  setup-turtles
end 

;;initial the turtles

to setup-turtles
  create-turtles number-people[
    move-to one-of non-hospital-patches
    set color green
    set shape turtle-shape
    set sick? false
    set cured? false
    set body-statue 0
    set self-protected? false
    set age random 30000
    set sick-time 0
    set cure-time 0
  ]
  ask n-of ((number-people * initial-infected-percent) / 100) turtles[
    get-sick
    set sick-time random 7    ;;set the sick-time random, so that the sicker that has sym can go to hospital
  ]
  reset-ticks
end 

;;if turtles sick, use this function

to get-sick
  set body-statue 1
  set color red
  set sick-time 1
  set sick? true
  set sum-sick sum-sick + 1
end 

to go
  ;;process all the turtles on hospital-area
  ask turtles-on hospital-patches
  [
    ;;caculate the cure sonsume
    set sum-cure-consume sum-cure-consume + average-cureconsume-oneday
    ;; the patient cured
    if cure-time > average-cured-time
    [
      cured
    ]
    ;;auto add the cure-time
    set cure-time cure-time + 1

    ;;process the death
    ;;because of the deathrate too small, the random hardly get
    ;;so use another way to process the death
    ;;pay attention if use die, the code after die will not process
    if random-float 1000 < deathrate
    [
      set sum-death sum-death + 1
      die
    ]
  ]

  ;;process all the turtles on non-hospital-area
  ask turtles-on non-hospital-patches
  [
    ;; move or not
    if not grounded
    [
      move
      ;;caculate the GDP
      set sum-GDP sum-GDP + average-GDP-oneday
    ]
    ;; if sick
    if body-statue = 1
    [
      ;; infect other first
      ask other turtles-here with [ body-statue = 0 ]
      [
        ifelse masked
        [
          if random-float 100 < infected-with-protect
          [
            get-sick
          ]
        ]
        [
          if random-float 100 < infected-without-protect
          [
            get-sick
          ]
        ]
      ]
      ;; go to hospital
      if sick-time > average-symptomappear-time
      [
        gotohospital
      ]

      ;; add sick-time
      set sick-time sick-time + 1
    ]
  ]
  ;; caculate the tick
  tick
end 

;; Turtles move if not in hospital at random.
;; if near hospital, random throw to non hospital area

to move ;; turtle procedure
  ifelse (abs xcor < 18 and abs ycor < 18)[
    move-to one-of non-hospital-patches
  ][
    rt random 100
    lt random 100
    fd 2
  ]
end 

;;go to hospital, set cure-time = 1

to gotohospital
  move-to one-of hospital-patches
  set cure-time 1
end 

;; if cured, move out of hospital

to cured
  set sick? false
  set cured? true
  set sick-time 0
  set cure-time 0
  set color blue
  set body-statue 2
  move-to one-of non-hospital-patches
end 

There is only one version of this model, created over 3 years ago by Wei Xu.

Attached files

File Type Description Last updated
corona.png preview Preview for 'corona' over 3 years ago, by Wei Xu Download

This model does not have any ancestors.

This model does not have any descendants.