Design of Feedback Control Strategies in a Plant-Wide Wastewater Treatment Plant for Simultaneous Evaluation of Economics, Energy Usage, and Removal of Nutrients

Simultaneous removal of nitrogen and phosphorous is a recommended practice while treating wastewater. In the present study, control strategies based on proportional-integral (PI), model predictive control (MPC), and fuzzy logic are developed and implemented on a plant-wide wastewater treatment plant. Four combinations of control frameworks are developed in order to reduce the operational cost and improve the effluent quality. As a working platform, a Benchmark simulation model (BSM2-P) is used. A default control framework with PI controllers is used to control nitrate and dissolved oxygen (DO) by manipulating the internal recycle and oxygen mass transfer coefficient (KLa). Hierarchical control topology is proposed in which a lower-level control framework with PI controllers is implemented to DO in the sixth reactor by regulating the KLa of the fifth, sixth, and seventh reactors, and fuzzy and MPC are used at the supervisory level. This supervisory level considers the ammonia in the last aerobic reactor as a feedback signal to alter the DO set-points. PI-fuzzy showed improved effluent quality by 21.1%, total phosphorus removal rate by 33.3% with an increase of operational cost, and a slight increase in the production rates of greenhouse gases. In all the control design frameworks, a trade-off is observed between operational cost and effluent quality.


Introduction
The increase in the global population and urbanization has emanated in an increase in the use of water and therefore in the production of contaminated water (wastewater). This causes the effect of the water cycle and generates disorder in natural functioning. The intensification of the demand for clean water with deficient water resources has eventually resulted in a growing interest towards resource recovery during the treatment of wastewater. It is perceived that valuable resources like clean water, energy, and nutrients can be recovered from wastewater [1]. This leads to the progression of wastewater treatment plants (WWTP) into a water resource recovery facility (WRRF) [2]. Modelling and control of WWTPs generated a lot of interest among the wastewater community to increase flexibility and reduce the costs while operating WWTPs. WWTP's are intricate because of chemical and biological interactions in between the processes, the peculiar nature of microbes, a disorder of concentrations, and dynamic rates of flow [3,4]. Among all the benchmark simulation models, BSM1-P is a platform with a defined plant layout, bioprocess models (activated sludge models (ASM)), influent loads, sensors, and actuators. Hence, BSM1-P platform allows unbiased comparison of carbon, nitrogen, and phosphorus removal in activated sludge control strategies [5,6]. Based on the models of WWTPs, plant-wide models take the attention of researchers for a long time run as the whole plant is understood by considering all process interactions [7][8][9]. Different plant-wide models are studied in the literature, which includes sludge control approaches, biogas production in primary settler, handling of the anaerobic digester, and phosphorus modeling with interactions of sulfur and iron cycles [10][11][12][13][14][15][16][17]. In the literature, many control applications like fuzzy logic controller (FLC), model predictive controller (MPC), proportional-integral (PI), and ammonia-based aeration control (ABAC) with different hierarchical combinations of PI, MPC, and fuzzy were studied, and it is observed that there is a trade-off between operational cost and effluent quality [18][19][20][21]. Maheswari et al. (2020) designed the nested control loop on three-stage biological treatment for ammonia changes and they observed that Effluent Quality Index (EQI) is improved with higher operational costs [22]. Shiek et al. (2021) implemented an ammonia-based aeration control (ABAC) with four different combinations of controllers like PI-MPC, MPC-MPC, PI-fuzzy, and MPC-fuzzy, which resulted in a tradeoff between Operational Cost Index (OCI) and EQI. In their study, the ammonia removal rate was improved by 18% in the case of MPC-MPC but P removal was not affected much [23].
Based on the benchmark simulation model on the plant-wide model (BSM2), different control applications like PI, artificial neural network (ANN), and sludge-based strategies, hierarchal control approaches are reported [24,25]. It was reported that the application of FLC improves EQI by 8% and reduces the aeration energy consumption up to 13%. Revollar et al. (2020) implemented a cascade strategy by using PI control with DO and ammonia on the BSM2 platform, and they noticed a 9% improvement on operational cost [26]. Barbu et al. (2017) implemented controllers for DO, ammonia, and TSS (total suspended solids) on the BSM2-G (greenhouse gas emission) platform, and as a result, an improved EQI of 11% and reduced OCI of 7.7% were achieved [27]. Supervisory control approaches on BSM2 are developed with different combinations of PI, MPC, and fuzzy, and it was found that PI-MPC showed a reduced OCI of 6.7%. Similarly, PI-fuzzy provided an improved EQI of 9.2% [28]. Even though many researchers designed control approaches based on BSM2, controllers design based on BSM2-P is limited. The benchmark simulation model (BSM2-P) is an integrated version of BSM1-P that includes both water and sludge treatment process units [29] and BSM2. In the BSM2-P framework, PI-based controlling DO in the sixth reactor and cascade PI in the control of ammonia and total suspended solids were developed and it was found that OCI and EQI are in the trade-off. Closed-loop control showed an improved result when compared with open-loop operation [30]. Sludge management strategies like bio-solids beneficiation facility (BBF) are studied to improve solubility, sludge dewaterability, and handle high sludge loads with change in the microbial population [31].
To the best of the authors' knowledge, advanced hierarchical control strategies are not implemented on the BSM2-P plant level layout to improve effluent quality and operational costs. On this note, the present work focuses on implementing advanced hierarchical control strategies based on MPC, fuzzy controllers; and the plant performance is evaluated by developing different control approaches. A lower-level control strategy is developed for DO control in the sixth reactor by manipulating the K L a of the fifth, sixth, and seventh reactors in the biological treatment process. PI controller is used at the lower level, whereas fuzzy and MPC are used at the supervisory level. The supervisory level is based on the ABAC to determine the dissolved oxygen set-point. EQI; OCI; percentage of nutrient removals; and production rates of methane, carbon dioxide, and hydrogen are studied while evaluating the control strategies.

