SIR Model Epidemic Simulator — Viral Infection Spread

Simulate viral epidemic spread using the SIR (Susceptible-Infected-Recovered) compartmental model. Set R₀, vaccination, interventions, and view epidemic curves, peak timing, attack rates, and herd...

About the SIR Model Epidemic Simulator — Viral Infection Spread

The SIR (Susceptible-Infected-Recovered) model is the foundational framework for understanding how infectious diseases spread through populations. Developed by Kermack and McKendrick in 1927, it divides a population into three compartments: those susceptible to infection (S), those currently infected and infectious (I), and those who have recovered and are immune (R). The model uses two key rates — the transmission rate (β) and the recovery rate (γ) — to simulate the epidemic trajectory over time.

The basic reproduction number R₀ (β/γ) determines whether an epidemic will grow (R₀ > 1) or decay (R₀ < 1). Each pathogen has a characteristic R₀: seasonal influenza ~1.3, original SARS-CoV-2 ~2.5, the Delta variant ~5-8, measles ~12-18. The herd immunity threshold — the fraction of the population that must be immune to stop transmission — is directly derived as 1 - 1/R₀. For measles with R₀ of 15, this requires ~93% immunity.

This simulator runs a complete SIR model with Euler method integration, allowing you to set population size, initial conditions, R₀, infectious period, vaccination coverage, and timed interventions (lockdowns, masking) that reduce transmission. It generates the epidemic curve, peak infected count and timing, total attack rate, and key time-point snapshots — making epidemiological concepts tangible and explorable.

Why Use This SIR Model Epidemic Simulator — Viral Infection Spread?

Understanding epidemic dynamics is essential for public health literacy, pandemic preparedness, and interpreting the policy decisions that affect daily life (lockdowns, vaccination targets, school closures). This simulator makes the abstract mathematics of epidemiology visual and interactive — allowing students, healthcare workers, and curious citizens to explore how R₀, vaccination, and interventions shape epidemic trajectories.

How to Use This Calculator

  1. Select a disease preset or manually enter R₀ and infectious period.
  2. Set the population size and initial number of infected individuals.
  3. Optionally set vaccination coverage to reduce the susceptible pool.
  4. Optionally configure an intervention (e.g., 50% transmission reduction starting day 30).
  5. Review the epidemic curve, peak infections, attack rate, and herd immunity threshold.
  6. Experiment with different parameters to see how interventions change the epidemic trajectory.

Formula

SIR differential equations: dS/dt = -β × S × I / N dI/dt = β × S × I / N - γ × I dR/dt = γ × I where β = R₀ × γ, γ = 1 / infectious period Herd immunity threshold = 1 - 1/R₀ Attack rate = total ever-infected / N × 100

Example Calculation

Result: Peak: 1,847 infected on Day 76, Total infected: 8,912 (89.1%), Herd immunity: 60%

With R₀ = 2.5 and no interventions, the epidemic grows exponentially, peaks around day 76 with ~18% of the population actively infected, and eventually infects ~89% before burning out as the susceptible pool is depleted below the herd immunity threshold.

Tips & Best Practices

Practical Guidance

Use consistent units, verify assumptions, and document conversion standards for repeatable outcomes.

Common Pitfalls

Most mistakes come from mixed standards, rounding too early, or misread labels. Recheck final values before use. ## Practical Notes

Use this for repeatability, keep assumptions explicit. ## Practical Notes

Track units and conversion paths before applying the result. ## Practical Notes

Use this note as a quick practical validation checkpoint. ## Practical Notes

Keep this guidance aligned to expected inputs. ## Practical Notes

Use as a sanity check against edge-case outputs. ## Practical Notes

Capture likely mistakes before publishing this value. ## Practical Notes

Document expected ranges when sharing results.

Frequently Asked Questions

What does R₀ actually measure?

R₀ (basic reproduction number) is the average number of secondary infections caused by one infected individual in a completely susceptible population. An R₀ of 2.5 means each infected person, on average, infects 2.5 others. It is NOT a rate — it's a dimensionless ratio determined by transmissibility, contact rate, and infectious duration.

Why does the epidemic end before everyone is infected?

As people recover and become immune, the effective number of susceptible contacts per infected person drops below 1 (effective R < 1), and the epidemic declines. This happens when the immune fraction exceeds the herd immunity threshold. The remaining susceptible individuals are "protected" by the immune population around them.

What are the limitations of the SIR model?

The basic SIR model assumes homogeneous mixing (everyone contacts everyone equally), permanent immunity, no births/deaths, no latent period, and constant rates. More realistic models add compartments: SEIR (Exposed/latent), SIS (no permanent immunity), SIRS (waning immunity), age-stratified models, and spatial/network models.

How do interventions like lockdowns affect the model?

Interventions reduce the effective transmission rate β. A 50% reduction in contacts (lockdown, masking, distancing) effectively halves β, reducing the effective R₀. If interventions reduce R₀ below 1, the epidemic declines. However, lifting interventions before herd immunity is reached can cause a second wave.

What is the difference between R₀ and Rₜ (effective R)?

R₀ is the theoretical maximum in a fully susceptible population. Rₜ (effective R at time t) accounts for current immunity: Rₜ = R₀ × (S/N). As S decreases through infection or vaccination, Rₜ drops. When Rₜ < 1, new infections decline. Rₜ is what public health officials report during an ongoing epidemic.

Why is herd immunity for measles so high (93%)?

Herd immunity threshold = 1 - 1/R₀. For measles with R₀ ≈ 15: 1 - 1/15 = 0.933 or 93.3%. Because measles is so transmissible, nearly the entire population must be immune to prevent sustained transmission. This is why even small drops in MMR vaccination coverage can trigger measles outbreaks.

Related Pages