SciEvidence Papers

PAPERCommunity contribution

  • Article
  • Environmental Engineering
  • Environmental Science & Technology

From Correlation to Causation: A Hybrid Physics-Data Approach with Double Machine Learning for Interpretable Phosphorus Regulation in Water Systems

Mengyao An, Zhaocai Wang, Ning Deng, Fuping Jiang, Jiachen Kong

Environmental Science & Technology10.1021/acs.est.6c09855View paper

Abstract

Artificial intelligence (AI) offers transformative potential for wastewater treatment plant (WWTP) optimization, yet black-box models often suffer from physical inconsistency and poor interpretability, causing overprediction and operational risks. This study develops a hybrid physics-data-driven framework (Phys-VMD-BiTCN-iTransformer) to enhance reliability of effluent total phosphorus (TP) prediction and control. By leveraging Variational Mode Decomposition (VMD) and Bidirectional Temporal Convolutional Network (BiTCN) for spatiotemporal feature extraction, and improved Transformer (iTransformer) for long-term dependency modeling, the framework integrates operational data with seven mechanistic features derived from ASM2d and physical laws. To transition from correlation to causality, a Double Machine Learning (DML) framework was implemented. Causal inference identified Aeration Tank 1 Dissolved Oxygen (AT1 DO) and Hydrolysis Tank 1 Oxidation–Reduction Potential (HT1 ORP) as primary drivers of effluent TP fluctuations. Based on these insights, an 8-tier staged DO adjustment strategy was developed; scenario analysis showed the effluent TP compliance rate increased from 36.1% to 58.7%, while reducing exceedance risk and unnecessary energy and chemical costs. The framework bridges deep-learning architectures with practical engineering logic. By providing interpretable causal pathways and a reliable control coefficient (K = 0.15), this research offers a scalable solution for intelligent, sustainable water systems.

1. Introduction

Phosphorus is a key factor causing eutrophication in aquatic ecosystems. (2, 3) Excessive discharge leads to algal blooms, dissolved oxygen depletion, and other ecological risks, threatening water environmental and supply safety. (9, 19) Wastewater treatment plants (WWTPs) are critical infrastructures for watershed phosphorus control. Accurate prediction and control of effluent total phosphorus (TP) are essential for improving water quality. (39) Mainstream processes such as anaerobic-anoxic-oxic (A2/O) and oxidation ditch adopt the coupled strategy of “biological phosphorus removal as the core, chemical phosphorus removal as the guarantee, and physical separation as the contingency.” These processes involve complex mechanisms including polyphosphate-accumulating organism metabolism, chemical precipitation, and solid–liquid separation. (55−57) Affected by influent fluctuations, operating parameters, and microbial community dynamics, effluent TP shows strong nonlinearity, nonstationarity, and multiscale fluctuation characteristics. (33−35) Therefore, high-precision TP time-series prediction can support process regulation and reagent optimization, helping control the risk of TP exceedance. This approach has important engineering value for ensuring water environmental safety and improving WWTP operation efficiency and economy. (36)

Effluent TP prediction has been addressed using mechanistic, statistical, machine-learning, and deep-learning models. Mechanistic approaches, such as Activated Sludge Models (ASM2d and ASM3), quantify phosphorus transformation through physicochemical and biological kinetics and offer strong interpretability under stable conditions. (12−14, 21, 37) However, their dependence on accurate parameters and limited ability to capture nonlinear responses to influent shocks and microbial shifts constrain practical adaptability and predictive performance. (47−49)

Advances in WWTP online monitoring have enabled data-driven models to learn nonlinear TP dynamics directly from large-scale historical time-series data without explicitly defining complex process equations. (45) Data-driven approaches include statistical, machine-learning, and deep-learning models. Statistical methods, such as autoregressive integrated moving average (ARIMA) (22) and exponential smoothing, (27) are simple and computationally efficient but perform poorly on nonstationary TP series with abrupt fluctuations. (25, 42) Machine-learning models such as random forest (RF), (35) extreme gradient boosting (XGBoost), (9) and support vector machine (SVM) (25) can perform nonlinear mappings and integrate multidimensional features. (11) For example, Chen et al. (4) integrated process simulation, machine learning, and multiobjective optimization for total nitrogen prediction and risk diagnosis, while Wang et al. (34) showed that machine-learning models outperformed an activated sludge model in effluent total nitrogen prediction. Despite their strong capabilities for nonlinear fitting and multifeature integration, machine learning models often fall short in capturing long- and short-term temporal dependencies, making it difficult to fully extract TP dynamic rules. (28, 58, 59) Deep-learning models, including long short-term memory networks (LSTM), temporal convolutional networks (TCN), and Transformers, (19, 38, 43) have become mainstream due to their strong feature-learning capability and ability to capture complex temporal dependencies in time-series data. For instance, Zhang et al. (50) proposed an attention-enhanced FTA-LSTM model to handle influent perturbation events and improve interpretability. Yin et al. (40) constructed a P-ED-LSTM probabilistic model to enhance total nitrogen prediction and early warning performance under shock loading. Li et al. (22) introduced an interpretable TCANRF model to accurately predict influent indicators and analyze temporal association patterns. Nevertheless, these models remain predominantly data-driven and insufficiently integrate WWTP process mechanisms, leaving several key challenges unresolved. (44−46)

Current WWTP effluent TP prediction relies largely on data-driven models that learn from historical data (6) but rarely incorporate coupled biological, chemical, and physical phosphorus-removal mechanisms, resulting in two major limitations: (1) Without process constraints, models may overfit noise and deviate under influent shocks or dosing changes; (22−26) (2) limited physical interpretability weakens mechanistic understanding, engineering credibility, and cross-plant transferability. (4, 16) Mechanistic models are interpretable but struggle with nonlinear, multiprocess dynamics, whereas data-driven models fit nonlinearities well but may generalize poorly and violate engineering logic. (8−10, 50) To address these limitations, we propose a “mechanistic feature embedding–process-constraint guidance” framework that integrates process knowledge with data-driven learning. Based on Activated Sludge Model No. 2d (ASM2d), (13, 16) chemical precipitation kinetics and Stokes separation law, mechanistic features such as anaerobic phosphorus release limiting factors and aerobic phosphorus uptake rates are extracted and fused with monitoring data. Meanwhile, a process-constrained loss function incorporating mass conservation, biological phosphorus-removal dominance, and removal-efficiency limits ensures physically consistent predictions.

Although deep-learning models can integrate heterogeneous TP data, conventional networks struggle with complex temporal dynamics, motivating hybrid architectures for improved prediction. (46) Gan et al. (10) developed the STL-mTCNA model, which achieves superior performance in long-term inflow forecasting. However, most existing fusion models only focus on a single temporal scale and cannot simultaneously capture TP long-term trends and short-term abrupt fluctuations under inflow shocks and dosing adjustments. In addition, single models easily suffer from gradient vanishing in long-sequence prediction, restricting their ability to learn long-range temporal dependencies. (37) The attention-enhanced iTransformer effectively captures TP long-term evolutionary patterns, (20−23) while BiTCN can sensitively extract short-term transient fluctuation features via bidirectional dilated convolution and residual connections. (15, 23) Therefore, this study constructs a BiTCN-iTransformer hybrid model to integrate their complementary strengths. The fused model improves effluent TP prediction accuracy and compensates for the inherent deficiencies of single-model structures.

