Real-Time Implementation of an Expert Model Predictive Controller in a Pilot-Scale Reverse Osmosis Plant for Brackish and Seawater Desalination

: This article addresses the design and real-time implementation of an expert model predictive controller (Expert MPC) for the control of the brackish and seawater desalination process in a pilot-scale reverse osmosis (RO) plant. This pilot-scale plant is used in order to obtain the optimal operation conditions of the RO desalination process through the implementation of di ﬀ erent control strategies, as well as in the training of operators in the new control and management technologies. A dynamical mathematical model of this plant has been developed based on the available ﬁeld data and system identiﬁcation procedures. Predictions of the obtained model were in good agreement with the available ﬁeld data. The designed Expert MPC is distinguished by having a plant identiﬁcation block and an expert system. The expert system, using a rule-based approach and the evolution of the plant variables, can modify the plant identiﬁcation block, the plant prediction model, and / or the optimizer in order to improve the performance, robustness and operational safety of the overall control system. The real-time comparison results of the designed Expert MPC and a well-designed model predictive controller (MPC) show that the proposed Expert MPC has a signiﬁcantly better performance and, therefore, higher accuracy and robustness.


Introduction
Water scarcity has become a progressively growing problem worldwide due to the accelerated increase in water demand, which is expanding nowadays at a rate never seen before in any previous time [1][2][3][4][5]. Therefore, the effective management of water resources is a challenge to face the complexity of the real problem [6][7][8][9].
Currently, to solve the growing global demand for freshwater, the desalination of brackish and seawater is being used [10][11][12]. Desalination is a powerful and hopeful technology for obtaining freshwater, and in many countries with scarce water resources, represents the only solution [13][14][15].
Desalination is a water treatment process that removes salt and other minerals from brackish and seawater to make them suitable for human consumption and/or industrial and agriculture use [16]. Water with salinity less 500 mg/L is adequate for human use [17]. The desalination process essentially separates saline water into two streams-one that has a low salt concentration (permeated flowrate, or product water), and the other with a higher salt concentration than the original feed water (brine flowrate, or simply concentrate) [18]. The seawater desalination is an energy-intensive consumption process [19][20][21][22][23].
There are two main possibilities to obtain desalted seawater: (a) thermal processes and (b) membrane processes [17]. However, membranes-based processes are the most energy-efficient option [24]. Consequently, reverse osmosis (RO) desalination method has become as one of the essential technologies for the commercial desalination industry, as well as the most commonly used approach to increase the provision of freshwater around the world [25]. Thereby, brackish and seawater RO desalination plants are quickly increasing in the world [26].
Seawater RO desalination plants need an effective controller to increase their performance, as well as to keep their operations close to the optimum conditions, which results in higher efficiency, along with extending the lifetime of their membranes [27][28][29]. Nevertheless, the effective control of these plants is not a simple assignment and has several challenges, among which are: (a) the dynamic processes in the membrane vessels are complex and cannot easily be modelled; (b) for the operation of the high-pressure pump, a large amount of energy is required; (c) the feed seawater features variations can considerably change the performance of the RO membrane units, which leads to lower water production, deficient system operations, membranes fouling or irreversible membranes damages; (d) the high-pressure setpoint has to be increased several times a day for compensation of the membranes fouling effect and to bring the permeate flowrate back to its operation value, which usually is done manually by plant operators; (e) continuous monitoring of membranes fouling is required to determine the appropriate time for membranes flushing (cleaning in place by chemical detergents is applied when membrane flushing is not sufficient to recover the good membranes performance); and (f) the operators of these plants are trained by conventional methods that only enable them to maneuver the infrastructures and not to control and manage these plants efficiently [30][31][32]. In addition, these plants have uncertainties, multivariable coupling, load disturbances, and dynamics dependent on the operation conditions, since a few of their parameters, such as the membrane permeability, are time-varying due to membranes fouling [33][34][35].
Membranes fouling result from the accretion of undesirable particles inside or around the membranes [36]. The impact of this unavoidable process has undesirable consequences on the performance of the RO desalination plants: a decrease in permeate flowrate production for constant operating pressures, or increase in the feed flowrate, which involves expensive pre-treatments, higher operating pressures, and prevalent chemical cleanings that can damage the membranes, decrease the permeate quality, and reduce the replacement time of membranes [37]. Moreover, the dynamic process parameters obtained after cleaning are different from the dynamic parameters existing before cleaning [35]. Consequently, the costs of water and energy consumption grow [17]. As seawater RO desalination plants turn more complex, the control theory allows the estimation of uncertainties, the determination of risks and safety measures, and the design of robust and reliable control systems [38][39][40].
For the critical variables' control of the seawater RO desalination plants, diverse controllers have been developed. These controllers are mainly: conventional [41][42][43], feedforward [37], optimal [28,44], adaptive [35], model predictive [45][46][47][48], fractional order [49], or robust [32,[50][51][52]. In these plants, the most implemented controller is the proportional integral derivative (PID), owing to the fact that many process engineers are much more familiar with this class of controller than with sophisticated advanced controllers, due their functional simplicity, which allows them to operate in a straightforward mode [53,54]. Moreover, it is well-known that in diverse industrial processes, the PID controllers show good performance, robustness, and simple implementation [55,56]. However, when the seawater RO desalination plants are characterized by time-varying dynamic behaviors, the PID controllers are not sufficient and fail to provide satisfactory performance [32,35,45].
To overcome the shortcomings of PID controllers, a number of advanced controllers have been developed over the last decades, for example the model predictive controller (MPC) [57]. The MPC is an industry-accepted controller for advanced control of processes with complex dynamical behaviors, which, in comparison to the PID controller, is considered a better tool based on many studies reported in the literature, see e.g., Ref. [58]. However, the MPC has not been intensively used in the automation of RO desalination plants, and only few contributions regarding this class of controllers can be found in the literature [46].
The MPC has some practical problems; for example, it requires a precise model of the plant to be controlled, which in many cases is difficult to obtain [57,58]. Usually, the MPC performs well initially, but as the plant dynamics change with process operating conditions, its performance usually deteriorates, see e.g., Refs. [35,45,49]. Linear time-invariant multivariable models are used in the MPC design of the RO desalination plants, although it is well-known that these plants are time-varying multivariable systems; therefore, the required control performance is very difficult to achieve over a reasonable range of operating conditions, see e.g., Refs. [33,45,46,48].
Artificial intelligence is one of the newest fields in science and engineering, which has provided successful solutions to many problems that are extremely difficult to be solved by traditional mathematical approaches, and it constitutes a powerful tool for control of complex dynamical processes [59][60][61]. In particular, the research field of knowledge-based systems has received a lot of attention; see e.g., Refs. [61,62]. The knowledge-based systems are defined as systems in which some symbolic representation of human knowledge is applied, usually in a way very similar to human reasoning. In this class of systems, the expert systems have been the most successful and those that have grown most rapidly nowadays [63,64].
An expert system is a software system that emulates the decision-making ability of human experts within a specific well-defined domain of knowledge to solve actual convoluted problems in this domain [64]. If these systems are designed to emulate the knowledge of human experts in the development of control operations, they are called expert controllers [65]. The reasons for using the expert systems in the process control are that there are some operational problems that can be solved more efficiently by heuristic or rules of thumb [65]. Therefore, expert controllers have been fruitfully applied to solve complex engineering problems, as well as for the control of industrial processes with time-varying parameters, nonlinearities, uncertainties, etc., see e.g., Refs. [66][67][68][69][70][71]. An important argument for applying expert controllers is the decrease of the effort required to effectively execute the control laws. This is because expert controllers support many of the functions usually achieved by operators and control engineers [65]. Consequently, the expert systems tools and techniques allow for the design of industrial controllers to be more accurate and effective than conventional ones [65]. Moreover, in recent years, expert controllers are being successfully applied in the water industry, because the solution of diverse control problems in this industry requires the knowledge and experience of the best specialists in this field, see e.g., Ref. [72].
In Ref. [73], for effective control of a seawater RO desalination plant of a mineral processing facility, an adaptive expert-generalized predictive multivariable controller was proposed. However, the main drawbacks of this controller are: The architecture of the used expert system is unknown; the knowledge base is not developed; and the real-time implementation of the designed controller in a real seawater desalination plant was not performed, so it has not been possible to evaluate its effectiveness. Note that the real-time implementation of an Expert MPC for the control of a seawater RO desalination plant is a challenging task because it requires the solution of different theoretical and practical problems.
This paper proposes the design of an Expert MPC for effective control of the critical variables of the brackish and seawater RO desalination plants and its real-time implementation in a pilot-scale RO desalination plant. The control of this pilot-scale plant is relevant since its dynamics closely resemble the dynamics of the real seawater RO desalination plants. Note that the dynamic behavior of the seawater desalination plants varies significantly when their operating conditions change due to membranes fouling, which makes the design of accurate controllers very difficult.
This paper is organized as follows. Section 2 gives a brief description of the pilot-scale RO desalination plant and presents the proposed plant dynamic model. In Section 3, the design of the Expert MPC is developed. Section 4 shows the discussions of the obtained results. Finally, Section 5 gives some conclusions.

