Predictive Control, a Strategy for Dissolved Oxygen Control in a Wastewater Treatment Plant

*Jose A. Muñoz Hernandez, Luis Eduardo Leguizamon and Helmer Muñoz Hernandez*

#### **Abstract**

This chapter presents a strategy for controlling the concentration of dissolved oxygen (DO) in the bioreactor of a pilot wastewater plant (WWTP). The control strategy being developed is model-based predictive control (MPC). To apply the control algorithm, the estimation of the oxygen transfer function (KLa) is first performed, then the model and linearization technique are determined and finally the MBPC controller is designed. The results are simulated in MATLAB® and executed in the plant control and supervision system Supervisory Control and Data Acquisition (SCADA) in LabVIEWTM. This chapter is organized as follows: Section 1 presents a brief introduction, and Section 2 determines and describes the model to be used and its respective linearization, as well as the results obtained for the KLa parameter. Finally, Section 3 describes the design methodology of the generalized predictive control (GPC) controller proposed by Clarke, using the Model Predictive Control Toolbox and the EPSAC strategy developed by De Keyser. It should be noted that the simulations in each of the sections were performed in MATLAB® and executed in the control and supervision system with the MATLAB® script interface in LabVIEWTM.

**Keywords:** predictive control, oxygen control, wastewater treatment plant, modeling, linearization

### **1. Introduction**

The WWTP treats water from a pipeline of a sector in a community, and the activated sludge used comes from the wastewater plant (WWTP) of a nearby residential complex. Its main objective is to serve as a didactic and experimental means for learning, simulation, and research in the area of control of this biological process. Oxygen transfer is an important factor for aerobic biological water purification processes; hence, the need to obtain a good estimation of this parameter. Consequently, this chapter discusses a strategy for the control of dissolved oxygen (DO). The proposed control strategy is the Model-Based Predictive Control (MPC). In this strategy, a model of the process is used to predict how the system will behave under a proposed sequence of control actions u(t). Traditionally, a linear model is used where an

optimal control action can be calculated; however, when nonlinear models are used in the algorithm, a numerical search algorithm is used to calculate an optimal sequence uopt(t).

#### **2. Process and modeling of wastewater systems**

In this part, the generalities of the process are described, and some techniques for obtaining important parameters in the modeling process of a wastewater treatment plant are proposed and a linear version of the ASM1 model is proposed.

#### **2.1 General concepts**

In the application of predictive control techniques based on models, it is necessary to have quality models; otherwise, you will have erroneous predictions and the control system will not be good. The predictions are carried out using a model of the process, with which the specification of a reference trajectory is obtained. De Keyser proposed some process models that can be used in the implementation of predictive control strategies (EPSAC Model) [1]. The output of the model can be seen in **Figure 1**.

**Figure 1** shows schematically the representation of the system taking into account the effect of noise n (colored noise), where the response to an input u can be obtained with the Eq. (1):

$$y(t) = x(t) + n(t) \tag{1}$$

The disturbance is represented by n(t) and corresponds to colored noise, a random signal that removes the offset. x is the result of the process model, while y corresponds to the measured value. The colored noise signal n(t) can be represented by Eq. (2):

$$m(t) = \frac{C(q^{-1})}{D(q^{-1})}e(t) \tag{2}$$

With, e(t): White noise (uncorrelated noise with zero mean value).

The transfer function (TF) between e(t) and n(t) describes the disturbance class and corresponds to the noise filter and is given by Eq. (3):

$$\frac{C(q^{-1})}{D(q^{-1})} = \frac{(1+cq^{-1})}{(1+dq^{-1})(1-q^{-1})}\tag{3}$$

The output of model x can be written as Eq. (4):

$$\mathbf{x}(t) = f[\mathbf{x}(t-1), \mathbf{x}(t-2), \dots, u(t-1), u(t-2), \dots] \tag{4}$$

**Figure 1.** *Process model representation.*

*Predictive Control, a Strategy for Dissolved Oxygen Control in a Wastewater Treatment… DOI: http://dx.doi.org/10.5772/intechopen.108816*

A special kind of EPSAC Model is the CARIMA Model [2]. This model links the process model and the disturbance model, as shown in Eq. (5):

$$\begin{aligned} A(q^{-1})y(t) &= B(q^{-1})u(t) + \frac{C(q^{-1})}{1 - q^{-1}} \\ y(t) &= \frac{B(q^{-1})}{A(q^{-1})}u(t) + \frac{C(q^{-1})}{A(q^{-1})(1 - q^{-1})} \\ y(t) &= \varkappa(t)u(t) + n(t)e(t) \end{aligned} \tag{5}$$

