- Johnathan Park ( PARKJX22@juniata.edu )
- Mansi Chandra ( CHANDMX20@juniata.edu )
This code simulates the spread of COVID-19 using the SIR (Susceptible-Infected-Recovered) model, which divides the population into three compartments: susceptible, infected, and recovered. The model assumes that people can transition between compartments based on certain parameters, such as the infection rate and recovery rate.
The simulation considers three different strategies for controlling the spread of COVID-19, each with different values for the infection rate and recovery rate. The strategies are:
- Strategy 1: lower infection rate (beta = 0.25) while keeping the recovery rate constant (gamma = 0.1)
- Strategy 2: higher recovery rate (gamma = 0.125) while keeping the infection rate constant (beta = 0.3)
- Strategy 3: increase the proportion of the population initially immune to the disease (by setting S0 to 90% of the population), while keeping the infection and recovery rates constant.
The code defines two functions:
SIR_model calculates the differential equations for the SIR model, and simulate_SIR_model runs the simulation for the given set of parameters and number of days.
The results of the simulation are plotted in two figures:
- A line plot of the percentage of the population that is infectious over time for each strategy.
- A line plot of the cumulative percentage of the population that has been infected over time for each strategy, scaled by a factor of 10.
The figures illustrate how different strategies can affect the spread of the disease, as well as the overall impact on the population.
This Python script produces a plot that shows the percentage of the population that needs to be immune in order to achieve herd immunity, as a function of the basic reproduction number (R0) of a disease. The plot is generated using the Matplotlib library and NumPy library.
This script requires the following Python libraries to be installed:
You can install these packages using pip:
$ pip install numpy matplotlibTo run the script, simply execute the following command in your terminal:
python3 Herd_immunity_by_R_nought.pyThe script defines a single functionherd_immunity that takes one parameter r_0, which represents the basic reproduction number of a disease. The function returns the fraction of the population that needs to be immune in order to achieve herd immunity.
The script also defines an array r_0_vals that contains a range of values for the basic reproduction number, and computes the corresponding values for the fraction of the population that needs to be immune using the herd_immunity function.
The script produces a plot that shows the percentage of the population that needs to be immune in order to achieve herd immunity as a function of the basic reproduction number of a disease. The plot has the following characteristics:
This code simulates the spread of an infectious disease using the SIR (Susceptible-Infected-Recovered) model. The simulation calculates the number of susceptible, infected, and recovered individuals over time, assuming a fixed population size, transmission rate (beta), and recovery rate (gamma).
To run the simulation, you need to have Python3 installed on your computer, as well as the following packages:
You can install these packages using pip:
$ pip install numpy pandas matplotlibTo run the simulation, simply execute the following command in your terminal:
python3 most_infected _date.pyThe simulation has the following parameters:
The script will save the results of the simulation to an Excel file named sir_simulation_results.xlsx, and will also generate a plot showing the most infected day as a function of the initial infected rate.
beta: The transmissioin rate, representing the rate at which susceptible individuals become infected upon contact with infected individuals.gamma: The recovery rate, representing the rate at which infected individuals recover and become immune.population: The total size of the population.days: The number of days to simulate.initial_infection_rates: An array of initial infection rates to simulate, expressed as a percentage of the population.
The simulation outputs a DataFrame containing the following columns:
Initial Infected Rate: The initial infection rate used in the simulation, expressed as a percentage of the population.Most Infected Day: The day with the highest number of infected individuals.Infected Cases Per Day: An array of the number of infected individuals per day.
sir_simulation_results.xlsx.
The simulation also generates a plot showing the most infected day as a function of the initial infected rate. The plot has the following axis labels:
SIRtest.py is a GUI file that allows you to check various results with graphs while modifying various parameters of the SIR standard model.
The tkinter, matplotlib, and numpy packages are required to run this file. numpy and matplotlib are installed by default with Python installed, so no other additional work is required, but tkinter must be installed separately. The tkinter can be installed in the following ways.
Make sure you have Python installed on your computer. You can download Python from the official Python website at https://www.python.org/downloads/. Follow the installation instructions for your operating system.
Open a command prompt (on Windows) or terminal (on macOS or Linux) on your computer. You can do this by searching for "Command Prompt" or "Terminal" in the search bar or by navigating to the appropriate application in your system's programs.
Enter the following command in the command prompt or terminal to install tkinter using the Python package manager pip:
For Windows:
$ pip install tk
For macOS/Linux:
$ pip3 install tk
Note: If you're using a virtual environment, make sure it's activated before running the above command.
After the installation is complete, you can verify that tkinter is installed by opening a Python interactive shell or an Integrated Development Environment (IDE) that supports Python, and then typing the following command: import tkinter If you don't see any errors, then tkinter is successfully installed on your system.
This project is licensed under the MIT License - see the LICENSE.md file for details.