System Identification of the Pilot-Scale Seawater RO Desalination Plant
The pilot-scale RO desalination plant considered in this paper is installed in the Control and Automation Laboratory of the Pontifical Catholic University of Peru, located in Lima. This installation is used in the development of research related to the design and implementation of new controllers, as well as in the preparation of personnel trained in the operation of RO processes, control, optimization, monitoring, fault detection, and management of brackish and seawater desalination commercial plants. Figure 1 shows a view of this plant, which in order to prevent water losses, the water flows inside the plant in a closed loop system; therefore, it does not have energy recovery devices and the post-treatment stage is not necessary. The schematic representation of Figure 2 shows the different components of this pilot-scale setup, which are: the pre-treatment system, the high pressure feed pump, the RO membranes rack, the brine and permeate tanks, and the storage and mixing system of the permeate and brine flowrates, that is integrated by the mixing valve, the feedback pump and the storage tank. The pre-treatment system is integrated by the feed pump, the UV filter, the multimedia filter, the active carbon filter, the fine filter, and the two additives tanks. The high-pressure feed pump is of the stainless steel model with variable pressure of up to 50 bar. This pump is connected to a speed variator that controls the inlet pressure to the RO membrane's rack.
The pilot-scale seawater RO desalination plant is equipped with an instrumental platform composed of a pH sensor (pHT), two pressure sensors (PT), a temperature sensor (TT), two flow sensors (FT), two conductivity sensors (CT), three ultrasonic level sensors (LT), two additive dosing pumps, four pressure gauges (PG), and four proportional control valves (PV). The flow sensor (FT1) and the conductivity sensor (CT2) located at the RO membranes rack outlet allow to control the flow and conductivity of the permeate, and therefore, the conversion rate. The permeate conductivity is controlled by the adjustment of the position of the proportional control valve (PV3) located at the exit of the brine flowrate. This pilot-scale plant was designed for normal operation with the brine flowrate control valve opening (PV3) 50% with a nominal pressure of 18 bars. In this plant, we use drinking water mixed with a certain minimum amount of salt, that is, we use brackish water and therefore the pressure of 18 bar is enough to desalt the incoming (raw) water. To avoid membranes damages, the proportional control valve PV3 should not be completely closed. This plant also has an automatic flushing and start-up system that protects the membranes from scaling and fouling. The recovery rate of this plant is 46%. The controllers of this plant are implemented in the PAC using the structured text language that allows the implementation of advanced controllers. Different control strategies and setpoint changes can be applied through the SCADA application. The SCADA also allows storing the plant signals of interest in a database and its export to other applications, as well as the alarm's generation and verification of potential failures, and the suggestion of different decision-making.
The design of MPC requires mathematical models that accurately describe the most relevant dynamic behavior of the plants to be controlled [57,71]. In the last years, for the development of adequate mathematical models of complex industrial plants, systems identification tools are being used successfully, see e.g., Refs. [74][75][76][77][78].
The main goal of a seawater RO desalination plant is to produce desalted water with a low total dissolved solids (TDS) index [17]. However, the permeate conductivity is used to evaluate the quality of the desalted water obtained because it is not possible to measure the TDS on-line [11]. Then, the permeate conductivity must be maintained within a certain range of values to guarantee the required quality of the desalted water. For example, for human consumption, the permeate conductivity should be maintained in a range of 400-500 µS/cm [17]. In addition, an augment in the permeate conductivity implies an increment in the membrane fouling and/or variations in the dynamic parameters of the RO desalination plant [45].
The RO desalination plant is a multivariable process, with two input variables and two output variables that must be controlled simultaneously. Each RO high-pressure feed pump is equipped with a variable frequency drive (speed variator) to change the rotational speed of the pump, which in turn varies both the flow rate and the pressure of the incoming stream to the RO rack. Moreover, in industrial practice, to change the concentration of the permeate flowrate, the brine flowrate is adjusted by varying the position of the brine flowrate control valve. Therefore, in this plant, the critical variables that must be controlled are: the permeate flowrate Q p (t) through the high feed pressure P f (t), and the permeate conductivity C p (t) by means of the brine flowrate Q b (t).
Through the application of the systems identification tools [74], a mathematical model that describes the dynamic behaviour of the pilot-scale plant under study was obtained, which is represented by the expression: where: Figure 3 shows the validation results of the mathematical model obtained of the seawater RO desalination plant under study, which exhibit degrees of accuracy (FIT) of 94.4%, 90.8%, 94.11%, and 90.2% respectively. Therefore, the model (1) adequately describes the dynamic behaviour of the plant under study and consequently can be used in the design of MPC.
The model (1) of the plant under study can be converted, without precision loss, in the following CARIMA model, which is used to predict the future dynamic behavior of the plant output variables [57]: The model (6), (7), can be expressed as a CARIMA model for a two-input two-output (MIMO) plant: where:ŷ (k + j) = Q p (k + j) C p (k + j) e(k + j) = [e 1 (k + j) e 2 (k + j)] T (11) y(k + j) is the vector of optimum j-step ahead prediction of plant outputs; u(k + j) is the input vector; e(k + j) is the noise vector; and I 2×2 is the identity matrix. The noise vector is supposed to be a white noise with zero mean.

