Skip to content

denniemok/seirs-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🦠 Interactive SEIRS Model

This interactive simulator demonstrates how infectious diseases spread through populations using a deterministic, mean-field SEIRS compartmental model. It features real-time parameter adjustments and elegant visualizations to help understand epidemic dynamics, including vaccination, immunity waning, and disease-induced mortality.



✨ Features

🎮 Interactive Controls

  • Real-time parameter adjustments
  • Intuitive slider controls
  • Instant visualization updates
  • Reset to defaults anytime

📊 Flexible Visualization

  • Linear & logarithmic Y-axis
  • Adjustable time horizons (3000 days)
  • Color-coded compartments (S, E, I, R)
  • Responsive plot design

🔬 Epidemiological Parameters

  • Basic reproduction number (R₀)
  • Incubation & infectious periods
  • Immunity duration
  • Vaccination rates
  • Disease-induced mortality

🎓 Educational Content

  • Built-in mathematical equations
  • Parameter explanations
  • Helpful tooltips
  • Clean, modern interface
  • Zero dependencies required


🚀 Getting Started

Prerequisites

  • A modern web browser (Chrome, Firefox, Safari, or Edge)
  • No installation or build process required!

Quick Start

  1. Get the code

    git clone https://github.com/denniemok/seirs-demo.git

    Or download ZIP directly.

  2. Open in browser

    Double-click index.html to open directly in your browser, or use a local web server for full functionality:

    cd seirs-demo
    
    # Python 3
    python -m http.server 8000
    
    # Node.js
    npx http-server

    Then open http://localhost:8000 in your browser.


📐 Technical Details

Framework

The model divides the population into four compartments:

Compartment Description
S (Susceptible) 🟦 Individuals who can contract the disease
E (Exposed) 🟩 Individuals who are infected but not yet infectious
I (Infectious) 🟧 Individuals who can transmit the disease
R (Recovered) 🟨 Individuals who have immunity (temporary or permanent)

Mathematics

The dynamics are governed by these differential equations:

dS/dt = -βSI + ωR - μS + μ(1-p)
dE/dt = βSI - σE - μE
dI/dt = σE - γI - (μ+α)I
dR/dt = γI - ωR - μR + μp
Symbol Description
β Transmission rate
σ Progression rate (1 / incubation period)
γ Recovery rate (1 / infectious period)
ω Immunity waning rate (1 / immunity duration)
μ Natural mortality rate (1 / life expectancy)
α Disease-induced mortality rate (1 / infection-to-death period)
p Vaccination rate

Implementation

Feature Technology
Numerical solver 4th-order Runge-Kutta (RK4)
Data structures Float64Array for performance
Visualization D3.js v3.5.17 (SVG)
Documentation JSDoc + inline comments

📁 Project Structure

seirs-demo/
├── 📄 index.html          # Main HTML page with structure and equations
├── 📜 seirs.js            # Core SEIRS model implementation and plotting logic
├── ⚙️  params.js           # Parameter definitions and UI control values
├── 🎨 seirs.css           # Styling and responsive design
└── 📊 d3.min.js           # D3.js library for visualization

🎨 Customisation

Modify Parameters

Edit params.js to change parameter ranges and defaults:

// Example: Extend R₀ range from 1-5 to 1-10
R0: generateParams(1, 10, 0.1, 3.0)

Change Styling

Modify seirs.css to customize the appearance. CSS variables make theming easy:

:root {
    --color-susceptible: #2c3e50;  /* Dark blue */
    --color-exposed: #27ae60;      /* Green */
    --color-infectious: #e67e22;   /* Orange */
    --color-recovered: #3498db;    /* Light blue */
}

🙏 Acknowledgments

This project is built upon and inspired by:



This model is intended for educational purposes to understand epidemiological dynamics. For public health decisions, please consult epidemiological experts and use validated, peer-reviewed models.

This project, including D3.js v3.5.17, is distributed under the BSD 3-Clause License.




Made with ❤️ for epidemiology education

⬆ Back to Top

About

An interactive web-based visualization of the SEIRS epidemiological model for understanding disease spread dynamics.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors