Skip to content

Simulations of flocking behaviour in active agents, using a simple Viscek model

License

Notifications You must be signed in to change notification settings

ajinkya-kulkarni/PyFlocking

Repository files navigation

License: GPL v3 DOI GitHub commit activity GitHub release (latest by date)

Viscek Model Simulation

Introduction

The Viscek model is a system of N self-propelled particles moving in 2D space. The particles align their velocities with those of their neighbors within a certain radius of influence. The model exhibits collective behavior such as swarming and phase transitions as the density of particles and the radius of influence are varied. This implementation allows the user to simulate the Viscek model [1] and output a .gif animation of the particles' motion over time.

Installation

To run the simulation, you will need to have the following dependencies installed:

  • numpy
  • pandas
  • matplotlib
  • imageio
  • tqdm

You can install the latest versions of the dependencies using the following command: pip install numpy pandas matplotlib imageio tqdm

Output

The output of the simulation is a .gif animation of the particles' motion over time. The animation will be saved as animation.gif in the working directory.

Usage

To run the simulation, follow these steps:

  1. Adjust the simulation parameters in the parameters.py file.
  2. Run the MainProgram.py script.
  3. The output animation will be saved as animation.gif in the working directory.

You can adjust the following parameters in the parameters.py file:

  • N: number of particles
  • L: size of simulation domain
  • Pspeed: self-propulsion speed of particles
  • eta: noise parameter
  • rad_influence: radius of interaction
  • Tstart: start time of simulation
  • Tend: end time of simulation
  • deltat: time step
  • bcond: boundary condition ('periodic' or 'reflective')

Example

Run the simulation using this command: python MainProgram.py

Example animation generated by this implementation for high noise (chaotic motion) and low noise (organized motion):

AnimationAnimation

References

  • [1] Vicsek, T., Czirók, A., Ben-Jacob, E., Cohen, I., I., & Shochet, O. (1995). Novel type of phase transition in a system of self-driven particles. Physical Review Letters, 75(6), 1226–1229. doi:10.1103/PhysRevLett.75.1226
  • [2] Kulkarni, A., Thampi, S. P., & Panchagnula, M. V. (2019). Sparse game changers restore collective motion in panicked human crowds. Physical Review Letters, 122(4), 048002. doi:10.1103/PhysRevLett.122.048002

License

This project is licensed under the GNU GENERAL PUBLIC LICENSE Version 3 - see the LICENSE file for details.