# SIRD: A Epidemic Model with Social Distancing
**Prof. Tony Saad (<a href='www.tsaad.net'>www.tsaad.net</a>) <br/>Department of Chemical Engineering <br/>University of Utah**
<hr/>


```python
#HIDDEN
from routines import plot_sird_model
import ipywidgets as widgets
from ipywidgets import interact, interact_manual
%matplotlib inline
%config InlineBackend.figure_formats = ['svg']

continuousUpdate = False

style = {'description_width': 'initial'}
beta = widgets.BoundedFloatText(value=0.5,min=0,max=1,step=0.01,description='Infection rate ($\\beta$):',continuous_update=continuousUpdate, style=style)
days = widgets.BoundedFloatText(value=14,min=1,max=20,step=1, description='Recovery (days):' ,style=style,continuous_update=continuousUpdate)
δ1 = widgets.BoundedFloatText(value=0.1,min=0,max=20.0,step=0.01,description='D to S ($\delta_1$):',readout_format='.3f',style=style,continuous_update=continuousUpdate)
δ2 = widgets.BoundedFloatText(value=0.15,min=0,max=20.0,step=0.01,description='S to D ($\delta_2$):',readout_format='.3f',style=style,continuous_update=continuousUpdate)
months = widgets.BoundedFloatText(value=12,min=1,max=60,step=1, description='Simulation (months):',style=style,continuous_update=continuousUpdate)
vaccinateAfter = widgets.BoundedFloatText(value=8,min=1,description='Vaccine found (months):',max=64,style=style,continuous_update=continuousUpdate)

minI = widgets.BoundedFloatText(value=1.0,min=0.0,max=50.0,step=0.001,description='Min Infected (%):',readout_format='.3f',style=style,continuous_update=continuousUpdate, disabled=True)
maxI = widgets.BoundedFloatText(value=10.0,min=0,max=50.0,step=0.001,description='Max Infected (%):',readout_format='.3f',style=style,continuous_update=continuousUpdate, disabled=True)

semilogy = widgets.Checkbox(value=False,description='semilogy plot:',style=style)

# widgets.link((maxI, 'value'), (minI, 'max'))
def on_value_change(change):
    minI.max = maxI.value*0.99
maxI.observe(on_value_change)

distanceModel = widgets.Dropdown(options=[('Constant'), ('Reactive')],description='Social Distancing Model:',style=style)
def show_max_min(change):
    if distanceModel.value == 'Constant':
        maxI.disabled=True
        minI.disabled=True
    else:
        maxI.disabled=False
        minI.disabled=False
distanceModel.observe(show_max_min)

ui1 = widgets.HBox([beta,months])
ui2 = widgets.HBox([days,vaccinateAfter])
ui3 = widgets.HBox([δ1,δ2])
ui4 = widgets.HBox([minI,maxI])
ui5 = widgets.HBox([distanceModel, semilogy])

out = widgets.interactive_output(plot_sird_model, {'infection_rate': beta, 'incubation_period': days, 'D_to_S': δ1, 'S_to_D': δ2, 'tend_months':months, 'vaccinateAfter': vaccinateAfter,'minIpercent':minI, 'maxIpercent':maxI,'distanceModel':distanceModel,'semilogy':semilogy})

display(ui1,ui2,ui3,ui4, ui5, out)
```


    HBox(children=(BoundedFloatText(value=0.5, description='Infection rate ($\\beta$):', max=1.0, step=0.01, style…



    HBox(children=(BoundedFloatText(value=14.0, description='Recovery (days):', max=20.0, min=1.0, step=1.0, style…



    HBox(children=(BoundedFloatText(value=0.1, description='D to S ($\\delta_1$):', max=20.0, step=0.01, style=Des…



    HBox(children=(BoundedFloatText(value=1.0, description='Min Infected (%):', disabled=True, max=50.0, step=0.00…



    HBox(children=(Dropdown(description='Social Distancing Model:', options=('Constant', 'Reactive'), style=Descri…



    Output()


# Description
SIRD is an epidemic model for infectious disease and is a variation of the SIR model with the addition of social distancing. A compartmental diagram is shown below:



The governing equations are:
\begin{equation}
\frac{\text{d}S}{\text{d}t} = -\beta SI - \delta_1 S + \delta_2 D
\end{equation}
\begin{equation}
\frac{\text{d}I}{\text{d}t} = \beta SI - \gamma I
\end{equation}
\begin{equation}
\frac{\text{d}R}{\text{d}t} =\gamma I
\end{equation}
\begin{equation}
\frac{\text{d}D}{\text{d}t} =\delta_1 S - \delta_2 D 
\end{equation}
where:
* $\beta$ is the average infection rate
* $\gamma$ is the fraction of people recovering, and is equal to $1/d$ where $d$ is the average number of days for recovery
* $\delta_1$ is the fraction at which people move from being socially distanced back to the general population
* $\delta_2$ is the average fraction at which people become socially distant

The goal of this model is to better understanding the effectiveness of social distancing on "flattening" the curve of an infectious disease. For example, is full lock-down better than a step-by-step implementation of social distancing?

## Social Distancing Models
Two social distancing models are supported on this page, Constant and Reactive.

### Constant Social Distancing
Assumes that both $\delta_1$ and $\delta_2$ are constant

### Reactive Social Distancing
This Model triggers social distancing when the # of infected reaches a certain percentage of the population (designated as Max Infected in the GUI, $I_\text{max}$) and relaxes social distancing when it reaches a minimum # of infected (designated as Min Infected in the GUI, $I_\text{min}$). This produces very interesting dynamics especially as $I_\text{max} \to I_\text{min}$

## Slides
You can see a more detailed description in the following <a href='https://github.com/saadtony/SIRD/blob/master/SIRD.pdf'>slides</a>.

f0cb7e3eeb8df2424cb013c86eed846fec54f5e4
ipynb
Jupyter Notebook
SIRD.ipynb
saadtony/SIRD
87888445826aa9db0e386cf23f0f262bb4f9ab55
MIT
SIRD.ipynb
saadtony/SIRD
87888445826aa9db0e386cf23f0f262bb4f9ab55
MIT
SIRD.ipynb
saadtony/SIRD
87888445826aa9db0e386cf23f0f262bb4f9ab55
MIT
Qwen/Qwen-72B
1. YES
2. YES