Materials and Methods
This section provides an explanation of the working regime of BSM2-P with details of the performance/economy assessment and indices. Model creation and simulation are performed using MATLAB/SIMULINK.

Influent Data
Model-based influent load generation as elucidated in [2,32,33] is used to generate dynamic influent load data to execute the performance of plant-wide scenarios of the wastewater treatment plants. The daily average dynamic mass flow rates are provided in Table 1. More information about the handling of influent generation is illustrated in [15,34,35]. Dynamic simulations are performed for 609 days with steady-state simulation for 300 days. S:COD is the ratio of added sulphate [2]. The last 1-year data are used for performance assessment of the plant. State variables of ASM2d, units with notations, and average influent data are reported in the Supplementary data Table S1.

Model Scenario
The plant-wide model of BSM2-P has a resemblance to BSM2 plant [9] but a modification is carried out in the activated sludge unit (ASU). In ASU, two anaerobic reactors are added ahead of anoxic and aerobic reactors (A 2 /O) to enhance phosphorus removal and to improve PAO's with a competitive dominance over other nitrogenous bacteria. The plant-wide model of BSM2-P consists of ASU, primary (PSU) and secondary (SSU) sedimentation units, Thickener (THK), anaerobic digestion (ADU) unit, storage (SU), and dewatering (DU) unit, with internal and external recycles. Figure 1 depicts the plant-wide model of BSM2-P and Table 2 represents each process unit of WWTP of BSM2-P with their working function and physical configurations. The internal recycle is maintained at three times the influent data, and sludge flow is at the rate of 600 m 3 /d.  The Effluent Quality Index (EQI) defines the amount of effluent to surface waters averaged over the assessment time interval related to the weighting factors of discharge loads of composition. The EQI (kg pollutants units/D) [2,7] is integrated with additional phosphorus process reactions, and the pollution composition with individual variables is illustrated below: The subscript 'ef' indicates the effluent discharge. θ i signifies the weighting factors of different pollutants to convert into basic pollution units, which are tabulated in Table 3. i COD i denotes the COD compounds, i N i denotes the nitrogen compounds, i P i denotes the phosphorus compounds, T signifies the total assessment time interval (364 days), and Q ef denotes the discharge flow rate (m 3 /d). The corresponding conversion factors for f i are reported in [2,5,32,41]. All the concentrations are addressed in g/m 3 units. Operational cost is a weighted summation of costs associated with the production of sludge (SP) (kg ss/d), methane (PM) (kg.CH 4 /d), pumping (PE), aeration (AE), mixing (ME), and heating (HE) energies (KWh/d); internal and external recycles are provided (m 3 /d). All individual components are addressed in [2,7]. Thus, the OCI is estimated as where z i denotes the weighting factors; z PS is 3 and z PM is 6. Aeration, pumping, and mixing energies are addressed in Equations (10), (11) and (13). Here, aeration power is needed to aerate bioreactors; pumping is used to alter the flow rate from one end to another end and for internal, external flow patterns [2,7].
The aeration energy (AE) is described as (kWh/d): where K L a i signifies the oxygen mass transfer coefficient, V i notifies the volume of the reactors and oxygen saturation coefficient. T is the length of evaluation time (364 days). The pumping energy (PE) is defined as (kWh/d): where Q intr is the internal recycle (m 3 /d), Q exr is the external recycle (m 3 /d), Q w is the waste flow (m 3 /d), Q PU is the primary clarifier underflow, Q TU is the thickener underflow, and Q DO is the dewatering overflow. The sludge production (SP) is expressed as (kg/d): Where Q X (t) is the sludge flow and TSS X is the total amount of solids in the sludge flow stream (after dewatering in BSM2-P). X TSS is elucidated as the sum of TSS mass present in an individual process unit. The subscripts refer to the concern process units.
The mixing energy (ME) is defined as (kWh/d): The mixing is highly necessary to avoid the biomass settling in the non-aerated and aerated reactors like all ASU tanks; anaerobic digester and the mixing energy (ME) is defined as (kWh/d): ME = ME ASU + ME ADU (13) where where, V i is the ith tank volume (m 3 ) and 0.005 kW/m 3 is the mixing power consumption factor in ASU. V ADU is the volume of liquid in ADU and the mixing power consumption factor 0.005 kW/m 3 . Methane production (kg CH 4 /d) is defined as: The average methane production per day value is defined by using Equation (14).
where, P gCH4 (bar) is the partial pressure of methane gas produced in the headspace; R denotes the universal gas law constant i.e., 8.3145.10 −2 bar m 3 kmol −1 k −1 ; T OT represents the operating temperature of the digester (308.15 K); P tg is the total gas pressure in the headspace; P atm is atmospheric pressure (1.013 bar); and Q g is the gas flow rate of produced gas. Net heating energy is described as: where HE is the amount of energy required to get the anaerobic digester up to operating temperature, as shown in the below Equation (16): Where, P H2O is the density of water (1000 kg/m 3 ), C H2O is the specific heat capacity of water (4.186 KJ kg −1 0 C −1 ). T ad,i is the temperature of ADU influent, and T OP is the optimal temperature of ADU. Q ad is the flow rate to the ADU (m 3 /d).
Following stringent regulations is a top priority for wastewater treatment plants. The legal constraints to be followed are the same as BSM1, i.e., TP is less than 2 gP/m 3 ; TN is less than 18 gN/m 3 ; biological oxygen demand (BOD 5 ) is less than 10 g/m 3 ; COD is less than 100 gCOD/m 3 ; TSS is less than 30 g/m 3 ; and S NH is less than 4 gN/m 3 .

