Term Paper 3


This work is a submission for the course Modelling Complex Systems(IDC-631) for the year 2020-21 Spring (Even) Semester by Dhruva Sambrani, MS18163
2.7 ms

Abstract

This paper mainly attempts to recreate Kuramoto's model of coupled oscillators as defined in [strogatz]. This paper consists of four sections-

  • §1. Describe and implement the model as in the paper

  • §2. Check that the model evolves as we expect it to and make pretty animations

  • §3. Show that simulated results agree with certain analytical properties

  • §4. Study the robustness of the model to different distributions

15.6 ms

How to read the paper

This paper is made using the Pluto[pluto] Package which provides an interface which can show both code and theory side by side, which will hopefully enhance the understanding of the work and also provide a reproducable implementation without having to go into the details of it. Those who wish to read the paper for the theory and results can easily skip over the code and still understand everything. Those who are attempting to recreate the work can use the code as a guide. However, in the interest of keeping the code aligned to the topic at hand, certain auxillary functions have been hidden. The content of these hidden cells can be found in the executable version of this notebook here

13.0 ms
100 ns

§0 Packages used

The Plots.jl[plots] package is used for plotting and the Statistics[stats] Package for some statistical analysis. Distributions.jl[distributions] is used to sample the . PlutoUI.jl[plutoui] is used for some UI elements such as the ToC. JLD[jld] is used for storing data between runs. Images.jl[images] is used for Gaussian smoothing. LsqFit.jl[lsqfit] is used to fit the κc vs σ function.

92.4 μs

hidden code cell

12.9 s

§1 - The Kuramoto Model

This is a model which attempts to simulate coupled oscillators. Consider a set of n oscillators Ai | 1in. Each Ai has an angular position and internal angular velocity θi and ωi. Then, the most general coupled oscillator equation would be

θ˙j=ωj+f(θi)1in

If the coupling is weak, and symmetric, this can be reduced to

θ˙j=ωj+κi=1nsin(θjθi)

Which can be recast into the following equation

θ˙j=ωj+κrsin(Ψθi)

where

reιΨ=mean(eιθi)1in

9.1 μs

Agent

Let us define a structure called Agent which holds two variables R and V, which correspond to θ and ω respectively.

8.5 μs
248 μs

Now let's define how an agent updates, given κ, r, Ψ and dt, as defined in the equations before

7.6 μs
update! (generic function with 1 method)
28.0 μs

Helper Functions

2.9 μs
init (generic function with 1 method)
94.4 μs
init (generic function with 2 methods)
82.0 μs

Evolution and Simulation

As always, we define a single step evolution along with a multistep simulate function.

The evolve function takes a list of agents and updates them according to the dynamics explained above. The simulate function sets the parameters and records certain variables for plotting and further analysis

4.3 μs
evolve! (generic function with 1 method)
27.9 μs
simulate (generic function with 2 methods)
59.0 μs

§2 Visualizing the model

Let us first make sure that the model is running correctly. We can either visualize the positions of the oscillators with time, or we can plot r vs time and make sure that the results match what is given in the paper. We will do both.

4.0 μs

r depends on κ

3.4 μs
8.2 s
65.3 ms

Animated visualization of the dynamics

For this, we define a simulate2 function which is of the same form as the previous function, but it also records the agents for each time step. Then we plot the locations of the oscillators and the mean vector for each time step and make an animation. Due to computational limitations, only 100 particles for 10000 timesteps are taken, and animation is made for every 20th frame. Also, for reproducability, the random seed is fixed. The seed was selected so that the results were clearer to show. However all observations are observed for any number of unseeded runs. To test, simply comment out the seed line.

4.6 μs
simulate2 (generic function with 1 method)
70.8 μs
8.0 s

hidden code cell

37.5 s
8.2 s
25.8 ms

hidden code cell

515 ms
409 ms

§3 Simulations agree with analysis

In section 3.3 of [strogatz], the author mentions the following observations of the simulations.

4.2 μs

r∞ vs κ

  • For all K less than a certain threshold Kc, the oscillators act as if they were uncoupled: the phases become uniformly distributed around the circle, starting from any initial condition. Then r(t) decays to a tiny jitter of size O(N1/2)

  • When K>Kc, this incoherent state becomes unstable and r(t) grows exponentially, reflecting the nucleation of a small cluster of oscillators that are mutually synchronized, thereby generating a collective oscillation. Eventually r(t) saturates at some level r<1, though still with O(N1/2) fluctuations.

Both of these claims are shown to be true in the first plot. For a "high" K(=7), r settles with jitter at 1, and for a "low" K(=1), r settles with jitter at 0.

9.6 μs

Individual Oscillators

  • The population splits into two groups: the oscillators near the center of the frequency distribution lock together at the mean frequency and co-rotate with the average phase ψ(t), those in the tails run near their natural frequencies and drift relative to the synchronized cluster.

  • This mixed state is often called partially synchronized. With further increases in K, more and more oscillators are recruited into the synchronized cluster, and r tends to 1

Both of these claims are also shown to be true in the animation and in the plots of the effective velocities. In the animation, we clearly see that most of the oscillators are in a clump, but there are a few that drift away from the mean and stay out of the cluster. In the velcity plot, this is almost clearly evident. Also, if looked at carefully, it shows that the particles which are not in sync are the ones which where far away from the mean in the initial distribution

6.4 μs

κc vs g(ω)