Moreover, effluent TP is a complex nonlinear time series shaped by multiple interacting factors, with trends, abrupt fluctuations, and background noise. (41) The superposition of multiple signals blurs the underlying patterns of the original series, rendering mutation features less distinct; consequently, prediction based solely on deep learning cannot effectively mine informative signals, leading to limited performance. (60−62) In contrast, sequence decomposition can separate complex TP series into interpretable components, suppress noise, and provide cleaner model inputs. (48−50) Common methods include wavelet transform (WT), (26) empirical mode decomposition (EMD), (45) and variational mode decomposition (VMD). (7) Through variational optimization, VMD is particularly effective for nonlinear, nonstationary water-quality series and multiscale feature separation, making it well suited to accurate TP prediction.

Overall, existing WWTP effluent TP prediction has three main limitations: (1) data-driven models lack mechanistic constraints, making them prone to noise overfitting, physically inconsistent predictions, and limited transferability; (2) weak integration of sequence decomposition and deep learning reduces robustness to influent shocks and sensor noise; and (3) single-network architectures cannot jointly capture long-term trends and short-term fluctuations. Moreover, most studies emphasize predictive accuracy while providing limited causal insight, operational interpretability, and actionable control strategies.

To address these gaps, we propose a Phys-VMD-BiTCN-iTransformer framework integrating mechanistic constraints, causal inference, and SHAP-based (Shapley Additive Explanations) interpretation for accurate and actionable effluent TP prediction. Mechanistic features and a process-constrained loss embed phosphorus-removal knowledge, while VMD and the BiTCN-iTransformer jointly capture short- and long-term dynamics. Causal analysis and SHAP identify key drivers and quantify their contributions, and a hierarchical control mechanism converts predictions into operational strategies. Validation using full-scale WWTP data demonstrates the framework’s predictive performance, interpretability, and engineering applicability.

The key contributions of this work are as follows:

Develop a dual-dimensional feature system combining nine monitoring variables with seven mechanistic features derived from ASM2d, chemical precipitation, and Stokes’ law.

Propose a mechanistic feature–VMD–heterogeneous network architecture in which BiTCN captures short-term fluctuations and iTransformer extracts long-term dependencies.

Construct a composite loss function integrating numerical error with mass conservation, removal-efficiency limits, and minimum biological phosphorus-removal contribution constraints.

Combine causal inference with SHAP to identify key TP drivers and quantify their effects, advancing prediction from correlation analysis to causal tracing.

Establish a prediction–control closed loop by translating causal findings into an eight-level stepwise DO regulation strategy (K = 0.15).

2. Material and Methods

2.1. Study Area

This study investigates a representative municipal WWTP using the A2O process. Its effluent must meet the GB 18918–2002 Class I-A TP limit of 0.5 mg/L. The treatment train includes anaerobic, anoxic, and aerobic bioreactors, chemical phosphorus dosing, and secondary clarification. An online monitoring system records water-quality, operational, and sludge variables hourly across multiple seasons and hydraulic conditions, providing a comprehensive data set for model development.

Figure 1 presents a 3D waterfall plot of the effluent TP time series from the plant. Combined with the ADF stationarity test results (Table S8), the effluent TP series exhibits nonlinear and nonstationary characteristics, together with multiscale fluctuations. (63−65) TP concentrations varied between 0 and 0.6 mg/L, exhibiting long-term trends, abrupt fluctuations, and weak noise. These dynamics reflect coupled biological, chemical, and physical phosphorus-removal processes, supporting temporal decomposition and multiscale feature extraction.

Figure 1. 3D waterfall chart of effluent TP.
Figure 1. 3D waterfall chart of effluent TP.

2.2. Modeling Framework

Table S9 lists all model inputs, including raw monitoring variables and mechanism-derived features. Figure 2 presents the proposed Phys-VMD-BiTCN-iTransformer, a physics-enhanced deep ensemble framework for accurate effluent total phosphorus (TP) prediction and operational control in wastewater treatment plants, integrating process constraints, time-series decomposition, heterogeneous deep learning, interpretability, and causal intervention. After plant-wide water-quality and process data preprocessing, (A) time-frequency filtering and decomposition separate the original series into modal components and a residual, which are classified by their correlations with auxiliary process variables. Feature components, significantly correlated with auxiliary variables, represent cross-variable coupling; self-components, with weaker correlations, mainly capture the intrinsic temporal dependence of effluent TP. Their separate modeling decouples exogenous coupling from endogenous dynamics and supports dual-branch feature extraction by iTransformer and BiTCN. (B) A two-dimensional feature system combining process monitoring and mechanism derivation is then established. Seven mechanism-derived features are extracted from ASM2d biological phosphorus-removal mechanisms, chemical precipitation kinetics, and Stokes settling theory to quantify the coupled dynamics of TP removal, while (C) nine core monitoring variables are retained as model inputs. Their explicit physical meanings help reduce the mechanistic distortion of purely data-driven models. A heterogeneous neural network is subsequently constructed. (D) Feature components, external variables, and mechanistic parameters are processed by iTransformer using a weighted loss that incorporates mass conservation, plausible removal efficiency, and minimum biological phosphorus-removal contribution. (E) Self-components, historical sequences, and mechanistic parameters are processed by BiTCN to capture complementary short- and long-term dependencies. After training, (F) the model outputs TP predictions. (G) SHAP quantifies feature contributions, while (H) double machine learning identifies key controllable process variables and their causal effects on effluent TP. Finally, (I) a staged regulation strategy targets the identified variable, forming a closed loop of “high-accuracy prediction–causal attribution–targeted regulation–performance validation” for precise TP management.

Figure 2. Modeling framework.
Figure 2. Modeling framework.

2.2.1. Data Preprocessing

WWTP monitoring data may contain missing values and anomalies due to sensor drift, equipment failure, transmission interruptions, and process disturbances. (1, 32) Missing values were imputed using nearest-neighbor interpolation to preserve temporal continuity. Additionally, to preserve temporal causality, the data set was strictly divided in chronological order according to the hourly monitoring records using an 8:1:1 ratio into training, validation, and test sets, which were used for model fitting, hyperparameter tuning, and model evaluation, respectively. To prevent data leakage, all VMD parameters were fitted and decomposition performed using only the training set; the validation and test sets were decomposed using the fixed parameters. Finally, all features were min–max normalized using parameters derived exclusively from the training set to prevent data leakage. Detailed formulas are provided in Supporting Information 1.1.

2.2.2. Extraction and Construction of Mechanistic Features