Expert Model Predictive Controller Design
The block diagram of the designed Expert MPC is depicted in Figure 4. Since the dynamic parameters of the RO desalination plants vary due to membrane fouling, this controller has a plant identification block that on-line calculates the parameters of the prediction model. Based on the information available, the Expert System can develop different on-line decision-making strategies to achieve the control objective, and the prediction error e(k + j) approaches zero.  The Data Base contains the information of all the signals of the control system (a set of facts). The Knowledge Base includes the available symbolic knowledge about the control system represented by a set of rules (the Rule Base). The Rule Base contains rules in the "IF (case) THEN (action)" format, which deals with conditions involving changing in the control system. The Inference Engine comprises the methods for applying the general knowledge of the control system (mechanism to match the left and sides of the rules in order to succeed the goals or sub-goals), i.e. to emulate the control expert's decision-making process in reasoning about what input to generate for the plant. The explanation module informs the users on how and why the conclusions are obtained.
The CLIPS commercial expert system shell was used because of its flexibility, expandability and low cost [79]. The shell refers to the software package containing a generic inference engine, a user interface, and a structured skeleton of a knowledge base in its empty state with the appropriate knowledge representation facilities that enable users to develop and use expert systems [63].
The Rules Base contains more than 50 rules. The rules were generated based on the knowledge of expert operators on the dynamic behaviour of these plants, as well as on the optimization and safety of their operation. Some rules of the Rule Base are the following: The Rule Base was tested by verifying that it is consistent, that it has no errors, and that it complies with the specifications and established objectives.
The Expert System, using the Rule Base and the evolution of the plant variables, can modify the plant identification block, the plant prediction model, and/or the optimizer in order to improve the performance, robustness and operational safety of the overall control system.
By minimizing the following cost function [57]: where r(k + j) is the reference trajectory for the output vector; N 1 and N 2 are the minimum and maximum prediction horizons respectively; N u is the control horizon; and R and Q are positive definite weighting matrices; the optimal control signal is obtained. The vector of optimum ahead prediction of plant outputs can be represented in compacted form as [57]: where G is the plant dynamic matrix, u is the vector of plant future inputs, and f is the plant free response vector. Finally, the derived optimal control signal, if there are not constraints, is obtained as [57]:

