Physics-informed MPC + foundation-model anomaly detection for industrial cooling towers. In operational use since 2025 as an advisory system at eight cooling towers across two Indian plants -- DCM Shriram Alkali and Atul Ltd (named with permission) -- where operators act on its water-chemistry risk indices, forecasts, and dosing recommendations. Autonomous closed-loop dosing is on the roadmap: TGF advises; it does not yet command dosing hardware.
Production status (advisory). TGF is in advisory production use since 2025 at eight cooling towers across two Indian plants — DCM Shriram Alkali and Atul Ltd (named with their permission). Plant teams run TGF on tower water data and act on its LSI/RSI risk indices, anomaly alerts, and forecast-informed dosing recommendations; a human authorizes every dose. TGF is not wired to dosing hardware — the closed-loop controller is validated in backtest only (5,614 historical water-analysis records from DCM Shriram Alkali), and autonomous actuation is on the roadmap. TGF depends on cooling-tower-chem for its water-chemistry indices.
- Where: eight industrial cooling towers across two Indian plants (DCM Shriram Alkali and Atul Ltd), named with the operators' permission.
- Since: 2025. TGF was developed against these plants' water-analysis data and open-sourced in 2026.
- Mode: advisory / decision support. Plant teams run TGF's analysis on tower water data and act on its outputs -- LSI/RSI scaling-corrosion risk assessment, anomaly alerts, and forecast-informed dosing recommendations. Humans stay in the loop for every dose.
- Boundary (stated plainly): TGF has not yet been connected to dosing hardware. The closed-loop controller exists and is validated in backtest below; wiring it to pumps on real towers is the roadmap, not the present.
India's cooling towers lose 2--5% of operational capacity annually to scaling, corrosion, and biofouling. Manual operators test water 2--3 times per day and react to problems after they appear, wasting 15--25% of chemicals through over-dosing. A single unplanned shutdown from scaling or corrosion costs $50K--$200K. The industry charges $50K--$200K/year for automation -- TGF targets $20K/year total cost.
By design, TGF ingests water parameters (pH and conductivity, plus temperature and ORP where instrumented) on a 5-minute loop, detects anomalies using a 385M-parameter foundation model, forecasts parameter trajectories 24 hours ahead, and optimizes chemical doses using Model Predictive Control -- all with a 5-tier safety layer that enforces hard limits by clamping. Validation to date uses historical lab water-analysis records (see the backtest results below), not live 5-minute telemetry; the released datasets carry pH and conductivity but not temperature or ORP.
graph TD
A[Sensors: pH, Conductivity, Temp, ORP] --> B[Data Ingestion Pipeline]
B --> C[5-Layer Anomaly Detection]
C --> D{Anomaly?}
D -->|Yes| E[Alert Manager]
D -->|No| F[Dosing Controller]
C --> F
F --> G[Physics Engine: LSI / RSI / CoC]
F --> H[Chronos-T5 Forecaster: 24h Ahead]
F --> I[MPC Optimizer: L-BFGS-B]
F --> J[Chemical Tracker: 7 Chemicals]
G --> I
H --> I
I --> K[5-Tier Safety Layer]
K --> L[Dosing Commands]
L --> M[SQLite: 7 Tables]
M --> N[FastAPI Dashboard: 18 Endpoints]
The advisory outputs are in production use (see above). The closed-loop controller metrics below are a different, stricter claim, and come from replaying 5,614 historical water-analysis records through the controller in simulation -- not from autonomous operation. The records are periodic lab reports (labelled roughly 2012--2025, with gaps; per-row timestamps were not preserved in the released CSV) consolidated across multiple cooling towers at DCM Shriram Alkali plants, used with the operator's permission. The manual-dosing baseline is modeled, not measured, and TGF has not commanded dosing on physical equipment.
| Metric (backtest) | Value |
|---|---|
| Cycles in optimal LSI range | 86.2% |
| Critical-risk cycles | 0% |
| Preemptive dosing rate | 78% |
| Modeled chemical savings vs manual baseline | 16.7% |
| Constraint violations (dose clamps exceeded) | 0 / 5,614 |
L-BFGS-B with 24-step receding horizon (2 hours at 5-minute intervals). 10-component cost function balancing chemical cost, scaling/corrosion/biofouling risk, Chronos-T5 forecast penalties, CPCB discharge compliance, and rate smoothing. Differential evolution fallback for non-convex cases. Only the first step is executed, then re-optimized next cycle.
385M-parameter pre-trained time-series foundation model (ICML 2024). Reconstruction-based anomaly detection with RevIN normalization and adaptive POT (Peaks Over Threshold) thresholding. Validated against two alternatives:
| Model | Type | Params | Val Loss | Status |
|---|---|---|---|---|
| MOMENT | Foundation (pre-trained) | 385M | 0.0069 | Selected |
| TransNAS-TSAD | NAS + Transformer | ~2M | 0.0145 | Evaluated |
| VTT | Variable Temporal Transformer | ~500K | 0.0203 | Evaluated |
These are internal validation figures; the trained checkpoint and raw artifacts are not yet published, so treat them as indicative rather than independently reproducible.
Detection uses 5 layers: range check, z-score, rate-of-change, cross-parameter correlation, and MOMENT reconstruction error.
Amazon's zero-shot probabilistic forecasting model. Returns p10/p50/p90 quantiles for a 24-hour horizon. Enables preemptive dosing -- treating problems before they manifest. When Chronos-T5 predicts pH will exceed 8.5 in 6 hours, the MPC begins scale inhibitor dosing immediately at a lower rate, rather than reacting later at a higher rate.
Granger-causality state machine detecting failure chains: corrosion → particles → biofilm → scale. Tests causal links between iron→turbidity, turbidity→free chlorine, and free chlorine→hardness. Left-to-right state transitions only (no backtracking).
Langelier Saturation Index (LSI) and Ryznar Stability Index (RSI) from classical water chemistry equations. Cycles of Concentration (CoC) estimated from conductivity. Virtual sensor provides physics-informed ML hybrid estimates of hardness and alkalinity when lab data is unavailable.
The water-chemistry index math has been extracted into a standalone, dependency-free library — cooling-tower-chem (LSI, RSI, Puckorius PSI, Larson-Skold, cooling-tower water balance) — which TGF now uses as its single source of truth for these calculations.
5-tier defense-in-depth:
- Sensor fault detection -- impossible values trigger PID fallback
- Hard limits -- absolute max/min for every chemical dose
- Rate limiting -- max 20% change per 5-minute cycle
- PID backup -- classical controllers with anti-windup saturation
- Emergency stop -- halt all dosing on multiple sensor failures
Mass balance for 7 Aquatech chemicals with Arrhenius temperature-dependent decay rates, Bayesian confidence scoring, and calibration from ORP sensor feedback and weekly lab tests.
- Works with ~5K samples -- RL needs millions of interactions
- Hard safety constraints -- enforced by clamping, not soft penalties
- Explainable -- "dosing because LSI forecast at +1.8 in 6 hours"
- Faster to a working prototype -- RL needs months of simulation-environment development
- No constraint violations in backtest during exploration
With ~5,600 historical water-analysis records and hard safety requirements for eventual industrial deployment, MPC was the principled engineering choice.
# Install dependencies
pip install -r requirements.txt
# Run simulation (headless, 100 cycles)
python -m tgf_dosing.main --data data/Parameters_5K.csv --cycles 100 --no-api --speed 0
# Run with dashboard (open http://localhost:8000)
python -m tgf_dosing.main --data data/Parameters_5K.csv --cycles 500 --speed 0
# Run with MOMENT anomaly detection
python -m tgf_dosing.main --data data/Parameters_5K.csv --moment-checkpoint checkpoints/moment_model.pkl
# Run tests
pytest tests/ -vtgf_dosing/ # Production package (~10K LOC)
config/ # Tower specs, 7 chemical definitions
core/ # Physics engine, MPC, safety layer, cascade detection
infrastructure/ # Data pipeline, anomaly detection, API, persistence
models/ # MOMENT wrapper, online detection
validation/ # Walk-forward backtester
tests/ # 10 test files (pytest)
data/ # Curated datasets from real Indian cooling towers
research/ # Model experiments (MOMENT, TransNAS, VTT, Tempura)
docs/ # Architecture, API reference, hardware guide
scripts/ # Model download utility
- Edge deployment on Raspberry Pi 4 ($12K hardware per tower)
- ONNX export for MOMENT inference at the edge
- Multi-tower fleet management
- MOMENT: Goswami et al., "MOMENT: A Family of Open Time-series Foundation Models", ICML 2024
- Chronos: Ansari et al., "Chronos: Learning the Language of Time Series", Amazon, 2024
- LSI: Langelier, W.F., "The Analytical Control of Anti-Corrosion Water Treatment", 1936
- RSI: Ryznar, J.W., "A New Index for Determining Amount of Calcium Carbonate Scale Formed by a Water", 1944
Apache 2.0 -- see LICENSE.