Keywords

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

1 Introduction

Ammonia nitrogen removal is one of the most important processes in wastewater treatment plants (WWTPs). It is performed by microorganisms (referred to as biomass) in aerobic reactors in an activated sludge process. For normal operation a sufficiently high oxygen concentration has to be maintained at all times in the reactor by appropriate aeration. Aeration should be such that the effluent ammonia concentration (daily averaged or peak values) never exceeds the limit prescribed by legislation irrespective of the variable influent, changing weather and plant condition. At the same time, the lowest possible air consumption must be achieved [19]. The reasons are purely economic. According to a study [10], air consumption is responsible for more than 50 % of the total electrical energy consumed by the plant. For example, aeration costs at a WWTP designed for around 100,000 people can be more than €150,000 per year.

In most plants airflow is manipulated by cascade PI control, where the ammonia concentration in the last aerobic reactor is controlled in the outer loop and oxygen concentrations in the aerobic reactors are controlled in the inner loops [13, 29]. One problem with such a controller is that it generates actions on process input only when changes in the influent become visible in the last aerobic reactor. Since the process dynamics are slow, the control actions take a long time to bring the ammonia concentration back to the desired value.

A better way to control ammonia removal is to apply a model-based feedforward controller such that airflow is manipulated based on information from the influent ammonia. Hence, a change in the influent ammonia concentration causes an immediate response in the airflow. The solution requires the installation of an ammonia sensor on the influent, which is an economically acceptable solution owing to the fact that prices for such sensors have decreased in recent years. Research has shown that a feedforward controller can considerably reduce effluent ammonia peaks and airflow consumption [10, 12, 16, 31, 32, 34].

The question at issue is whether ammonia removal can be improved and air consumption reduced by using more elaborated control laws. A model predictive controller (MPC) is such an algorithm that has proved successful in many industrial applications. It utilises a process model to predict the process output and optimisation to calculate the optimal future control sequence. For example, in various studies [1, 8, 15, 21, 22, 27, 28, 35] MPCs with complex or reduced nonlinear mathematical models were proposed for ammonia, nitrate, or oxygen control in WWTPs, while in [3, 9, 11, 17, 23, 25, 28, 33] MPCs with a linear mathematical model were used.

Thus far, the above-mentioned model-based feedforward and MPC ammonia controllers have been tested mainly on simulated WWTPs. Despite extensive research, they are almost non-existent in real applications and their validation on real WWTPs is still needed.

The purpose of this chapter is to investigate what benefit could be achieved from model-based control algorithms for ammonia removal in the context of various performance criteria both in simulation and on a real plant. A further purpose is to inform the reader of the problems and limitations of applying advanced control to a real plant.

This chapter is organised as follows: In the following section, the validation of ammonia controllers on the WWTP benchmark model is presented. Then, the application of the ammonia controllers to a real pilot plant is shown. After that, the problems and limitations of applying the control theory in practice are described. Finally, some conclusions are drawn.

2 The Validation of Ammonia Controllers on the Benchmark Simulation Model

2.1 The Wastewater Treatment Plant Benchmark Simulation Model

The simulated WWTP used in this study was the benchmark simulation model No. 1 (BSM1) [4], which describes the common activated sludge process for organic and nitrogen removal [7]. The BSM1 has been developed by working groups within the EU COST Actions 624 and 682 for evaluating and comparing different control strategies for WWTPs. It defines the plant layout, simulation model, influent data, test procedures and evaluation criteria [4]. The layout of the BSM1 is shown in Fig. 5.1. It consists of one anoxic and four aerobic reactors. The volumes and default flow rates of the benchmark are given in Table 5.1.

Fig. 5.1
figure 1

Layout of the benchmark simulation model

Table 5.1 Benchmark volumes and flow rates

Organic compounds are merely removed in the anoxic reactor and to some extent also in the aerobic reactors. The removal of nitrogen compounds is performed in two steps. In the first step, ammonia nitrogen is removed in the aerobic reactors. This process is called nitrification. It occurs only if there is a sufficiently high amount of oxygen available. In the nitrification process nitrate nitrogen is produced, which is recycled back to the anoxic reactors by the internal recycle. In the second step, nitrate nitrogen is removed in the anoxic reactor. Removal of the nitrate nitrogen in the anoxic reactor is called denitrification. The process of denitrification is successful only if there is no oxygen. Wastewater treatment takes place only if the biomass concentration in the reactors is high enough. This is achieved by recycling biomass back from the settler to the reactors by the external recycle.

The biological processes in the reactors are modelled by means of the activated sludge model No. 1 (ASM1) [6]. The ASM1 model includes 13 nonlinear differential equations and 19 parameters. The secondary settler is modelled as a non-reactive, ten-layer process with the double exponential settling velocity model [30]. The settler model is described with 10 nonlinear differential equations and five parameters. The state vector of the BSM1 includes 15 variables: 13 ASM1 states, total suspended solids and flow rate.

The influent data of the benchmark includes 14-days of operation in different weather conditions, i.e., dry, rainy and stormy weather. In our case, dry weather influent data is used. The average influent flow rate for the dry weather data is 18446 m3/d.

The test procedure for evaluating the controllers is prescribed within the benchmark. First, the process has to be brought to a steady state by simulating the plant at the defined constant influent. Then, the simulation continues by applying one of the dynamic weather influent data. The performance of the benchmark is evaluated for the last seven days of simulation.

In our case, the control variables are oxygen transfer coefficients in the aerobic reactors (K L a 2, K L a 3, K L a 4 and K L a 5). Note that the air dosing into reactors in the BSM1 is not performed by air valves, but by directly manipulating the oxygen transfer coefficients K L a i (i=2,…,5). Other possible control inputs such as the internal recycle flow rate, external recycle flow rate and waste sludge flow rate were set to constant values (see Table 5.1). The controlled variables were the oxygen concentrations in the aerobic reactors (S O2, S O3, S O4, S O5) and the ammonia concentration in the last aerobic reactor (S NH5).