Design of Proportional-Integral (PI) Controller
The PI controllers can be framed using a wide variety of techniques accessible in the literature. In the present work, the Skogested internal model control (SIMC) method is used to design the PI controllers [44]. The first-order plus time order delay (FOPTD) model as prescribed in Equation (17) is identified for the design of the PI controllers for each loop.
where, K P denotes the process gain, θd denotes the delay, and τ p signifies the time constant of the system. For more clarification, the method of approach is depicted in the flow diagram in the Supplementary data Figure S1. The identification method and designed controllers are elucidated distinctly. Figure S2 depicts the PI controller in the wastewater flow diagram.

Design of Model Predictive Controller (MPC)
MPC is a well-known advanced controller in which the objective is to predict the future move of the variable of significance and by using optimization, the corresponding control moves are determined systematically. At each control time interval, MPC predicts the nature of the variables of outputs over the prediction horizon (P). The control move sequence is computed over the control horizon (M) based on output predictions [23,45]. A quadratic cost function (Q) is selected for the operation of MPC, which is defined in the mode of Equation (18).
Here, Γ L and Γ ∆v denotes the input and output rate weights respectively. L(A + l/A) is the controlled variable output at the future time interval of A + l, where the model is predicted at a particular time of A. The identification method and designed controllers are elucidated distinctly. Figure S3 depicts the MPC controller in the wastewater flow diagram. The third order state-space model of the system as shown in Equations (19) and (20) is as below: x Here x(A) signifies the state of vector, and G, N, S, and Z denote the state-space matrices.

