This is a project that I worked on during my senior year which simulates a pandemic in real time with an animation. I have various constraints that I have outlined in my report and try to predict/track mortality and infectious rates based on tuneable parameters of any given virus and the population that it infects.
- Simulates individuals moving and interacting in a confined space
- Models infection spread, recovery, immunity, and death
- Compares scenarios with and without mask usage
- Visualizes results with animated scatter plots and statistical graphs
numpymatplotlib
Install dependencies with:
pip install numpy matplotlib-
Clone the repository:
git clone https://github.com/yourusername/Pandemic-Simulation.git cd Pandemic-Simulation/Final\ Project
-
Run the simulation:
python pandemic.py
This will run the simulation with default parameters and display the animation and plots.
-
Adjust parameters:
- You can change simulation parameters (population size, infection rate, etc.) at the top of
pandemic.py:g_size = 15 # Grid size (population = g_size^2) infectious_rate = 0.4 mortality = 0.9 recovery_time = 100 total_time = 500 mask_percent = 0.5
- You can change simulation parameters (population size, infection rate, etc.) at the top of
-
Compare runtimes:
- To compare simulation runtimes for different population sizes, uncomment the following line at the end of
pandemic.py:# plot_runtime_vs_population([5, 8, 12, 16])
- To compare simulation runtimes for different population sizes, uncomment the following line at the end of
- Each individual is represented as a moving point in a grid.
- Infection spreads when an infected and a healthy individual come close.
- Mask usage reduces infection probability.
- Individuals recover or die based on probabilities and become immune if they recover.
- The simulation visualizes the number of healthy, infected, immune, and dead individuals over time.
- Animated scatter plots showing the state of each individual at each timestep.
- Line plots for infected and dead counts over time.
- Bar charts for state distribution at each timestep.
- Modify parameters at the top of
pandemic.pyto explore different scenarios. - You can add more features or tweak the logic for research or educational purposes.
Created for educational purposes. If any questions or contributions, please open an issue or pull request.