Abstract
Two separate goals should be jointly pursued in wastewater treatment: nutrient removal and energy conservation. An efficient controller performance should cope with process uncertainties, seasonal variations and process nonlinearities. This paper describes the design and testing of a model predictive controller (MPC) based on neuro-fuzzy techniques that is capable of estimating the main process variables and providing the right amount of aeration to achieve an efficient and economical operation. This algorithm has been field tested on a large-scale municipal wastewater treatment plant of about 500,000 PE, with encouraging results in terms of better effluent quality and energy savings.
HIGHLIGHTS
Artificial Intelligence helps improve the energy efficiency of a wastewater treatment plant.
Model predictive control produces a better effluent quality in a wastewater treatment plant.
A neuro-fuzzy controller improves the reliability of a wastewater treatment plant.
NOMENCLATURE
- Acronyms
- AI
Artificial Intelligence
- AIE
Artificial Intelligence Engine
- ANFIS
Adaptive Neuro-Fuzzy Inference System
- CC
Conventional Controller
- DO
Dissolved Oxygen (mg/l)
- DOsp
Dissolved Oxygen set-point (mg/l)
- EW
Energy Way
- FL
Fuzzy Logic
- GA
Genetic Algorithm
- MPC
Model Predictive Control
- Ntot
Total Nitrogen (mgN/l)
- PID
Proportional-Integral Derivative controller, equivalent to CC
- Qin
Input recycle flowrate (m3/s)
- Qr
Internal recycle rate (percentage of maximum)
- Qras
External recycle rate (percentage of Qin)
- Qw
Waster rate (percentage of Qin)
- Ua
Air flow rate (Nm3/h)
- WWTP
Waste Water Treatment Plant
Symbols

Ammonium-N concentration (mgN/l)

Nitrate-N concentration (mgN/l)

