SIR Epidemic Model Simulator Back
Epidemiology · Mathematical Biology

SIR Epidemic Model Simulator — Herd Immunity & Outbreak Dynamics

Drag β and γ to watch R₀ change in real time. Raise vaccination coverage until herd immunity kicks in. Compare COVID-19, influenza, and measles to see just how contagious each disease really is.

Presets
Model Type
Parameters
Population N 10,000
Initial infected I₀ 10
Transmission rate β (/day) 0.35
Recovery rate γ (/day) 0.10
Basic reprod. number R₀ = β/γ 3.50
Vaccination & Options
Vaccination coverage V (%) 0%
Simulation duration (days) 365
Seasonal forcing ε 0.00
Key Metrics
Peak infection
Attack rate
Days to peak
Herd immunity

SIR Model Equations

$$\frac{dS}{dt}= -\frac{\beta S I}{N}$$ $$\frac{dI}{dt}= \frac{\beta S I}{N}- \gamma I$$ $$\frac{dR}{dt} = \gamma I$$

N = S + I + R = const (conservation)

CAE connection: SIR ODEs are solved with the same Runge-Kutta integrators used in structural dynamics, CFD, and chemical reaction simulations.
Time Series: S / I / R vs Days

What is the SIR Model & Herd Immunity?

🧑‍🎓
What exactly is this R₀ number I keep hearing about in the news? It seems super important for pandemics.
🎓
Basically, R₀ (pronounced "R-naught") is the reproduction number. It tells you, on average, how many other people one infected person will pass the disease to in a population where *everyone* is susceptible. In practice, if R₀ > 1, the outbreak grows; if it's less than 1, it fizzles out. In this simulator, you can see it directly: R₀ = β/γ. Try moving the "Transmission rate (β)" slider up for COVID-19 and watch how the infected curve explodes!
🧑‍🎓
Wait, really? So if R₀ is fixed for a disease, how do we ever stop an outbreak? That seems hopeless.
🎓
Great question! That's where herd immunity comes in. R₀ assumes everyone is susceptible (S ≈ N). But as people recover or get vaccinated, they move to the Recovered (R) group. The *effective* reproduction number, R_t, becomes R₀ * (S/N). When enough people are immune, S/N gets so small that R_t drops below 1. For instance, slide the "Vaccination coverage" up to 70% for measles (R₀~15) and see the outbreak collapse—that's herd immunity in action.
🧑‍🎓
Okay, that makes sense. But what about the "Incubation period" and "Seasonal forcing" parameters? They weren't in the basic SIR equations you showed earlier.
🎓
Sharp observation! The classic SIR model is a foundation, but real diseases are more complex. Adding an "Exposed" (E) compartment creates an SEIR model, where 1/σ is the incubation period. Seasonal forcing (ε) models how transmission (β) can wobble with seasons, like flu in winter. Try adding a 20% seasonal forcing to the flu preset and run a 2-year simulation—you'll see recurring winter waves, just like in real life.

Physical Model & Key Equations

The core SIR model is a set of coupled Ordinary Differential Equations (ODEs) that track the flow of people between three compartments: Susceptible (S), Infectious (I), and Recovered (R). The rate of new infections depends on the contact rate (β) and the probability that a contact is with a susceptible person (S/N).

$$ \begin{align*}\frac{dS}{dt}&= -\frac{\beta S I}{N}\\[6pt] \frac{dI}{dt}&= \frac{\beta S I}{N}- \gamma I \\[6pt] \frac{dR}{dt}&= \gamma I \end{align*}$$

β is the transmission rate (per day). γ is the recovery rate (per day); its inverse, 1/γ, is the average infectious period. N is the total constant population (S + I + R = N).

From these equations, we derive the critical threshold for herd immunity and the basic reproduction number R₀. The outbreak peaks when the effective reproduction number R_t = R₀ * (S/N) falls to 1.

$$ R_0 = \frac{\beta}{\gamma}, \quad \text{Herd Immunity Threshold}= 1 - \frac{1}{R_0} $$

R₀: Basic reproduction number. If R₀ > 1, epidemic grows. Herd Immunity Threshold: The fraction of the population that must be immune (via recovery or vaccination) to stop sustained transmission. For measles (R₀=15), over 93% must be immune.

Real-World Applications