To overcome the limited ability of purely data-driven models to represent coupled biological, chemical, and physical phosphorus-removal processes, we develop a mechanistic-feature-enhanced deep-learning framework for TP prediction. Seven structured features are derived from the ASM2d, chemical precipitation kinetics, and Stokes’ law using key variables, including oxidation–reduction potential (ORP), dissolved oxygen (DO), influent chemical oxygen demand (COD), chemical dosage, and secondary-clarifier turbidity. These features characterize carbon-source availability, biological transformation, chemical removal efficiency, physical separation, and load balance, thereby improving physical consistency and better reflecting actual WWTP operation. Detailed definitions are provided in Supporting Information 5. However, continuous data on active metal-ion concentration and the metal-to-phosphorus stoichiometric ratio were unavailable, preventing calculation of the chemical phosphorus-removal-efficiency coefficient (ηchem). It was therefore excluded, leaving seven mechanism-derived features for modeling. To quantify the impact of ASM2d kinetic-parameter uncertainty on effluent TP predictions, Latin hypercube sampling and Monte Carlo simulation were combined for sensitivity analysis. The results in Supporting Information 9 confirm the model’s robustness to variations in standard ASM2d parameters.

Classical Stokes’ law assumes dilute, discrete spherical particles and is not directly applicable to activated sludge. Secondary-clarifier sludge forms irregular flocs undergoing hindered settling with particle interactions. We therefore used a modified Stokes equation incorporating floc-shape and suspension-concentration corrections. These coefficients were calibrated against long-term measurements of total suspended solids (TSS) and sludge-settling measurements to ensure that the separation feature ηsep reflects actual plant conditions.

2.2.3. Design of Composite Loss Function with Mechanistic Constraints

Conventional TP prediction models commonly use mean squared error (MSE), which measures numerical deviations but ignores biological–chemical–physical removal mechanisms and operational constraints. This may produce predictions inconsistent with engineering practice. We therefore incorporate mass conservation, removal-efficiency plausibility, and ASM2d-based biological phosphorus-removal priors into the loss function, guiding the iTransformer toward physically consistent learning while preserving its long-range temporal modeling capability.

2.2.3.1. Base Value Loss

MSE is employed to quantify the baseline discrepancy between predicted TP values and the true values, with its expression given by

Lbase=MSE=1N∑i=1N(yi−yi^)2

(1)

where y(t) and y^(t) denote the observed and predicted TP values at time t, respectively, and N denotes the data sample size.

2.2.3.2. Mass Conservation Constraint

Based on the ASM2d-based biological phosphorus removal mechanism, the effluent TP concentration should not exceed the influent TP concentration. Additionally, acknowledging sensor measurement error and process fluctuations encountered in industrial settings, ϵ is introduced as a tolerance coefficient to accommodate practical engineering conditions.

Lmass=softplus(TPout^−TPin×(1+ϵ))

(2)

The softplus function, softplus(x) = ln (1 + ex), is employed as a smooth penalty function to prevent gradient vanishing caused by hard truncation; TPout and TPin denote the TP concentrations at the effluent and influent, respectively; The tolerance coefficient ϵ was set to 0.08 based on historical monitoring data, for which the 95th percentile of the positive relative deviation between effluent and influent TP was approximately 7.8%, thereby avoiding excessive penalties for minor deviations caused by measurement uncertainty and short-term process fluctuations. (66, 67)

2.2.3.3. Removal Efficiency Feasibility Constraint

Based on operational data from A2O/conventional biological phosphorus removal processes, the TP removal efficiency should not be excessively low or high and should lie within the interval [0.05, 0.98], with penalties applied if it falls outside this range. Its mathematical expression is

Leff=softplus(0.05−ηTP)+softplus(ηTP−0.98)

(3)

where ηTP=TPin−TPoutTPin denotes the total phosphorus removal efficiency.

2.2.3.4. Minimum Biological Phosphorus-Removal Contribution Constraint Loss

Based on the ASM2d model, biological phosphorus removal is the core mechanism for TP removal. In industrial practice, when the carbon source is abundant (fVFA ≥ 1), PAOs exhibit an excess phosphorus uptake efficiency above 60%; consequently, under carbon-replete conditions, the overall TP removal efficiency must exceed 60%. When the carbon source is insufficient (fVFA < 1), biological phosphorus removal is inhibited, and this constraint is automatically deactivated to avoid excessive penalties that are not representative of actual process conditions. Its mathematical expression is

Lbio={0,fVFA<1softplus(0.6−ηTP),fVFA≥1

(4)

2.2.3.5. Composite Loss Function

Weighted fusion of three types of constraint losses according to their physical significance:

Lphys=ω1·Lmass+ω2·Leff+ω3·Lbio

(5)

The optimal weights ω1, ω2, and ω3 were set to 0.60, 0.25, and 0.15 through grid search, consistent with A2/O phosphorus-removal mechanisms and plant-level constraint priorities. Mass conservation is a fundamental physical law and therefore received the highest weight as a strong constraint. The TP-removal-rate range represents a routine operational boundary and was assigned an intermediate weight. The minimum biological phosphorus-removal contribution applies only under sufficient carbon availability and was therefore given the lowest weight.

Finally, the baseline numerical loss and the mechanistic-constraint loss are combined via weighted fusion to yield the final composite loss function

Ltotal=Lbase+λ·Lphys

(6)

where λ balances numerical fitting accuracy against mechanistic consistency. Comparative tests identified (λ = 0.15) as optimal: larger values overconstrain model fitting, whereas smaller values weaken mechanistic correction. The grid-search strategy is detailed in Supporting Information 16.

To assess robustness to mechanistic-constraint weights, ω1, ω2, and ω3were perturbed by ±20% around their optimal values while fixing λ = 0.15 (Table S6). The maximum absolute changes in RMSE and R2 were only 0.0022 and 0.0098, respectively, with R2 > 0.965 in all cases, indicating no substantial performance degradation and good framework robustness.

2.2.4. VMD

VMD is an adaptive, nonrecursive method that decomposes a time series into multiple intrinsic mode functions (IMFs) by solving a constrained variational problem. Frequency-domain mode separation enables multiscale component extraction while reducing mode mixing. (30) VMD thus separates trend, fluctuation, and noise components in water-quality series, providing cleaner inputs for downstream models. The complete iterative procedure is provided in Supporting Information 1.2.

2.2.5. BiTCN

BiTCN combines bidirectional processing with causal dilated convolutions for time-series modeling. Stacked dilated convolutions enlarge the receptive field, enabling extraction of short-term water-quality fluctuations (25, 49) and long-range temporal dependencies while alleviating vanishing gradients. This structure is therefore suitable for nonstationary and highly nonlinear TP series. BiTCN consists of an input layer, bidirectional residual blocks, a fully connected layer, and a regression layer; key equations are provided in Supporting Information 1.3.

2.2.6. iTransformer

In multivariate time-series forecasting, conventional Transformer models face two key limitations: (1) insufficient modeling of cross-variable dependencies, restricting their applicability to multifactor systems such as water-quality prediction; and (2) quadratic computational complexity (O(n2)) of self-attention, leading to inefficiency in long-sequence modeling. (23) To address these issues, this study adopts iTransformer, which introduces a dimension-reconstruction mechanism that treats each variable’s full temporal trajectory as an independent unit. This enables decoupled learning of intervariable features and temporal dynamics while reducing computational cost. The model adopts an encoder-only architecture, with its core innovation lying in the dimension-reconstruction module; implementation details are provided in Supporting Information 1.4.

2.2.7. Evaluation Metrics

Model performance was evaluated using five metrics: Root Mean Square Error (RMSE), Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), Coefficient of Determination (R2), and Relative Prediction Deviation (RPD). Lower RMSE, MAE, and MAPE indicate higher accuracy, whereas R2 values closer to 1 and larger RPD values indicate better fit, stability, and predictive reliability. Detailed definitions and formulas are provided in Supporting Information 1.5.

