OpenWQ

Biogeochemistry Engines
From empirical kinetics to thermodynamic equilibrium geochemistry
β€” flexible frameworks for any water quality application

Contents

β€’ Three Biogeochemistry Engines

Section 01: NATIVE_BGC_FLEX

β€’ Kinetic Reactions

β€’ Host Model Variables

β€’ JSON Configuration

Section 02: Thermodynamic Extension

β€’ FT Factor Theory

β€’ Gibbs Energy Constraints

β€’ Redox Ladder

Section 03: PHREEQC

β€’ Equilibrium Geochemistry

β€’ Input Files (.pqi + .dat)

β€’ Integration with OpenWQ

β€’ Selected Outputs

β€’ Comparison & When to Use

β€’ Available Templates

01

NATIVE_BGC_FLEX

Reaction Network Paradigm

Each transformation is defined by four elements:

  • Consumed species β€” reactant being transformed
  • Produced species β€” product being created
  • Kinetics expression β€” rate formula
  • Parameters β€” rate constants, Km, etc.
Expression Parser: Uses exprtk β€” any mathematical expression is valid!
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”   nitrification   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  NH₄⁺  β”‚ ───────────────▢ β”‚  NO₃⁻  β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           Rate = k Γ— [NHβ‚„] Γ— f(Oβ‚‚) Γ— f(T)


    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”   denitrification β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  NO₃⁻  β”‚ ───────────────▢ β”‚   Nβ‚‚   β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           Rate = k Γ— [NO₃] Γ— f(DOC) Γ— g(Oβ‚‚)
                            

Supported Rate Laws

First-Order Kinetics
Rate = k Γ— C
Monod / Michaelis-Menten
Rate = kmax Γ— C / (Km + C)
Temperature Correction (Q10)
Rate = k20 Γ— ΞΈ(T-20) Γ— C

Available Functions

Mathexp, log, sqrt, abs, pow
Trigsin, cos, tan
Comparemin, max, clamp
Logicif(cond, true, false)

Available Variables

  • T β€” Temperature (Β°C)
  • [species] β€” Any defined species
  • Host model variables

JSON Configuration

// Define chemical species
"CHEMICAL_SPECIES": {
    "list": {
        "1": "NO3_N",
        "2": "NH4_N",
        "3": "DOC",
        "4": "DO"
    },
    "BGC_GENERAL_MOBILE_SPECIES": ["NO3_N", "NH4_N", "DOC", "DO"]
}

// Define transformation
"CYCLING_FRAMEWORKS": {
    "NITROGEN_CYCLE": {
        "1": {
            "_name": "nitrification",
            "consumed": "NH4_N",
            "produced": "NO3_N",
            "kinetics": ["k_nitrif * NH4_N * (DO/(Km_DO+DO)) * 1.047^(T-20)", "mg-N/L/day"],
            "parameter_values": { "k_nitrif": 0.1, "Km_DO": 0.5 }
        }
    }
}
                
No recompilation needed! Change reactions by editing JSON files.
02

Thermodynamic Extension

Why Thermodynamics?

Traditional Kinetic Approach

Uses inhibition terms (Ki) to suppress reactions:

Finhibit = Ki / (Ki + [Oβ‚‚])

⚠️ Empirical β€” requires calibration of Ki

Nature's Reality

Microbes use electron acceptors in order of energy yield:

  1. Oβ‚‚ β†’ most energy
  2. NO₃⁻
  3. Mn(IV), Fe(III)
  4. SO₄²⁻
  5. COβ‚‚ β†’ least energy

βœ“ The "redox ladder" β€” thermodynamically controlled

Solution: Add a thermodynamic potential factor (FT) that automatically enforces the redox sequence

The FT Factor

Jin & Bethke (2003, 2007)
FT = 1 βˆ’ exp( βˆ’(Ξ”Gavail βˆ’ Ξ”Gmin) / (Ο‡ Γ— R Γ— T) )
SymbolDescriptionValue
Ξ”GavailFree energy from reactionVaries by reaction
Ξ”GminMin. for ATP synthesis~45 kJ/mol
Ο‡Stoichiometric number1-4
RGas constant0.008314 kJ/molΒ·K

FT Behavior

  • Ξ”G >> Ξ”Gmin β†’ FT β‰ˆ 1.0
  • Ξ”G β‰ˆ Ξ”Gmin β†’ FT β‰ˆ 0.5
  • Ξ”G < Ξ”Gmin β†’ FT β†’ 0

The Redox Ladder

FT automatically enforces electron acceptor sequence based on energy yield

Oβ‚‚ Aerobic respiration Ξ”GΒ° = βˆ’125 kJ/mol FT β‰ˆ 1.0
NO₃⁻ Denitrification Ξ”GΒ° = βˆ’119 kJ/mol FT β‰ˆ 1.0
Mn(IV) Manganese reduction Ξ”GΒ° = βˆ’95 kJ/mol FT β‰ˆ 1.0
Fe(III) Iron reduction Ξ”GΒ° = βˆ’50 kJ/mol FT β‰ˆ 0.64
SO₄²⁻ Sulfate reduction Ξ”GΒ° = βˆ’25 kJ/mol FT β†’ 0*
COβ‚‚ Methanogenesis Ξ”GΒ° = βˆ’20 kJ/mol FT β†’ 0*

* Requires concentration-dependent Ξ”G adjustment to proceed

Implementation

Simply append the FT term to your kinetic expression β€” no code changes!

// Standard kinetic expression:
"kinetics": ["k_denit * NO3_N * (DOC/(Km+DOC)) * (Ki/(Ki+DO))"]

// With thermodynamic constraint (add F_T term):
"kinetics": [
    "k_denit * NO3_N * (DOC/(Km+DOC)) * (Ki/(Ki+DO)) * (1 - exp(-((119-45)/(2*0.008314*(T+273)))))"
]

