⇠ Back to the gallery

Coupled hopf oscillators

Implementation of a Hopf oscillator template in codyn. The Hopf oscillator is represented in polar coordinates. After having defined the template, 5 oscillators are created with randomized initial conditions. Bidirectional coupling between subsequent oscillators (i.e. coupled in a chain) is defined such that the oscillators converge to exactly one single traveling wave across all oscillators. Line 40 shows how to use embedded calculations which are evaluated at parse time.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
templates {
  node "polar_hopf" {
    f = 1
    omega = "2 * pi * f"

    p' = "omega"

       mu = 1
    gamma = 5

     r = "mu"
    r' = "gamma * (mu - r^2) * r"

    x = "r * cos(p)"
  }

  edge "polar_coupling" {
    bias = 0
    weight = 1

    p' += "weight * input.r *
           sin(input.p - output.p - bias)"
  }
}

# Define a macro 'n'. Its value can be used later
# using the @n syntax.
defines {
  n = "5"
}

node "h{1:@n}" : polar_hopf {
  p = "rand(-pi, pi)"
  r = 0.001
}

<bidirectional>
edge from "h{1:@n}" to "h$(@1 + 1)" : polar_coupling {
  s = [-1, 1]
  bias = "s * $(2 * pi / @n)"
}

⌦ Open in playground