2.3. Model Efficiency and Engineering Deployment

The computational cost of Phys-VMD-BiTCN-iTransformer mainly arises from VMD decomposition and the deep-learning backbone. The iTransformer uses inverted attention with complexity linear in sequence length, while BiTCN retains linear complexity through causal dilated convolutions. VMD is performed only during offline preprocessing and introduces no online inference delay. All experiments were conducted on a workstation with an Intel Core i7–13700H CPU (2.40 GHz), an NVIDIA GeForce RTX 4060 Laptop GPU (8 GB VRAM), and 16 GB RAM. Full single-site training required approximately 30 min, and single-sample inference took less than 0.5 s. As shown in Table S7, VMD increased training time relative to BiTCN and iTransformer baselines, but prediction required no repeated decomposition, yielding comparable inference speed. The proposed model showed only slightly higher latency than iTransformer while achieving substantially better accuracy, providing a practical trade-off for engineering deployment, particularly in accuracy-critical environmental monitoring.

3. Results

3.1. Feature Selection

This study compiled 35 monitoring and derived variables related to phosphorus removal, including water-quality indicators from anaerobic, anoxic, and aerobic tanks, operational parameters, secondary-clarifier separation indicators, and seven mechanistically derived features. Detailed definitions are provided in Table S1. The maximal information coefficient (MIC) was first used to assess associations between each factor and effluent TP (Table S10), together with cross-correlation analysis (Figure 3). Variables with weak linear correlation but high MIC were retained as potential nonlinear drivers, whereas variables low in both metrics were removed. Overall associations were weak, indicating that phosphorus removal results from nonlinear coupling among biological removal, chemical precipitation, and physical separation, jointly driven by carbon supply, microbial metabolism, and chemical reactions. (69) Therefore, seven mechanism-derived features based on ASM2d, precipitation kinetics, and Stokes’ law were added. The final input comprised nine process variables and seven mechanism-derived features; their MIC values with effluent TP are listed in Table S11.

Figure 3. Cross-correlation mapping.
Figure 3. Cross-correlation mapping.

3.2. Parameter Optimization of the Model

This study uses grid search to optimize the parameters of the VMD-BiTCN-iTransformer hybrid model, with R2 and RMSE on the validation set as evaluation metrics to select the optimal configuration. Based on the architectural characteristics of the component modules, the temporal dynamics of influent TP at the wastewater treatment plant, and established general algorithmic practice, the baseline parameters are fixed, while appropriate search ranges are defined for the core hyperparameters: For the VMD module, Kϵ [3, 15] and αϵ[1000,5000]; BiTCN module, Nfilters ϵ [32, 64, 128], Learning_rateϵ [1e – 4, 5e – 4, 1e – 3 ], L2_regularizationϵ [1e – 5, 1e – 4, 1e – 3]; iTransformer module, dmodel ϵ [64, 128, 256], nheads ϵ [2, 4, 8], nencoder ϵ [2, 3, 4]. Following grid-search validation, the optimal parameter combination for each module is presented in Table 1, and this configuration achieves the best balance between validation-set TP prediction performance and model generalization. (70−717273747576)

Table 1. Optimal Parameters of Each Module

modelparameteroptimal value
VMDK10
α1000
BiTCNNfilters64
Learning_rate1e-3
L2_regularization1e-3
iTransformerdmodel64
nheads8
nencoder2

3.3. Feature and Self-Term Screening

The raw effluent TP series contains multiscale fluctuations whose positive and negative correlations may cancel, yielding a maximum correlation of only 0.34 with monitored variables. VMD was therefore used to decouple the TP series into single-scale intrinsic mode functions (IMFs) before correlation analysis. Following correlation-classification criteria used in related water-quality forecasting studies (5, 68) and considering the plant’s marked variations in influent load, aeration, and chemical dosage, |r| ≥ 0.6 was adopted as an empirical threshold for strong synchronous association, reducing interference from weakly correlated modes. Only IMF1 met this criterion with external process variables and was classified as a feature component, indicating dominant external process control. The remaining IMFs and residual were treated as self-components, reflecting the intrinsic dynamics of phosphorus removal. Detailed correlations are listed in Table S2.

The external inputs to iTransformer were screened in two steps. First, variables were preliminarily selected using the |r| ≥ 0.6threshold reported in Table S2. Second, each variable was verified against ASM2d kinetics, chemical precipitation, and Stokes settling theory; indicators lacking a plausible causal link to phosphorus transformation were treated as spurious correlations and excluded. For example, sludge concentration in Secondary Clarifier 1 had a correlation coefficient of 0.6481, satisfying the quantitative criterion. Biologically, it determines the inventory of polyphosphate-accumulating organisms in return sludge and thereby affects the balance between anaerobic phosphorus release and aerobic phosphorus uptake, ultimately influencing long-term biological phosphorus-removal efficiency. Physically, sludge concentration governs floc settling performance; imbalance weakens the retention of phosphorus-bearing microflocs and increases particulate phosphorus in the effluent. Because it exhibited both robust statistical association and a complete mechanistic basis, it was retained as an external model input.

3.4. Prediction Results of Effluent TP Concentration

This study employs the Phys-VMD-BiTCN-iTransformer hybrid model, using nine core process-monitoring features and seven mechanistic-structural features as inputs to predict effluent TP concentration at a wastewater treatment plant on the test set. To benchmark predictive performance, 17 additional mainstream deep-learning models were selected as baselines; predictions for all models are shown in Figure 4, with predictive accuracy summarized in Table 2 and comparisons of evaluation metrics presented in Figure 5, while scatter plots for selected models appear in Figure 6.

Figure 4. Comparison chart of predictions by each model.
Figure 4. Comparison chart of predictions by each model.
Figure 5. (a–d) Evaluation metrics radar chart.
Figure 5. (a–d) Evaluation metrics radar chart.
Figure 6. (a–i) Scatter plot of predictions from some models.
Figure 6. (a–i) Scatter plot of predictions from some models.

Table 2. Comparison of Prediction Results across Different Models

