Firefly Synchronization

Fireflies synchronize their internal flashing clocks by obtaining inputs from nearby fireflies. This simulation tries to mimic this phenomenon.


Simulation

The circles represent the fireflies. Each firefly has an internal phase \(\theta \in [0, 2\pi)\) that advances by phase velocity \(\omega\) in every update. If \(\theta\) increases beyond \(2\pi\) then it resets to zero, and the firefly emits light. The color of the firefly is an indicator of it's phase. The phase circle at the centre depicts the current phase of all the fireflies. The motion of the fireflies is essentially random walks + repulsion. Initially, all fireflies have a random phase between 0 and \(2\pi\).







Description

This simulation uses the Kuramoto model of phase oscillators for synchronization. For a given firefly \(i\): \[ \dot{\theta_i} = \omega + \frac{K}{N} \sum_{j \in S} \sin(\theta_j - \theta_i) + \eta \] where θ is the phase, ω is the phase velocity, \(K\) is the synchronization strength and \(S\) is the set of fireflies within the synchronization radius of the given firefly. The first term depicts the advancing of phase, whereas the second term depicts the 'nudge' that each firefly gets from the nearby fireflies, and leads to their eventual synchronization. The value of this 'nudge' becomes zero only when the phase of the firefly is aligned with all other fireflies in it's vicinity. Additionally, phase is also affected by a random noise term \(\eta\). This represents errors in judgement made by the firefly.

A higher sync strength \( K \) leads to faster synchronization of nearby. A higher sync radius \( r \) ensures tha synchronization is present over greater areas. Higher phase noise makes synchronization harder. Higher the global synchronization, lower the standard deviation of phase.




Note:
  1. Standard deviation of phase has an oscillatory behaviour because of the cyclic nature of phase. Even when all fireflies are synchronized, SD briefly peaks whenever the phases cross the 360 ° threshold.
  2. This simulation is computationally complex, and may lag on lower-end devices.
  3. Related: Collective Behaviour.


Developed by ChanRT | Fork me at GitHub