## 4 Application to WWTP
### Performance Indices  
The measures used to characterize the effluent quality and energy usage during the N-removal process are the standard performance indices recommended in the BSM1 platform for the evaluation of control strategies applied to WWTPs. The Effluent Quality Index \((EQ)\) that integrates the total amount of pollutants in the process with different weights depending on their severity, the Aeration Energy \((AE)\) and the Pumping Energy \((PE)\) are applied in this work.  
First of all, \(EQ\) (kg pollution/d) is considered as a direct and important indicator of the performance of the control systems as well as the entire wastewater treatment plant. For the BSM1, it is defined as a daily average of a weighted summation of the concentration of different compounds in the effluent over a certain time period as follow:  
\[\begin{split} EQ=&\frac{1}{1000T}\int_{t_{0}}^{t_{ 0}+T}(2 TSS_{e}(t)+COD_{e}(t)+30N_{tot,e}(t)\\ &+10S_{NO}(t)+2 BOD_{e}(t))Q_{e}(t)dt\end{split} \tag{52}\]  
Where for the model described in Section 4.1:  
\[\begin{split} COD_{e}&=(S_{S,e}+X_{B,Ae}+X_{B,He}) \ g/m^{3}\\ BOD_{e}&=0.25((1-0.08)+(1-0.08)(X_{B,A}+X_{B,H})) \ g/m^{3}\\ N_{tot,e}&=S_{NOe}+S_{NHe}+i_{xb}(X_{B,He}+X_{B,Ae}) \ g/m^{3}\\ TSS_{e}&=0.75(X_{B,Ae}+X_{B,He})\ g/m^{3}\end{split} \tag{53}\]  
In the above equation, \(TSS\) denotes total suspended solids and \(N_{tot}\) is the nitrogen total concentration in the effluent. The subscript 'e' indicates that those concentrations are associated with the effluent of the settler. The weighting factors of \(TSS_{e}\), \(COD_{e}\) and \(N_{tot}\), and \(BOD_{e}\) are adopted from [32]. The detailed expressions of these variables can be found in [33]. For the model considered in this work, it is assumed that the separation in the settler produces: \(X_{B,Ae}=0.0038.X_{B,A}\) and \(X_{B,He}=0.0038.X_{B,H}\).  
As for the energy consumption, the total average pumping energy expressed in kWh/d \((PE)\) over a certain period of time, \(T\), depends directly on the internal recirculation flaw rate \(Q_{a}\) and it is calculated as [34]:  
\[PE=\frac{0.04}{T}\int_{t_{0}}^{t_{0}+T}(Q_{r}(t)+Q_{a}(t)+Q_{w}(t))dt \tag{54}\]  
where \(Q_{r}\) denotes the return sludge flow rate and \(Q_{w}\) the excess sludge flow rate, both in units of m\({}^{3}\)/d.  
The aeration energy \((AE)\) in kWh/d required to aerate the last three comportments can in turn be written as:  
\[AE=\frac{24}{T}\int_{t_{0}}^{t_{0}+T}(0.4032K_{La}(t)^{2}+7.8408K_{La}(t))dt \tag{55}\]where \(K_{La_{k}}\) is the oxygen transfer function in the \(k\)th aerated tank in units of h\({}^{-1}\).  
The overall cost index (\(OCI\)) includes the pumping energy (\(PE\)) and the aeration energy (\(AE\)) denoted by \(f_{exo}\):  
\[f_{exo}=AE+PE \tag{56}\]  
In the current work, it has been preferred to not work directly with the overall effluent quality index as part of the cost function, because it involves several concentrations not available for measurement. Instead, here, it has been preferred to keep the two main variables of interest (oxygen and nitrate) around desired values, while attempting to keep effluent ammonia under the established limits.