Coupled oscillators

Coupled oscillators preview image

1 collaborator

Default-person julien siebert (Author)

Tags

code example 

Tagged by julien siebert over 11 years ago

oscillation 

Tagged by julien siebert over 11 years ago

physics 

Tagged by julien siebert over 11 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.4 • Viewed 825 times • Downloaded 39 times • Run 0 times
Download the 'Coupled oscillators' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

The Stuart-Landau oscillator model. Several oscillators are coupled.

HOW IT WORKS

Each node (turtle) represent a single oscillator: a variable 'z' which is complex (i.e. z = a + i*b).

The nodes coordinates represent both real part and imaginary part of 'z' (i.e. xcor is the real part and ycor is the imaginary part).

Each node follows the following equation of motion:

dz/dt = (lambda + iomega - |z|^2)z + sigma*c

Where lambda and omega are control parameters.

|z| represents the modulus of the complex number z.

sigma is the strength of the coupling (interaction) between linked nodes.

c represents the coupling and corresponds to the weighted average of distance between nodes (some kind of center of mass).

All the nodes are linked together via a "Watts and Strogatz Small World" where blue links are weighted +1 (excitatory links) and red links are weighted -1 (inhibitory links)

HOW TO USE IT

Choose the number of nodes (note that in this model the nodes do not interact with each other, so you can simply put one node) with the 'nb-node slider'.

Choose the values of lambda and omega.

Set dt (I usually use 0.001). This is the increment of time in the model. For more details about 'dt' see Euler algorithm for numerical simulation of derivative equations.

Choose if you want to see the trajectories of the nodes or if you want to see the link.

Choose the K and beta parameters for the Watts and Strogatz Small World algorithm.

Choose sigma, the strength of the coupling.

Push 'setup' and 'go' :)

THINGS TO NOTICE

Drawing the trajectories helps to see the the stable region (here a cycle).

THINGS TO TRY

Move lambda and omega to see their influence on the behaviour of the nodes. Try with only two or three nodes to see the impact of the coupling.

EXTENDING THE MODEL

You could change the way the nodes are coupled.

NETLOGO FEATURES

RELATED MODELS

Stuart-Landau model

CREDITS AND REFERENCES

I used the code for complex operations directly from the "Mandelbrot model". Thanks, it was really helpful.

See http://www.scholarpedia.org/article/Periodic_orbit if you want to know more about oscillators in general.

For the Watts and Strogatz algorithm, see http://en.wikipedia.org/wiki/WattsandStrogatz_model

Find mode about the "Stuart-Landau" oscillator in Handbook of Chaos Control, edited by E. Schoell and H. G. Schuster (Wiley-VCH, Weinheim, 2008), second completely revised and enlarged edition.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

breed [nodes node]

links-own [ weight ]

to setup
  clear-all
  ;; creates all the nodes
  set-default-shape nodes "circle"
  create-nodes nb-nodes [ setxy random-xcor random-ycor set size 0.125 ]
  ;; link the nodes
  link-nodes
  ;; set simulation time to 0
  reset-ticks
end 

to go
  ifelse draw-trajectories [  ;; draw the trajectories?
    ask nodes [pen-down]
  ][
    ask nodes [pen-up]
  ]
  ifelse draw-links [  ;; show the trajectories?
    ask links [show-link]
  ][
    ask links [hide-link]
  ]
  
  move-nodes
  tick
end 

to move-nodes
  ask nodes
  [
    ;; x and y coordinates of the nodes
    let z-real xcor
    let z-imag ycor
    
    ;; f(z) = (lambda + i*omega - |z|^2)*z
    let mod-z-sq (modulus z-real z-imag) * (modulus z-real z-imag) ;; modulus(z) square
    let fz-real (rmult (lambda - mod-z-sq) omega z-real z-imag)
    let fz-imag (imult (lambda - mod-z-sq) omega z-real z-imag)
    
    ;; interaction of the neighbors: [SUM_j (xj - xi) * wj]/nb_links
    let coupling-real (sum [weight * [xcor - z-real] of other-end] of my-links) / (count my-links)
    let coupling-imag (sum [weight * [ycor - z-imag] of other-end] of my-links) / (count my-links)
    
    ;; euler algorithm
    setxy (xcor + (fz-real + sigma * coupling-real) * dt) (ycor + (fz-imag + sigma * coupling-imag) * dt)
  ]
end 




;; create the links among nodes (Watts and Strogatz algorithm), add weight and color

to link-nodes  
  ;; create a regular lattice
  ask turtles [
    let n 1
    while [ n <= K ]
    [
      ifelse who < (count turtles - K)
      [
        ifelse (random-float 1) < beta
        [
          random-link
        ]
        [
          normal-link n
        ]
      ]
      [
        normal-link n
      ]
      set n (n + 1)
    ]
  ]
end 

to normal-link [n]
  create-link-with turtle ((who + n) mod count turtles)
  [ 
    set color blue
    set weight 1
  ]
end  

;; create a link with another 'not-yet linked' node whose id > caller id 

to random-link  
  let myid who
  let other-node one-of other turtles with [(who > myid) and (not link-neighbor? turtle myid)]
  if other-node != nobody
  [
    create-link-with other-node
    [
      set color red
      set weight -1
    ]
  ]
end 

;;; Real and Imaginary Arithmetic Operators

;;; real part of the multiplication (a+ib)*(c+id) = (ac-bd) + i(ad+cb)
;;; returns the real part (ac-bd)

to-report rmult [real1 imaginary1 real2 imaginary2]
  report real1 * real2 - imaginary1 * imaginary2
end 

;;; imaginary part of the multiplication (a+ib)*(c+id) = (ac-bd) + i(ad+cb)
;;; returns the imaginary part (ad+cb)

to-report imult [real1 imaginary1 real2 imaginary2]
  report real1 * imaginary2 + real2 * imaginary1
end 

;;; returns the modulus of a complex number a+ib

to-report modulus [real imaginary]
  report sqrt (real ^ 2 + imaginary ^ 2)
end 

There is only one version of this model, created over 11 years ago by julien siebert.

Attached files

File Type Description Last updated
Coupled oscillators.png preview Preview for 'Coupled oscillators' over 11 years ago, by julien siebert Download

This model does not have any ancestors.

This model does not have any descendants.