modelRMSEMAER2MAPERPD
BiTCN0.03220.02620.82590.82682.6229
iTransformer0.02740.02300.87380.49322.8203
BiTCN-BiGRU-AM0.02890.02350.86060.78632.6971
VMD-BiTCN-BiGRU-AM0.02490.02030.89590.68933.1046
CEEMDAN-BiTCN-BiGRU-AM0.02580.02080.88880.49323.2015
BiTCN-BiLSTM-AM0.03020.02500.84700.80842.5582
VMD-BiTCN-BiLSTM-AM0.02780.02300.87060.51642.8854
CEEMDAN-BiTCN-BiLSTM-AM0.02960.02470.85300.73012.6772
BiTCN-iTransformer0.02460.01940.89830.59333.1382
VMD-BiTCN-iTransformer0.02090.01690.92690.73943.7983
CEEMDAN-BiTCN-iTransformer0.02320.01870.90940.75553.3400
GJO-CLTCN0.02840.02360.86490.66732.7229
SSA-CVMD-AM-GRU0.02360.01880.90620.86653.2713
CEEMDAN-SE-VMD-LSTM0.02660.02180.88150.61182.9676
WOA-CVMD-CBiLSTM-AM0.02100.01660.92590.69993.6748
iTransMamba0.01480.01200.96280.28275.2362
FEDformer0.01890.01450.93950.42334.0719
Phys-VMD-BiTCN-iTransformer0.01200.00780.97560.12496.4942

The test set results indicate that the proposed Phys-VMD-BiTCN-iTransformer model achieves the best performance, with R2 reaching 0.9756. Its RMSE, MAE, and MAPE are reduced to 0.0120 mg/L, 0.0078 mg/L, and 0.1249%, respectively, while RPD increases to 6.4942. All metrics are significantly superior to those of the comparison models. Among all competing architectures, the single-network models exhibit the lowest predictive accuracy. Specifically, the BiTCN model attains an R2 of only 0.8259 because it directly uses the raw TP time series as input, without effectively decoupling trend components, fluctuation components, and noise, thereby making it difficult to simultaneously capture the coupled short-term and long-term characteristics of TP concentrations. For hybrid models incorporating sequence decomposition (e.g., VMD-BiTCN-BiGRU-AM and CEEMDAN-BiTCN-BiLSTM-AM), R2 improves to 0.8530–0.9269; however, in the absence of process-mechanistic constraints and structured feature support, these models provide insufficient interpretability of the intrinsic rules governing phosphorus migration and transformation, as well as the process-driven mechanisms underlying multiscale fluctuation patterns. Consequently, the feature extraction remains insufficiently targeted. To validate the effectiveness of mechanism fusion, we compared against the VMD-BiTCN-iTransformer model lacking mechanistic features and constraints; results show that the proposed model yields a 4.87 percentage-point improvement in R2 and a 42.58% reduction in RMSE, confirming the essential enabling role of mechanism fusion in model performance. Finally, six representative forecasting models were included for comparison: GJO-CLTCN, (18) SSA-CVMD-AM-GRU, (36) CEEMDAN-SE-VMD-LSTM, (17) WOA-CVMD-CBiLSTM-AM, (31) iTransMamba, (53) and FEDformer. (54) The first four are purely data-driven, whereas iTransMamba and FEDformer are efficient state-of-the-art models for long-sequence forecasting. iTransMamba uses selective state-space modeling to capture key long-range dependencies, while FED former combines decomposition and frequency-domain learning for efficient global modeling. The proposed model improved R2 by 12.80%, 7.65%, 10.67%, 5.37%, 1.32%, and 3.84%, respectively. Its advantages over iTransMamba and FEDformer arise from global–local modeling through iTransformer–BiTCN fusion and physics-informed constraints, which improve adaptation to nonlinear, delayed wastewater processes. Wang et al. (51) further noted that strong temporal autocorrelation in wastewater-treatment data may artificially inflate R2. To exclude inflated performance caused by effluent TP autocorrelation, a persistence baseline, y^t+1 = yt, was added. It directly uses the current TP observation as the next-step prediction without decomposition or deep learning. As shown in Supporting Information 7, the baseline achieved only R2 = 0.7427 and RPD = 1.9807 on the same test set.

To assess cross-facility applicability, we conducted auxiliary external validation using the Southern California Bight multi-POTW data set. Because its monitored variables differ from ours, only shared water-quality variables were used to evaluate the VMD–BiTCN–iTransformer backbone. Given interplant differences in effluent ranges and discharge standards, R2, MAPE, and other relative metrics were adopted. Results are provided in Supporting Information 17 and demonstrate the model’s predictive capability across facilities and operating conditions.

In addition, Taylor diagrams were employed to synthesize and visualize the correlation coefficient, normalized root-mean-square error, and standard deviation ratio between each model’s predictions and the corresponding observations (Figure 7). Taylor diagrams enable the integrated visualization of multidimensional evaluation metrics, thereby overcoming the representational limitations inherent in relying on a single index or tabular summaries. As shown in Figure 7, the proposed model yields the closest overall agreement with the ideal optimum across the three evaluation dimensions, exhibiting high predictive correlation, low error, and a strong concordance between the predicted and observed data distributions. Consequently, its integrated performance is significantly superior to the other 15 comparison models.

Figure 7. Box plots and Taylor diagrams of various models.
Figure 7. Box plots and Taylor diagrams of various models.

3.5. Ablation Experiment

Ablation experiments were conducted to quantify the contribution of each module in the Phys-VMD-BiTCN-iTransformer framework. Key components were progressively removed, and all variants were trained under identical conditions and evaluated on the same WWTP test set using RMSE, MAE, R2, and RPD. Performance comparisons are reported in Table 3, with raincloud plots shown in Figure 8.

Figure 8. Ablation experiment cloud-rain diagram for each model.
Figure 8. Ablation experiment cloud-rain diagram for each model.

Table 3. Ablation Experiment Results

modelRMSEMAER2MAPERPD
BiTCN0.03220.02620.82590.82682.6229
iTransformer0.02740.02300.87380.49322.8203
BiTCN-iTransformer0.02450.02020.89930.66153.2686
VMD-BiTCN-iTransformer0.02280.01860.91280.64273.3941
VMD-Res-BiTCN-iTransformer0.02090.01690.92690.73943.7983
PhyLoss-VMD-Res-BiTCN-iTransformer0.01760.01390.94790.31164.3877
Rpf-PhyLoss-VMD-Res-BiTCN-iTransformer0.02110.01650.92400.77593.7586
RFF-PhyLoss-VMD-Res-BiTCN-iTransformer0.02390.01900.90330.91833.2185
Phys-VMD-Res-BiTCN-iTransformer0.01200.00780.97560.12496.4942

Ablation-based comparisons show that single-network models have clear predictive limitations. BiTCN captures short-term local TP fluctuations via bidirectional causal dilated convolution but cannot model long-term dependencies across multiple processes, yielding R2 = 0.8259. iTransformer improved R2 by 4.79 percentage points (R2 = 0.8738) through variate-wise attention. However, the ADF test confirmed that the raw effluent TP series was nonstationary (Table S8). Under coexisting multiscale fluctuations and random noise, iTransformer could not fully separate dynamics across temporal scales, limiting its predictive accuracy. The heterogeneous BiTCN-iTransformer separates short- and long-term representations, raising R2 to 0.8993; however, without sequence decomposition, trend-fluctuation-noise coupling persists, reducing adaptability to complex operating conditions. After VMD decomposition, VMD-BiTCN-iTransformer performs adaptive frequency-domain splitting with better physical interpretability, increasing R2 by 1.35 percentage points and reducing RMSE by 6.94%. With residual connections, VMD-Res-BiTCN-iTransformer further improves long-term evolution (R2 = 0.9269, RMSE = 0.0209 mg/L). Incorporating process constraints into PhyLoss-VMD-Res-BiTCN-iTransformer prevents physical distortion by enforcing mass conservation, biological phosphorus removal, and removal-efficiency rationality; compared with the model without mechanistic constraints, R2 improves by 2.10 percentage points and MAPE decreases by 57.86%. Finally, Phys-VMD-Res-BiTCN-iTransformer integrates seven structured mechanistic features from ASM2d, chemical precipitation kinetics, and Stokes separation laws in a dual-fusion architecture with process-constrained loss, achieving the best performance (R2 + 2.77 percentage points, RMSE = 0.0120 mg/L, RPD = 6.4942). As shown in the raincloud plot in Figure 8, it yields a compact prediction distribution with a narrow error interval and no evident outliers, indicating stronger robustness and improved stability under complex operating conditions. To distinguish gains from generic nonlinear transformations and domain-specific mechanisms, two equal-dimensional controls were added. Using the same raw inputs, seven features were generated by second-order random polynomial features (RPF) and random Fourier features (RFF), matching the dimensionality and nonlinear capacity of the seven mechanism-derived features (Supporting Information 8). Relative to PhyLoss-VMD-Res-BiTCN-iTransformer, RPF and RFF reduced R2 by 2.39 and 4.46 percentage points, whereas the ASM2d-, Stokes-, and precipitation-based features increased R2 by 4.87 points. Thus, the gain is not merely due to nonlinear basis expansion, but to process priors and physical, biochemical, and kinetic constraints unavailable to generic transformations.

The ablation results reveal the hierarchical contributions of the model components. The mechanistic fusion module, comprising structured mechanistic features and the process-constrained loss, provides the largest R2 improvement (4.87%), followed by VMD (2.76%) and heterogeneous network fusion (2.55%). These results highlight the limitations of purely data-driven models and demonstrate that integrating process mechanisms, multiscale decomposition, and complementary temporal learning is essential for accurate and reliable TP prediction under complex operating conditions.

4. Discussion

4.1. Multistep Prediction

Proactive operational control in WWTPs strongly depends on multihorizon TP concentration forecasting. In this study, we select 12, 24, and 48 h as representative prediction horizons, corresponding to key engineering scenarios such as optimization of chemical dosing, aeration and sludge recirculation regulation, and the development of operation strategies under special operating conditions. (14−16) Using R2 as the primary evaluation metric, we benchmark the multistep forecasting performance of the proposed model against that of leading baseline models.

Table 4 summarizes the multistep forecasting R2 of each model, and Figure 9 depicts the other metrics’ trends. The proposed model achieves the best results at 12, 24, and 48 h: R2 = 0.9722 (12 h; <1% drop vs single-step), 0.9715 (24 h), and 0.9662 (48 h), markedly outperforming the baselines. In contrast, other models’ errors increase quickly with forecast horizon because they lack mechanistic constraints and long–short temporal feature adaptation. Without these, data-driven models fail to separate TP temporal features or maintain consistency with process-based phosphorus removal dynamics, and a single architecture cannot capture both short- and long-term dependencies, leading to error accumulation in mid-to-long-range forecasts.

Figure 9. Multistep prediction indicator change chart.
Figure 9. Multistep prediction indicator change chart.

Table 4. Multistep Prediction Results

Phys-VMD-BiTCN-iTransformerSSA-CVMD-AM-GRUCEEMDAN-SE-VMD-LSTMWOA-CVMD-CBiLSTM-AM
step sizeR2R2R2R2
10.97560.90620.88150.9259
120.97220.88250.87200.9021
240.97150.87130.86470.8876
480.96620.82390.84760.8434

4.2. Interpretability Analysis

The black-box nature of purely data-driven models limits their utility in real-world wastewater treatment operations and maintenance. Elnakar identified interpretable machine learning and physics-informed hybrid modeling as essential for deploying intelligent water-treatment systems. (52) The proposed Phys-VMD-BiTCN-iTransformer improves interpretability through mechanism-informed features and physics-guided constraints, revealing feature contributions, process interactions, and mechanistic consistency. SHAP is employed to quantify each feature’s contribution and characterize nonlinear feature–TP relationships, providing mechanistic explanations and theoretical support for the model outputs.

Consistent with the SHAP results in Figure 10, the feature-contribution ranking matches wastewater-treatment TP removal logic: biological phosphorus removal as the core, chemical removal as the safeguard, and physical separation as the fallback.

Figure 10. SHAP summary analysis combination chart (pie chart percentages rounded to two decimal places).
Figure 10. SHAP summary analysis combination chart (pie chart percentages rounded to two decimal places).

Process monitoring features were the primary data source for prediction. Preanoxic Tank 2 ORP (P8) had the largest mean absolute SHAP contribution (50.80%), making it the dominant predictor of effluent TP. The seven mechanism-derived features contributed approximately 25.4% in total, demonstrating their value for both prediction accuracy and interpretability. Derived from ASM2d-based biological phosphorus removal and supplemented by chemical precipitation and secondary-clarifier separation mechanisms, these features translate process knowledge into model inputs and compensate for the limitations of purely data-driven approaches. Among them, fpH,chem contributed the most (11.50%), indicating that the match between the chemical environment and optimal dosing conditions strongly affects effluent TP. ruptake,aero contributed 5.02%, highlighting the importance of anoxic phosphorus uptake. ηsep and ruptake,aero contributed 2.60% and 2.59%, respectively, reflecting the combined effects of solid–liquid separation and aerobic phosphorus uptake. In contrast, the mean SHAP value of fVFA was close to zero, indicating the weakest marginal effect, consistent with the sufficient carbon supply and absence of substrate limitation for phosphorus release under actual operating conditions.

