This project is a pandemic simulation application built using cellular automata to model the spread of infectious diseases. It enables users to configure parameters, run simulations, and visualize the dynamics of a pandemic over time in an interactive and user-friendly way.
The simulator models a population on a 2D grid where cells represent individuals in different states of health, such as:
- S: Susceptible
- E: Exposed
- I: Infected
- Q: Quarantined (isolated infected individuals)
- R: Recovered
- D: Deceased
- -1: Obstacles (non-interactive zones)
The application offers real-time animations of the simulation and supports statistical analysis of the disease progression.
-
Configurable Parameters:
- Grid size (default: 100)
- Disease Parameters:
- Infection rate (
p_inf, default: 0.2) - Incubation period (
t_inc, default: 7 steps) - Recovery rate (
p_rec, default: 0.05) - Death rate (
p_dec, default: 0.01) - Recovery to susceptible period (
t_il, default: 30 steps)
- Infection rate (
- Disease Control:
- Quarantine probability (
p_quar, default: 0.1) - Mask usage parameters
- Quarantine probability (
- Environment:
- Obstacle ratio (default: 0.1)
- Mask Usage:
- Initial mask usage ratio (0-1, default: 0.0)
- Dynamic mask usage toggle (0/1, default: 0)
- Mask usage growth rate per step (default: 0.001)
- Mask change start time (default: 50 steps)
- Simulation:
- Total steps (default: 200)
- Animation interval (default: 30ms)
-
Visualization:
- Interactive 2D animations of the grid
- Line plots showing the number of infected, recovered, and deceased over time
- Color-coded cells representing different health states
-
Social Distancing Measures:
- Face Masks: Reduces transmission probability
- Static or dynamic mask usage configuration
- Initial mask usage ratio configurable (0-1)
- Optional automatic increase in mask adoption over time
- Masked susceptible individuals: 50% reduction in infection probability
- Masked infected individuals: 70% reduction in transmission probability
- Masks are randomly distributed among non-obstacle cells
- Dynamic mask usage allows gradual increase with configurable:
- Start time for mask usage changes
- Growth rate per simulation step
- Face Masks: Reduces transmission probability
- Programming Language: Python
- Libraries:
numpy: For numerical operations and matrix manipulationsmatplotlib: For visualizations and animations
- Python 3.8 or higher
- Poetry package manager
- Clone the repository:
git clone git@github.com:KajSob/pandemic-spread-simulation.git cd pandemic-simulator - Install dependencies using Poetry:
poetry install
- Run the application:
poetry run python pandemic_simulation/main.py