The paper also analyses κc as a function of g(ω). While Kuramoto and Nishikawa had previously assumed that the drifters would not have any effect on the coherence of the oscillators, they later recanted their stance and assumed that the drifters did in fact have an effect on the evolution of the coherence. Probably if they had the luxury of fast computers and easy computer languages, they would have seen that the drifters did in fact have an effect on r(t). In the animation above, there are small but fast changes in the angle and the amplitude of the mean vector, and these are directly related to the movement of the drifters. Obviously, a simulation of only 100 oscillators is obviously not in the thermodynamic limit and the effect on r is more apparent.

None the less, we can be reasonably sure that Kuramoto and Nishikawa's second attempt (§6.2 in [strogatz]) was more accurate, and by extension so was Strogatz's own analysis. From their analysis,

κc=2πg(0)

In the case of the gaussian distribution,

g(0)=1σ2π

Hence,

κc=2σ2ππ=8πσ

9.3 μs

Computational implementation

We define a function simulate_for_sigma which searches by bisection for κs which are useful for our plot. We limit the difference of κ and difference in r for the sake of computational time. r is evaluated by taking a mean over the last 10% timesteps.

In the ideal case, we'd average r over many initial conditions to make sure that there are infact no artifacts of the initial conditions. This is especially true, near the bifurcation, where the transition times can be very long. However, we take the easier path by simply box-smoothing over the data (a tool often employed by statisticians when they get noisy data).

10.1 μs
get_rinf (generic function with 1 method)
30.5 μs
simulate_for_sigma (generic function with 1 method)
796 μs
boxsmooth (generic function with 1 method)
53.0 μs

Run new simulation?

11.8 ms
849 ms

Stability of κc over σ

Using the powerful computers at our disposal, we can run the simulation on multiple κs and σs and find the r for each of these. Then, we can analyse the results to find κc for each σ and fit it to a straight line and see if the slope is equal to 8π. Like before, we smooth our data, but this time we convolve the data with a 2dimensional Gaussian blur filter.

We measure the points of phase transition by taking a derivative along κ, and picking points where the derivative is above a certain threshold(=0.09).

11.5 μs

Code to generate data

function graph(κs::Array{Float64}, σs::Array{Float64})
    arr = zeros(Float64, length(κs), length(σs))
    for (i, κ) in enumerate(κs), (j, σ) in enumerate(σs)
        arr[i,j] = mean(
                abs, 
                @view simulate(Int(1e5), 1000, σ, κ, 1e-4)[end - 1000:end]
        )
    end
    arr
end
κs, σs = collect(0.0:0.1:2.5), collect(0.0:0.1:2.5)
zs = graph(κs, σs)
save("save.jld", "zs", zs, "ks", κs, "ss", σs)
12.7 ms
10.7 s

Interactive plot below

2.1 ms
11.8 s

Interactive plot below

9.9 μs
3.7 s
868 ms

κc=1.56σ

24.1 ms

Observations

The single run and the extended analysis both show the same result that the κc follows the analysis in the paper closely, however, there is a small disparity. Any finite simulation will inevitably not have the sharp nature of the bifurcation. In §4, we run the same simulations for other distributions, and see the effect of the kind of distribution on this.

44.2 μs

§4 Robustness of results to distributions

As mentioned in the previous subsection, let's run the same simulation with some other distributions

19.7 ms
kappas
0.0:0.5:10.0
2.4 μs

Gaussian Distribution

We've already run this before, but let's do it again.

g(ω)=12πσ2exp[ω22σ2]; g(0)=12πσ2; κc(3)=8π3=1.596

12.2 μs
88.5 s
8.3 ms

Lorenz-Cauchy distributions

g(ω)=1πσ(1+(ωσ)2); g(0)=1πσ; κc(3)=6

19.9 μs
348 s
1.2 s

Reflected exponential decay

g(ω)=12aexp(|x|a); g(0)=12a; κc(3)=4π3=4.189

45.5 μs
red (generic function with 1 method)
74.8 μs
518 μs
110 s
12.4 ms

Observations

Like the Gaussian, the other distributions also have a slight discrepancy from the expected value. However by a visual analysis, we can say that the theoretical results are close to what we would get in the infinite limit. For a more accurate analysis, one could fit the function as mentioned in the paper to the data, and then look at the value of κc.

Another observation that we can see is that distributions that are tail heavy are much more prone to variations in the partially coherent part of the graph. In order to reduce this, we average results over 3 runs with random initial conditions for the Lorenz Cauchy distribution

59.6 μs

References

strogatz

Steven H. Strogatz, From Kuramoto to Crawford: exploring the onset of synchronization in populations of coupled oscillators, Physica D: Nonlinear Phenomena, Volume 143, Issues 1–4, https://doi.org/10.1016/S0167-2789(00)00094-4

julia

Julia: A Fresh Approach to Numerical Computing. Jeff Bezanson, Alan Edelman, Stefan Karpinski, Viral B. Shah. (2017) SIAM Review, 59: 65–98. doi: 10.1137/141000671

plots

Plots - powerful convenience for visualization in Julia. Thomas Breloff. docs.juliaplots.org

pluto

Pluto - Reactive Notebooks for Julia. Fons van der Plas and Mikołaj Bochenski. https://github.com/fonsp/Pluto.jl

plutoui

PlutoUI. Fons van der Plas. https://github.com/fonsp/PlutoUI.jl

stats

Statistics - Julia stdlib for Statistics. https://docs.julialang.org/en/v1/stdlib/Statistics/

images

JuliaImages: image processing and machine vision for Julia. https://juliaimages.org/stable/

lsqfit

LsqFit.jl: Basic least-squares fitting in pure Julia under an MIT license. https://github.com/JuliaNLSolvers/LsqFit.jl

distributions

1.Dahua Lin. JuliaStats/Distributions.jl: v0.24.15. (2021). doi:10.5281/zenodo.4577319

28.3 ms