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 Excel/VBA workbook with a web interface and a cloud-hosted Python port of the QUAL2Kw 5.1 solver. Existing QUAL2Kw workbooks (.xls, .xlsx, .xlsm) can be imported directly, and the engine reproduces the output sheets of 15 calibrated QUAL2Kw models within 5% or a fixed absolute band (see Validation results).

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

  • Time-stepping simulation: an explicit Euler time step over a repeating daily cycle, as in QUAL2Kw, reporting the daily mean, minimum and maximum per reach
  • Water quality: DO, CBOD (fast and slow), nitrogen species, phosphorus, phytoplankton and bottom algae, detritus, pathogens, ISS, alkalinity, with pH solved at every step
  • Heat balance for water and sediment temperature from solar, long-wave, wind 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, Tsivoglou-Neal, Thackston-Dawson and user-specified
  • Point sources and diffuse sources with mass-balance mixing at reach boundaries
  • Auto-calibration of 18 kinetic rates against observed field data (differential evolution, with a genetic algorithm as fallback)
  • QUAL2Kw workbook import (.xls, .xlsx, .xlsm) plus CSV and JSON import/export

Supported Constituents

Water quality columns in the results (temperature and pH are reported too)

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 with NumPy and SciPyQUAL2Kw 5.1 solver port and auto-calibration
DataJSON / CSVPortable data interchange formats

Design Principles

  1. Measured fidelity - the engine reproduces the output sheets of 15 calibrated QUAL2Kw models within 5% or a fixed absolute band (pH 0.05, temperature 0.2 °C)
  2. Zero installation - 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 - every formula is documented in this guide with references to the original QUAL2K technical documentation
  4. Data portability - all inputs and outputs can be exported as JSON or CSV for use in external tools

Model the whole river in the prediction engine

Import your QUAL2Kw workbook or open the example project. Results reproduce 15 calibrated QUAL2Kw models within 5% or a small absolute band.

See the prediction engine