Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

111 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Black Death Spread Simulation in Medieval Europe

A network-based Python simulation of the spread of the Black Death across medieval European cities between 1346 and 1353.

The program combines local stochastic SIRD epidemic models with a weighted network of intercity trade connections. It includes configurable epidemiological parameters, rare outbreak events and an animated Tkinter visualisation of the epidemic over time.

Overview

Each city is represented by a local SIRD model consisting of four population groups:

  • S — Susceptible: people who may become infected;
  • I — Infectious: people who are currently infected;
  • R — Recovered: people who have recovered and are treated as resistant;
  • D — Dead: people who have died.

The state of every city is recalculated once per simulated day. The model determines the number of newly infected, recovered and deceased inhabitants using stochastic probability distributions.

Cities are connected through a weighted undirected graph created with NetworkX. The graph edges represent intercity trade routes, while their weights determine the relative intensity of contact between connected cities.

Model structure

Local epidemic dynamics

Each city has its own SIRD state and the following principal parameters:

Parameter Description
beta (β) Daily infection coefficient
gamma (γ) Daily recovery coefficient
mu (μ) Daily mortality coefficient among infected inhabitants
cap_frac Infection-prevalence threshold representing local capacity
overload_mult Mortality multiplier applied when the capacity threshold is exceeded

When the proportion of infected inhabitants exceeds the configured capacity threshold, the effective mortality probability increases.

Small random variations are applied to selected parameters in individual cities so that all cities do not behave identically.

Intercity transmission

The model does not directly transfer susceptible, infected or recovered inhabitants between cities.

Instead, infected neighbouring cities generate an external infection pressure. Its strength depends on:

  • the proportion of infected inhabitants in the source city;
  • the weight of the trade connection;
  • the total weight of the source city's connections;
  • the global intercity contact coefficient.

Stronger trade connections and a higher proportion of infected inhabitants therefore increase the probability that the disease will spread to a connected city.

Rare outbreak events

The simulation also includes occasional high-intensity transmission events, representing developments such as the arrival of a ship or a large group of travellers carrying the disease.

These events:

  • occur only at configured intervals;
  • have a configurable probability of occurring;
  • may affect one or more connected cities;
  • temporarily generate a substantially stronger external infection pressure.

Stochastic behaviour

Infections, recoveries, deaths and major outbreak events are calculated probabilistically.

Consequently, repeated simulations with identical parameters may produce different epidemic trajectories.

Graphical interface

The program uses Tkinter and is operated through three consecutive views.

1. Global parameter configuration

The first window allows the user to configure the principal parameters of the simulation, including:

  • infection, recovery and mortality coefficients;
  • intercity contact intensity;
  • local capacity threshold;
  • outbreak frequency and probability;
  • number and intensity of major outbreak events;
  • total simulation duration;
  • animation speed.

2. Initial infections

The second window allows the user to specify the initial number of infected inhabitants in each city.

This makes it possible to test different epidemic starting points and compare alternative transmission scenarios.

3. Animated network visualisation

After the parameters have been confirmed, the program displays the European city network.

  • Grey lines represent trade connections between cities.
  • Black outlined circles represent the living population: N = S + I + R.
  • Red circles represent the infected population: I.

The radius of each circle is updated after every simulated day, providing a visual representation of changes in the living and infected populations.

Running the program

There are two ways to run the simulation.

Option 1: Run the Windows executable

A prebuilt executable is available at:

dist/black_death_sim.exe

Open the file directly to launch the program.

This version is intended for Windows.

Option 2: Run the Python source code

Requirements

  • Python 3.12 or later
  • NetworkX
  • NumPy
  • Tkinter, normally included with standard Python installations

Clone the repository:

git clone https://github.com/Vladusty/black-death-spread-simulation.git
cd black-death-spread-simulation

Install the required packages:

python -m pip install -r requirements.txt

Move to the source-code directory:

cd py_code

Run the main script:

python black_death_sim_main.py

Repository contents

Demonstration

A complete recording of the simulation from day 1 to day 2554 is available on YouTube:

Watch the Black Death spread simulation

Historical and methodological limitations

This program is an exploratory historical simulation rather than a precise reconstruction of the Black Death.

The following limitations should be considered when interpreting its results:

  • city populations are approximate model inputs;
  • the trade-route network represents selected connections rather than a complete reconstruction of medieval transport;
  • edge weights are simulation parameters and should not be interpreted as directly measured historical trade volumes;
  • intercity transmission is represented as infection pressure rather than the explicit movement of individual inhabitants;
  • the model does not include age, social status, household structure, seasonality, pathogen evolution or regional environmental differences;
  • the visualisation uses approximate modern geographical coordinates and does not represent historical political borders;
  • stochastic calculations mean that individual simulation runs are not deterministic historical predictions.

The program is therefore intended for experimentation with epidemic modelling, historical networks and computational approaches to historical processes.

Project background

This project was submitted as a group course project at the University of Latvia in 2025.

The project concept, historical research design, source selection, simulation model, network structure, Python implementation, graphical user interface, documentation and subsequent development were carried out primarily by Vladislavs Babaņins.

Course project participants

  • Vladislavs Babaņins
  • Dzintars Seņičevs
  • Daniela Gaigule-Kadiķe

Licence

This project is licensed under the MIT Licence.

See the LICENSE file for the full licence text.

About

Python simulation of the Black Death across medieval Europe using stochastic SIRD models and a weighted city network, 1346–1353.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages