Create Your Own Active Matter Simulation (With Python)

Philip Mocz
The Startup
Published in
3 min readJan 8, 2021

--

For today’s recreational coding exercise, we simulate active matter, i.e., swarming. Such a system may describe a flock of birds or a school of fish. We will look at how very simple rules may lead to the emergence of self-ordered motions.

You may find the accompanying Python code on github.

But first, below is a gif of what running our simulation looks like:

Viscek model for flocking behavior

We will describe a famous minimal model for active matter called the Viscek model (1995). Despite its simplicity, the model is able to describe universal properties of swarming behavior.

The model consists of N moving particles, indexed by i=1,…,N. Each particle has an angle Θrepresenting the direction in which it moves. All particles move with the same speed v₀. Particles will interact with each other within an interaction radius R, which will force them to change their direction (angle).

At each timestep, each particle i has its position rᵢ updated as

--

--

Philip Mocz
The Startup

Computational Physicist. Sharing intro tutorials on creating your own computer simulations! Harvard ’12 (A.B), ’17 (PhD). Connect with me @PMocz