Figure 11’s SHAP dependence plot provides an intuitive depiction of the marginal effects of core mechanistic features on the predicted TP. The relationship between the aerobic phosphorus uptake rate ruptake,aero and the effluent TP shows a pronounced inflection near 0.068, with a clear positive–negative crossover: when ruptake,aero < 0.068, the uptake rate is below the process-critical threshold, PAOs’ excess uptake capacity is not effectively realized, the core efficiency of biological phosphorus removal is insufficient, and the model predicts higher TP in the effluent; conversely, PAOs transition to a high-efficiency uptake state, reducing the predicted effluent TP. The anoxic uptake rate ruptake,anox, as a complementary component of the core phosphorus removal process, exhibits a similar pattern, consistent with the ruptake,aero rule. The chemical phosphorus removal pH correction coefficient fpH,chem in the sub-2.5 range displays a clear negative relationship with effluent TP: larger values push the SHAP value further negative and lower the predicted TP, indicating that the actual pH of the chemical phosphorus removal reactor is closer to the optimal PAC/PFS reaction window, pH deviations impose less inhibition on reagent–phosphorus reactions, chemical phosphorus removal becomes more effective, and its contribution to TP reduction strengthens. Conversely, deviations from the optimum pH markedly weaken chemical removal’s guarantee. Owing to the saturation of chemical phosphorus removal, its efficiency reaches the process’s theoretical limit; further increases in fpH,chem do not yield additional gains, and its marginal contribution to TP prediction tends to vanish, with SHAP values approaching zero. The complete SHAP dependence analysis for the remaining mechanistic parameters is provided in Supporting Information 6.

Figure 11. SHAP dependency graph.
Figure 11. SHAP dependency graph.

4.3. Causal Inference

SHAP quantifies feature contributions and associations with predicted TP but cannot identify true causal drivers. In WWTP operation, distinguishing causal factors from correlated responses is essential for targeted control. We therefore introduce a Double Machine Learning (DML) causal inference framework (77) to extend the analysis from predictive association to causal attribution, providing a reliable foundation for subsequent precise regulation.

In causal inference, conditioning on post-treatment mediators blocks indirect pathways and may introduce collider bias, failing to legally provide unbiased estimates of natural direct/indirect effects. To overcome this, we strictly follow the causal mediation framework of Daniel et al. (79) Based on intervention feasibility, mechanistic interpretability, and logical consistency, five controllable variables were selected as treatments (A): coarse-screen lift-pump flow (CSLPF), dissolved oxygen in Aeration Tank 1 (AT1 DO), dissolved oxygen in Aeration Tank 2 (AT2 DO), oxidation–reduction potential in Hydrolysis Tank 1 (HT1 ORP), and oxidation–reduction potential in Anoxic Tank 1 (ANOX1 ORP) (Table S12). The seven mechanistic features are strictly defined as mediators (M), representing coupled biological, chemical, and physical phosphorus-removal pathways, with effluent TP as the outcome (Y). To achieve unbiased causal estimation, we explicitly state and justify five core identification assumptions: (1) consistency; (2) sequential ignorability given covariates X (no unmeasured confounding); (3) positivity; (4) temporal ordering (treatment precedes mediators, which precede outcome); and (5) no unmeasured mediator-outcome confounding. (78) Details of the assumption testing and justification are provided in Table S13.

Following the orthogonalization and cross-fitting principles of Chernozhukov et al., (77) DML effectively reduces regularization and overfitting bias from high-dimensional covariates, yielding robust and asymptotically efficient Average Treatment Effect (ATE) estimates. To accurately separate direct and indirect pathways, we abandon conditional approximation and adopt the g-computation/multiple imputation mediation framework recommended by Daniel et al. (79) to estimate the Natural Direct Effect (NDE), Natural Indirect Effect (NIE), and interaction term, explicitly defining the total effect decomposition allowing for A-M interaction (Total = NDE + NIE + interaction). (78) In the model incorporating mechanistic features as mediators, the DML-estimated ATEs and effect decompositions are presented in Tables 5, 6 and Figure 12. Results show that AT1 DO exhibits the largest significant positive total effect on effluent TP (ATE = 0.0650, p < 0.001), marking it as the predominant causal driver. Further decomposition reveals that AT1 DO acts almost entirely through a direct pathway (NDE% = 97.18%, NIE% = 2.82%), indicating its causal influence is primarily direct and immediately regulable. In comparison, CSLPF also shows a significant positive effect (ATE = 0.0492, p < 0.05), while HT1 ORP acts primarily through a direct pathway but with a smaller magnitude (ATE = 0.0162, NDE = 67.43%, NIE = 32.57%) (Table S12). Meanwhile, AT2 DO shows a relatively balanced direct and indirect effect (NDE = 53.82%, NIE = 46.18%). Thus, AT1 DO acts as the most powerful and direct controllable lever for mitigating effluent TP, suggesting priority control of aeration intensity in Tank 1; AT2 DO requires balancing aeration control with biological responses (Table 6).

Figure 12. Causal mediation decomposition: NDE and NIE.
Figure 12. Causal mediation decomposition: NDE and NIE.

Table 5. Estimated ATE of Each Treatment Variable on Effluent TP after Including Mechanistic Characteristicsa

handle variableATE meanATE standard deviationP-valuedirection of effect
CSLPF0.04920.02350.0363positive (p < 0.05)
AT1 DO0.06500.01940.0008strongly positive (p < 0.001)
AT2 DO–0.00660.01470.6536weakly negative (p > 0.05)
HT1 ORP0.01620.01410.2506weakly positive (p > 0.05)
ANOX1 ORP–0.06440.04520.1542weakly negative (p > 0.05)

a P-values were calculated using a two-sided Z-test based on the asymptotic normality of the DML estimator, where Z = ATE mean/ATE standard deviation and P = 2 × (1 – Φ(|Z|)).

Table 6. Causal Mediation Effect Decomposition of Effluent TP (NDE, NIE)a

handle variableTENDENIEproportion of NDE (%)proportion of NIE (%)
CSLPF0.04830.0650–0.016779.5320.47
AT1 DO0.10830.1115–0.003297.182.82
AT2 DO0.10000.05380.046253.8246.18
HT1 ORP0.08120.1571–0.075967.4332.57
ANOX1 ORP0.27770.3263–0.048587.0512.95

a(Proportion of NDE = NDE/TE × 100%, Proportion of NIE = NIE/TE × 100%).

DML alone cannot prove that observational data satisfy exchangeability/no unmeasured confounding. (77) To quantitatively assess the robustness of our causal conclusions to potential unmeasured mediator–outcome confounding, we calculated E-values based on the framework of VanderWeele and Ding (80) and Smith and VanderWeele. (81) The E-value represents the minimum strength of association that an unmeasured confounder would need to have with both the mediator and the outcome to fully explain away the observed effect. As shown in Table S13, the E-values for the natural direct effects (NDE) are generally large (e.g., AT1 DO: 14.59; HT1 ORP: 34.05), indicating that the direct effects are robust to unmeasured confounding. In contrast, the E-values for the natural indirect effects (NIE) are relatively small (e.g., AT1 DO: 1.31; CSLPF: 2.05), suggesting that the indirect effects are more susceptible to unmeasured confounding. However, for effects that are not statistically significant (e.g., ANOX1 ORP ATE, p = 0.1542), the E-value should be interpreted with caution because the point estimate may already be indistinguishable from zero. Overall, the large NDE E-values support the robustness of the main direct causal pathways identified in this study, while the smaller NIE E-values highlight the need for cautious interpretation of indirect pathways.

