2021–22 Project III

Sheepdog trial

Sheepdog trials: collective motion in 2D


Fans of BBC Alba’s Farpaisean Chon-Chaorach will know that sheep herding is a competitive business. It will not surprise you, then, to learn that the motion of individual sheep as a moving herd — collective motion known as flocking or swarming — is mathematically quite well described.

At the local level, each sheep behaves as an individual, but if we zoom out, the herd of sheep behaves as a continuum. And at the continuum level, we can describe the motion of sheep using partial differential equations. How do herds decide where to go? Do they ever end up just going round in circles?

This project offers you to chance to model this interesting behaviour. We will derive the governing PDEs of some common models, and then numerically solve these equations. At the same time, we can simulate a bunch of individual sheep operating using simple rules. Will these two approaches converge? We will see!

This dichotomy of microscale vs macroscale, and how we move between them, is a key concept in applied mathematics.

How we might structure the the project

At the start, we could have something like:

  • What is flocking? Where else do we see this behaviour?
  • Looking up different models for how sheep behave around other sheep
  • Coding up a few sheep in Python and seeing what they do
  • Investigating the Vicsek model
  • Deriving PDEs for our sheep and beginning to look for ways to numerically solve them


This is an applied maths project and you will have to do a bit of practical coding. You should therefore have some familiarity with Python, but you do not have to be a numerical analysis expert at all! We will learn some numerical differential equation solving techniques together. There will be plenty of support.

Courses to take at the same time

Nothing essential. You might enjoy comparing these models to those you see in Mathematical Biology III and Fluid Mechanics III, but this is optional.