Design of Fuzzy-Logic Controller (FLC)
Fuzzy logic is a widely used tool in a variety of control applications. FLC's have been used in all stages of wastewater treatment processing. According to the literature, the most advanced control and processing units in WWTP are solved using fuzzy control or rule (FLC). This is achieved by employing fuzzy rules that are identical to those used in human inference design. FLC is used on the WWTP in this study [19,23]. Figure S4 depicts the FLC controller in the wastewater flow diagram.

Results and Discussion
Implementation of control strategies on plant wide-models: The results after implementing all the four control strategies are discussed here.

PI Control (2 Loops)
In ASU, S O,7 , in the last aerobic tank (tank7), and S NO,4 , in the second reactor of anoxic (tank 4), are controlled. The corresponding input variables are mass transfer coefficient (K L a) and internal recycle (Q intr ). The set points are chosen according to the requirements of the WWTP. Usually, the value of S O,7 in the oxic reactor is retained in the range of 1.5 to 4 gO 2 /m 3, and the practiced value is 2 gO 2 /m 3 . Similarly, the advisable working values for the nitrate levels in the anoxic tank are in the range of 1-3 gN/m 3 and the practiced value is 1 gN/m 3 [21]. The corresponding control relevant models are developed using the attained open-loop data for each S NO,4 and S O,7 control loops. For the values of 88,000 and 73, the concentrations of NO and DO are reported as 2 gO 2 /m 3 and 1 gN/m 3 respectively. In the seventh and fourth reactors, a random input signal with a ±10% variation in these values is given and the attained output data for NO and DO are collected. The NO and DO output data are now used to build state-space models and also first-order plus time order delay (FOPTD) models using the method of prediction error minimization. Based on these models, each loop is equipped with PI controllers that are designed using SIMC [44]. The respective obtained FOPTD model parameters are: NO loop: K P = 0.000026144, τ p = 0.012515, and θ d = 0.000875. DO loop: K P = 0.04538, τ i = 0.010085, and θ d = 0.
Based on these models, PI controllers are designed using the SIMC method and are obtained for NO and DO loops like K c =35748.16, T i = 0.01215, K c =11.015, and T i = 0.010085 respectively. With these controllers, the plant-wide model is simulated and the corresponding simulation results are given in Section 4.4. The resultant tracking performance of S O and S NO is depicted in Figure 2A,B. The default control approach associate with two control loops is shown in Figure 3A.

