← All work
Project

Spread of infectious disease

The SIR model solved with SciPy and a hand-written RK4, with stability read off symbolically in SymPy.

PythonSciPySymPyMatplotlib

The SIR (susceptible, infectious, recovered) model is derived analytically and its coupled differential equations are solved both with SciPy’s integrators and with a manual fourth-order Runge–Kutta implementation. The stability of the disease-free and endemic states is determined symbolically with SymPy, and the evolution of the disease through a population is visualized with Matplotlib.

dSdt=−βNSIdIdt=βNSI−γIdRdt=γI\begin{aligned} \frac{dS}{dt} &= -\frac{\beta}{N} S I \\[1ex] \frac{dI}{dt} &= \frac{\beta}{N} S I - \gamma I \\[1ex] \frac{dR}{dt} &= \gamma I \end{aligned}

Here β\beta is the infection rate, γ\gamma the recovery rate and N=S+I+RN = S + I + R the population size. The interactive note puts β\beta and γ\gamma on sliders.

Numerical solution of the SIR model
Numerical solution of the SIR model.

In the same manner, a model for the spread of HIV infection inside the body is built and compared with publicly available data from an academic journal.

Numerical solution of an HIV infection model
HIV infection model, numerical solution.