Simple visualization of how fast a virus can spread among population.
During the Covid-19 outbreak I saw a very nice article from the Washington Post explaining how a virus spread among people. It includes nice embedded visuals made by Harry Stevens. I wanted, as a personal challenge and as an aspiring programmer, to write a similar simple program but in python 3.
The collision algorithm was heavily inspired (copied) from Peter Collingridge python 2 physics simulation and his very nice tutorial.
It's a simple simulation. There is yet no chart implementation.
The algorithm is quite expensive, so above a few hundred particles the simulation is not usable.
It's a quick side project, optimisation, PEP compliance, documentation and general code readability will be worked in the future.
I used Python 3.7. I use pipenv to manage dependencies.
- Clone the repo
git clone https://github.com/smtr42/spread.git
- Install required dependencies
pipenv install
- Create a virtual environment
python3 -m venv env
- Install requirements
pip install -r requirements.txt
Open a Command Line Interface and launch the main.py script with Python.
python -m main
To modify the parameters, open the main.py file :
sim.add_particle(n=150, speed=6, freezed=93, killer=4)
- n is the number of particles
- speed is the initial speed of a particle
- freezed is the percentage of particles fixed in space
- killer is the number of particles sick at the start
Depending on how much particles is instantiated, one should modify the speed for better render. Note that the algorithm is O(n²) and for large n this simulation doesn't work.
Project Link: [https://github.com/smtr42/P5_openfoodfact]
-
Simonnet T - Initial work - smtr42
Inspired from Peter Collingridge physics simulation and his very nice tutorial. Photo by Markus Spiske on Unsplash