Simulate disease spread using the SIR compartmental model. Adjust R₀, vaccination coverage, and intervention timing to explore herd immunity thresholds and flatten the curve.
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₀.
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₀.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.