Public Health Policy & Vaccination Campaigns: This model is the bedrock for planning vaccine rollout. Officials use it to calculate the coverage needed to achieve herd immunity for diseases like measles, mumps, and polio. During the COVID-19 pandemic, SIR and SEIR models were used daily to project hospital bed needs and evaluate the impact of social distancing (which lowers β).

Pharmaceutical & Clinical Trial Planning: Drug companies use epidemic models to forecast the potential market size for a new vaccine or antiviral drug. They also model trial outcomes in different transmission scenarios to determine optimal trial size and location.

CAE & Computational Simulation: The ODEs in the SIR model are solved numerically using Runge-Kutta methods—the exact same solvers used in engineering CAE for simulating car crashes (structural dynamics), airflow over a wing (CFD), and chemical reactions in a battery. This simulator is a direct example of using computational methods to solve a real-world "physics" problem of population dynamics.

Economic Impact Forecasting: Governments and financial institutions couple SIR model outputs with economic models to estimate the cost of outbreaks and the economic benefit of intervention measures. This helps in weighing the cost of a lockdown against the projected healthcare cost of an unmitigated wave.

Common Misunderstandings and Points to Note

When you start using this simulator, there are a few key points to keep in mind. First, understand that "the basic reproduction number R₀ is not an absolute constant." For example, the R₀≈2.5 for COVID-19 is a value based on an environment where people interact normally. In reality, measures like avoiding crowds or wearing masks will lower the effective reproduction number R_t. In this tool, lowering the "infection rate β" simulates precisely the effect of such interventions.

Next, consider the realism of your parameter settings. For instance, setting the "recovery rate γ" to 1/5 (=0.2) implies an average infectious period of 5 days, but this often refers to the entire symptomatic period. The actual "period of being contagious" might be shorter. If tweaking parameters produces unrealistic curves (e.g., where the number of infected individuals I exceeds the total population N), get into the habit of reviewing your settings.

Finally, hold the understanding that "the herd immunity threshold is not the goal." While reaching a threshold like 60% will stop the epidemic, what matters is the magnitude of the infection peak (the healthcare burden) that occurs before that point. For example, relying solely on natural infection without vaccination could lead to over 20% of the population being infected simultaneously at the peak, potentially causing healthcare system collapse. A practical way to use this simulation is to observe how increasing the vaccination rate can alleviate the "peak pressure."

Related Engineering Fields

The calculations behind the SIR model are, in fact, mathematically deeply connected to various engineering fields beyond epidemiology. The first to mention is Chemical Reaction Engineering. The state transition S→I→R is described by exactly the same equations as the kinetics of a consecutive chemical reaction (A → B → C). The parameters β and γ are essentially reaction rate constants.

Next, consider simulations of heat transfer or fluid dynamics (CFD). The methods used to discretize and solve the SIR model's differential equations on a computer are common to fundamental CAE techniques like the finite difference method and finite volume method. Tracking the temporal evolution of state variables (S, I, R) is fundamentally the same process as calculating the time-dependent changes of temperature or flow velocity.

Furthermore, it can be applied to Reliability Engineering. The SIR model can be repurposed to model "common cause failures" in systems with many components, where the failure (infection) of one triggers a chain of failures. In this context, the recovery rate γ corresponds to the "repair rate," and the vaccination rate corresponds to the "ratio of redundancy or scheduled replacement." Even in seemingly distant fields, there is a common foundational tool for understanding the "dynamic behavior of systems involving state transitions."

For Further Learning

Once you're comfortable with this simulator, a recommended next step is to gradually make the model more realistic. Start by looking into the SEIR model. This model adds an "Exposed period (E)" between S and I, used for simulating diseases like chickenpox or COVID-19 where there's a significant delay between infection and symptom onset. The equations become slightly more complex with an added variable, but understanding its behavior is a natural extension of the SIR model.

From a mathematical perspective, be aware that we are solving these simultaneous differential equations using numerical integration. Internally, the tool uses algorithms like Euler's method or the Runge-Kutta method to calculate the incremental changes in S, I, and R over tiny time steps. This concept of "discretization" is at the core of more complex CAE simulations.

To go further, you could explore models that incorporate "spatial structure" or "individual contact networks." The current tool assumes the entire population mixes uniformly (a perfectly mixed model), but reality is more complex. "Agent-based models," which simulate spread through movement between regions or within community units like families and workplaces, are advanced techniques used for detailed policy evaluation. The best shortcut to understanding them is first getting an intuitive feel for how parameters affect the curves in this simple SIR model.