Random Walk Periodic Boundary Condition 2D Lattice
Model was written in NetLogo 5.0.4
•
Viewed 638 times
•
Downloaded 38 times
•
Run 0 times
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
;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; variable declarations ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;; globals [ root-mean-square sum-distance sum-prob west-prob-scale east-prob-scale north-prob-scale south-prob-scale prob ] ;;;;;;;;;;;;;;;;;;;;;; ;; setup procedures ;; ;;;;;;;;;;;;;;;;;;;;;; ;; set up the patches and creates turtles to setup clear-all set-patch-size (200 / boundary) resize-world (- boundary) boundary (- boundary) boundary ask patches [ set pcolor gray + 3 ] init-constant setup-turtles reset-ticks end to setup-turtles crt number-of-particles [ set color black pen-down ] end to init-constant set sum-prob (west-prob + east-prob + north-prob + south-prob) set west-prob-scale (west-prob / sum-prob) set east-prob-scale (east-prob / sum-prob) set north-prob-scale (north-prob / sum-prob) set south-prob-scale (south-prob / sum-prob) end ;;;;;;;;;;;;;;;;;;;;;;;; ;; runtime procedures ;; ;;;;;;;;;;;;;;;;;;;;;;;; to go ;; have the turtles randomly pick north, south, west, east and ;; move in that direction ask turtles [ set color blue set prob (random-float 1) if (prob < west-prob-scale) [ ;; go west set heading 270 forward 1 ] if (prob > west-prob-scale) and (prob < west-prob-scale + east-prob-scale) [ ;; go east set heading 90 forward 1 ] if (prob > west-prob-scale + east-prob-scale) and (prob < west-prob-scale + east-prob-scale + north-prob-scale) [ ;; go north set heading 0 forward 1 ] if (prob > west-prob-scale + east-prob-scale + north-prob-scale) [ ;; go south set heading 180 forward 1 ] set color black ] ;; calculate root mean square of distance of all particles set sum-distance 0 foreach sort turtles [ ask ? [ set sum-distance (sum-distance + (xcor * xcor + ycor * ycor)) ] ] set root-mean-square (sqrt (sum-distance / (count turtles))) tick end
There are 4 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Random Walk Periodic Boundary Condition 2D Lattice.png | preview | Preview for 'Random Walk Periodic Boundary Condition 2D Lattice' | about 11 years ago, by Do Trong Thanh | Download |
This model does not have any ancestors.
This model does not have any descendants.