Introduction to Complex Systems


Practical Problem 12: Phase Coupled Oscillators

In this problem you will implement a spatial version of the Kuramoto Model, defined by the dynamical system:

$$ \dot\theta_n=\omega+\frac{1}{N}\sum_{m\neq n}K_{nm}\sin(\theta_m-\theta_n). $$

The point is to establish this model and couple individual oscillators to their neighbors, on the lattice of patches.

Setup

Set up the system to give patches two different variables theta and dtheta, the first defining the phase, the the phase increment governed by the differential equation.

The phase should initially be a number between 0 and 360.

Also write a paint function that colors the patches according to phase making use of the hsb function.

Simulation

Now write a go function that iterates over all patches twice. In the first look the increment dtheta should be computed and in the second loop the state variable theta like so

ask patches [
	set dtheta dt * ( ... )
]
ask patches [
	set theta theta + dtheta mod 360
]

Don’t forget the mod 360, it makes sure that the angle variable theta gets wrapped around.

You see in the first loop that you need a time increment dt, let this be a slider variable between 0 and 1.

The universal coupling constant $K$ should also be a slider as well as the natural frequency of the oscillators $\omega$.

The difficulty is computing the increment, specifically computing the sum

$$ K \frac{1}{8}\sum_{m\neq n}\sin(\theta_m-\theta_n). $$

You can try to figure out how to do this. If you fail here’s something you might find helpful:

to-report force [ x neigh ]
	let f 0
	foreach [theta] of neigh [
	y -> set f f + sin (y - x) 
	]
report f	 
end

This reporter takes two arguments a set of agents neigh and a number x. It then loops over the list [theta] of neigh and maps each element (named y), subtracts x, computes the sin of that difference and adds it to the f.