Migrating from QUAL2K Excel VBA to the Python Web Interface

The original QUAL2K model ships as a Microsoft Excel workbook with embedded VBA macros, available from the EPA Center for Exposure Assessment Modeling. While functional, this architecture creates significant operational challenges: VBA crashes on large models, macro security settings block execution, and the file is limited to Windows. This web-based Python implementation eliminates these limitations while maintaining numerical equivalence with the legacy model.

Feature Comparison

QUAL2K Excel vs Python Web Wizard

FeatureExcel/VBA (Legacy)Python/Web (This Tool)
PlatformWindows only (requires Excel)Any browser (Windows, Mac, Linux, mobile)
ExecutionLocal VBA macrosCloud-hosted Python 3.12
Data entryManual cell editing across 20+ sheets10-card guided wizard
Import/ExportCopy-paste within ExcelJSON + CSV import/export
Simulation time10–60 seconds (VBA interpreted)2–5 seconds (compiled Python)
CalibrationManual trial-and-errorAutomated genetic algorithm (planned)
Crash recoveryLost if unsavedBrowser state persists, JSON backup
CollaborationEmail .xlsm filesShare JSON config file
Constituents15 state variables15 state variables (identical)
HydraulicsManning's / Rating curvesManning's / Rating curves (identical)
Diel simulation24-hour loop24-hour loop (identical)
Source codeLocked VBA modulesOpen Python (documented in these docs)

Data Mapping: Excel Sheets to Wizard Cards

The Excel model stores data across multiple spreadsheet tabs. Each tab maps to one or more wizard cards in the web interface.

Sheet-to-Card Mapping

Excel SheetWizard CardKey Fields
QUAL2K (rows 8–32)1. Project SetupRiver name, date, time zone, calc step, options
Reach (rows 10–60)2. Reach DefinitionReach names, geometry, Manning's n, slopes
Headwater (rows 8–28)3. HeadwaterFlow, temperature, DO, nutrients, pathogens
Point Sources (rows 10+)4. Point SourcesLocation, flow, concentrations
Diffuse Sources (rows 10+)5. Diffuse SourcesLocation range, flow, concentrations
Rates (rows 10–80)6. Kinetic RatesDecay rates, stoichiometry, algae parameters
Light and Heat (rows 10–20)7. Light & HeatPAR, extinction, solar/wind methods
Meteorology (hourly)8. MeteorologyAir temp, dew point, wind speed, cloud cover
WQ Data (field observations)9. Observed DataCalibration targets at stations
— (run button + results)10. Review & RunSummary, submit, view results

Migration Steps

  1. Export from Excel: Open your existing .xlsm file and manually note the key parameters (reach geometry, headwater conditions, kinetic rates). Alternatively, use the CSV export format to transfer data in bulk.
  2. Create a wizard JSON: Build a JSON file matching the JSON Schema with your model parameters. Use the Paraluz test file as a template.
  3. Import and validate: Use the "Import JSON" button in the wizard to load your configuration. Review each card to confirm the data transferred correctly.
  4. Run and compare: Execute the simulation and compare results with your Excel output. The Validation section demonstrates the expected agreement between the two engines.

Common Issues When Migrating

IssueCauseSolution
All zeros in resultsEmpty reaches list in wizard stateVerify Card 2 has reaches defined; use Import JSON
Timezone parsing errorText timezone like 'Eastern' not recognizedUse numeric offset (e.g., -5) or recognized name
Manning's n = 0Missing geometry data in reach definitionEnsure all reaches have non-zero Manning n values
DO saturation too highDefault elevation = 0 (sea level)Set correct elevation in reach definition
No diel variationMeteorology card emptyAdd hourly met data or use constant values

Ready to model your river?

Try the QUAL2K prediction engine with your own data

Launch Prediction Engine