Predator-Prey Swarm Colloqium Demo

This code was written during a University of Toronto Mathematics Department Colloquium on Feb 8th, 2016. The talk was given by Theodore Kolokolnikov titled, Swarms: from molecular dynamics to biological aggregations. The talk described results from his paper:

Chen, Y., & Kolokolnikov, T. (2014). A minimal model of predator-swarm interactions. Journal of the Royal Society, Interface / the Royal Society, 11(94), 20131208. http://doi.org/10.1098/rsif.2013.1208

For this Mathematica demonstration I implement the predator-prey swarm dynamic system that Kolokolnikov describes.

(* Equations for system of ODEs for predeator and prey movement *)
(* Paper gives naming convention z for predator and x for prey *)
dpred:=c/numprey Sum[Normalize[x[k][t]-z[t],Norm[#]^3&],{k,1,numprey}]

dprey[j_]:=1/numprey Sum[Normalize[x[j][t]-x[k][t],Norm[#]^2&]-a(x[j][t]-x[k][t])+b Normalize[x[j][t]-z[t],Norm[#]^2&],{k,Delete[Range[numprey],j]}]

numprey=150;

(*Random Initial Positions for prey*)
prey0=RandomReal[{-10,10},{numprey,2}];

(*Swarm Parameters as Described in Paper*)
a=1;
b=0.3;
c=1.5;

(*Create ODE System*)
odesys=Append[Table[{
x[j]'[t]==dprey[j],
x[j][0]==prey0[[j]]},
{j,numprey}],{z'[t]==dpred,z[0]=={0,0}}];

depvars=Flatten[{z,Table[x[j],{j,numprey}]}];

(*Solve System of ODEs with NDSolve*)
tfinal=40;sol=NDSolve[odesys,depvars,{t,0,tfinal}(*,PrecisionGoal->2,AccuracyGoal->2*)][[1]];
predpos=z/.sol;
preypos=Array[x,{numprey}]/.sol;

(*Visualize Swarm with Manipulate*)
Manipulate[Graphics[{PointSize[0.05],Point[{#@t&/@preypos}],Red,Point[predpos[t]]}],{t,0,tfinal}]