Practical Problem 8: Pinwheels
Spatial Oscillators
Now we will look at a system of spatially arrange oscillators. Each patch in the netlogo world is an oscillator with a phase variable phase
. Each patch interacts with neighboring patches.
Part 1
Initiale a system in which every patch has a random phase in the range 0,360. Color the patches accordingly e.g. with the command
ask patches [
set pcolor hsb phase 100 100
]
Now we would like to write a go function that, at each tick, sets the phase of a patch to the average of the phases of the neighboring patches. How do we compute the average of phases, because they are defined on a circle? Well, we can use cartesian coordinates has a helper. Say $\theta_n$ are the phases of the neighbors we can compute
[ a = \sum_n \cos (\theta _n)\quad b = \sum_n \sin (\theta _n) ]
and then compute the angle via
[ \theta = \tan^{-1} (a,b) ]
Check the netlogo manual for how the trig functions work. Here's a little tip how this can be accomplished:
ask patches [
let p phase
let x 0 let y 0
ask neighbors [
set x x + sin phase
set y y + cos phase
]
set phase atan x y
]
Part 2
Now make the phase a dynamic quantity such that the phase in each step is replaced by the average of the phases of the neighbors
[ \theta_n \rightarrow \left<\theta\right> ]