// F_T breakdown:
//   119 = Ξ”GΒ° for denitrification [kJ/mol]
//   45  = Ξ”G_min (ATP synthesis) [kJ/mol]
//   2   = Ο‡ (stoichiometric number)
//   0.008314 = R [kJ/molΒ·K]
//   T+273 = temperature in Kelvin
                
Advantage: Ξ”GΒ° values are known from literature β€” reduces calibration parameters!
03

PHREEQC

Equilibrium Geochemistry

A different paradigm: compute speciation based on thermodynamic equilibrium

Law of Mass Action
K = [C]c[D]d / [A]a[B]b
  • Automatic speciation β€” N β†’ NO₃⁻, NH₄⁺, Nβ‚‚...
  • Mineral reactions β€” precipitation/dissolution
  • pe-based redox β€” electron activity

What PHREEQC Computes

  • Ion speciation & complexation
  • Saturation indices (SI)
  • pH, pe, alkalinity
  • Gas-water equilibria
  • Mineral saturation states
Database: 100+ minerals, extensive thermodynamic data (USGS phreeqc.dat)

OpenWQ-PHREEQC Integration

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          Each Timestep                                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                        β”‚
β”‚  β”‚     OpenWQ      β”‚  Convert  β”‚    PhreeqcRM    β”‚                        β”‚
β”‚  β”‚  chemass [g]    │──────────▢│  conc [mol/kgw] β”‚                        β”‚
β”‚  β”‚  T, volume      β”‚   Units   β”‚  T, P, volume   β”‚                        β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β”‚
β”‚                                         β”‚                                 β”‚
β”‚                                         β–Ό                                 β”‚
β”‚                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                      β”‚
β”‚                              β”‚    RunCells()       β”‚                      β”‚
β”‚                              β”‚  β€’ Equilibrate      β”‚                      β”‚
β”‚                              β”‚  β€’ React            β”‚                      β”‚
β”‚                              β”‚  β€’ Speciate         β”‚                      β”‚
β”‚                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                      β”‚
β”‚                                       β”‚                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                        β”‚
β”‚  β”‚     OpenWQ      │◀──────────│    PhreeqcRM    β”‚                        β”‚
β”‚  β”‚ Ξ”mass = new-old β”‚  Convert  β”‚  updated conc   β”‚                        β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   Units   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    

PHREEQC Input (.pqi)

SOLUTION 1  Surface Water
    temp      20.0
    pH        7.5
    pe        12.0     # Redox (high=oxic)
    units     mg/L

    # Elements (NOT species!)
    N(5)      5.0      # Nitrate
    N(-3)     0.2      # Ammonium
    Ca        40.0
    C(4)      100 as HCO3

EQUILIBRIUM_PHASES 1
    O2(g)     -0.7  10.0
    Calcite   0.0   10.0
                        

Key Blocks

SOLUTIONInitial chemistry
EQUILIBRIUM_PHASESMinerals/gases
KINETICSUser kinetics (optional)
RATESRate expressions
Important: Use element names (Ca, N, S), not species (Ca²⁺, NO₃⁻). PHREEQC computes speciation!

Comparison

Feature BGC_FLEX (Kinetic) BGC_FLEX + FT PHREEQC
Approach User-defined kinetics Kinetics + Ξ”G constraint Thermodynamic equilibrium
Speciation Manual Manual Automatic
Minerals Not supported Not supported Full database
Redox Manual Ki terms Automatic via FT Automatic via pe
Parameters Many (calibrate) Fewer (Ξ”GΒ° known) Fewest (database)
Best for Watersheds, SWAT-style Sediment diagenesis Groundwater, AMD

When to Use Each Approach

BGC_FLEX (Kinetic)

  • Nutrient cycling in watersheds
  • SWAT, HYPE, INCA methods
  • Calibrating against obs.
  • Computational efficiency
  • Simple, transparent

Thermodynamic + FT

  • Sediment diagenesis
  • Multiple electron acceptors
  • Redox ladder enforcement
  • Research applications
  • Reduce calibration params

PHREEQC

  • Detailed speciation needed
  • Mineral reactions matter
  • Acid mine drainage
  • Carbonate chemistry
  • pH calculation critical

Available Templates

Individual Chemicals

  • Nitrogen, Phosphorus, Carbon
  • Dissolved oxygen
  • Phytoplankton/Algae
  • Plant uptake
  • Emerging contaminants
  • Groundwater age
  • Sediment diagenesis
  • Wetland/BMP
  • Tile drainage
  • pH/Alkalinity

Thermodynamic Templates

  • Aerobic respiration, nitrification
  • Denitrification, anammox
  • Fe/Mn/SOβ‚„ reduction
  • Methanogenesis
  • Full sediment diagenesis

Model Frameworks

  • SWAT β€” N & P soil
  • QUAL2E/2K β€” Stream WQ
  • HYPE β€” Nordic nutrients
  • WASP8 β€” Eutrophication

PHREEQC Templates

  • Major ions, N/P speciation
  • DO, Phyto, Plant uptake
  • Emerging contaminants
  • Groundwater age tracers
  • Sediment diagenesis
  • Wetland processing
  • Tile drainage
  • pH/Alkalinity

Summary

πŸ§ͺ BGC_FLEX

Flexible kinetic expressions for any reaction. JSON-based, no recompilation.

⚑ Thermodynamic

FT factor enforces redox ladder. Fewer parameters, more mechanistic.

βš—οΈ PHREEQC

Full equilibrium geochemistry. Automatic speciation and mineral reactions.

Choose the right tool for the job β€” all three approaches use the same OpenWQ framework

Thank You

Questions?