This is a real SEIR compartmental model — Susceptible, Exposed (infected but not yet infectious), Infectious, Recovered/immune — extended with a continuous vaccination rate v that moves susceptibles directly into the immune pool, integrated with 4th-order Runge–Kutta (RK4) at a fixed daily sub-step:
dS/dt = −β·S·I − v·S
dE/dt = β·S·I − σ·E (σ = 1 / incubation period)
dI/dt = σ·E − γ·I (γ = 1 / infectious period)
dR/dt = γ·I + v·S
R0 = β / γ
Herd-immunity threshold = 1 − 1/R0
Effective reproduction Rt = R0 · S(t)
S, E, I, R are fractions of the population (they always sum to 1). The exposed compartment is what makes this SEIR rather than SIR: it delays a newly infected person becoming infectious by the incubation period, which changes both the timing and the shape of the curve compared to a plain SIR model. Vaccination shrinks S directly, so it lowers Rt = R0·S even before anyone has caught the disease — once enough people are vaccinated (or recovered) that S drops below 1/R0, Rt falls under 1 and the outbreak cannot sustain itself, which is exactly the herd-immunity condition 1 − 1/R0.
- Transmission rate β — new infections per day an infectious person generates while everyone around them is susceptible.
- Incubation period — average days a newly infected person stays exposed but not yet contagious.
- Infectious period — average days a person remains contagious before recovering.
- Vaccination rate v — % of the remaining susceptible pool immunized per day, starting from day 0.
- "Vax to HIT" button — sets v so vaccination alone would reach the herd-immunity threshold in about 30 days, letting you watch Rt cross below 1 and the curve flatten before it ever really rises.