PI Control (One Loop)
In this approach, a close-loop control framework contains a single PI controller as shown in Figure 3B. According to this scheme, S O in the sixth tank is maintained at a setpoint of 2 mgO 2 /l by regulating the K L a 6 . In addition, the oxygen mass transfer coefficients entering tank 5 and tank 7 are multiplied by a factor of 1 and 0.5, respectively, to have improved manipulation and thus efficient aeration in these tanks [30].

Ammonia-Based Aeration Control (ABAC) Approach
In this approach, cascade configuration, as shown in Figure 3C, is used, in which MPC/Fuzzy controllers for ammonia (S NH,6 ) control are used by manipulating S O,6 set point in the aeration tank 6. Here, S O,6 in aeration tank 6 is controlled by regulating the airflow rates of reactors 5, 6, and 7 as implemented in strategy 2. PI controller is designed at the lower level with combinations of fuzzy and MPC at the supervisory level. PI-MPC and PI-fuzzy combinations are proposed as overall control structures. The corresponding list of all four different control approaches is listed in Table 4.

PI-MPC Control Strategy
Here, PI controller is implemented for BSM2-P at the lower level and MPC is implemented in the supervisory layer. To design MPC in the supervisory layer, system identification of the model in the supervisory layer is carried out. In which, the S O set-point is varied by ±10% around the operating point, and the resulting S NH concentration values are collected. The prediction error method is used to identify a third order state-space model based on this data set [46]. The identified state-space model for the supervisory layer is expressed below Equation (21)

PI-Fuzzy Control Strategy
In this case, the fuzzy controller manipulates the S O set-points at a supervisory layer to minimize ammonia peaks. The membership functions (MF) of S O,6 and S NH,6 are considered in the range of 0-4 mg O 2 /l and 0.1-20 mg N/l, respectively. The MF's for both input and output variables are in a Gaussian bell-shaped curve, which is divided into three linguistic variables, "high," "low," and "medium," as shown in Figure 5A,B. A total of three rules are considered according to the S O control loop requirement [23,28].

•
If S NH level is "low", then S O level is "low" • If S NH level is "high", then S O level is "high" • If S NH level is "medium", then S O level is "medium" The corresponding linguistic variables for "high," "low," and "medium," are given in Table 5. With these controllers, closed-loop simulations are carried out and the results are given in Figure 5C. It can be observed that a good supervisory set-point tracking is achieved by using the PI-fuzzy controller design framework. The effluent quality and operational cost details along with other quantitative results are given in Section 4.4.

Comparison of Four Control Design Frameworks on BSM2-P
Nitrification oxidizes ammonium to nitrate, and denitrification reduces nitrate to nitrogen gas. Then a high DO improves nitrification, but an excess of nitrate perhaps is not fully denitrified in the anoxic reactors due to a lack of COD. Moreover, phosphorous removal is largely influenced by dissolved oxygen, which is directly proportional to the formation of orthophosphates. The effluent concentrations of ammonia, TN, TP, and TSS are compared for all four control frameworks with their corresponding pollutant limit value. These are depicted in Figure 6A-D.  Based on the simulation results of all four control designs [PI controllers (two loops), PI controller (one loop), PI-MPC at supervisory level, and PI-fuzzy at a supervisory level], the corresponding average values of effluent concentrations are given in Table 6. From Table 6, comparing with only lower-level controllers, the ammonia, TP, TSS, and TN removal concentrations are improved. For ammonia, TP, TSS, and TN, the removal efficiency is improved by 36%, 33.6%, 1.02%, and 11.3% in PI-MPC, PI-fuzzy, PI (one loop), and PI (two loops) respectively.    Figure 6E depicts the average values of energy usages like aeration, pumping, mixing, heating, consumed energies (kwh/d), and sludge production rate (kg ss/d). From the graph, it was observed that energy consumption was high in the case of PI-MPC and low in the case of the PI-fuzzy controller. The sludge production rate and heat energy are high with the PI-fuzzy controller. In comparison, the fuzzy controller shows less aeration energy to obtain better nutrient removal with a slight increase in the cost. In the literature, also it was showed that the fuzzy control is favorable for better removal of phosphorous. In comparison, PI (one loop) and PI-fuzzy showed an improved EQI of 21.1% with a 0.52% increase in OCI. In the comparison of all four control strategies, there is a trade-off between OCI and EQI. Overall, in comparison with the PI (one loop) controller, ammonia removal is improved with PI-MPC, and TP is improved with PI-fuzzy strategies. In both cases, PI-MPC and PI-fuzzy showed improved EQI with an increase of OCI. The corresponding greenhouse gases like methane, hydrogen, and carbon dioxides of averages production rates are also reported in Table 6. It is noticed that PI-fuzzy shows high methane, hydrogen, carbon dioxide, and gas flow production rates of 28.7%, 4.87%, 6.8%, and 3.2% in comparison with PI (one loop). PI-fuzzy and PI-MPC showed good improvement in minimizing the percentage of violations in TP and ammonia. The percentage of violations is also reported in Table 6. PI-fuzzy showed good removal efficiency in the phosphorus. Moreover, PI-fuzzy showed lower OCI when compared with PI-MPC.

