Run a 10 ML/d drinking-water plant: dose alum and chlorine, tune flocculation, schedule filter backwashes and keep every limit green. Click a filter to backwash it, a basin to desludge, a tag or a stage button for details.
Sliders are locked while a mission scripts the river.
Limits (simplified): filtered water 0.3 NTU (never above 1 NTU), chlorine residual 0.2 to 4 mg/L, finished pH 6.5 to 8.5, CT ratio at least 1, filter head loss under 2.5 m.
Alum chemistry. Al2(SO4)3·14H2O + 6 HCO3- → 2 Al(OH)3 + 6 CO2 + 3 SO42- + 14 H2O. Per mg/L of alum: 0.505 mg/L alkalinity (as CaCO3) consumed, 0.444 mg/L CO2 released, 0.262 mg/L Al(OH)3 solids. The pH comes from the Henderson-Hasselbalch relation pH = 6.35 + log10([HCO3-]/[CO2]); caustic soda converts CO2 back to bicarbonate.
Coagulation window. Efficiency = f(dose / optimum) x f(pH): the dose-response saturates and then restabilises above about twice the optimum; the pH factor is a Gaussian around pH 6.7 (the minimum-solubility region of Al(OH)3). The jar-test optimum grows as 7 + 1.5 sqrt(NTU) + 2.6 TOC mg/L (an empirical rule of thumb, not a plant standard).
Flocculation. Velocity gradient G = sqrt(P / (μ V)). Floc growth saturates with the Camp number: 1 - exp(-G t / 20 000); cold water grows flocs slower, and G above about 90 1/s breaks flocs.
Sedimentation. Overflow rate SOR = Q / A. Floc settling speeds are lognormal with a mean that scales as 1/μ(T) (Stokes) and rises with particle load. An ideal quiescent basin removes the share E[min(1, v / SOR)] of flocs, which has a closed form through the normal CDF; it is multiplied by the fraction of particles that were destabilised. Sludge volume = removed solids / 6 kg/m3, and a blanket above 0.5 m sheds turbidity.
Filtration. Iwasaki: dC/dz = -λ C with λ = λ0 (v/5.2)-0.5 (1 + 0.6 s)(1 - s2) x ripening, where s is the deposit fraction. Clean-bed head loss from Carman-Kozeny, h = h0 (1 + 14 s2). Ripening: λ is 45 % lower right after a backwash and recovers with a 15 min time constant. Filtered turbidity is flow-weighted over the filters in service.
Disinfection. Chlorine demand, then first-order decay (faster when warm and when organic carbon is high). Six cells in series (the serpentine tank): T10 = BF V / Q with BF from the gamma distribution (0.525 for six cells). Chick-Watson kill: log N/N0 = -λ(T) · efficacy(pH, T) · CT, with the HOCl fraction from pKa(T) = 3000/T - 10.0686 + 0.0253 T (Morris) and OCl- counted at 1/80 strength. The rate constant is calibrated to 3-log Giardia at CT = 100 mg·min/L (10 C, pH 7) with a 2.1x change per 10 C. Filtration earns credit (2.5 log when the combined effluent is at or below 0.3 NTU, 1 log below 1 NTU, otherwise none); disinfection must supply the rest of the 3-log target.
One lumped flocculation train and two identical basins; perfectly mixed cells for chlorine; no ammonia or chloramines, no THM chemistry, no Cryptosporidium or virus targets; alkalinity and pH from a closed carbonate system; the turbidity-to-solids factor is a fixed 2 mg/L per NTU; floc, filter and chlorine constants were tuned so typical textbook behaviour appears, not fitted to one plant. The 3-log credit scheme follows the idea of the US surface-water treatment rules, but this is an educational model, not a compliance or design tool, and is not affiliated with any utility or regulator. Real plants add many more safeguards (turbidimeters on every filter, filter-to-waste, redundant dosing).
Backdrop and equipment: modelled and rendered in Blender (Cycles). Dynamics, physics and interface: HTML Canvas 2D and JavaScript. The 3D cutaway twin runs the same model.