Activity 3: Exploring Coupled Oscillators


In this activity, you will use a program called fireflies+ to study the properties of a system of coupled oscillators. The program is written in StarLogo, a programming language which is designed to implement parallel algorithms. We are interested in coupled oscillators because of their ability to capture the behavior of biological systems which synchronize with each other or with periodic phenomena in their environment. An example of such a biological system is the fireflies described in the Strogatz and Stewart article. These fireflies have the capacity to synchronize their flashes with nearby fireflies.

In this activity we will not be concerned with actually modeling these fireflies. Instead we will be investigating some of the general properties of coupled oscillators. For convenience, however, we will refer to the oscillators as "fireflies." The main behavior we would like to see in our fireflies is synchronization; that is, all of the fireflies should flash at roughly the same time. We will vary the model by changing the values of parameters that control its behavior. In each case, we will observe the effect of the changes and try to explain it.

When you are done with the activity, you should have a better idea of what a computational model is and what it means to experiment with a computational model, as well as how coupled oscillators work and why we are interested in them.

Using StarLogo

When you start up StarLogo, you get 7 windows. Windows which are not visible can be made so by selecting them from the Windows menu. The Interface window contains the various controls to run programs (you won't see anything there until you open a StarLogo program such as fireflies+). The Graphics window shows the graphically displayed output of the program. The title of this window will be the name of the StarLogo program you are running (or "StarLogo" if you aren't running anything). The Output window is where textual output from the program you are running is printed out. The Info window contains information about the program. The Procedures window contains the program itself; you will not need to be concerned about it at this time. We will not be using the Command Center and Toolbar windows. The Toolbar window is the small window containing four images which sits in front of the Interface window. You should close it (by clicking in the upper-left corner) because it will only get in the way.

Start up a particular program, such as fireflies+, in StarLogo by doubling-clicking on its icon or by selecting it after choosing Open... from the StarLogo File menu. It will take a few seconds for the program to load. When it is done, you will see several buttons and sliders in the Interface window. You click on the buttons to set up and run the program. A button with arrows pointing on two directions causes the program to keep doing the same thing over and over again until you click on the button again. The sliders are for setting the values of various variables which control how the program runs.


Make sure that you have a copy of the latest version of the program. It is called fireflies+. You can find it using the instructions for obtaining files with FTP which you should already be familiar with. The file is in Do not get the file fireflies, which is an older version of the program.

The fireflies+ program is described in the Info window which you can access after you have started up the program. What follows is a copy of the text from the Info window of the program.


This program implements a system of coupled oscillators
rougly analogous to a group of fireflies of the type which
synchronize their flashes.  The oscillators will hereafter
be referred to as "fireflies".  A firefly couples with other
fireflies only when those fireflies are "flashing".  Flashes
happen just before and after a firefly's zero phase angle.

The program has two modes, "spatial" and "non-spatial".
In spatial mode, the position of the fireflies matters.
A firefly can "see", that is, can couple with,  other
fireflies only when it is close enough to them; how close
depends on the "flashing radius" of the fireflies.  In
spatial mode, the fireflies move in random directions around
their world.  You can control how often they move.

In non-spatial mode, a firefly sees (couples with) any other
firefly which is flashing; that is, the fireflies have no
position, and hence they do not move.

Fireflies are represented in the Graphics window by blue
dots which turn white when the fireflies are flashing. 
Beyond this detail, however, the display for the two modes
is completely different.  In spatial mode, the fireflies are
shown in their current locations.  When a firefly flashes,
the flashing radius around it is displayed, and any firefly
within the flashing radius, that is, any firefly which
couples with the flashing firefly, turns temporarily pink. 
In this mode, there is also a display option which indicates
the current phase angle and period of each firefly.  These
are represented by a brown line whose direction indicates
the phase angle (3 o'clock is 0 and the movement is
counter-clockwise), and whose length indicates the period
(a length of 10 is a period of 100).

