β’ Setup Overview
β’ Available Modules
Section 01: Master JSON
β’ Project Settings
β’ File Path Configuration
Section 02: Configuration
β’ Compartments
β’ Initial Conditions
Section 03: Loading Modules
β’ BGC, Transport & Other Modules
Section 04: External Sources
β’ Sources, Sinks & Fluxes
Section 05: Running the Model
β’ Execution & Validation
β’ Setup Checklist
β’ Common Issues & Solutions
OpenWQ uses JSON configuration files organized in a hierarchical structure:
ββββββββββββββββββββββββ
β Master JSON β β Entry point
β (project settings) β
ββββββββββββ¬ββββββββββββ
β
βββββββββββββββΌββββββββββββββ
βΌ βΌ βΌ
ββββββββββββββ ββββββββββββββ ββββββββββββββ
β Config β β Modules β β External β
β (IC, comp) β β (BGC, etc) β β Sources β
ββββββββββββββ ββββββββββββββ ββββββββββββββ
python model_config_template.py| NATIVE_BGC_FLEX | User kinetics |
| BGC_FLEX_THERMO | With FT factor |
| PHREEQC | Equilibrium |
.json or .pqi + .dat
| ADVDISP | Advection + Dispersion |
| ADV | Advection only |
| NONE | No transport |
| BOUNDMIX | Between compartments |
| LANGMUIR | qmax, KL, Kadsdes |
| FREUNDLICH | KF, n, Kadsdes |
| HYPE_HBVSED | HBV-sed approach |
| HYPE_MMF | Modified MMF |
openWQ_master.json β "MODULES" section
python model_config_template.py
openWQ_master.jsonopenWQ_config.jsonopenWQ_MODULE_*.jsonopenWQ_SS_*.jsonopenWQ_EWF_*.json
{
// Project metadata
"PROJECT_NAME": "My_Watershed_WQ",
"GEOGRAPHICAL_LOCATION": "Saskatchewan, Canada",
"AUTHORS": "Your Name",
"DATE": "Feb_2026",
// Computational settings
"COMPUTATIONAL_SETTINGS": {
"RUN_MODE_DEBUG": false,
"USE_NUM_THREADS": "all" // or integer (e.g., 8)
},
// Input file references
"OPENWQ_INPUT": {
"CONFIG_FILEPATH": "openwq_config.json",
"SINK_SOURCE": {
"1": { "LABEL": "Fertilizer", "FILEPATH": "sources_fertilizer.json" }
},
"EXTERNAL_WATER_FLUXES": {
"1": { "LABEL": "Precipitation", "FILEPATH": "precip_chemistry.json" }
}
},
// Module selection
"MODULES": {
"BIOGEOCHEMISTRY": { "MODULE_NAME": "NATIVE_BGC_FLEX", "MODULE_CONFIG_FILEPATH": "bgc_cycling.json" },
"TRANSPORT_EROSION": { "MODULE_NAME": "OPENWQ_NATIVE_TRANSP_DISS_ADVDISP", "MODULE_CONFIG_FILEPATH": "transport.json" }
},
// Output configuration
"OPENWQ_OUTPUT": {
"RESULTS_FOLDERPATH": "../openwq_out",
"FORMAT": "HDF5",
"CHEMICAL_SPECIES": ["NO3_N", "NH4_N"],
"UNITS": "mg/L",
"TIMESTEP": [1, "day"]
}
}
{
"BIOGEOCHEMISTRY_CONFIGURATION": {
// River compartment
"RIVER_NETWORK_REACHES": {
"CYCLING_FRAMEWORK": ["N_CYCLE"],
"INITIAL_CONDITIONS": {
"DATA_FORMAT": "JSON",
"NO3_N": {
"1": ["all", "all", "all", 2.0, "mg/L"]
},
"NH4_N": {
"1": ["all", "all", "all", 0.1, "mg/L"]
}
}
},
// Soil compartment (from HDF5)
"SOIL": {
"CYCLING_FRAMEWORK": ["N_CYCLE", "P_CYCLE"],
"INITIAL_CONDITIONS": {
"DATA_FORMAT": "HDF5",
"FOLDERPATH": "ic_hdf5/",
"UNITS": "mg"
}
}
}
}
Must match host model compartments:
Two formats supported:
"all" for uniform IC across entire compartment
Three biogeochemistry engines available:
User-defined kinetic reactions
"MODULE_NAME": "NATIVE_BGC_FLEX" // Define species & reactions "kinetics": ["k * A * B"] "parameter_values": {...}
π Config: .json files
Kinetics + equilibrium constraints
"MODULE_NAME": "NATIVE_BGC_FLEX_THERMODYNAMIC" // Kinetics + equilibrium "equilibrium_species": [...]
π Config: .json files
Full geochemical modeling
"MODULE_NAME": "PHREEQC" // Uses PHREEQC input files "FILEPATH": "*.pqi" "DATABASE": "*.dat"
π Config: .pqi + .dat files
Start from existing templates instead of writing from scratch:
Individual Chemicals
Mimicking Popular Models
Thermodynamic Templates
Full Geochemistry
+ phreeqc.dat database
supporting_scripts/Model_Config/config_support_lib/BGC_templates/
{
"MODULE_NAME": "OPENWQ_NATIVE_TRANSP_DISS_ADVDISP",
// Dispersion coefficients
"ADVDISP_CONFIGURATION": {
"dispersion_x": 10.0, // mΒ²/s
"dispersion_y": 1.0,
"dispersion_z": 0.1,
"characteristic_length_m": 100.0
},
// Lateral exchange between compartments
"BOUNDMIX_CONFIGURATION": {
"1": {
"DIRECTION": "z",
"UPPER_COMPARTMENT": "RUNOFF",
"LOWER_COMPARTMENT": "SOIL",
"K_VAL": 0.001
},
"2": {
"DIRECTION": "z",
"UPPER_COMPARTMENT": "SOIL",
"LOWER_COMPARTMENT": "GROUNDWATER",
"K_VAL": 0.0001
}
}
}
| ADVDISP | Advection + Dispersion |
| ADV | Advection only |
| NONE | No transport |
K_VAL controls mixing rate between adjacent compartments (1/s)
model_config_template.py generates an interactive HTML report with ready-to-copy Docker commands β paths are auto-filled from your template configuration.
# General pattern (auto-filled in the HTML report) docker exec docker_openwq /bin/bash -c \ "cd <output_dir> && \ mpirun --allow-run-as-root -np 2 \ <executable> <control_file>" # Example with actual paths docker exec docker_openwq /bin/bash -c \ "cd /code/my_project && \ mpirun --allow-run-as-root -np 2 \ /code/bin/mizuroute_openwq_Release \ /code/my_project/mizuroute.control"
mpirun -np 2 (minimum 2 MPI processes) for domain decomposition. Do not use -g 1 1 -m flags.
In openwq_out/ folder:
RIVER@NO3_N#mg_L.h5RIVER@NH4_N#mg_L.h5Log_OpenWQ.txt{COMPARTMENT}@{SPECIES}#{UNITS}.h5
| Issue | Solution |
|---|---|
| File not found errors | Check paths are relative to master JSON location |
| Unknown compartment name | Ensure compartment names match host model exactly |
| Species not defined | Add species to CHEMICAL_SPECIES list before referencing |
| Kinetics expression error | Check exprtk syntax β use ^ for power, not ** |
| Negative concentrations | Reduce timestep or check reaction rates |
| No output produced | Check OPENWQ_OUTPUT species list matches defined species |
"RUN_MODE_DEBUG": true for verbose logging
Create directory structure with openwq_in/ and openwq_out/ folders
Edit model_config_template.py β generates JSON configs + interactive HTML report
Copy Docker commands from report, run model, use Python snippets to visualize
Documentation: openwq.readthedocs.io