Swarmalators
Author
Kevin O'Keeffe
Title
Swarmalators
Description
Minimal model of oscillators that sync and swarm
Category
Academic Articles & Supplements
Keywords
synchronization, swarming, collective phenomena, emergence
URL
http://www.notebookarchive.org/2019-05-cgd0h02/
DOI
https://notebookarchive.org/2019-05-cgd0h02
Date Added
2019-05-27
Date Last Modified
2019-05-27
File Size
114.94 kilobytes
Supplements
Rights
Redistribution rights reserved



Introduction
Introduction
Code to simulate “swarmalators”: oscillators that sync and swarm (see paper https://www.nature.com/articles/s41467-017-01190-3). These are particles which have a position in space and an internal phase, whose dynamics are mutually coupled. Potential, real-world swarmalator systems are Japanese Tree frogs, groups of sperm, or colloidal suspensions of magenetic particles. The governing equations of our proposed model are=1+Jcos---=where .Here we use a simple Euler step integrator to solve the above equation, and study the collective states that emerge. Swarmalators can be visualized as colored dots in the plane, where the color corresponds to the phase ∈ (0,2π) -- see the original paper (link above) for more details.In a follow-up paper, we also discovered ring states were possible. SeeSome other useful links1. A https://golden.com/wiki/Swarmalator2. https://github.com/Khev/swarmalators (python )
x
i
1
N
∑
j
(-)
x
j
x
i
-
x
j
x
i
θ
j
θ
i
x
j
x
i
-
x
j
x
i
2
|
θ
i
K
N
∑
j
sin-
θ
j
θ
i
-
x
j
x
i
1≤J≤1
(x,y)
Simulations
Simulations
Dynamic visual
Dynamic visual
{dt,n1}={0.05,200};(*dt=timestep,n=numberofswarmalators*){J,k}={1,-0.05};(*Changetheseparameterstoexperimentwiththeswarmalatorsystem*){z0,znew}={Table[RandomReal[{-π,π}],{i,1,3},{j,1,n1}],ConstantArray[0,{3,n1}]};results={};Dynamic[results]{t,T}={0,};(*T=numberoftimesteps*)While[t<T,znew=eulerStep[z0,rhsPowerLawCompiled,dt,J,k];z0=znew;t++;results=plotResults[znew]]
4
10
results
Collective states
Collective states
Preamble
Preamble
solveSim[J_,k_]:=Module[{dt,n1,z0,znew,results,t,T},(*Simdetails*){dt,n1}={0.05,200};{z0,znew}={Table[RandomReal[{-π,π}],{i,1,3},{j,1,n1}],ConstantArray[0,{3,n1}]};{t,T}={0,5*};(*DoEulerintegration*)While[t<T,znew=eulerStep[z0,rhsPowerLawCompiled,dt,J,k];z0=znew;t++;];Return[znew]];plotResultsWithTitle[z_,plotTitle_]:=Block{colors},colors=ColorData["VisibleSpectrum"]/@(750-380)+380;Return[Graphics[{PointSize[0.02],Point[{z[[1,All]],z[[2,All]]},VertexColorscolors]},PlotRange{{-2,2},{-2,2}},AxesTrue,AxesLabel{"x","y"},TicksNone,AspectRatio1,PlotLabelplotTitle]];
4
10
Mod[z[[3,All]],2π]-1
2π
Main
Main
The five collective states are found at
(J,K)=(0.1,1)--Staticsynchrony(J,K)=(0.1,-1)--Staticasynchrony(J,K)=(1.0,0)--Staticphasewave(J,K)=(1.0,-0.1)--Splinteredphasewave(J,K)=(1.0,-0.75)--Activephasewave
names={"Static sync","Static async","Static phase wave","Splintered phase wave","Active phase wave"};pars={{0.1,1},{0.1,-1},{1.0,0},{1.0,-0.1},{1.0,-0.75}};res=ParallelTable[solveSim[x[[1]],x[[2]]],{x,pars[[1;;-1]]}];(*Thiscantakequiteawhile--changethenumberoftimestepsTinthesolveSimfunctionifyouwanttomakeitrunslower*)
TableForm[{Table[plotResultsWithTitle[res[[i]],names[[i]]],{i,1,Length[res]}]}]
Functions
Functions
rhsPowerLawCompiled=Compile{{z,_Real,2},{n,_Integer},{J,_Real},{k,_Real}},Module{i,j,xji,yji,thetaji,inverseDistSq,inverseDist,xtemp,ytemp,thetatemp,vel=ConstantArray[0.0,{3,n}]},Fori=1,i≤n,i++,Forj=i+1,j≤n,j++,xji=z[[1,j]]-z[[1,i]];yji=z[[2,j]]-z[[2,i]];thetaji=z[[3,j]]-z[[3,i]];inverseDistSq=1.0(+);inverseDist=+380;Return[Graphics[{PointSize[0.02],Point[{z[[1,All]],z[[2,All]]},VertexColorscolors]},PlotRange{{-2,2},{-2,2}},AxesTrue,TicksNone,AspectRatio1,AxesLabel{"x","y"},LabelStyle20]];findWm[z_]:=Block{sum,i,n},(*Orderparameter,:=SumExp[(ϕ-θ)],whereϕ:=arctan(y/x)*)sum=0.0;n=Dimensions[z][[2]];For[i=1,i≤Dimensions[z][[2]],i++,sum+=Exp[(ArcTan[z[[1,i]],z[[2,i]]]-z[[3,i]])]];Return[sum/N[Dimensions[z][[2]]]];findWp[z_]:=Block{sum,i,n},(*Orderparameter,:=SumExp[(ϕ+θ)],whereϕ:=arctan(y/x)*)sum=0.0;n=Dimensions[z][[2]];For[i=1,i≤Dimensions[z][[2]],i++,sum+=Exp[(ArcTan[z[[1,i]],z[[2,i]]]+z[[3,i]])]];Return[sum/N[Dimensions[z][[2]]]];plotResultsWithOrderParameter[z_,Wp_,Wm_]:=Block{colors},colors=ColorData["VisibleSpectrum"]/@+380;Return[Graphics[{PointSize[0.025`],Point[Transpose[{z〚1,All〛,z〚2,All〛}],VertexColorscolors],PointSize[0.05`],Cyan,Point[{(Abs[Wp])Cos[Arg[Wp]],(Abs[Wp])Sin[Arg[Wp]]}],Magenta,Point[{(Abs[Wm])Cos[Arg[Wm]],(Abs[Wm])Sin[Arg[Wm]]}]},PlotRange{{-2,2},{-2,2}},AxesTrue,TicksNone,AspectRatio1]];
2
xji
2
yji
inverseDistSq
;xtemp=xji*(inverseDist*(1+JCos[thetaji])-inverseDistSq);ytemp=yji*(inverseDist*(1+JCos[thetaji])-inverseDistSq);thetatemp=k*Sin[thetaji]*inverseDist;vel[[1,i]]+=xtemp;vel[[1,j]]+=-xtemp;vel[[2,i]]+=ytemp;vel[[2,j]]+=-ytemp;vel[[3,i]]+=thetatemp;vel[[3,j]]=-thetatemp;;;velN[n],RuntimeAttributesListable,ParallelizationTrue,CompilationTarget"C";eulerStep[z_,F_,dt_,J_,k_]:=Block[{znew,n,i,j,vel},znew=ConstantArray[0,Dimensions[z]];n=Dimensions[z][[2]];vel=F[z,n,J,k];For[j=1,j≤3,j++,For[i=1,i≤n,i++,znew[[j,i]]=z[[j,i]]+dt*vel[[j,i]]];];Return[znew]];plotResults[z_]:=Block{colors},colors=ColorData["VisibleSpectrum"]/@(750-380)Mod[z[[3,All]],2π]-1
2π
W
-
1
N
W
+
1
N
(750-380)(Mod[z〚3,All〛,2π]-1)
2π


Cite this as: Kevin O'Keeffe, "Swarmalators" from the Notebook Archive (2016), https://notebookarchive.org/2019-05-cgd0h02

Download