Unlike SHAP, which explains associations between features and model outputs, DML estimates causal drivers of effluent TP under the stated identification assumptions, (77) extending model interpretation from correlation to causation. Main conclusions are as follows: First, AT1 DO is the dominant causal driver of increased effluent TP (ATE = 0.0650, strongly positive), primarily acting through a direct pathway (NDE% = 97.18%), highlighting the paramount importance of precise aeration control in Tank 1 as the most actionable regulation strategy. Second, CSLPF and HT1 ORP serve as secondary causal drivers (ATE = 0.0492 and 0.0162, respectively), with HT1 ORP mainly acting through a direct pathway (NDE% = 67.43%, NIE% = 32.57%), suggesting that maintaining a stable reducing environment in the hydrolysis tank remains necessary. Third, AT2 DO acts through both direct and indirect pathways (NDE% = 53.82%, NIE% = 46.18%), requiring balanced regulation of aeration intensity and biological responses. Fourth, ANOX1 ORP has limited direct causal influence on TP under current conditions (ATE = −0.0644, p = 0.1542), potentially being more relevant to denitrification control. Importantly, the E-value sensitivity analysis (Table S13) shows that the direct effects (NDE) are robust to unmeasured confounding, whereas the indirect effects (NIE) have relatively small E-values and should therefore be interpreted with caution. These causal conclusions provide a theoretical basis for the directed regulation mechanism in Section 4.4, forming a closed loop from causal attribution to precise control (Tables 5, 6, and Figure 12).

4.4. Directed Regulation Mechanism Based on DO in Aeration Tank

Based on the average treatment effect (ATE) estimated using the DML causal framework, dissolved oxygen in Aeration Tank 1 (AT1 DO) was identified as a key driver of effluent TP. Higher AT1 DO exerted a significant positive direct effect on effluent TP and indirectly weakened phosphorus removal by suppressing biological phosphorus-removal reactions. AT1 DO was therefore selected as the primary control variable. Considering the Class 1A limit of GB 18918–2002 and influent fluctuations, 0.1–0.3 mg/L was defined as the engineering-economic optimum for effluent TP, balancing compliance, operating cost, and ecological risk. (29, 36) Plant records showed that TP below 0.1 mg/L generally required chemical or advanced treatment, increasing chemical use by approximately 32% and, in some cases, aeration energy by approximately 28%. Excessive aeration may also disrupt anaerobic conditions, impair biological phosphorus removal, and increase chemical dependence. Because further TP reduction below 0.1 mg/L provides limited benefit after compliance while increasing energy use, chemical consumption, and sludge production, it was defined as overtreatment for this plant. Accordingly, a DO-control mechanism for Aeration Tank 1 was developed to translate the causal findings into an operational TP-reduction strategy.

Following Elnakar’s model-driven control framework for water-treatment systems (52) and multiscenario comparisons, staged DO regulation was identified as the optimal strategy for effluent TP control, enabling a closed loop from model prediction to operational implementation. As shown in Table 7, deviations between predicted TP and the 0.1–0.3 mg/L range are classified into eight levels, where negative values denote TP below the lower bound, positive values denote TP above the upper bound, and zero indicates compliance. eq (7) is proposed to regulate AT1 DO concentration, with the Phys-VMD-BiTCN-iTransformer model predicting the resulting TP concentration. The control coefficient K in eq (7) was calibrated through multilevel simulations to match actual process responses. The TP stability attainment rate Er (see eq (8)) is defined to quantify regulatory performance, where higher values mean more TP data remain within the 0.1–0.3 mg/L range. Pre- and postregulation results are compared in Figure 13.

Figure 13. Comparison chart of effluent TP adjustment.
Figure 13. Comparison chart of effluent TP adjustment.

Table 7. Classification of TP Concentration

range of TP contentgraderange of TP contentgrade
(0, 0.03)–3(0.3, 0.4)1
(0.03, 0.07)–2(0.4, 0.5)2
(0.07, 0.1)–1(0.5, 0.7)3
[0.1, 0.3]0(0.7, +)4

Using the stable TP compliance rate Er as the performance metric, the model-based scenario results for different K-values are shown in Table 8. Without DO regulation, the stable TP compliance rate was only 36.1%; 2.1% of samples exceeded 0.3 mg/L, whereas 61.8% were below 0.1 mg/L, indicating widespread overtreatment and unnecessary aeration and chemical costs. The optimal performance was achieved at K = 0.15. After targeted DO regulation for 379 test samples, Er increased to 58.7% (a 22.6 percentage-point rise), and the overlimit sample ratio decreased to 0.52%, mitigating the risk of TP exceedance. The average effluent TP rose from 0.09 mg/L to 0.12 mg/L and concentrated within the reasonable range; off-range data also presented much smaller deviations, better satisfying practical operational demands.

Table 8. Comparison of Optimization Outcomes with Varying K-Values

constantquantity optimizationsuitability rate (%)
0.0114838.9
0.0517245.3
0.1020152.9
0.1522358.7
0.2021957.6
0.2520654.2
0.3019551.3
0.3518648.9

Validation used 379 hly samples covering influent-load fluctuations, water-quality changes, and sensor errors. About 16.4% involved disturbances such as carbon-to-phosphorus imbalance or abrupt flow changes. After staged DO regulation, TP exceedances remained below 0.6%, indicating strong adaptability to short-term disturbances. The discrete hierarchical strategy adjusts DO only when TP crosses preset thresholds, reducing sensitivity to minor sensor fluctuations and control oscillations. Due to the limited data duration, the samples do not cover a full seasonal cycle. Thus, the robustness conclusions are limited to the observed operating conditions and should not be extrapolated to unobserved seasons. Further validation using long-term multiseasonal data is needed.

DO Regulation Formula for Aerobic Tank 1: DO′=DO−G×K (7) where DO′ denotes the DO-control target for Aerobic Tank 1 (mg/L); DO denotes the current measured DO in Aerobic Tank 1 (mg/L); G denotes the deviation level coefficient of the effluent TP concentration; and K denotes the DO-control coefficient.

The calculation formula for the Er is defined as Er=TPETPA (8) where Er represents suitability ratio, TPE denotes the count of TP data points within the [0.1, 0.3] interval, and TPA signifies the total number of TP data points.

Because of operational, safety, and process constraints, all control effects were derived from model-based counterfactual simulations. Within the data-covered operating range, the model enables rapid comparison of the theoretical effects of different DO settings and provides preliminary guidance for process control. However, the results remain constrained by the model response surface and may not represent actual performance under unseen plant conditions. Nevertheless, the identified causal pathways and quantified control coefficients provide a basis for future closed-loop field trials and multiobjective optimization of energy use and effluent quality. (52)

The Supporting Information mainly contains methodological details of the model, relevant parameter settings, diverse experimental analysis details, and auxiliary verification results for this study.

Author Contributions

M.A.: Conceptualization, methodology, software, writing─original draft, data curation, investigation. Z.W.: Methodology, validation, writing─review and editing, supervision. N.D.: Writing─review and editing, supervision. F.J.: Writing─original draft. J.K.: Validation.