Summary of Previous and Present Studies on BSM2-P
For the biological seven-reactor A2O process, different control frameworks have been designed [47,48]. Optimal set-points are computed by higher-level control loops [49,50]. In [30] used BSM2-P as a simulation platform. PI controllers are designed to control DO by regulating the oxygen mass transfer coefficient with additional aeration-based ammonia controller and TSS control by regulating the external recycle. The control strategy showed significant improvement in both effluent quality and operating costs. The designed controllers showed improved EQI of 31% with decreased OCI of 6.9% when compared with open loop. As far as pollutant concentration is concerned, TN and TP are improved by 17% and 42.1% respectively.
In the present work, an ammonia-based aeration controller at the supervisory level is designed. By using two different control combinations, PI-MPC and PI-fuzzy, the performance is compared with [30] PI-fuzzy showed improved EQI of 13.5% with an increase of 13.6% OCI. Phosphorus and TN removal are improved by 29.7% and 5.4%, respectively, with the PI-fuzzy control framework and produce better EQI. PI-fuzzy shows a high production rate of methane when compared to [30].

Conclusions
In this study, MPC and fuzzy were designed at the supervisory level, and PI was designed for lower-level control for BSM2-P in ASM2d as an activated sludge model. A total of four control frameworks were implemented to evaluate and test the plant performance, concentrations, as well as effluent quality. The resultant performance indices were compared with the PI strategy. In each control application case, there was a trade-off between EQI and OCI. In comparison with PI (one loop), PI-fuzzy showed an improved EQI of 21.1% with a 0.52% increase in OCI. Of all the compared outcomes, PI-fuzzy showed better EQI and increased OCI. When comparing all four control strategies, it was reported that average effluent pollutant concentrations like BOD 5 , COD, TN, ammonia, and TSS attained the regulatory limits, except for phosphorus. Optimized ammonia removal was noticed in PI-MPC, whereas better optimized phosphorous removal was noticed in PI-fuzzy. PI-fuzzy showed high production rates of greenhouse gas emissions and low consumption of aeration energy. The percentage of violations of total phosphorus was less in the case of PI-fuzzy.
Supplementary Materials: The following are available online at https://www.mdpi.com/article/ 10.3390/en14196386/s1, Figure S1: Systematic procedure for model identification and control implementation, Figure S2: A simple PI controller in WWTP, Figure S3: Model Predictive Controller scheme in WWTP, Figure S4: A classical Fuzzy controller in WWTP, Table S1: State variables of ASM2d, units with notations, and average influent data.  Acknowledgments: Xavier Flores-Alsina, Senior Researcher, Denmark Technical University, Denmark, is acknowledged for sending the BSM2-P Matlab/Simulink codes.

Conflicts of Interest:
The authors declare no conflict of interest.