## Morphed phase oscillators

Example of the implementation of a phase based Morphed oscillator. Here we see how
to define a template (`morphed`

) which uses the automatic derivation features of
codyn to obtain the derivative (line 12) of a user defined function `f`

(line 9).

Having defined the template, two oscillators are instantiated from it each defining
their own shaping function `f`

(line 23 and 31). The two oscillators
are then phase coupled to bring them into phase.

1 2 3 4 5 6 7 8 9 |
templates { node "morphed" { omega = "2 * pi" mu = "1" gamma = 1 # User defined shaping function. This can be # overridden in realizations of this template f(theta) = "sin(theta)" p' = "omega" r' = "mu * f(p)' + gamma * (mu * f(p) - r)" } edge "coupling" { bias = 0 weight = 1 p' += "weight * sin(input.p - output.p - bias)" } } node "m1" : morphed { f(theta) = "cos(theta * 2 + 0.2 * pi) * (0.1 + sin(theta))" p = "rand(-pi, 0)" r = 6 } node "m2" : morphed { f(theta) = "cos(theta * 2 + 0.2 * pi) * (0.1 + sin(theta)) + 0.5" p = "rand(0, pi)" r = -4 } <bidirectional> edge from "m1" to "m2" : coupling { weight = 0.5 } |