x(t) represents a pulse transfer function and B(q-1) and A(q-1) are given by Eq. (6):

$$\begin{aligned} B(q^{-1}) &= b\_1 q^{-1} + \dots + b\_{nb} q^{-nb} \\ A\left(q^{-1}\right) &= \mathbf{1} + a\_1 q^{-1} + \dots + b\_{na} q^{-na} \end{aligned} \tag{6}$$

The model can also be obtained using neural networks or Fuzzy modeling techniques. The model obtained for the wastewater treatment plant is presented below.

#### **2.2 Oxygen transfer function estimation, KLa**

In a wastewater treatment system, oxygen must be available at a rate equivalent to the oxygen demand load exerted by the wastewater entering the plant. The process consists of bringing the wastewater in contact with oxygen, transferring it across the gas-to-liquid interface to dissolve it in the liquid, and then transferring the dissolved oxygen through the liquid to the microorganisms. The dynamics of DO concentration change can be represented by Eq. (7):

$$\frac{d\text{So}}{dt} = K\_L a (\text{So}\_{sat} - \text{So})\tag{7}$$

where So is the dissolved oxygen concentration DO, Sosat is the oxygen saturation concentration, KL is the oxygen transfer coefficient, and a is the total interfacial contact area per unit volume of liquid. Since it is admittedly impossible to measure the interfacial area a, the total term KLa is estimated [3]. To obtain the KLa parameter, the integration, differentiation, and with oxygen consumption methods were initially used in transient regime [4], assuming negligible biomass concentrations, proceeding first to deoxygenate the wastewater, bringing the DO to a value close to zero. Then aeration is restarted, measuring the increase in DO concentration over time using the DO sensor. In **Figure 2**, it can be seen how the DO concentration increases at different airflow rates until reaching a steady state.

The determination of KLa with the integration method proposes to separate variables and integrate Eq. (7). Assuming that KLa does not depend on the sampling time, it is obtained Eq. (8):

$$\ln\left(\text{So}\_{\text{sat}} - \text{So}\right) = -K\_L \text{at} \tag{8}$$

With this equation, a straight line can be obtained from a semi-logarithmic graph (Sosat - So) as a function of time, where KLa is its slope, as shown in Eq. (9):

$$K\_L a = -\frac{\ln\left(C\_f/C\_i\right)^\*}{t\_f - t\_i} \text{ } \mathbf{60} \tag{9}$$

**Figure 2.**

*DO concentration. Left: Function on time. Right: Function on time and airflow.*

**Figure 3.** *Slope (-KLa). Left: Function on time. Right: Function on time and airflow.*

**Figure 4.** *KLa integration method.*

where ti and tf are the initial and final time selected for the slope, Ci = (Sosat - So) in ti and Cf = (Sosat - So) in tf. It is multiplied by 60 to convert from minutes to hours, when the samples have been taken in minutes. The results obtained can be seen in **Figure 3**. Here, it is observed that the greater the airflow, the greater the slope (KLa).

With these results, **Figure 4** shows the curve obtained from KLa, whose behavior resembles a first-order system.

The differentiation method is based on the difference of (Sof - So), where Sof is the last sampled OD data. KLa is obtained from Eq. 10:

$$K\_L a = \frac{d\left(\ln\left(\text{So}\_f - \text{So}\right)\right)^\*}{dt} \text{ 60} \tag{10}$$

*Predictive Control, a Strategy for Dissolved Oxygen Control in a Wastewater Treatment… DOI: http://dx.doi.org/10.5772/intechopen.108816*

The results are shown in **Figure 5**, where it is observed that the slope for the different levels of airflow can be obtained in the first 300 seconds, during which period the slope remains constant.

In a similar way, the KLa curve is obtained, as a function of the airflow, observing a behavior similar to that of a first-order system, as shown in **Figure 6**.

In activated sludge processes, when the wastewater under treatment has a significant concentration of microorganisms, it is necessary to take into account the oxygen consumption (respiration) [4], since the mass balance presented in Eq. (7) is affected as show in Eq. (11):

$$\frac{d\text{So}}{dt} = K\_L a (\text{So}\_{\text{sat}} - \text{So}) - R \tag{11}$$

where R is the rate of oxygen utilization (respiration rate). Then Eq. (11) can be written as Eq. (12):

