From 4e8c2b297069eadc054c66d262a1cdccb7b912b2 Mon Sep 17 00:00:00 2001 From: Martin Lange <martin.lange@ufz.de> Date: Mon, 8 Feb 2021 00:51:33 +0100 Subject: [PATCH] simple infection model, slider for beta --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ nlogo/Model.nlogo | 27 +++++++++++++++++++++------ 2 files changed, 63 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2f966ea..3660d7b 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Each patch has a disease state. ;- State variables patches-own [ state + infected-neighbours ] ``` @@ -41,10 +42,12 @@ set R 3 ```netlogo ;- Go to go + infect-patches update-patches tick end +; ==> Infection. ; ==> Update patches. ``` @@ -57,6 +60,14 @@ end to setup clear-all ; ==> Setup disease states. + + ask patches [ + set state S + ] + ask one-of patches [ + set state I + ] + update-patches reset-ticks end @@ -66,6 +77,37 @@ end ### Submodels +#### Infection + +```netlogo +;- Infection +to infect-patches + ask patches [ + set infected-neighbours 0 + ] + ask patches with [ state = I ] [ + ask neighbors [ + set infected-neighbours infected-neighbours + 1 + ] + ] + ask patches with [ state = S ] [ + if random-float 1 < calc-infection-prob [ + set state I + ] + ] +end + +; ==> Infection probability. +``` + +```netlogo +;- Infection probability +to-report calc-infection-prob + report 1 - (1 - beta) ^ infected-neighbours +end +``` + + #### Visualization ```netlogo diff --git a/nlogo/Model.nlogo b/nlogo/Model.nlogo index 9437b79..d55b648 100644 --- a/nlogo/Model.nlogo +++ b/nlogo/Model.nlogo @@ -1,9 +1,9 @@ __includes["Code.nls"] @#$#@#$#@ GRAPHICS-WINDOW -220 +230 10 -733 +743 524 -1 -1 @@ -30,7 +30,7 @@ ticks BUTTON 10 10 -80 +110 50 NIL setup @@ -45,9 +45,9 @@ NIL 1 BUTTON -90 +115 10 -160 +215 50 NIL go @@ -59,7 +59,22 @@ NIL NIL NIL NIL +0 + +SLIDER +10 +62 +215 +95 +beta +beta +0 1 +0.2 +0.01 +1 +NIL +HORIZONTAL @#$#@#$#@ ## WHAT IS IT? @@ -90,5 +105,5 @@ true Line -7500403 true 150 150 90 180 Line -7500403 true 150 150 210 180 @#$#@#$#@ -0 +1 @#$#@#$#@ -- GitLab