QUAL2K Python & Web Wizard: Water Quality Simulation Software

This tool is a React and Python-based alternative to the EPA QUAL2K water quality model. It replaces the legacy Excel/VBA spreadsheet with a modern web interface and a cloud-hosted Python simulation engine, while maintaining numerical equivalence with the original model.

QUAL2K System Architecture

The system consists of three layers: a React-based web wizard for data entry, a Firebase Cloud Function that receives the wizard state, and a Python simulation engine that performs the hydraulic and water quality calculations. Results are returned to the browser for display and export.

QUAL2K Simulation Capabilities

  • Steady-state simulation of 15 water quality constituents including DO, CBOD (fast and slow), nitrogen species, phosphorus, pathogens, and ISS
  • 24-hour diel simulation with hourly time-stepping for temperature, light, and meteorological forcing
  • Manning's equation hydraulics with Newton-Raphson iterative depth solver for trapezoidal cross-sections
  • Arrhenius temperature correction on all first-order kinetic rates
  • Multiple reaeration formulas: O'Connor-Dobbins, Churchill, Owens-Gibbs, and user-specified
  • Point sources and diffuse sources with mass-balance mixing at reach boundaries
  • Auto-calibration using genetic algorithm optimization against observed field data
  • CSV and JSON import/export for interoperability with Excel and other tools

Supported Constituents

15 Water Quality State Variables

IndexConstituentUnitsProcess
0ConductivityμmhosConservative
1Inorganic Suspended Solids (ISS)mg/LSettling
2Dissolved Oxygen (DO)mg/LReaeration, oxidation, SOD
3Slow CBODmg/LSlow oxidation, hydrolysis source
4Fast CBODmg/LOxidation, hydrolysis from slow
5Organic Nitrogenμg/LHydrolysis, settling
6Ammonium (NH₄)μg/LNitrification
7Nitrate (NO₃)μg/LDenitrification, nitrification source
8Organic Phosphorusμg/LHydrolysis, settling
9Inorganic Phosphorusμg/LSettling
10Phytoplanktonμg Chl-a/LGrowth, respiration, death
11Detritusmg/LDissolution, settling
12Pathogenscfu/100mLDie-off, settling
13GenericuserUser-defined decay
14Alkalinitymg CaCO₃/LConservative

Technology Stack

ComponentTechnologyPurpose
FrontendReact 19 + ViteMulti-step wizard UI with state management
StylingVanilla CSSDark/light theme with design tokens
AuthFirebase AuthenticationGoogle Sign-In for user access
HostingFirebase HostingCDN-backed static site delivery
BackendFirebase Cloud Functions (2nd gen)Serverless Python execution
EnginePython 3.12QUAL2K simulation with NumPy-free math
DataJSON / CSVPortable data interchange formats

Design Principles

  1. Numerical equivalence \u2014 the Python engine produces results within 1% of the legacy Excel model for all validated test cases
  2. Zero installation \u2014 runs entirely in the browser with cloud computation; no software installation, no VBA macros, no OS restrictions. See Getting Started to begin your first simulation
  3. Transparent math \u2014 every formula is documented in this guide with references to the original QUAL2K technical documentation
  4. Data portability \u2014 all inputs and outputs can be exported as JSON or CSV for use in external tools