In non-spatial mode, fireflies trace paths in circles around
the center of the Graphics window.  Their position on the
path indicates their phase angle (again 3:00 is 0 phase,
and movement is counter-clockwise), and their distance from
the center indicates their period.  To make it easier to see
the firefly periods, gray bands on the background indicate
period increments of 20.  The edge of the outermost gray
band represents a period of 200 (twice the average).  When
the period of a firefly goes beyond 200, it is displayed in
red, and it remains at the outer edge of the largest band,
no matter what how great its period, until its period drops
below 200 again.  Where there is more than one firefly on a
particular square, they are displayed in a lighter blue

The phase angle and period of each firefly is updated on
each "time slice".  Each time slice represents a time of
length 2.  The average period of fireflies is 100, that is,
50 time slices.  An option allows the user to have
information printed out about the fireflies on every 10th
time slice.

Both phase angle and period coupling are implemented.  Since
coupling only takes place when a firefly flashes near its 0
phase, the relevant variable is the current phase angle of
the affected firefly.  The coupling function is the negative
sine of this phase angle; the value of this function goes to
zero at a phase angle of .5.  The period of fireflies does
not decay to a resting period.


This button creates a new set of fireflies and initializes
the display according to the value of the "spatial" slider.

This forever button repeatedly updates the phase angles
and periods of the fireflies and redraws the display.


You can change some of the sliders (clock, mv-prob, flash%,
output?, pa-C, and pd-C) even when the fireflies are
running. To change the other sliders (spatial, howmany,
fl-rad, and pd-rng), you need to first stop the fireflies if
they are running (by clicking on the go button), then move
the slider, and then click on the setup button to create a
new set of fireflies.

This slider determines whether spatial or non-spatial mode
is to be used.  A value of 0 indicates spatial mode, a
value of 1 non-spatial model.  As discussed above, the two
modes differ in the behavior of the fireflies and in the
type of display which appears.  With this slider, you must
click on setup for its new value to take effect.

This slider is only relevant for spatial mode (spatial = 1).
When it is set to 1, the "clock hands" indicating phase
angles and periods of fireflies are displayed.

When this slider is set to 1, information about the
fireflies (number flashing; phase angle, period, and
resting period of each firefly) is display in the Output
Window on every 10th time slice.

This value of this slider determines the number of fireflies
in the system.  With this slider, you must click on setup
for its new value to take effect.

This slider is relevant only in spatial mode.  It indicates
the "flashing radius" of the fireflies, that is, the
maximum distance from a flashing firefly at which another
firefly is affected.  With this slider, you must click on
the setup button for its new value to take effect.

This slider is also relevant only in spatial mode.  It
indicates the probability with which each firefly moves on
each time slice.  When it is 0, the fireflies never move;
when it is 100, they always move.

The value of this slider is the percentage of a firefly's
cycle during which it flashes.  If this is set to 10, for
example, each firefly flashes from a phase angle of .95
until a phase angle of .05.

The value of this slider indicates the range of initial
periods of the fireflies.  The average period is 100.  If
this slider is set to 100 (its maximum), the initial periods
of the fireflies range from 50 to 150.  With this slider,
you must click on the setup button for its new value to take

This slider sets the phase angle coupling factor.  When it
is set to 0, there is no phase angle coupling.

This slider sets the period coupling factor.  When it is set
to 0, there is no period coupling.

The Activity Itself

In this activity, you will be asked to describe what happens under certain conditions. You should attempt to single out what is interesting to describe. For example, it is not especially interesting to note that "one firefly in the lower-left corner and another in the center had very similar phase angles." But it might be interesting to say that "about half of the fireflies were synchronized with each other, while the others appeared to be completely unrelated." Also try to explain what happens whenever this seems possible.

[Go to the Rhythm and Cognition Home Page]

Last updated: 26 September 1995
Copyright 1995, The Trustees of Indiana University