2.2 Feedforward-Feedback Control of Ammonia Nitrogen

The ammonia concentration in the last aerobic reactor can be controlled by cascade control (see Fig. 5.2). The outer ammonia controller determines the oxygen set-point in the aerobic reactors while the inner oxygen controllers maintain oxygen at the desired set-point by changing the airflows, in our case, K L a in the reactors [13, 29]. To reduce effluent ammonia peaks, the outer controller applies the feedforward term by using the influent flow rate and ammonia concentration as measurable disturbances. Such a feedforward-feedback ammonia control has been suggested by [10, 12]. In those studies, a reduced model derived from a complex ASM1 model [6] was used for the feedforward term. If we apply the reduced model and assume that all four aerobic reactors are considered as one aerobic reactor, the following equation for the ammonia removal rate holds approximately [32]:

$$\begin{aligned} \frac{dS_{\mathit{NH}5} ( t )}{dt} =& \frac{Q ( t ) ( S_{\mathit{NH}0} ( t ) - S_{\mathit{NH}5} ( t ) )}{V} \\&{}- \frac{\mu _{\mathit{Am}}X_{\mathit{BA}} ( t )}{Y_{A}}\frac{S_{\mathit{NH}5} ( t )}{ ( S_{\mathit{NH}5} ( t ) + K_{\mathit{NH}} )} \frac{S_{\mathit{O}} ( t )}{ ( S_{\mathit{O}} ( t ) + K_{\mathit{OA}} )} \end{aligned}$$
(5.1)

where Q is the total incoming flow rate (the sum of the influent and recirculated flow rates), V is the total volume of the aerobic reactor, S NH0 is the ammonia concentration in the total incoming flow, S NH5 is the ammonia concentration at the outlet of the aerobic reactor, X BA is the concentration of the autotrophic biomass in the aerobic reactor, μ Am is the maximum specific growth rate of the autotrophic biomass, Y A is the yield for the autotrophic biomass, K NH and K OA are the ammonia and oxygen half saturation constants and S O is the oxygen concentration in the aerobic reactor.

Fig. 5.2
figure 2

Plant layout with the ammonia feedforward-feedback control

The first term on the right-hand side of Eq. (5.1) represents ammonia transport and the second term the ammonia reaction rate. By considering model shown by Eq. (5.1) in a steady state, the following equation for the oxygen set-point can be derived:

$$ S_{\mathit{OsetFF}} ( t ) = \frac{K_{\mathit{OA}}}{\frac{X_{\mathit{BA}} ( t )VS_{\mathit{NH}5\mathit{set}}\mu _{\mathit{Am}}}{Q ( t ) ( S_{\mathit{NH}0} ( t ) - S_{\mathit{NH}5\mathit{set}} ) ( S_{\mathit{NH}5\mathit{set}} + K_{\mathit{NH}} )Y_{A}} - 1} $$
(5.2)

where S NH5set is the set-point for the ammonia concentration at the outlet of the aerobic reactor. In the feedforward term (5.2) the concentration of the autotrophic biomass is needed but it cannot be measured on line. Since this concentration changes slowly in practice, it may be determined by laboratory tests and entered into the controller as a constant. In our case, it is assumed that this concentration is known, whereas for the other parameters (μ Am , Y A , K NH and K OA ) the default values are used [4]. The values of the feedforward parameters are given in Table 5.2.

Table 5.2 Parameters of the feedforward controller

The feedforward control gives an approximate oxygen set-point in the reactor and hence should be used in combination with the slow feedback. The outer ammonia feedforward-feedback controller used in our case can be written as follows:

$$ S_{\mathit{Oset}} ( t ) = S_{\mathit{OsetFF}} ( t ) + \frac{K_{\mathit{pNH}}}{T_{\mathit{iNH}}}\int _{0}^{t} \bigl( S_{\mathit{NH}5\mathit{set}} - S_{\mathit{NH}5} ( \tau ) \bigr) \,d\tau $$
(5.3)

where K pNH is the proportional gain and T iNH is the integral time constant of the ammonia I controller. The oxygen concentration was controlled by inner PI controllers [2] changing the K L a in each reactor

$$\begin{aligned} &K_{L}a_{j} ( t ) = K_{\mathit{pO}} \bigl( S_{\mathit{Oset}} ( t ) - S_{\mathit{Oj}} ( t ) \bigr) + \frac{K_{\mathit{pO}}}{T_{\mathit{iO}}}\int _{0}^{t} \bigl( S_{\mathit{Oset}} ( \tau ) - S_{\mathit{Oj}} ( \tau ) \bigr) \,d\tau, \\&\quad j = 2, 3, 4, 5 \end{aligned}$$
(5.4)

where K pO is the proportional gain and T iO is the integral time constant of the oxygen PI controller.

By using the ammonia feedforward-feedback controller as described above, the oxygen set-point is the same in all four aerobic reactors.

At the outer and inner control outputs anti-windup protection was added in order to avoid long settling times caused by the limited set of feasible values of the control variables [20]

$$ u_{\mathit{AW}}(t) = \frac{1}{T_{i}}\int_{0}^{t} \bigl( u_{\mathit{lim}} (\tau ) - u(\tau ) \bigr)\,d\tau, $$
(5.5)

where