Nitrite-N concentration (mgN/l)
- γ1, γ2, γ3
Unconstrained optimisation coefficients
- ρ1, ρ2, ρ3
Constrained optimisation coefficients
- δ
Control sampling time (min)
- α, β
Prediction and control horizons, as multiples of δ
INTRODUCTION
A wastewater treatment plant (WWTP) is a complex process that uses microbiological reactions to remove pollutants from wastewater. In its operation, this energy-intensive process must reconcile two partially conflicting objectives: pollution abatement and energy conservation. It appears that a balance between these two diverging goals can be achieved through automatic control based on Artificial Intelligence (AI).
In the last two decades, as recently documented, there has been a growing integration between Artificial Intelligence and wastewater treatment processes (Mannina et al. 2019; Zhao et al. 2020). Biological treatment processes are intrinsically complex, involving a variety of microbial communities, of natural conditions, of influent characteristics, each with inherent uncertainties and time changes. On the other hand, governing legislation demands consistent effluent standards, while financial constraints call for energy savings. Reconciling effluent quality and economical operation, given the time-varying and uncertain nature of the process, requires advanced control solutions, which can be provided by Artificial Intelligence. This powerful tool can cater for both of the process operational requirements previously defined.
Artificial Intelligence is a universe of differing mathematical tools, which can be roughly grouped into Artificial Neural Networks (Kosko, 1992; Hagan et al. 1996), Fuzzy Logic (Yager & Zadeh 1994; Babuska 1998), and Genetic Algorithms (Goldberg 1989; Holland 1998), each with varied sub-categories, as aptly analysed in Zhao et al. (2020). Often these techniques are combined to produce high-level supervisory systems, generally referred to as Expert Systems (Castillo et al. 2016; Torregrossa et al. 2018; Judson 2019; Nikolopoulos 2019) or Decision Support Systems specifically aimed at harmonising conflicting objectives in the design of WWTP (Iglesias et al. 2007; Snip et al. 2014; Corominas et al. 2018), as later reviewed by Mannina et al. (2019). AI tools have also been used in WWTP to develop soft sensors to provide a double-check, or even substitute for hard sensors (Haimi et al. 2013, 2016; Mulas et al. 2015; Fernandez de Canete et al. 2016).
The application of Artificial Intelligence to the wastewater treatment area has been documented in many successful applications. Unlike many industrial processes where an approximating linear model can be used to implement a model predictive controller (MPC) (Borrelli et al. 2017; Rawlings et al. 2017), WWTP is a highly nonlinear, time-varying process and ad-hoc versions of MPC must be designed. A carbon-dosing system based on a fuzzy model predictive controller was proposed by Marsili-Libelli & Giunti (2002) to improve the nitrification performance. An evolutionary self-organising model of a municipal WWTP based on genetic programming was designed by Hong & Bhamidimarri (2003) to successfully model the many process nonlinearities. The primary aspect of WWTP management is the harmonisation of the effluent quality requirements with the energy conservation. This challenge has produced many studies in which the multi-objective nature of the problem was approached with AI tools and solved by the application of MPC, resulting in a multi-loop structure, as surveyed by Qiao et al. (2018). Differing nitrogen control strategies were proposed by Stare et al. (2007), while the specific problem of dissolved oxygen (DO) control using an MPC was considered by Holenda et al. (2008). O'Brien et al. (2011) used an MPC to reduce the plant power consumption by a quarter. A multivariable MPC for improving the nitrogen removal and reducing the operational costs was proposed by Dainotto et al. (2012) and Mulas et al. (2013), to be later extended to the control of a full-scale WWTP (Han & Qiao 2014; Mulas et al. 2015; Foscoliano et al. 2016). Francisco et al. (2015) described a procedure to determine the most economically viable controlled variable in the WWTP and proposed a nonlinear MPC integrated with a PI to monitor the process constraints. A similar approach was used by Goldar et al. (2016) to design a decentralised nonlinear MPC combined with a PI controller, which compared favourably to the previous centralised controller based on PI alone.
MATERIAL AND METHODS
Description of the plant and the information technology
The WWTP from which the data were acquired, and which is being used as a test plant, is the municipal plant of the city of Modena, in Northern Italy. It consists of a conventional biological treatment plant for nutrient removal with pre-denitrification, with a capacity of approximately 500,000 PE.
The process instrumentation consists of a Dissolved Oxygen meter and a nutrient sensor (Hach, Endress + Hauser). These field measurements are routed to the plant SCADA for real-time operation. An encrypted connection between the plant and the Energy Way centre was created to allow prototypical testing. This arrangement enables specific clients to access the controller through a LAN. Through VPN encrypted tunnelling, clients can mount directories on the controller as NFS folders and obtain services directly from the controller, enabling fast analysis iteration and maintenance.
Communication between the centre and the plant SCADA is based on the Modbus protocol over TCP/IP, physically linking the controlling machine to the PLC-front-end with an Ethernet patch cable, enabling peer-to-peer IP communication.
The AI components of the MPC were trained and validated using plant data spanning over one year of operation of the same plant.
Before this MPC was designed, the plant automation consisted of conventional Proportional-Integral-Derivative (PID) control loops, which are now used as yardsticks to assess the performance of the new controller.
ANFIS – a systematic approach to neuro-fuzzy modelling
is the vector of inputs, and
are the coefficients of the linear Sugeno consequents.General structure of ANFIS. The dashed lines indicate the adjustment paths of both the antecedents and the consequents, depending on the squared error between the ANFIS output and the training data (Marsili-Libelli 2016).
General structure of ANFIS. The dashed lines indicate the adjustment paths of both the antecedents and the consequents, depending on the squared error between the ANFIS output and the training data (Marsili-Libelli 2016).
The improvement of ANFIS with respect to the classical Sugeno fuzzy models is in its ability to adjust both the antecedent membership functions and the linear consequents to minimise the sum of squared differences between the ANFIS output and a training data set. As explained later, this structure has been used repeatedly to develop the MPC.
Development of the model predictive controller
The present real-time MPC was designed to improve the energy efficiency of the nutrient removal process in the full-scale municipal WWTP described earlier. The process control scheme is shown in Figure 2, where the set-points for the dissolved oxygen DOsp and the recycle flow Qr,sp are determined on the basis of the forecasted future nutrient loading provided by the artificial intelligence engine (AIE). These set-points are fed to local controllers to deliver the proper amount of air flow (Ua) and internal recycle (Qr). The grey boxes indicate the low-lever controllers/actuators.
Process scheme of the WWTP to which the MPC is applied. The two control loops are indicated by the dashed lines: the DO control loop regulates the airflow (Ua), while the recycle loop controls the internal recycle (Qr).
Process scheme of the WWTP to which the MPC is applied. The two control loops are indicated by the dashed lines: the DO control loop regulates the airflow (Ua), while the recycle loop controls the internal recycle (Qr).
The observed variables used to train the ANFIS are the DO, oxidation reduction potential (ORP), temperature, the nitrogen species (NH4 and NO3) in the oxidation tank, and the output total nitrogen (Ntot). The manipulated variables are the airflow rate (Ua) and the internal recycle Qr, the latter expressed as a percentage (0–100%) of the maximal allowable flow. This reflects the fact that the recycle pump operates at a fixed regime, so the percentage represents the fraction of the ON time in each time frame.
It is assumed that the controlled variables (DO and Qr) can track their set-points without appreciable error, being locally controlled by low-level PID regulators. They act on the blowers delivering the air flow Ua and on the recycle pump providing the internal recycle (Qr). The MPC aims to reduce the amount of output total nitrogen (Ntot), while at the same time minimising the energy consumption.
All of the process variables are sampled at regular intervals δ = 5 min, which represents the MPC time-base, of which the control (β) and prediction (α) horizons are multiples. The control horizon is equal to the sampling time, so β = 1, while the prediction horizon α > β was suitably defined as a multiple of β, which cannot be further specified here because of industrial confidentiality.
Equation (4) indicates that for operational reasons the internal recycle must remain inside the range [60, 100]% of its nominal value, in other terms it can only be decreased down to nearly half its nominal value, but not increased beyond that limit. The inner structure of the MPC is shown in Figure 3, and consists of two parts represented by the dashed boxes: the optimisation in the upper block implements Equations (2) and (3), while the lower block produces the forecasts on which the optimisation is based. The purpose of the upper block is to determine the best DOsp by testing all of the possible DOsp(t + β) values, within a predefined grid of values, on the basis of the forecasts of the lower block. The current DOsp(t + β) under test is also fed into the inverse ANFIS, which yields the corresponding value of air flow Ua(t + β). From the blower rating curve, this value is converted into the energy consumption E(t + β), which is returned to the upper block. The lower block also computes the next recycle flow Qr(t + β) according to Equations (4) and (5).
General scheme of the neuro-fuzzy MPC. The prediction is made α steps ahead, while the control is applied at β steps ahead. The grey boxes represent the manipulated variables to be applied to the plant at the next step (t + β).
General scheme of the neuro-fuzzy MPC. The prediction is made α steps ahead, while the control is applied at β steps ahead. The grey boxes represent the manipulated variables to be applied to the plant at the next step (t + β).
its estimate. Figure 4 shows the performance of the trained neuro-fuzzy predictors in estimating the process variables α steps ahead for the nitrogen species and β steps ahead for the airflow.Performance of process variables prediction, at time t + α for the nutrients and at t + β for the airflow provided by the trained neuro-fuzzy networks. Normalised values are shown to preserve confidentiality.
Performance of process variables prediction, at time t + α for the nutrients and at t + β for the airflow provided by the trained neuro-fuzzy networks. Normalised values are shown to preserve confidentiality.
A sensitivity assessment was also performed on the model by considering the percentage variations of the output variables
caused by a ±20% variation in DO. Figure 5(a) shows that a positive DO variation of 20% produces a
decrease in 95.8% of the cases (red bars), while a −20% DO variation results in an increase of
in 96.1% of the times (blue bars). Likewise, Figure 5(b) shows that a +20% DO increase is followed by an
increase in 91.7% of the cases, while a −20% DO decrease results in a lower
in 92.3% of the times. The spread in the response is due to the influence of other process conditions.
Sensitivity assessment of the ANFIS predictors (lower block in Figure 3). The ammonium-N variations (ΔNH4+) in response to a 20% change in DO are shown in (a), while (b) shows the corresponding ΔNO3− variations. Note the opposite response of the two output variables. Please refer to the online version of this paper to see this figure in colour: http://dx.doi.org/10.2166/wst.2020.298.
Sensitivity assessment of the ANFIS predictors (lower block in Figure 3). The ammonium-N variations (ΔNH4+) in response to a 20% change in DO are shown in (a), while (b) shows the corresponding ΔNO3− variations. Note the opposite response of the two output variables. Please refer to the online version of this paper to see this figure in colour: http://dx.doi.org/10.2166/wst.2020.298.
RESULTS AND DISCUSSION
After testing the consistency of the predictions via error assessment of Equation (6) and the sensitivity analysis, the proposed EW controller has been compared to the conventional controller (CC) that was previously in operation. The preliminary test shown in Figure 6 consists of three time-windows and compares the total output nitrogen (Ntot) produced by the two controllers, only one of which is engaged at any one time. The total output nitrogen follows the reference value produced by the active controller within the model error tolerance. In the first and third time-window, the conventional controller (CC) is active, yielding a higher value of Ntot, while in the central grey window, the EW controller is engaged and produces a lower output Ntot. However, since both controllers are always updated, they continue to produce a reference output even when disengaged. Hence, in the grey slot, the CC controller still produces a higher reference, which, however, has no effect on the output because it is disconnected, being disengaged.
Comparison of total-N output with the conventional (CC) and EW controller, operating between samples 180 and 280 (shaded area) corresponding to the test period in March 2019. A lower Ntot output was obtained by the EW controller.
Comparison of total-N output with the conventional (CC) and EW controller, operating between samples 180 and 280 (shaded area) corresponding to the test period in March 2019. A lower Ntot output was obtained by the EW controller.
A further test was then carried out to test the EW controller's adaptability to differing operational situations, putting the emphasis either on the effluent quality, or on the energy conservation, as the conditions required. Figure 7 shows the average relative weights of the performance function Equations (2) and (3) during two different periods in which the EW controller was operating. The left bar corresponds to a high-load condition, when the effluent quality is the primary concern. The blue bar, corresponding to the unconstrained NH4 term γ1, is predominant because the premium is set on limiting the ammonium-N discharge. For the same reason, the constrained weight on Ntot (ρ3) is the second largest coefficient, while the energy weight γ2 is comparatively much smaller. The severity of the loading is also apparent in the comparatively large activation of the constrained terms ρ1, ρ2, and ρ3, indicating that both Nitrogen species are approaching their limit.
Average relative weights in the performance function Equation (2) during two separate EW controller experiments in the period indicated below each bar. In the left bar, the emphasis is on effluent quality, and thus the most active constraint is on NH4 and Ntot, while in the right bar the energy term γ2 is the most important. Please refer to the online version of this paper to see this figure in colour: http://dx.doi.org/10.2166/wst.2020.298.
Average relative weights in the performance function Equation (2) during two separate EW controller experiments in the period indicated below each bar. In the left bar, the emphasis is on effluent quality, and thus the most active constraint is on NH4 and Ntot, while in the right bar the energy term γ2 is the most important. Please refer to the online version of this paper to see this figure in colour: http://dx.doi.org/10.2166/wst.2020.298.
The right bar, by contrast, shows the weights distribution during a mild load period, during which energy saving becomes the primary concern. It can be seen that while the constrained weights ρ1, ρ2, and ρ3 are not activated, the energy weight γ2 is now the dominant one.
This performance assessment shows that the EW controller is able to combine the two operational modes and selects the overall goal to be pursued, depending on the incoming load, by dynamically adapting its performance function Equations (2) and (3), depending on the present and predicted loading conditions.
After the goal-shifting experiments of Figure 7, the two controllers were run on alternate weeks from 10 June to 9 September 2019. To compare their performance over this period, the influent NH4 was divided into three classes based on percentiles, as shown in Table 1, and the corresponding effluent NH4 was observed.
Partitioning of influent NH4 during the period 10 June–9 Sept. 2019 into three classes
| Influent NH4 class . | Percentile range . | NH4 values (mg/l) . |
|---|---|---|
| Low | 0–25th | 0–17.9 |
| Medium | 25th–75th | 17.9–28.7 |
| High | 75th–100th | 28.7–62.8 |
| Influent NH4 class . | Percentile range . | NH4 values (mg/l) . |
|---|---|---|
| Low | 0–25th | 0–17.9 |
| Medium | 25th–75th | 17.9–28.7 |
| High | 75th–100th | 28.7–62.8 |
Table 2 summarises the performance of the two controllers during this period. It shows that while the average input NH4 is nearly the same for both controllers, indicating two comparable operational periods, their process management is very different: looking at the values of the DOsp and actual DO value, they are both higher in the CC case, indicating a larger energy consumption. Conversely, the EW controller keeps the DO lower, but still at a safe level, to ensure adequate NH4 oxidation. It is not surprising that the air flow is highest for both controllers in the Medium input range, because in this segment the oxidation needs are highest, while in the High range of NH4, the air flow can be safely decreased without exceeding the effluent allowable limit.
Weekly averages of the main process variables over the period 10 June – 9 Sept. 2019
| . | Input NH4 . | DO . | DOsp . | Air flow . | Output NO3 . | Output NH4 . | Output Ntot . | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| NH4 class . | CC . | EW . | CC . | EW . | CC . | EW . | CC . | EW . | CC . | EW . | CC . | EW . | CC . | EW . |
| Low | 5.23 | 8.63 | 0.95 | 0.49 | 0.48 | 0.31 | 1,194.42 | 1,081.35 | 5.96 | 6.10 | 0.61 | 0.89 | 6.56 | 6.99 |
| Medium | 25.14 | 24.05 | 0.56 | 0.47 | 0.49 | 0.42 | 1,425.83 | 1,240.48 | 6.84 | 6.15 | 0.95 | 1.11 | 7.79 | 7.26 |
| High | 32.47 | 31.99 | 0.54 | 0.44 | 0.50 | 0.38 | 1,135.97 | 876.09 | 8.36 | 6.19 | 0.73 | 1.13 | 9.09 | 7.32 |
| . | Input NH4 . | DO . | DOsp . | Air flow . | Output NO3 . | Output NH4 . | Output Ntot . | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| NH4 class . | CC . | EW . | CC . | EW . | CC . | EW . | CC . | EW . | CC . | EW . | CC . | EW . | CC . | EW . |
| Low | 5.23 | 8.63 | 0.95 | 0.49 | 0.48 | 0.31 | 1,194.42 | 1,081.35 | 5.96 | 6.10 | 0.61 | 0.89 | 6.56 | 6.99 |
| Medium | 25.14 | 24.05 | 0.56 | 0.47 | 0.49 | 0.42 | 1,425.83 | 1,240.48 | 6.84 | 6.15 | 0.95 | 1.11 | 7.79 | 7.26 |
| High | 32.47 | 31.99 | 0.54 | 0.44 | 0.50 | 0.38 | 1,135.97 | 876.09 | 8.36 | 6.19 | 0.73 | 1.13 | 9.09 | 7.32 |
The EW controller achieves a better overall performance, though the output ammonium-N is higher, but still within the regulatory limit. This is due to the fact that the EW controller lowers the DOsp in order to save energy and avoid an excessive nitrate-N build-up, which would then be difficult to eliminate in the denitrification phase because of the limited availability of organic carbon. In fact, although the ammonium-N output is slightly higher than that produced by the CC controller, it still remains well within the prescribed limit, so any further reduction in output NH4 would only imply a larger energy expenditure, without any benefit in effluent quality.
From the values of Table 2, the percentage improvements of the EW controller are computed in Table 3, assessing the improvement of EW over CC.
Performance improvement of EW over CC during the period 10 June – 9 Sept. 2019
| . | Measured averages over the three input classes . | |||
|---|---|---|---|---|
| Effluent Ntot . | Air flow (Ua) . | DO . | Energy saving . | |
| Δ(EW-CC) % | −8.1% | −16.7% | −29.0% | −16.0% |
| . | Measured averages over the three input classes . | |||
|---|---|---|---|---|
| Effluent Ntot . | Air flow (Ua) . | DO . | Energy saving . | |
| Δ(EW-CC) % | −8.1% | −16.7% | −29.0% | −16.0% |
To better appreciate the differing behaviour of the two controllers over the test period of weekly switching, several box plots were produced, as shown in Figure 8. As noted, the NH4 input ranges were about the same for both controllers (Figure 8(a)), and the thickness of the Low plot shows that the low loading was the most common situation. Conversely, Figure 8(b), 8(c), and 8(d) show that the effluent quality obtained by the EW controller was consistently lower than in the CC case, save for the output Ntot that was slightly higher in the Low input case, though this increase is hardly significant, and well within the limit. For the air flow, which is strictly related to the energy consumption, Figure 8(e) shows that under the EW controller management the aeration was consistently lower than in the CC case. Further, the wider box of the Low percentiles in the High input case indicates a net energy saving for the EW controller. This is also reflected in the lower DO values shown in Figure 8(f), particularly evident in the Low input case, when the CC produced a higher DO, with the risk of adversely affecting the sedimentation characteristics of the sludge.
Box plots of the controller performances over the period 10 June – 9 Sept. 2019. The band width represents the amount of data in the 5th, 25th, 50th, 75th, and 95th percentiles, while the mean value is represented by the white segment. (a) Distribution of input NH4; (b) distribution of output NO3; (c) distribution of output NH4; (d) distribution of Ntot; (e) distribution of air flow; (f) distribution of DO.
Box plots of the controller performances over the period 10 June – 9 Sept. 2019. The band width represents the amount of data in the 5th, 25th, 50th, 75th, and 95th percentiles, while the mean value is represented by the white segment. (a) Distribution of input NH4; (b) distribution of output NO3; (c) distribution of output NH4; (d) distribution of Ntot; (e) distribution of air flow; (f) distribution of DO.
CONCLUSIONS
This paper has described the design and field testing of the EW MPC based on neuro-fuzzy networks and heuristic search. Its main asset is the ability to predict the Ntot peaks sufficiently in advance (α >30 min) to adapt the air low and secure safe effluent standards while saving energy.
During the initial test, the two controllers (EW and CC) were alternatively engaged as shown in Figure 6. The flexibility of the EW controller is further demonstrated by comparing the average relative weights of the cost function Equations (2) and (3) in two periods with differing treatment requirements, as demonstrated in Figure 7.
Further tests obtained by alternating the two controllers on a weekly basis have confirmed the improved reliability of the EW controller in achieving a better effluent quality while conserving energy, particularly by decreasing the air flow during the low load periods, but also by limiting the oxidation during high load peaks, provided that the nutrients limit is never reached. In all cases, the effluent is kept well within the regulatory limit. This aspect is demonstrated in statistical terms in Figure 8, where the EW controller compares favourably to the previous scheme, being able to consistently shift the percentile plots towards lower values of each output indicator and of the air flow.
The system is presently in operation at the previously mentioned plant, where its testing against the conventional controller continues.
ACKNOWLEDGEMENT
The authors gratefully acknowledge the collaboration of HERA SpA for supporting this research and for consenting to the present publication.
DATA AVAILABILITY STATEMENT
All relevant data are included in the paper or its Supplementary Information.
















%20cropped.png?versionId=5508)