From 31642fc01923c78b07f5a320f86bff54ee7a2d92 Mon Sep 17 00:00:00 2001 From: Martin Lange <martin.lange@ufz.de> Date: Mon, 8 Feb 2021 00:40:58 +0100 Subject: [PATCH] setup basic no-op model with globals --- README.md | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 20157be..2f966ea 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,51 @@ # Literate NetLogo -This is an example project to demonstrate Literate Programming to create [NetLogo](https://ccl.northwestern.edu/netlogo/) models from ODD+C protocols. +This is an example project to demonstrate Literate Programming to create [NetLogo](https://ccl.northwestern.edu/netlogo/) models from ODD+C protocols. ## Rabies model - ODD protocol ### Purpose +### Entities, state variables, and scales +Each patch has a disease state. -### Entities, state variables, and scales +```netlogo +;- State variables +patches-own [ + state +] +``` -### Process overview and scheduling +```netlogo +;- Disease states +globals [ + EMPTY + S + I + R +] +``` ```netlogo -;- file:Code.nls -; ==> Setup. -; ==> Go. +;- Setup disease states +set EMPTY 0 +set S 1 +set I 2 +set R 3 ``` +### Process overview and scheduling + + ```netlogo ;- Go to go + update-patches tick end + +; ==> Update patches. ``` ### Design concepts @@ -32,6 +55,9 @@ end ```netlogo ;- Setup to setup + clear-all + ; ==> Setup disease states. + update-patches reset-ticks end ``` @@ -40,8 +66,35 @@ end ### Submodels +#### Visualization + +```netlogo +;- Update patches +to update-patches + ask patches [ + ifelse state = EMPTY [ set pcolor white ] + [ ifelse state = S [ set pcolor blue ] + [ ifelse state = I [ set pcolor red ] + [ set pcolor green ] ] ] + ] +end +``` + ## Appendix +### Code + +```netlogo +;- file:Code.nls +; ==> Disease states. + +; ==> State variables. + +; ==> Setup. + +; ==> Go. +``` + ### NetLogo file In the main `nlogo` file, we only "include" an `nls` file to allow for the reverse mode. -- GitLab