Results and Discussions
The designed Expert MPC was programmed and real-time implemented in the remote supervision station of the pilot-scale RO desalination plant under study (see Figure 1). In order to evaluate the performance and robustness of the designed Expert MPC controller, two real-time tests were developed based on real industrial operation scenarios involving demanded setpoint changes. Moreover, a step disturbance to all plant outputs was applied at different time instants. The controllers' performance was evaluated based on the settling time, overshoot and steady state error obtained from the plant steps changes responses. To ensure the rapid fouling of the membranes, the water used in this plant is rich in dissolved and suspended solids.
The first test scenario was developed to validate the performance of the Expert MPC, as well as its rejection to the negative impact of the plant time-varying parameters near specified nominal operating conditions. The design parameters of the Expert MPC were next: The sampling period was established at T = 10 s, the minimum and maximum prediction horizons were set like N 1 = 3, N 2 = 15 samples respectively, the control horizon was established as N u = 3, and the positive definite weighting matrices were set like R = diag(5, 1) and Q = diag (1,6), respectively. Figure 6 shows, in the PanelView 1500 of the pilot-scale plant, the real-time closed-loop responses of the control system with the designed Expert MPC. In this figure, at time t = 25 s, simultaneous step changes were applied at the setpoint (SP) of the permeate flowrate that increased it from 5 l/min to 20 l/min, as well as at the setpoint (SP) of the permeate conductivity that decreased it from 580 µS/cm to 430 µS/cm.    From Figure 6, it is observed that the permeate flowrate and the permeate conductivity attain the new setpoints (20 l/min, 430 µs/cm respectively) with a setline time (t s ) of approximately 125 s, and with an undershoot (M p ) of 12.5% for the permeate conductivity. However, due to membranes fouling, time variations in the dynamic parameters of the plant take place from time t = 200 s, and consequently the permeate flowrate decreases and the permeate conductivity increases; therefore, the time responses of the control system worsen. As in this test scenario, the error signal e(k) between the output vector of the plant y(k) and the output vector of the prediction modelŷ(k) is greater than the value of the threshold error e n ; the first rule of the expert system is triggered, and therefore the parameters of the prediction model are tuned by the expert system (see Figure 4). Consequently, at time t = 290 s, the time responses of the control system return to their operations values with zero steady-state errors. Thus, the designed Expert MPC keeps its robust performance throughout this test scenario.
The second test scenario was performed to comparatively evaluate the performance of the designed Expert MPC against another standard MPC designed under the same conditions but without the expert system. In this test scenario, at time t = 15 s, simultaneous step changes were applied at the setpoint of the permeate flowrate, that increased it from 22 l/min to 30 l/min, as well as at the setpoint of the permeate conductivity that decreased it from 480 µS/cm to 425 µS/cm. The real-time closed-loop responses and control signals of this test scenario are displayed in Figures 9 and 10 respectively. From Figure 9, it is observed that both controllers perform likewise against setpoints changes. However, when plant time-varying parameters take place (at time t = 200 s), the designed Expert MPC gives a better performance compared to the standard MPC.
In order to compare the robustness of the designed controllers, two performance indexes were used: (a) the Integral Absolute Error (IAE), which is an integral index of the output time response, and (b) the control effort (TV), which provides a measure of the smoothness of the control signals [80][81][82]. Table 1 summarized the comparative results of the performance indexes of both controllers against the effect of plant time-varying parameters. From Table 1, it is observed that the lowest IAE with the least control effort is obtained with the designed Expert MPC; therefore, this controller exhibits the best robustness. This means that the Expert MPC makes it more possible to get faster and accurate responses for the stabilization and control of the pilot-scale plant critical variables than the standard MPC. Consequently, the designed Expert MPC will guarantee a better operation of the actual industrial scale RO desalinization plants, as well as a higher conversion rate, with lower energy consumption. Nevertheless, in these plants, there are more disturbances compared with our pilot scale plant; therefore, the Rule Base of the Expert System will need to be extended.

Conclusions
In this paper, an Expert MPC was designed for the accurate and robust control of the critical variables of the brackish and seawater RO desalination plants, and it was real-time implemented in the remote supervision station of the pilot-scale RO desalination plant of the Pontifical Catholic University of Peru. By the application of the system identification procedures, a dynamic mathematical model that satisfactorily depicts the main dynamic features of this plant was derived.
The designed Expert MPC enables the accurate control of the permeate flowrate and the permeate conductivity by varying the high feed pressure and the brine flowrate respectively, which is more consistent with the industrial practice developed in the commercial seawater desalination plants. This controller is characterized by having an expert system, which, based on the information available, develops different decision-making strategies online to achieve the control objective and to ensure that the prediction error e(k + j) becomes zero.
The efficiency and robustness of the designed controller were evaluated through some real-time tests and two performance indexes considering different real industrial operation scenarios and a well-designed standard MPC. The results obtained show that the efficiency and robustness of the control system of the plant under study with the designed Expert MPC are much better compared to the standard MPC in terms of plant time-varying parameters rejection.
Our future research objective in this direction will focus on the real-time implementation of the Expert MPC designed in an actual industrial scale RO desalination plant, which will guarantee a better plant operation, as well as a high conversion rate and lower energy consumption.