Toolyard

Epidemic Spread Simulator: SIR and SEIR

Equations in this simulation

dS/dt = −β S I′ ÷ N, dE/dt = β S I′ ÷ N − σ E, dI/dt = σ E − γ I, dR/dt = γ I
S, E, I, Rsusceptible, exposed (infected but not yet infectious), infectious, recoveredvaccinated people start outside S and never catch it
βinfectious contacts per infectious person per dayR₀ × γ × (1 − distancing)
I′infectious people who are not in quarantineI × (1 − quarantine share)
σrate of becoming infectious1 ÷ the incubation period; with 0 days E is skipped and this is the SIR model
γrecovery rate1 ÷ the infectious period

With the current values:

R_t = R₀ × (1 − distancing) × (1 − quarantine) × S ÷ N
R_teffective reproduction number nowthe outbreak grows while it is above 1 and shrinks once it falls below 1

With the current values:

herd immunity threshold = 1 − 1 ÷ R₀
1 − 1/R₀share that must be immune to stop an outbreak growingwith distancing and quarantine R₀ is replaced by the reduced value

With the current values:

ln(S₀ ÷ S∞) = R_e × (1 − v − S∞ ÷ N)
S∞people never infected, by the final size equationR_e = R₀ × (1 − distancing) × (1 − quarantine), v the vaccinated share; the same for SIR and SEIR

With the current values:

How to use the epidemic simulator

  1. Set R₀, the incubation and infectious periods and the size of the town. Everyone starts susceptible except a few infectious people. Infectious people pass the infection on through random contacts across the town; the newly infected become exposed, then infectious, then recovered and immune. Short red lines show each new infection.
  2. The chart compares the town, in solid lines, with the SIR or SEIR equations for the same numbers, dashed. Read the peak and when it comes, how many catch it so far and in the end, and the effective R, which falls as people become immune. Once it drops below 1 the outbreak shrinks.
  3. Try the measures: vaccinate a share of the town before the outbreak, cut contacts by distancing, or send a share of cases to quarantine. Push vaccination past the herd immunity threshold, 1 − 1/R₀, and the outbreak cannot take off. The Cell Doubling Time Calculator finds the doubling time of the early, exponential rise.

Frequently asked questions

What is R₀?

The basic reproduction number: how many people one infectious person infects, on average, in a population where everyone is susceptible. Above 1 an outbreak can grow; below 1 it fades. Measles has an R₀ of about 12 to 18, seasonal flu about 1.3, and the first strains of COVID-19 about 2.5 to 3.

What is the difference between the SIR and SEIR models?

SIR puts everyone in three groups: susceptible, infectious and recovered. SEIR adds an exposed group for people who have caught the infection but cannot pass it on yet. The final number infected is the same, but the incubation period makes the outbreak rise more slowly and peak later.

What is herd immunity?

Once enough of a population is immune, each case infects fewer than one other on average and outbreaks die out, which protects people who are not immune. The threshold is 1 − 1/R₀: two thirds for R₀ = 3, about 95% for measles. Without vaccination an outbreak overshoots it, infecting far more people than the threshold.

Why does flattening the curve matter?

Cutting contacts lowers the peak and spreads the cases over a longer time, so fewer people are ill at once and hospitals can cope. It also lowers the total number infected, because the outbreak overshoots the herd immunity threshold by less.

It says WebGL is turned off.

The 3D view needs WebGL, which every current browser has. It can be switched off by hardware acceleration being disabled in the browser settings, or by a very old graphics driver. Turn hardware acceleration on, or try another browser.

Is anything uploaded?

No. The simulation is drawn by your own browser with WebGL; nothing is sent anywhere, and it keeps working offline once the page has loaded.

More science simulations

Projectile Motion SimulatorPendulum SimulatorDouble-Slit Experiment SimulatorElectric Field SimulatorOrbit SimulatorMass-Spring Oscillator SimulatorRutherford Scattering SimulatorParticle Collider Event DisplayRadioactive Decay SimulatorBohr Atom Simulator3D Molecule ViewerIdeal Gas SimulatorDiffusion and Osmosis SimulatorDNA and RNA Folding ViewerBacterial Growth SimulatorCentrifuge SimulatorLens and Mirror Ray Diagram SimulatorStanding Wave SimulatorDoppler Effect SimulatorCollision and Momentum SimulatorRC and RL Circuit SimulatorCharged Particle in a Magnetic Field SimulatorBlackbody Radiation SimulatorSpecial Relativity SimulatorRefraction and Total Internal Reflection SimulatorSeries and Parallel Circuit SimulatorFluid Flow and Bernoulli's Principle SimulatorElectromagnetic Induction SimulatorTitration Curve SimulatorReaction Rate and Collision Theory SimulatorChemical Equilibrium Simulator (Le Chatelier)Galvanic Cell and Electrolysis SimulatorHeating Curve and Phase Change SimulatorAtomic Orbitals 3D ViewerBuffer SimulatorChromatography SimulatorSpectrophotometer and Beer-Lambert Law SimulatorCrystal Lattice 3D ViewerEnzyme Kinetics SimulatorAction Potential SimulatorPCR SimulatorNatural Selection and Population Genetics SimulatorHeart and Cardiac Cycle SimulatorGel Electrophoresis SimulatorMitosis and Meiosis SimulatorProtein Synthesis Simulator: Transcription and TranslationPhotosynthesis and Limiting Factors SimulatorPredator and Prey Population SimulatorSeasons and Day Length SimulatorPlate Tectonics and Earthquake SimulatorMoon Phases, Tides and Eclipses SimulatorGreenhouse Effect SimulatorStellar Evolution and Hertzsprung–Russell Diagram SimulatorGalton Board SimulatorFourier Series Simulator

Related calculators and tools

Guides