$$\frac{d\text{So}}{dt} = (K\_L a \text{So}\_{\text{sat}} - R) - K\_L a \text{So} \tag{12}$$

Eq. (12) indicates that the derivative term dSo/dt as a function of So provides a straight line whose slope is equal to KLa and its cutoff point with the ordinate is (KLa. Sosat - R), value from which R can also be calculated. **Figure 7** shows the derivative

**Figure 5.** *Slope ln(Sof - So). Left: Function on time. Right: Function on time and airflow.*

**Figure 6.** *KLa differentiation method.*

**Figure 7.** *Slope (dSo/dt). Left: Function on time. Right: Function on time and airflow.*

**Figure 8.** *KLa oxygen consumption method.*

dSo/dt with respect to So, the value of KLa (slope), and the value of R (cutoff point on the ordinate).

**Figure 8** shows that the behavior of KLa as a function of the airflow obtained by this method also follows a dynamic similar to that of a first-order system.

The oxygen transfer function KLa describes the rate at which oxygen is transferred to the activated sludge by the aeration system. This function is nonlinear and depends on several factors, the main one being the airflow rate. Eq. (7) can be written as Eq. (13):

$$\frac{d\text{So}}{dt} = K\_L a \left( q\_A(t) \right) \left( \text{So}\_{\text{sat}} - \text{So} \right) \tag{13}$$

where qA(t) is the airflow rate entering the bioreactor. Here, it is assumed that KLa depends on the nonlinearity of the airflow rate. A typical function of KLa is shown in: **Figure 4**, **Figure 6**, and **Figure 8**, where it is observed that the slope of KLa changes when the airflow rate changes [3]. Based on the behavior of KLa observed in these figures, it can be assumed that it corresponds to a first-order system that can be represented by the differential equation, Eq. (14):

$$b\frac{dK\_L a\left(q\_A(t)\right)}{d\left(q\_A(t)\right)} + K\_L a\left(q\_A(t)\right) = a u\left(q\_A(t)\right) \tag{14}$$

*Predictive Control, a Strategy for Dissolved Oxygen Control in a Wastewater Treatment… DOI: http://dx.doi.org/10.5772/intechopen.108816*

where b is the time constant of the system, a is the gain of the system, and u(qA (t)) is the input of the system. Applying the Laplace transform to Eq. (14), the transfer function of the system is modeled with Eq. (15):

$$\frac{K\_L a(s)}{u(s)} = \frac{a}{bs + 1} \tag{15}$$

The step response of the system is obtained with of the inverse Laplace transform, as shown in Eq. (16):

$$K\_L a\left(q\_A(t)\right) = a\left(1 - e^{\frac{-q\_A(t)}{b}}\right) \tag{16}$$

The values of the parameters a and b are determined by identification using the Smith model [5]. In this model, it is proposed that the steady state gain a can be easily obtained from the graph of the step response of the system, while the system constant b corresponds approximately to the time in which 63.2% of the final steady state response is reached [6].

The gains (a) at steady state are determined to be 30.05, 61.38, and 61.66 for the integration, differentiation, and oxygen consumption methods, respectively. On the other hand, the constants of qA(t) are 1.386, 0.214, and 0.2042. These constants are calculated by linear interpolation or by a cubic spline. The identified models for integration, differentiation, and with oxygen consumption correspond to the following transfer functions, as shown in Eq. (17), Eq. (18), and Eq. (19):

$$\frac{K\_L a(s)}{u(s)} = \frac{30.05}{1.386s + 1} \tag{17}$$

$$\frac{K\_L a(s)}{u(s)} = \frac{61.38}{0.214s + 1} \tag{18}$$

$$\frac{K\_L a(s)}{u(s)} = \frac{61.66}{0.2042s + 1} \tag{19}$$

The verification of the models is performed by comparing the process signal (red) with the model signal (blue), as shown in **Figure 9**, in which it can be seen that there is a good tracking and consequently the error is low. The value of KLa is found by applying Eq. (16), for a given value of airflow qA(t).

**Figure 9.** *Transfer function KLa. Left: integration. Center: differentiation. Right: with oxygen consumption.*

**Figure 10.**

For data acquisition, supervision, and control of the WWTP, a Supervisory Control and Data Acquisition (SCADA) system is designed in LabVIEWTM [7]. The block diagram and the front panel of the virtual instrument (VI) in the control and monitoring system are shown in **Figure 10**.
