SIR spatial simulation

This program simulates epidemiology of the COVID-19 virus using SIR Models. For given regional segmentation and commuter data it simulates how infections spread over time. It plots the SIR data over time and generates an animated map to visualize the infection and recovery ratio.

Simulation Model

Each regional area, which can be a city, district or any other type of division, has its own SIR model instance. We model social exchange between those area using commuter data. For simplification, we assume that during daytime, commuters are at there working place, interacting with everyone in the same area. At night, everyone is at home, possibly infecting everyone else with the same home area.

We use these SIR differential equantions:

dS/dt = -beta * I/N * S
dI/dt = beta * I/N * S - I * gamma
dR/dt = I * gamma


git clone
cd sirmodel/simulator
pip install -r requirements.txt

After the simulation has finished, open web/animation.html with your browser to view the animated map.


SIR Parameters

You can edit the beta and gamma for the SIR differential equations in simulator/

    beta = 1.1
    gamma = 1 / 14

Initial Infections

Edit the file simulator/pendlerData/start.csv, defaults are:


Columns: id is the area ID (for Germany you can find the real values inside BewohnerProLandkreis.csv) inf is the inital count of infected individuals rec is the inital cound of recovered individuals

Further Improvements

  • Use Monte Carlo simulation for infection distribution between commuting groups
  • Add random commuting "noise"

Built With

Share this project: