The water quality engine computes the numerical solution to the 1D advection-diffusion-reaction equation for the transport and transformation of a water quality constituent. This equation can be derived from first principles, including conservation of mass and volume (see for example, Fischer et al., 1979).

\frac{\partial C}{\partial t} + \frac{\partial (vC)}{\partial x} = \frac{\partial }{\partial x} \left( K \frac{\partial C}{\partial x} \right) + S

where

C is the concentration of the water quality constituent (mg/L),
t is time (s), 
x is the length dimension - longitudinally for reaches and vertically for reservoirs (m),
v is the water velocity (m/s),
K is the dispersion or diffusion coefficient (m2/s), and
S is the source-sink term (mg/L/s).

The first term on the left is the unsteady or time-derivative term. The second term on the left is the advective transport term, which quantifies changes in water quality as a result of movement by the mean flow of a water body. The first term on the right is the diffusive term, quantifying transport as a function of the concentration gradient. In 1D river models, the longitudinal spreading of material primarily derives from cross-channel velocity variation, and is referred to as dispersion. In 1D vertical reservoir models, non-advective mixing can be driven by a number of physical mechanisms (including wind, convection, and shear at internal interfaces - see Fischer et al., 1979 for details), and is typically referred to as (turbulent) diffusion. Methods for parameterizing these mixing mechanisms will be described in later sections. The source-sink (or reaction) term incorporates chemical reactions as well as inputs and withdrawals of a constituent that occur without the input of water (for example, aeration or heating of water as is passes through a penstock). 

A general first-order reaction term is represented as S = -kC, where k is the reaction rate (1/s). For transport of a conservative scalar, the source-sink term is identically zero. For water temperature, the source-sink term is 

S = \frac{q_{\textrm{net}}A}{V \rho \, C_p}

where

A is the surface area (m2), 
V is the water volume (m3), 
\rho is the water density (kg/m3), 
C_p is the specific heat of water (4179 J/kg/
°C), and
q_{\textrm{net}} 
is the net heat flux (Watts/m2).

The net heat flux term includes: shortwave solar radiation, longwave downwelling and back radiation, latent or evaporative heat flux, sensible or convective heat flux, and bed conduction (optional). Equations describing those heat fluxes are given in the Water Temperature Simulation Module section. Equations describing source-sink terms for nutrient transformations, algal growth, dissolved gases, and other non-temperature water quality constituents are given in the Nutrient Simulation Module I section.