$$ u_{\mathit{lim}} ( t ) = \left \{ \begin{array}{l@{\quad}l} u_{\mathit{min}},& \mbox{if } u ( t ) < u_{\mathit{min}} \\u ( t ),& \mbox{if } u_{\mathit{min}} \le u ( t ) \le u_{\mathit{max}} \\u_{\mathit{max}},& \mbox{if } u ( t ) > u_{\mathit{max}} \end{array} \right . $$
(5.6)

The parameter T i is the integral time constant and the u min and u max are the lower and the upper limits of the control variable u.

The parameters of the PI controllers were tuned from step response experiments using the internal model control (IMC) tuning rules [19]:

$$\begin{aligned} K_{p} =& \frac{1}{K_{\mathit{pr}}} \end{aligned}$$
(5.7)
$$\begin{aligned} T_{i} =& T_{\mathit{pr}} \end{aligned}$$
(5.8)

where K pr is the process gain and T pr is the main process time constant. According to these rules, the proportional gain of the controller K p and the integral time constant T i are set equal to the inverse of the process gain and the process time constant, respectively. This approximately equalises the closed-loop time constant with the open-loop time constant and in most cases gives satisfactory results. The minimum and maximum values of the K L a in the reactors were set to the values defined in the BSM1, whereas the maximum value of the oxygen set-point S Oset was manually set to such a value to prevent over-aeration of the reactors. The values of the parameters of the PI controllers are given in Table 5.3. Note that the parameters of the PI controllers provide basic information about the gain and the time constant of the process.

Table 5.3 Parameters of the PI controllers

2.3 Model Predictive Control of Ammonia Nitrogen

The feedforward-feedback controller above uses a limited number of disturbances and dominant dynamics of the process. A question that arises is whether full information on the process disturbances and a more detailed process description can give a better response.

In order to answer this question, a nonlinear model predictive controller (MPC) of ammonia was designed and tested. The ideal process model was assumed, which means the plant BSM1 with perfect measurements was employed as the process model for the predictive controller design. Moreover, all influent disturbances were assumed to be known in advance over the future prediction horizon. The aim of this ideal setup was to investigate the upper limit of what can be achieved by ammonia control.

The control sequence of the MPC is calculated at each time step based on the set-point, a process model, measured disturbances and output [14]. The cost function used in our MPC can be written as follows [27]:

$$\begin{aligned} J ( k ) =& \sum_{i = 1}^{H_{p}} Q_{e} \bigl( \hat{y}(k + i) - r(k + i) \bigr)^{2} + \sum _{i = 1}^{H_{u}} R_{\Delta u}\Delta u(k + i)^{2} \\&{}+ \sum_{i = 1}^{H_{u}} R_{u} \bigl( u(k + i) - u_{0} \bigr)^{2} + \rho \sum _{i = 1}^{H_{p}} \varepsilon (k + i) \end{aligned}$$
(5.9)

where k denotes the sampling instants, \(\hat{y}(k+i)\) is the predicted output value, r(k+i) is the future set-point value, Δu(k+i) is the future input change, u(k+i) is the future input value, ε(k+i) is a slack variable which is non-zero only when the constraint is violated [14], H p is the prediction horizon, H u is the control horizon, Q e is a weight penalising the error between the predicted process output and the set-point, R Δu is a weight to penalise changes in the control signal, R u is a weight to penalise deviations of the future input from the desired steady-state value (u 0), while ρ is a weight to penalise soft constraint violations.

A cascade control scheme with the ammonia MPC is shown in Fig. 5.3. It is similar to that of the ammonia feedforward-feedback control (see Fig. 5.2). The only difference is that the ammonia MPC is used in the outer loop instead of the ammonia feedforward-feedback controller.

Fig. 5.3
figure 3

Plant layout with the ammonia MPC

The output and input of the ammonia MPC were the following:

$$ y = S_{\mathit{NH}5},\qquad u = S_{\mathit{Oset}} $$
(5.10)

where S NH5 is the ammonia concentration in the last aerobic reactor and S Oset is the oxygen set-point for the inner oxygen PI controllers. The MPC parameters, i.e., the prediction and control horizon and the weights, affect the closed-loop behaviour of the plant. In our case, MPC parameters were tuned based on process knowledge and tuning guidelines given in [14]. Since the dynamics of ammonia removal processes is on the time scale of hours, the prediction horizon was set to 1.5 h, which equals six time steps (one time step was 15 minutes). To simplify calculation of the input sequences, only one control move Δu was optimised at each sampling instant (H u =1), meaning that the control signal was assumed to be constant during the prediction horizon. The weight Q e was set to 10 so that a deviation of S NH5 from the desired set-point of 2 g/m3 was penalised. Other values were chosen according to Table 5.4.

Table 5.4 Parameters of the MPC controller

2.4 Comparison of the Ammonia Controllers Tested on the Simulation Benchmark Model

To determine how much can be gained from the control strategies, a comparison of the controllers was performed on the simulated process. The controllers described above were compared with the commonly used ammonia feedback cascade control which employs PI controllers in the outer and inner loops. The parameters of the outer ammonia PI controller were in this case the same as the parameters of the feedback part of the outer ammonia feedforward-feedback controller (see Table 5.3). The parameters of the oxygen PI controllers were the same in all cases. The chosen ammonia set-point S NH5 set at the outlet of the aerobic reactors was set to 2 g/m3.

Note that the comparison of the controllers is not completely objective because the parameters of the controllers were set by using different tuning rules and guidelines and considering different performance criteria. Nevertheless, we assumed that such comparison still provides the reader with the most important differences in control performance.

A comparison of the ammonia controllers for four days of operation under the dry weather influent is shown in Fig. 5.4. Note that the influent data are prescribed by the benchmark. They include typical variations of the influent flow rate and concentrations during the dry weather period.

Fig. 5.4
figure 4

Comparison of ammonia feedback control (the blue solid line), ammonia feedforward-feedback control (the black dashed line) and ammonia MPC control (the red dotted line)

The performance of the controllers was evaluated according to the legislated criteria used. In most countries upper limits for daily averaged effluent values or for effluent peak values are prescribed. Therefore, averaged ammonia concentrations and ammonia peaks in the last reactor were used as performance criteria. Average K L a values in the reactors were also calculated in order to estimate the air consumption. Note that the K L a values are proportional to the air consumption in the reactors. Values of the performance criteria are shown in Table 5.5.

Table 5.5 Performance criteria of the validated ammonia controllers by simulation

In the upper diagram of Fig. 5.4 the influent ammonia mass flow rate is shown. This represents a measurable disturbance to the plant. It can be seen that the disturbance changes by up to 300 % during the day. Such huge changes have a large effect on the ammonia concentration in the last reactor. Controllers can attenuate disturbances up to some extent, but cannot completely remove them mainly because of the limitations in the actuators.

All the controllers involved demonstrate very similar performance with regard to the average ammonia obtained in the last reactor (see Table 5.4). If nothing is important other than the fact that the daily averaged effluent ammonia is below a certain limit, then all the controllers do the job equally well. However, assessment criteria should always include air consumption (average K L a in reactors) and in this light a significant difference between the controllers exists. With the feedforward-feedback controller about 9 % lower and with the MPC about 7 % lower air consumption was achieved in comparison with the feedback controller.

From the point of view of the ammonia peaks obtained in the last reactor, a large difference between the controllers can be observed. If effluent ammonia peaks have to be below a certain limit, then much better performance can be obtained with the MPC and slightly better with the feedforward-feedback controller than with the feedback controller. At the same time, much lower air consumption is needed. But it has to be noted that the MPC controller in our case uses the ideal process model and provides too optimistic results.

3 Application of Ammonia Controllers to the Pilot Plant

In order to test the performance of ammonia controllers in a real environment, we applied them to the large-scale pilot plant in the Domžale–Kamnik WWTP. Note that controllers cannot be tested on the pilot plant in the same form as they were used in the simulation. As will be shown, they have to be simplified and properly accommodated when applied to a real plant.

3.1 Description of the Pilot Plant

Testing of the controllers was done on the pilot plant with moving bed biofilm reactor technology (MBBR). In this technology biomass is attached to the small free-floating plastic carriers that are added into the reactors [18]. Consequently, much lower concentrations of the suspended solids are obtained in the liquid in comparison with the conventional suspended biomass technology. Therefore, a smaller sludge settler can be used and the external recycle can be omitted. However, higher oxygen concentrations are needed in the aerobic reactors to obtain successful ammonia removal, because oxygen has to diffuse into biofilm. The pilot plant consists of two anoxic reactors, two aerobic reactors, the non-aerated fifth reactor and a settler. A photo of the pilot plant is shown in Fig. 5.5, the scheme of the pilot plant equipped with sensors is presented in Fig. 5.6 and the volumes and the flow rates of the pilot plant are given in Table 5.6.

Fig. 5.5
figure 5

Photo of the pilot plant

Fig. 5.6
figure 6

Scheme of the pilot plant equipped with sensors

Table 5.6 The pilot plant’s volumes and flow rates

In the pilot plant’s aeration system, the total airflow into the aerobic reactors can be manipulated. Half of the total airflow goes into the first and the other half into the second aerobic reactor. Mixers are installed in the anoxic reactors to maintain mixing, while the aerobic reactors are mixed by airflow. The influent of the pilot plant is wastewater after mechanical treatment. The influent flow rate is kept constant to fix the hydraulic retention time of the pilot plant.

Several sensors are installed on the pilot plant for monitoring and control purposes, i.e., an airflow sensor (Q air ) that measures the total airflow into the aerobic reactors, an oxygen sensor in the last aerobic reactor (S O4), two ammonia sensors, one in the last aerobic reactor (S NH4) and the other in the pilot plant influent (S NHin ), a wastewater temperature sensor (T), etc. All sensors were serviced for maintenance purposes at least once per week to ensure normal operation.

3.2 Feedforward-Feedback Control of Ammonia Nitrogen

The ammonia feedforward-feedback control scheme tested on the pilot plant was different from the one used on the benchmark model. One difference was that an additional airflow controller was used in the cascade structure. Another difference was that the ammonia feedforward controller used a simple linear model in contrast to the nonlinear feedforward controller applied in the simulation. This is so because the nonlinear feedforward controller used in the simulation includes various variables which are hard to measure in practice, and it is therefore difficult to implement on a real plant. The cascade control scheme of the ammonia feedforward-feedback control tested on the pilot plant is shown in Fig. 5.7 [34].

Fig. 5.7
figure 7

Control scheme of the ammonia feedforward-feedback control tested on the pilot plant

The outer ammonia PI controller determines the oxygen set-point in the last aerobic reactor (S O4set ) from the difference between the desired (S NH4set ) and the measured ammonia concentration in the last aerobic reactor (S NH4). The oxygen set-point is maintained by the oxygen PI controller that calculates the airflow set-point (Q airset ) from the difference between the desired oxygen concentration and the actual oxygen concentration in the last aerobic reactor (S O4). The airflow set-point is maintained by the inner airflow PI controller that adjusts the air valve.

Since the inner oxygen PI control is much faster than the outer ammonia PI control, disturbances that appear inside the oxygen concentration process are quickly compensated for. The inner airflow PI control is much faster than the outer oxygen PI control, which improves disturbance rejection inside the aeration system. The inner airflow PI control also linearises the nonlinear characteristic of the air valve.

In all control loops the discrete version of the linear PI controller with the anti-windup protection which was used in the simulation is applied [2]

$$ u ( k ) = K_{p} \Biggl( e ( k ) + \frac{T_{s}}{T_{i}}\sum _{j = 1}^{k} e ( j ) \Biggr) - \frac{T_{s}}{T_{i}}\sum _{j = 1}^{k - 1} \bigl( u ( j ) - u_{\mathit{lim}} ( j ) \bigr), $$
(5.11)

where

$$ u_{\mathit{lim}} ( k ) = \left \{ \begin{array}{l@{\quad}l} u_{\mathit{min}},& \mbox{if } u ( k ) < u_{\mathit{min}} \\u ( k ),& \mbox{if } u_{\mathit{min}} \le u ( k ) \le u_{\mathit{max}} \\u_{\mathit{max}},& \mbox{if } u ( k ) > u_{\mathit{max}} \end{array} \right . $$
(5.12)

Parameter K p is the proportional gain of the controller, T i is the integral time constant, T s is the sampling time, e is the control error (the difference between the set-point and the measured value of the controlled variable), and u min and u max are minimum and maximum values of the manipulated variable. The first term on the right-hand side of Eq. (5.11) represents the PI algorithm, and the second term the anti-windup protection.

In order to obtain good performance with the described ammonia cascade controller it is necessary to select minimum and maximum airflow set-point limits, which are realisable with the inner airflow PI controller. The limit value of the oxygen set-point u NHlim in the ammonia PI controller was calculated as follows [20]:

$$ u_{\mathit{NH}\mathit{lim}} ( k ) = u_{\mathit{NH}} ( k ) - \frac{u_{\mathit{O}} ( k ) - u_{\mathit{O}\mathit{lim}} ( k )}{K_{\mathit{pO}}} $$
(5.13)

where u O is the airflow set-point calculated by the oxygen PI controller, u Olim is the limit value of the airflow set-point, and K pO is the proportional gain of the oxygen PI controller. The oxygen set-point limits depend on the airflow limits. The oxygen set-point is limited between the lower and upper limits, which change according to the airflow limits.

The proposed feedforward control changes the oxygen set-point only proportionally to the influent ammonia concentration. The influent flow rate is not included as a measurable disturbance because the pilot plant operates at a constant influent flow rate.

The proposed ammonia feedforward-feedback controller calculates the oxygen set-point as a sum of the feedforward and PI controls

$$ u ( k ) = u_{\mathit{FF}} ( k ) + u_{\mathit{PI}} ( k ) $$
(5.14)

where u FF is the output of the ammonia feedforward controller and u PI is the output of the ammonia PI controller. In our case, the feedforward controller was implemented with a linear first order model, which was realised in the discrete form [24]

$$ u_{\mathit{FF}} ( k ) = \biggl( 1 - \frac{T_{s}}{T_{\mathit{FF}}} \biggr)u_{\mathit{FF}} ( k - 1 ) + \biggl( \frac{K_{\mathit{FF}}T_{s}}{T_{\mathit{FF}}} \biggr)S_{\mathit{NHin}} ( k - 1 ) $$
(5.15)

where S NHin is the ammonia concentration in the influent, K FF is the gain, T FF is the time constant of the feedforward controller and T s is the sampling time. The feedforward controller uses only two parameters, which can be tuned manually, and is therefore very appropriate for practical implementation.

The parameters of the PI controllers were first calculated from step response experiments using internal model control (IMC) tuning rules [19] (see Eqs. (5.7)–(5.8)). To ensure non-oscillatory performance of the controllers the proportional gains were manually reduced and the integral time constants were increased. The gain of the feedforward controller K FF was manually adjusted by a trial and error procedure, whereas the feedforward time constant T FF was set to the estimated delay of the ammonia transport in the pilot plant. The minimum and maximum values of the total airflow were selected with due care to prevent clogging of the plastic carriers in the reactors due to too low or too high airflow.

Measurements of the oxygen concentration in the last aerobic reactor (S O4) contain significant noise. Noise in the oxygen measurement can be attributed mainly to the imperfect mixing of reactors. In our case, noise was reduced by filtering the measurement of the oxygen concentration with the first order filter

$$ S_{\mathit{O}4\mathit{f}} ( k ) = \biggl( 1 - \frac{T_{s}}{T_{f}} \biggr) S_{\mathit{O}4\mathit{f}} ( k - 1 ) + \biggl( \frac{T_{s}}{T_{f}} \biggr) S_{\mathit{O}4} ( k - 1 ) $$
(5.16)

where S O4f (k) is the filtered oxygen concentration at the current sampling instance, S O4f (k−1) is the filtered oxygen concentration from the previous sampling instance, S O4(k−1) is the oxygen measurement from the previous sampling instance, T f is the filter time constant and T s is the sampling time. The filter time constant T f was manually set to a value high enough to ensure substantial noise reduction. The values of the parameters of the controllers are given in Table 5.7.

Table 5.7 The parameters of the controllers

3.3 Model Predictive Control of Ammonia Nitrogen

The control scheme of the ammonia MPC tested on the pilot plant was similar to that of the feedforward-feedback control scheme, except that the ammonia MPC was used in the outer loop. The control scheme of the ammonia MPC applied on the pilot plant is shown in Fig. 5.8 [35].

Fig. 5.8
figure 8

Control scheme of the ammonia MPC tested on the pilot plant

The MPC tested on the pilot plant was different from that tested in the simulation. The main difference was that the MPC tested on the pilot plant used a simplified process model and a limited number of measured disturbances, while the MPC tested in the simulation applied an ideal process model and all disturbances were assumed to be known. Another difference is that a reduced cost function was used in the MPC algorithm.

3.3.1 Mathematical Model of the Ammonia Nitrogen for Model Predictive Control

A good mathematical model is essential for predictive control of ammonia nitrogen. Various models have been used thus far, for example linear models [25, 28, 33], reduced nonlinear models [1, 8, 22], fuzzy models [15], etc.

In our study a reduced nonlinear model of ammonia nitrogen similar to the one proposed in [26] was used. The model was additionally simplified by merging the first and second anoxic reactors into a single anoxic reactor, and the first and second aerobic reactors into one aerobic reactor. Hence, the reduced nonlinear model consists of three nonlinear differential equations:

$$\begin{aligned} \frac{dS_{\mathit{NH}2} ( t )}{dt} =& \frac{1}{V_{12}}Q_{\mathit{in}} ( t )S_{\mathit{NHin}} ( t ) + \frac{1}{V_{12}}Q_{\mathit{int}} ( t )S_{\mathit{NH}5} ( t ) \\&{} - \frac{1}{V_{12}} \bigl( Q_{\mathit{in}} ( t ) + Q_{\mathit{int}} ( t ) \bigr)S_{\mathit{NH}2} ( t ) \end{aligned}$$
(5.17)
$$\begin{aligned} \frac{dS_{\mathit{NH}4} ( t )}{dt} =& \frac{1}{V_{34}} \bigl( Q_{\mathit{in}} ( t ) + Q_{\mathit{int}} ( t ) \bigr) \bigl( S_{\mathit{NH}2} ( t ) - S_{\mathit{NH}4} ( t ) \bigr) \\&{}- r_{\mathit{NH}} \biggl( \frac{S_{\mathit{NH}4} ( t )}{K_{\mathit{NH}} + S_{\mathit{NH}4} ( t )} \biggr) \biggl( \frac{1}{1 + e^{ - K_{\mathit{OA}1}S_{\mathit{O}4} ( t ) + K_{\mathit{OA}2}}} \biggr)\varTheta ^{ ( T ( t ) - 20^\circ )} \\ \end{aligned}$$
(5.18)
$$\begin{aligned} \frac{dS_{\mathit{NH5}} ( t )}{dt} =& \frac{1}{V_{5}} \bigl( Q_{\mathit{in}} ( t ) + Q_{\mathit{int}} ( t ) \bigr) \bigl( S_{\mathit{NH}4} ( t ) - S_{\mathit{NH}5} ( t ) \bigr) \end{aligned}$$
(5.19)

The model variable S NH2 represents the ammonia concentration at the outlet of the second anoxic reactor, Q in is the influent flow rate, Q int is the internal recycle flow rate, S NHin is the influent ammonia concentration, S NH4 is the ammonia concentration at the outlet of the second aerobic reactor, S NH5 is the ammonia concentration at the outlet of the fifth reactor, S O4 is the oxygen concentration in the second aerobic reactor and T is the wastewater temperature. Model parameter V 12 is the volume of the combined anoxic reactors, V 34 is the volume of the combined aerobic reactors, V 5 is the volume of the fifth reactor, r NH is the nitrification reaction rate parameter, K NH is the ammonia half-saturation coefficient, K OA1 and K OA2 are the parameters of the exponential switching function and Θ is the temperature coefficient.

The anoxic reactors as well as the fifth reactor were not aerated, hence only ammonia transport processes were modelled. In aerobic reactors an exponential function was used to model the ammonia reaction rate instead of the commonly used Monod function. An exponential function was applied to get a better description of the reaction rate limitation at lower oxygen concentrations in the biofilm [26]. The model shown in Eqs. (5.17)–(5.19) describes the relationship between oxygen and ammonia concentrations in the pilot plant.

The differential equations of the reduced mathematical model were discretised using the Euler method before use in the MPC algorithm. A sampling time of 5 minutes was considered small enough since the order of magnitude of the time constant of ammonia removal processes is in hours. An additional time delay of two hours was introduced at the output of the model shown in Eqs. (5.17)–(5.19). Hence, we compensate for the delay between the peaks of the measured and modelled ammonia concentrations caused by delayed response of the ammonia sensor. The reason is that the sensor was not located in situ but in the laboratory building close to the pilot plant reactors. A time delay significantly reduces the performance of ammonia control.

The values of the flow rates and volumes that were used in the model were taken from the project documentation and are given in Table 5.8.

Table 5.8 Values of the flow rates and volumes used in the reduced nonlinear model

Our mathematical model is nonlinear in unknown parameters; hence their values can be estimated from measurements only by applying some optimisation technique. Since some model parameters are not identifiable from the plant measurements, the kinetic parameter Θ has to be tuned manually, whereas the parameters r NH , K NH , K OA1 and K OA2 can be tuned by an optimisation algorithm so that the best fit in the least-squares sense is achieved between the model and the measurements. In our case, a gradient optimisation algorithm with constraints was used to tune the parameters. The values of the estimated parameters are given in Table 5.9.

Table 5.9 Values of the kinetic parameters of the reduced nonlinear model

The model parameters were estimated using the data from 8 days of pilot plant operation. The comparison between modelled and measured ammonia concentrations in the last aerobic reactor during the validation period is seen in Fig. 5.9. The modelled ammonia follows the measured ammonia in the last reactor poorly. An offset between the modelled and measured ammonia of around 1 g/m3 can be also observed. This offset was not so visible when the model was calibrated because the ammonia concentration was not controlled and its values were much higher. However, offset is not a problem in our case because it can be compensated for inside the controller. In the middle of the validation period a large peak in the measured ammonia occurred which cannot be seen in the modelled ammonia. The reason for that was the failure of the influent ammonia sensor, which caused the ammonia model to be fed with different influent ammonia than the pilot plant. It can be noticed that the measured and simulated ammonia concentrations do not start from the same initial value. This is so because only the last part of the validation period is shown.

Fig. 5.9
figure 9

Comparison between modelled and measured ammonia concentrations in the last aerobic reactor

The mean relative squared error of the obtained model was large and similar to that presented in [26], i.e., around 50 %. There are different reasons for such poor model accuracy. One is that various process disturbances that also have a strong impact on ammonia removal (i.e., soluble substrate concentration, nitrate nitrogen concentration), are not included in the model because they were not measured at the plant. Another reason is that the model structure and parameter values are not accurate. The model can be improved, for example, by estimating unmeasured disturbances and including them in the model. Another possibility is to slowly adjust the model parameters, such as r NH , to compensate for the slow changes in the process [26]. However, the model is nonlinear in parameters and the adjustment of its parameters cannot easily be made. Note that none of the mentioned approaches are simple and they do not warrant a substantial improvement in the model.

4 The Model Predictive Control Algorithm

Once the mathematical model of the plant is available, the structure and values of the parameters of the control algorithm have to be defined. The operation of the ammonia MPC algorithm used is shown in Fig. 5.10. At every sampling instance the ammonia nitrogen (S NH4) is predicted for the finite prediction interval by using the model described above. The MPC calculates the oxygen set-point (S O4set ) along the prediction interval. A reduced cost function was used in the MPC by considering only the difference between the predicted and set-point ammonia concentrations (S NH4set ) at the end of the prediction interval. Furthermore, only a single oxygen set-point move is calculated inside the prediction interval, i.e., a constant oxygen set-point within the prediction interval is considered. Its value is constrained within a limited range. These two presumptions simplify the optimisation problem significantly. By taking a long enough prediction interval, the relation between the oxygen set-point and the ammonia concentration is a monotonically decreasing function. Hence, a simple bisection method can be applied to solve the optimisation problem. The bisection optimisation ends as soon as a change in the manipulated variable in the last iteration is smaller than some defined value. Another simplification used was that measurable disturbances (the concentration of the influent ammonia and temperature of the wastewater) are assumed to be constant for the whole prediction interval.

Fig. 5.10
figure 10

Operation of the ammonia MPC algorithm

The mathematical model used has a large model error. This error can be compensated for to some extent by estimating the unmeasurable disturbance using a constant output disturbance model. The unmeasurable disturbance \(\hat{d} ( k )\) can be calculated at each sampling instance k as (following [5])

$$ \hat{d} ( k ) = y ( k ) - \hat{y} ( k ) $$
(5.20)

where y(k) and \(\hat{y} ( k )\) are measured and modelled ammonia concentrations, respectively, in the last aerobic reactor at sampling instance k. The unmeasurable disturbance \(\hat{d} ( k )\) is added to the predicted model output at every sampling instance. In this way the steady-state control error is compensated for and feedback control is incorporated into the predictive controller [5].

However, a constant output disturbance model can result in too high control gain, especially when the process model has a large error [5]. This can lead to the unstable operation of the controller. The controller’s gain can be reduced by filtering the unmeasurable disturbance

$$ d_{f} ( k ) = K_{f} \cdot d_{f} ( k - 1 ) + ( 1 - K_{f} ) \cdot d ( k - 1 ) $$
(5.21)

where d f (k−1) is the filtered unmeasurable disturbance from the previous sampling instance, K f is the constant of the filter and d(k−1) is the unmeasurable disturbance from the previous sampling instance. The filtered unmeasurable disturbance d f (k) is added to the predicted model output at every sampling instance.

Note that a constant output disturbance model was not applied in the simulation since a perfect model of the process was used.

The ammonia MPC includes several control parameters that have to be properly tuned. These parameters are: the sampling time T s , the prediction interval P, the constant of the model error filter K f , the maximum oxygen set-point change at sampling time instance ΔS O4max and the minimum and the maximum values of the oxygen set-point, S O4min and S O4max , respectively.

The prediction interval P was set to a high value of 12 hours (144 samples of 5 minutes). Oscillations of the control signal can be reduced with such a high prediction interval. Other parameters of the ammonia MPC were manually tuned so that satisfactory control performance was obtained. Values of the parameters of the oxygen and airflow PI controllers were the same as in the ammonia feedforward-feedback control described above. The parameter values of the ammonia MPC are given in Table 5.10.

Table 5.10 Values of the parameters of the ammonia MPC

4.1 The Experimental Environment for Testing the Ammonia Nitrogen Controllers

The required experimental environment needed to test the ammonia controllers is shown in Fig. 5.11.

Fig. 5.11
figure 11

The experimental environment for testing the ammonia controllers

This environment is based on MATLAB®, which was running at the Jožef Stefan Institute (JSI) and was linked on-line through the Internet to the existing control system at Domžale–Kamnik WWTP. For this purpose, a VPN (Virtual Private Network) connection was established between the JSI and the Domžale–Kamnik WWTP. On-line real plant data were accessed by MATLAB through the MATLAB-OPC server connection. The OPC server (OLE for Process Control) was implemented at Domžale–Kamnik WWTP and provided information on the pilot plant data on a PLC (Programmable Logic Controller) level. The MATLAB-OPC server connection was established by OPC for MATLAB software from IPCOS (http://www.ipcos.be/). Calculations were performed by MATLAB in real time. The airflow controller was realised in the PLC while all other controllers were implemented in MATLAB. The calculated process variable was the airflow set-point, which was sent every 20 seconds to the OPC server at the Domžale–Kamnik WWTP and from there to the PLC.

4.2 Comparison of the Ammonia Controllers Tested on the Pilot Plant

The ammonia feedforward-feedback controller and ammonia MPC described above were compared with a commonly used ammonia feedback controller. The parameters of the ammonia feedback controller were the same as those in the feedback part of the ammonia feedforward-feedback controller (see Table 5.7).

During the testing period the daily average of influent ammonia did not change much (there were no rain or other special conditions) and the wastewater temperature was around 15 °C the whole time. The set-point for the ammonia controllers was set to 1 g/m3.

The results of testing different ammonia controllers are shown in Figs. 5.12 to 5.14. The variables shown are different from those presented in the simulation (compare with Fig. 5.4). The influent ammonia concentration instead of the influent ammonia mass flow rate is shown and the total airflow rate instead of the K L a value is presented.

Fig. 5.12
figure 12

Results of the ammonia PI controller

It can be seen that the inner oxygen and airflow PI controllers follow the corresponding set-points very accurately. In the case of feedforward-feedback control, the ammonia concentration is maintained close to the desired value (see Fig. 5.13) in spite of considerable changes in the influent ammonia concentration.

Fig. 5.13
figure 13

Results of the ammonia feedforward-feedback controller

The MPC successfully controls the ammonia concentration in the last aerobic reactor at the selected set-point (see Fig. 5.14), except for the short interval in the middle of the testing period when the influent ammonia sensor failed. During this interval the MPC was out of operation and the dissolved oxygen set-point concentration was kept constant at the last calculated value. A peak in the ammonia in the last aerobic reactor occurred as the oxygen concentration was too low. When the influent ammonia sensor measurement was restored, the MPC reduced the ammonia peak by rapidly increasing the oxygen-set point to the upper limit.

Fig. 5.14
figure 14

Results of the ammonia MPC

The performance of the applied controllers was evaluated by calculating different performance criteria addressing ammonia removal and air consumption. In the evaluation of the ammonia MPC the period when the influent ammonia sensor failed to work was not considered. The values of the performance criteria are given in Table 5.11.

Table 5.11 Performance criteria of the validated ammonia controllers on the pilot plant

All the controllers provided a similar average ammonia concentration in the last aerobic reactor. This means that if performance had to be judged only from the achieved average effluent ammonia, then all the controllers tested did the job equally well. If, at the same time, air consumption is also considered, the difference between the controllers immediately becomes apparent. Compared to the feedback controller, with the feedforward-feedback controller it takes 29 % less air to remove a kg of ammonia. Though not that high, the reduction obtained by MPC is still significant, i.e., about 15 %. This shows that a certain amount of energy savings can be achieved on a yearly basis if more advanced control is used. Furthermore, if penalties on effluent ammonia peaks were introduced, the distinction between the controllers becomes even more apparent. Significantly lower ammonia peaks could be obtained with the ammonia feedforward-feedback controller and MPC.

The ammonia feedforward-feedback controller and ammonia MPC give better results than the ammonia feedback controller because they use an additional measurable disturbance of the influent ammonia. Surprisingly, poorer results were obtained with the ammonia MPC than with the ammonia feedforward-feedback controller. This shows that a greater improvement in ammonia removal could be achieved by applying feedforward action based on measurable disturbances than by applying a more complex MPC algorithm.

One possible explanation for the poorer performance of the MPC could be associated with the insufficient accuracy of the reduced nonlinear model of the ammonia nitrogen. The less than expected performance of the MPC could be explained by the fact that only one input and one output of the process was used. An advantage of the MPC is normally expected when multiple process inputs and outputs are used. Thus, better results are expected when both ammonia nitrogen and total nitrogen are controlled. Potential improvements in the ammonia MPC are also to be expected by upgrading the control criteria from the control error at the end of the prediction interval to the sum of all the square control errors inside the prediction interval.

The above results were obtained during a relatively short period of operation and are used as an indication of what the potential of different control strategies might be. The controllers were also evaluated under different influent conditions, which influence the comparison. A longer testing period is needed for a more reliable evaluation of controllers.

5 Problems and Limitations in Applying the Theory

When advanced controllers are applied to a real plant various problems limit their performance:

  • Model inaccuracy. Models used for the control of activated sludge processes are usually not very accurate. This can be attributed to the bio-chemical processes of the activated sludge, which are complex and time-varying and therefore it is very hard to find a proper model structure and obtain adequate model parameter values. Because of the model inaccuracy, the feedback gain of the controller should be significantly reduced.

  • Unmeasurable disturbances. Various disturbances, i.e., the soluble bio-degradable substrate, inert substrate, active biomass, etc., which have a strong impact on the bio-chemical process, cannot be measured on-line at a real plant. An accurate process model cannot be obtained and the process cannot be properly controlled without knowing all the important disturbances. Therefore, estimation of unmeasured disturbances at the real plant can be of great importance.

  • Sensor failures. Sensor failures are quite common in real plants, especially with the sensors used for feedforward control. This is so because these sensors are located in the initial stages of the plant, which are subject to more polluted wastewater. Therefore, controllers applied to a real plant should always use some sort of sensor failure detection algorithm.

  • Imperfect measurements. Measurements of the variables in real plants commonly contain significant noise and time delay. Such noise can be attributed to the imperfect mixing of reactors, whereas the time delay can be attributed to the fact that sensors are usually not located in situ but in a laboratory removed from the reactors. Measurements at the real plant should be filtered before they are used for control. The control parameters should be properly adjusted due to the measurement time delay.

  • Design effort. Advanced controllers are more demanding as regards implementation in a real plant. The reason for this lies in the fact that they require a nonlinear process model and in most cases a complex optimisation algorithm to calculate the control sequence. Modelling of the activated sludge process is a very time-consuming process. An appropriate model structure is difficult to obtain and optimisation techniques have to be used to estimate unknown model parameters. Once the model is available, an optimisation algorithm has to be applied to calculate the control sequence. The optimisation algorithm should be robust enough to provide a feasible solution at every sampling instance. In order to ensure this, various limitations on the control variables should be imposed.

6 Conclusion

The aim of this chapter was to investigate what can be gained with model-based ammonia controllers in terms of various performance criteria in simulation and on a real wastewater plant. The simulation results indicate that the feedforward-feedback controller and ammonia MPC result in reduced air consumption in comparison with the feedback controller while achieving the same or better ammonia removal. The application of ammonia controllers to the pilot plant confirmed that the ammonia feedforward-feedback controller and MPC give better results than the ammonia feedback controller. The main reason for this lies is the fact that they use the additional measurable disturbance of the influent ammonia. Surprisingly, the ammonia MPC gave poorer results than the feedforward-feedback controller at the real plant. The explanation for this could be associated with the various limitations in applying a more complex MPC in a real environment.