HomeMedicine & BiophysicsEpidemic Model — SIR & Vaccination Thresholds

🦠 Epidemic Model — SIR & Vaccination Thresholds

Simulate disease spread using the SIR compartmental model. Adjust R₀, vaccination coverage, and intervention timing to explore herd immunity thresholds and flatten the curve.

Medicine & Biophysics3DEasy60 FPS
epidemic-model ↗ Open standalone

Physics & Equations

The SIR model divides population N into Susceptible (S), Infectious (I), and Recovered (R). The governing ODEs are: dS/dt = −β·S·I/N; dI/dt = β·S·I/N − γ·I; dR/dt = γ·I. The basic reproduction number R₀ = β/γ determines how many people one case infects on average. Herd immunity threshold is p_c = 1 − 1/R₀.

Herd Immunity

Vaccination reduces the susceptible pool: S(0) = (1−v)·N. When vaccination coverage v exceeds the herd immunity threshold p_c, the epidemic cannot grow. For COVID-19 (R₀≈3), ~67% vaccination is needed; for measles (R₀≈15), ~93% is required. The epidemic peaks when S = N/R₀.

Interventions

Lockdown and social distancing reduce the transmission rate β (halving it cuts R₀ in half). The Intervention Day slider simulates non-pharmaceutical interventions starting at day d. Earlier interventions delay and reduce the peak but don't eliminate the epidemic unless combined with high vaccination.

About this simulation

This simulation runs a compartmental SIR model of infectious disease spread across a fixed population of 400 individuals. Susceptible (S), Infectious (I) and Recovered (R) counts evolve under the coupled ODEs dS/dt = −β·S·I/N, dI/dt = β·S·I/N − γ·I, dR/dt = γ·I, integrated with a simple explicit time step. The transmission rate β is derived from your chosen R₀ and recovery rate γ (β = R₀·γ), and can be cut by a lockdown toggle or a scripted intervention day, letting you compare unmitigated spread against public-health responses in real time.

🔬 What it shows

A 20×20 grid of 400 agents colour-coded blue (Susceptible), red (Infectious) and grey (Recovered), animated alongside a live S/I/R curve chart. Each simulated day the SIR differential equations are stepped forward, moving people between compartments according to the current transmission and recovery rates, while running statistics track the epidemic's peak and total size.

🎮 How to use

Set R₀ (1–15), Vaccination % (0–90, removed from the susceptible pool at start), Recovery Rate γ (0.05–0.5 per day) and an Intervention Day (0–150) that cuts transmission by 30% once reached. Press Run to animate the outbreak, toggle Lockdown at any time to halve β, or load a preset — COVID-19 (R₀≈3), Measles (R₀≈15), Flu (R₀≈1.5) or a pre-vaccinated Controlled scenario — and watch Peak Infected, Attack Rate, Herd Immunity Threshold and Current Day update live.

💡 Did you know?

The herd immunity threshold p_c = 1 − 1/R₀ explains why more contagious diseases need much higher vaccination coverage: COVID-19-like R₀≈3 needs roughly 67% immunity to stop spread, while measles, with R₀ as high as 15, needs about 93% — one of the reasons measles resurges so quickly wherever vaccination rates dip even slightly.

Frequently asked questions

What is the SIR model and what do S, I and R stand for?

SIR stands for Susceptible, Infectious and Recovered — the three compartments a fixed population is divided into. Susceptible people can catch the disease, Infectious people are currently sick and can transmit it, and Recovered people have either recovered or died and can no longer be infected or infect others in this simple model. The model tracks how people flow from S to I to R over time using a pair of coupled differential equations.

How does the simulation calculate new infections each day?

Each simulated day, the number of new infections is proportional to β·S·I/N, where β is the transmission rate, S and I are the current susceptible and infectious counts, and N is the total population (400). This term is largest when both S and I are sizeable — early in an outbreak, when almost everyone is susceptible and the number of infectious people is growing — and shrinks automatically as either group empties out.

What is R₀ and how does it relate to the transmission rate β?

R₀, the basic reproduction number, is the average number of secondary infections one infectious person causes in a fully susceptible population. In this simulation it is linked to the transmission rate by β = R₀·γ, where γ is the recovery rate. Raising the R₀ slider therefore increases β directly, causing infections to grow faster and produce a higher, earlier epidemic peak.

How do vaccination and lockdown change the outcome?

Vaccination removes a percentage of the population from the susceptible pool before day zero, so those people can never be infected, directly shrinking the pool available to sustain an outbreak. Lockdown instead reduces the transmission rate β by half for as long as it is active, slowing — but not necessarily stopping — spread. The Intervention Day slider models a similar but permanent 30% cut in β once a chosen day is reached, representing measures like mask mandates or social distancing introduced partway through an outbreak.

What is the herd immunity threshold and why does it depend on R₀?

The herd immunity threshold is the fraction of the population that needs to be immune (through vaccination or prior infection) for an epidemic to no longer be able to grow, calculated here as p_c = 1 − 1/R₀. A higher R₀ means each infectious person can reach more susceptible contacts, so a larger share of the population must be protected to break the chain of transmission — this is why the simulation shows roughly 67% for a COVID-19-like R₀ of 3 but around 93% for measles-like R₀ of 15.

⚙ Under the hood

SIR compartmental model with vaccination: see how herd immunity threshold, R0 and vaccination rate interact. Adjust parameters and watch epidemic curves in real time.

SIR modelepidemicvaccinationherd immunityR0disease spread

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)