Design, implementation, control and optimization of single stage pilot scale reverse osmosis process

In this paper, a single-stage pilot-scale reverse osmosis (RO) process is considered. The process is mainly used in various chemical industries such as dye, pharmaceutical, beverage, and so on. Initially, mathematical modeling of the process is to be done followed by linearization of the system. Here a dual loop construction with a master and a slave is used. The slave uses the conventional proportional integral derivative (PID) with a reference model of the RO process and the master uses the fractional order proportional integral derivative (FOPID) with a real time RO process. The slave ’ s output is compared with output of the real time RO process to obtain the error which is in turn used to tune the master. The slave controller is tuned using Ziegler Nichols method and the error criterion such as integral absolute error (IAE), integral squared error (ISE), integral time squared error (ITSE), integral time absolute error (ITAE) are calculated and the minimum among them was chosen as the objective function for the master loop tuning. Hence the tuning of the controller becomes a whole. Therefore two optimization techniques such as particle swarm optimization (PSO) and bacterial foraging optimization algorithm (BFO) are used for the tuning of the master loop. From the calculations, the ITSE had the minimum value among the performance indices, hence it was used as the objective function for the BFO and PSO. The best-tuned values will be obtained with the use of these techniques and the best among all can be considered for various industrial applications. Finally, the performance of the process is compared with both techniques and BFO outperforms the PSO from the simulations.


INTRODUCTION
The need for clean and reverse osmosis water is growing day by day and one of the industries that needs it most is the agriculture industry. It is a well-known fact that India is one of the leading agricultural producers of the world. Fifty-eight percent of Indians are engaged in agriculture; 18% of the GDP is contributed by agriculture in India; 11% of Indian agriculture production increased in the past 14 years. As agricultural production process needs a lot of this precious resource, the water used to sustain livestock and grow fresh produce is known as agriculture water. Without it, growing grains, fruits and vegetables and raising livestock is not possible. And without livestock, fruits, grains, and vegetables, humans cannot survive. Apart from growing produce and sustaining livestock, it is also used for crop cooling, irrigation, and frost control and pesticide and fertilizer applications. The agriculture industry needs pure RO water to ensure the perfect health of humans. If livestock is fed contaminated water or irrigation is done with it, the food you eat would also be contaminated and you will fall ill easily. In the earlier times, groundwater was considered to be pure but due to factors like industrial waste dumping and pollution, it is not that reliable anymore. But still, most irrigation is done with surface and groundwater. Some of the other sources include open canals, streams, rivers, and irrigation ditches, impounded water such as lakes, reservoirs, and ponds, groundwater from wells, water collected in cisterns and rain barrels, municipal water systems and rainwater. An estimated 62,000 million litres per day (MLD) of sewage is generated in urban areas, while the treatment capacity across India is only 23,277 MLD, or 37% of sewage generated, according to data released by the government in December 2015. RO helps in improving the quality and safety of water for domestic as well as for industrial use. RO helps in removing many types of suspended and dissolved species from water. It helps in removing bacteria and removes the impurity of the water. In the process of RO desalination, pressure is applied to overcome the osmotic pressure which is driven by all the chemical potential solvents. The solute solution is passed through a semi-permeable membrane in which the solvent passes and leaves a highly concentrated solute.
The dynamic behavior and non linearity of a process in a chemical plant is due to many processes and manipulated variables. Therefore this type of process (multi input multi output) is tedious to control (Alatiqi et al. 1989). In theory, a control system is assumed to have a single manipulated variable and a single controlled variable. But practically, there are a number of variables that have to be controlled and manipulated leading to the use of multi input multi output (MIMO) systems. There are several methods to control the MIMO process. In this paper, the design of feedback control for controlling the pH and turbidity of contaminated water in the RO process is proposed (Senthil & Senthilmurugan 2016) by manipulating the inlet flow rate and pH. The proposed system has two input and output variables, also called 2 Â 2 MIMO process ( Figure 1).
Each manipulated variable can affect both controlled variables. To choose the controlled and manipulated variable pairs in order to produce the desired response, relative gain array (RGA) is employed (Chang & Yu 1992). The use of decouplers in this process reduces interaction between minor process variables which involves a large number of feedback control loops in a highly complex multi-variable process (Anqi et al. 2015). This is a system with high non linearity and also a dynamic system too. So at first the mathematical model of the single-stage pilot-scale RO process is done by the principle of linearization and the proposed system state-space model can be represented using the Jacobian matrix. Linearization is the procedure of taking the gradient of a nonlinear function with respect to all variables and using a linear representation at that point. The Jacobian matrix is calculated as below: Using Taylor series: at the point (X 0 , U 0 ) . . . @f n @x 1 Á Á Á @f n @x n 2 6 6 6 6 6 4 3 7 7 7 7 7 5 (X0,U0) . . . @f n @u 1 Á Á Á @f n @u n 2 6 6 6 6 6 4 3 7 7 7 7 7 5 (X0, U0) In this prototype, a pump is used to deliver the water that is contaminated to the system. This also comprises two tanks in which one is for the storage of contaminated water (input) and the other is for pure water (output) with membranes Water Science & Technology Vol 84 No 10-11, 2925 connected in series between them. Tanks are connected in such a way that change in the inlet will have an effect on both the process variables. And also the input flow in any liquid will affect the pH and turbidity of the process and also the FOPID controller (Idir et al. 2018) parameters, hence the technique is used for many water treatment industries because of the working and maintenance cost. They also provide satisfactory performance. Tuning of FOPID parameters is a difficult task since the number of variables that has to be tuned is five in FOPID compared to the conventional PID where it is only three, hence optimization, techniques such as bacterial foraging optimization algorithm (BFO), ant colony algorithm, particle swarm optimization (PSO) (Cao & Cao 2006), etc. can be employed. Among them in this paper, we use two optimization techniques such as BFO and PSO. Popularity of PSO in the last decades is due to its uncomplicated structure and only a small number of parameters are desired to alter the optimization of any sort of problems. BFO was reported to do better than many powerful optimization algorithms in terms of convergence speed along with final accuracy. Controllers are provided with the optimized and tuned parameters of the system which is designed in the SIMULINK and assess the performance by comparing the methods with BFO and PSO techniques. The paper is comprised of Section 1, which deals with mathematical modeling of RO process, Section 2 deals with FOPID tuning of a single stage pilot scale RO process, Section 3 deals with real time implementation and technical specifications of RO process in pilot scale, Section 4 deals with optimized tuning with BFO and PSO, and Section 5 is simulation and results.

MATHEMATICAL MODELING OF SINGLE STAGE PILOT SCALE RO PROCESS
The enactment of single stage pilot scale RO plant is quite complex to the quality of the feed water and plant operating conditions ( Janghorban Esfahani et al. 2012). Most perfect membrane transport equations of steady-state in the form of distributed parameters can be derived based on solution-diffusion model and film theory.
The overall fluid and solute mass balance equations for the RO membrane are: From the above equations, subscripts f, r, and p refer to feed, reject, and product streams. Hence Q and C refer to the flow and salt concentration. n l , W, and L represents the number of leaves, width, and length of the RO module respectively (Al-Obaidi et al. 2018).
The solution-diffusion model is expected to be effective for the transport of solvent and solute through the membrane (Shenvi et al. 2015). Conferring to this model, solvent flux J v and solute flux J s through membrane are stated by the following equations: Then where, A w solvent transference parameter P f feed pressure P d pressure drop along a RO single stage process module P p pressure in the permeate side (atmospheric pressure) Dp osmotic pressure loss B s solute transference parameter C m solute deliberation on feed side C p solute deliberation on permeate side P b pressure along the channels of the filters in the RO module DP density of permeate water Since solvent transport parameter and solute transference parameter are sensitive to the operating temperature and the experimental factors, the relationship is expressed as: A w0 and B s0 are inherent transport parameters in normal conditions with a 1 , a 2 and b 1 as constant parameters for transport and T as the functioning temperature in Kelvin.
where, R is the gas constant and C p is the value of C b at the end of the module. By concentration polarization theory and steady-state material balance, Sherwood number Sh is expressed as: where, d e hydraulic diameter of the feed insertionpassage r density of permeate water m kinetic viscosity D AB dynamic viscosity For the calculation of dynamic viscosity D AB the regression equation can be expressed as: D AB ¼ 6:725 Â 10 À6 : exp 0:1546 Â 10 À3 C b À 2513 273:15 þ T Solvent flux J v and solute flux J s can be related by: The pressure loss along the RO channel can be formulated as: where, The friction factor l ¼ 6:23 K l Re À0:3 (13) K l is the empirical parameter. We have V is axial velocity in feed passage and satisfies where, h sp is the height of feed spacer channel. The variation in bulk concentration can be expressed as: Water recovery rate R ec and specific energy consumption (SEC) (Park et al. 2020) can be intended by the equations: SEC ¼ The vital parameters reflecting the enactment of RO process are Salt passage S p and salt rejection coefficient R y and hence they are formulated as: 1 p and 1 ef are mechanical efficiency and energy recovery efficiency respectively.

CONVENTIONAL PROPORTIONAL INTEGRAL DERIVATIVE CONTROLLER (PID CONTROLLER)
A PID controller is a control of closed loop feedback mechanism mostly used in industrial control systems (Durgadevi et al. 2017;Tudoroiu et al. 2019). It calculates an error as the difference among the measured variable and set point. It attempts to reduce the error by adjusting the flow rate of inlet through use of a input variable. The PID control algorithm involves three constant parameters like the proportional, the integral and derivative time constants values and it is denoted Kp, T I , T D . A closed loop PID controller possibly will have different structures. Different design methodologies are available for designing the controller in order to attain the desired performance level.
Above Equation is the fundamental form of continuous PID algorithm in the time domain. The PID algorithm is a simple equation given as a function of error e(t) with three terms, namely proportional gain (K P ), integral gain (K I ) and derivative gain (K D ). The variable c(t) denotes the controller output; the variable e(t) is the error, which is the difference among the manipulated variable and the set point. The most frequently used feedback control approach, functional to pH control uses the PID algorithm. Controller tuning is a complex problem; despite the fact that there are only three constant parameters and the operating mechanism is simple to describe, it must assure the complex criteria limited by PID control.

Ziegler Nichols method for tuning PID controller
Ziegler Nichols closed loop tuning technique was possibly the first accurate method to tune PID controllers. The technique is not widely used today because the closed loop behavior tends to be oscillatory and responsive to uncertainty (Kambale et al. 2015).
Ziegler Nichols also proposed a tuning parameter for the process that has been recognized as first-order plus time delay process with a maximum slope of K ¼ Kp/τ at t ¼ td for a unit step input changes. The values of Kp, Ti, Td can be obtained from the information given in Table 1.

FRACTIONAL ORDER PROPORTIONAL INTEGRAL DERIVATIVE CONTROLLER (FOPID CONTROLLER)
FOPID offers a completely unique modelling approach for systems with astonishing dynamical properties by introducing the notion of a derivative of non-integer (fractional) order. An evaluation of tuning methods for FOPID controllers are often categorized into analytic, rule-based, and numerical depending on the approach to the tuning problem (Tufenkci et al. 2020). If a process reveals such dynamics, the model-based control design procedure might be administered using the corresponding tools. This furnishes the matter of fractional model identification which is said to have many issues. This includes the selection of an efficient simulation method of the identified fractional model (as well as process models), deciding the parameters of the model to acknowledge, and limiting the amount thereof to enhance the conditioning of the next optimization of the matter, and the choice of an appropriate optimization algorithm for estimating the parameters of the model (Reddy et al. 1997). Since the fractional model has many complexities, we have chosen an integer order model given by G(s) ¼ 9:8148 e À1:21s 17:9099s þ 0:1 , to make sure convenient usability of the obtained model, and methods for its validation with reference to experimental data should be executed.
Once the integer order model of a process is recognized, one may progress with a model-based control design. Fractional dynamics are best remunerated with fractional controllers. However, the tuning thereof is more concerning compared to standard controllers. Numerical optimization methods are frequently wont to embark upon this issue. Thanks to the complexity of fractional models, the optimization problem must be accurately found out. Due to additional tuning flexibility, FOPID controllers are typically capable of outperforming their conventional counterparts, since more design specifications could also be fulfilled (Ghernaout 2017). Thus, emerging a general method for FOPID controller tuning is extremely desirable. Such a way should be lithe enough to beat issues with simulating fractional or integer-order models of the control plant within the time domain, and at an equivalent time take into consideration design specifications imposed within the frequency domain to sustain the robustness of the controller.
A complimentary quality of FOPID type controllers is the realization of robustness criteria that guarantee stability and recital of the control loop under reasonable operating conditions (Riverol & Pilipovik 2005). Modern nonlinear control methods based only on the time-domain evaluation of the system dynamics commonly require this quality thanks to the complexity of developing a unified robustness concept for an in depth enough class of nonlinear systems. To use the developed FO control algorithms to specific control problems the corresponding controllers need to be used.
Two sorts of recognition of such controllers are often proposed which include digital implementation and analog. Direct realizations supported mathematical definitions of fractional operators have definite limitations for real-time control, which is why approximations of fractional operators are frequently used instead. Several issues could also be delineated in connection to the present. Namely, the computational stability of the signal processing algorithm such as fast Fourier transform (FFT). An FFT is an algorithm that computes the discrete Fourier transform (DFT) of a sequence, or its inverse (IDFT). Fourier analysis converts a signal from its original domain (often time or space) to a representation in the frequency domain and vice versa must be guaranteed just in case of digital implementation, and a feasible set of discrete electronic components must be chosen for the analog implementation of practice circuits. As stated above, particular importance is given to the utilization of fractional models and controllers in industrial applications. Studies show that a huge portion of commercial control loops (about 90%) are of PI/PID type; moreover, it had been found that about 80% of those existing control loops are scantily tuned. Since FOPID controllers offer more tuning liberty and stabilizing abilities, it is expected that industrial integration of those controllers will end in considerable benefit.
Therefore, an extra set of specific research goals could also be anticipated to review fractionation models and to supply means for implementation of an automatic controller tuning, to widen the gain and order scheduling approach for obtaining a group of FOPID controllers working flawlessly across several operating points, to supply means for stabilizing an unstable fractional or integer order plants, to scrutinize the chances for the incorporation of newly designed fractional controllers, offering superior performance, into existing conventional PI/PID control loops thereby reducing process downtime and related costs, to develop a hardware controller prototype supported developed controller design and synthesis methods (Feliu-Batlle et al. 2017).
Fractional order PID controller (PI λ D μ ) is the extension of conventional PID control. From the literature, it can also be perceived that FOPID controller augments the system performance, less profound to a change in parameters and accomplishes the property of iso-damping very effortlessly (Tepljakov et al. 2018).
Where, as shown in Figure 2, where,

U(s) is the controller's output
The control signal output of the FOPID controller is stated in time domain as: With the values of λ and μ (Figure 3), the conventional PID controller is getting converted to the FOPID controller model. Therefore a PID controller along with a reference model is tuned first, then one of the optimization techniques is used to optimize the input that is given to the FOPID control, and hence the exact process model is tuned by the FOPID control algorithm respectively.
The detailed technical specification of single stage pilot scale RO system is shown in (Table 2). The tuning of the controllers using reference model originated from the model reference adaptive control. The Ziegler Nichols method tuned PID controller along with the reference model forms the slave loop (Table 3). The reference model is designed based on the expected output expected from the real time plant (Table 4). For the RO process, the settling time was taken as t s ¼ 5 min and the overshoot is M p ¼ 3%. The obtained reference model is 5=s 2 þ 2:55s þ 1. The FOPID controller tuned using PSO serves as the master loop.  The Dual Loop Construction of the Reverse Osmosis Process is shown in Figure 4. Comparison of the controllers in terms of performance indices is shown in (Table 5).

REAL TIME SETUP AND TECHNICAL SPECIFICATIONS OF SINGLE STAGE PILOT SCALE RO SYSTEM
The real time experimental setup of the single stage pilot scale RO process comprises two tanks with one for inlet and the other for outlet. The micro filtration membranes are arranged in a series, consisting of sedimentation, pre-carbon and post-carbon filters, respectively. Process control toolbox contains the communication bus namely the MODBUS and the PLC which help in data acquisition, the interface modules forms the communication between the personal computer and the real time RO process using the Rs-232 and the communication bus. Process control toolbox with the interface modules  connected to the setup for the purpose of generating experimental values continuously for various sampling intervals. The experimental setup is provided in Figure 5. Time(s) vs Flow rate (m 3 /h) for mathematical model is shown in Figure 6 and time series plot of various samples from the real time experiment are shown in Figures 7 and 8.
Real time experimental setup of the single stage pilot scale RO process  1. Inlet tank: Contaminated water is stored in the inlet tank 2. Outlet tank: Treated water with the specified pH is stored in outlet tank. 3. Activated carbon filter: The activated carbon filters are designed to remove free chlorine, organic matter, odor and color present in the raw water and wastewater. 4. Carbon filter: Carbon filtering is a method of filtering that uses a bed of activated carbon to remove impurities from a fluid using adsorption. 5. Sedimentation filter: A sediment filter acts as a barrier against different types of sediments or suspended solids. It sieves or holds back physical impurities like dust, dirt, sand, silt, clay, and other solid particles. 6. Human machine interface (HMI) module: The process control toolbox with interface modules is the HMI.

OPTIMIZATION ALGORITHM USED FOR OPTIMIZING THE PERFORMANCE OF FOPID CONTROLLER
The controller parameters for PID controller are K p , K i and K d were optimized using various optimization techniques such as PSO and BFO (Zare et al. 2020). For FOPID controller the controlled parameters are K p , K i , K d , λ and μ. The parameters of FOPID controllers are optimized by Nelder-Mead optimization technique.  Water Science & Technology Vol 84 No 10-11, 2934 Particle swarm optimization Particle swarm optimization (PSO) is a population-centered, random optimization procedure. Every particle monitors its directions within the issue space which are related to the simplest arrangement (fitness) it has accomplished so far. (The fitness value is additionally stored). This value is named pbest (particle best). Another 'best' value that is followed by the particle swarm enhancer is the best esteem acquired thus far by any particle within the neighbors of the particle. This area is called lbest (local best). At the purpose when a particle takes all the populations as its topological neighbours, the simplest value may be a global best and is named gbest (global best).
The particle swarm optimization concept consists of every time step, changing the speed of (accelerating) each particle toward its pbest and lbest locations (local version of PSO) (Phuc et al. 2017). With discrete random numbers being produced for acceleration to pbest and lbest locations, as acceleration is biased by a random term. The basic idea of particles searching individually while communicating with one another concerning the worldwide best so as to supply a more capable collective search applies to all or any forms of PSO from the originally conceived algorithm through the more capable models available today. As published  Water Science & Technology Vol 84 No 10-11, 2935 by Kennedy J, PSO consisted of a swarm of particles each moving or flying through the search space according to velocity update equation: where, Vi(k) is the velocity vector of particle i at iteration k, xi(k) is the position vector of particle i at iteration k, Pi(k) is then-dimensional personal best of particle i found from initialization through iteration k, g(k) is then-dimensional global best of the swarm found from initialization through iteration k, C 1 is the cognitive acceleration coefficients on a med for its terms use of the personal best, which can be thought of as a cognitive process whereby a particle remembers the best location and tends to return to that state, C 2 is the social acceleration coefficients on a med for its terms of use of the global best which attracts all particles simulating social communication, r 1 (k) and r 2 (k) are vectors of pseudo-random numbers with components selected from uniform distribution U(0,1) at iteration k, and r is the Hadamard operator representing element-wise multiplication.
PSO uses particles which represent potential solutions of the problem. Each particle flies in search space at a certain velocity which can be adjusted in light of preceding flight experiences. The projected position of i th particle of the swarm x i , and the velocity of this particle v i at (t þ 1) th iteration are defined and updated as the following two equations: where, i ¼ 1, 2, 3… n and n is the size of the swarm, C 1 and C 2 are positive constants, r 1 and r 2 are random numbers which are uniformly distributed, determines the iteration number, P i represents the best previous position (the position giving the best fitness value) of the i th particle, and g represents the best particle among all the particles in the swarm (Table 6).
At the end of the iterations, the best position of the swarm will be the solution of the problem. It cannot always be possible to get an optimum result of the problem, but the obtained solution will be an optimal one (Table 7). Bacterial foraging optimization Bacterial foraging algorithm (BFA) is a new comer to the family of nature inspired optimization algorithms. Application of group foraging approach of a swarm of Escherichia coli (E. coli) bacteria in multi-finest function optimization is the foremost indication of this new algorithm. To exploit energy gained per unit time, bacteria look for nutrients. Each bacterium communicates with others by sending signals (He et al. 2014). Chemotaxis is the process in which the bacterium moves in small steps to examine for nutrients. The main idea of BFA is impersonating chemotaxis crusade of virtual bacteria within the delinquent search space (Syafiie et al. 2000). In the optimization algorithm progress, the parameters are defined as follows (Table 8): P is dimension of the search space (number of parameters to optimize) S is the number of bacteria in the population (for simplicity, S as chosen for even number) N c is the number of chemotactic steps per bacterium life time between reproduction steps N s is the maximum number of swim of bacteria in the same direction N re is the number of reproduction steps N ed is the number of elimination and dispersal events p ed is the probability that each bacterium will be eliminated i ¼ 1, 2… S as the index for the bacterium j ¼ 1, 2…N c as the index for chemotactic step k ¼ 1, 2…N re as the index for reproduction step l ¼ 1, 2…N ed as the index of elimination and dispersal event m s ¼ 1, 2…N s as the index for number of swim The BFA algorithm is instigated with the following steps: Step 1: Elimination and dispersal loop l ¼ l þ 1 Step 2: Reproduction loop l ¼ l þ 1 Step 3: Chemotaxis loop j ¼ j þ 1 a. For i ¼ 1, 2, 3… S, a chemotaxis step for i th bacterium will be as follows: b. Calculate fitness function J (i, j, k, l). Let J(i,j,k,l) ¼ J(i,j,k,l) þ J cc (u i (j,k,l), P(j,k,l)) is cell to cellattractant effect to the nutrient concentration). c. Let J last ¼ J(i,j,k,l). d. Tumble: generate a random vector (i)Rp with each elementm (i), m ¼ 1, 2… P a random number on [À1, 1]. e. Move: Compute. f. Compute J (i, j þ 1, k,l). g. Swim: Let m ¼ 0. While m, Ns. Let m ¼ m þ 1. If J(i,j þ 1,k,l) , J last . Compute J last ¼ J (i, j, k, l) and calculate and use this u i (j þ 1, k, l) to compute the new J (i,j þ 1,k,l) as same in step. (f) Else, let m ¼ Ns. This is the end of the while statement. h. Go to next bacterium (i þ 1), if yes go to step (b).
Step 4: If j , N c , go to step 3 for next chemotaxis step as the chemotaxis process is not complete Step 5: Reproduction. With current values of k, l, compute overall fitness (cost function). J i , ¼ 1 for each i th bacterium and sort the fitness in descending order. Higher value of cost function means less fitness.
Step 6: Half of the bacteria with less fitness will die and the other half will reproduce. They will split into two and be placed at the same locations of their parents. So, population remains constant.
Step 7: If k , N re , go to step 2. Increment the reproduction counter and start new chemotaxis process.
Step 8: Elimination-dispersion. Eliminate the bacterium with probability P ed and disperse one at a random location in the optimization space.
Step 9: If l , N ed , go to step 1. Otherwise end.
Optimized parameters for PID controllers with BFO tuning is shown in (Table 9).

SIMULATION AND RESULTS FOR THEORITICAL AND EXPERIMENTAL DATA
From the above results, it is found that the time domain specifications for the PID controller are better than FOPID controller. Also, the minimum of the performance index (objective function value) is small for ITSE and in comparison with the PID and FOPID controllers (Table 5); the objective function value is minimum for PID controller (Jin et al. 2017). Then graphical proof for IAE as the criterion in Table 5 is shown in Figure 9. Graphical proof for ISE, ITAE and ITSE as the criterion is shown in Figures 10, 11 and 12. Therefore, the parameters of the PID controllers are further tuned using PSO and BFO. The results of these optimization techniques are shown below.
The PSO tuned results as well as graph for the PID controller are shown below, as shown in Figure 13.  The objective function of the PSO is obtained by introducing the ITSE into the function and given as: The BFO tuned results as well as graph for the PID controller are shown below, as shown in Figure 14.   The objective function of the BFO is obtained by introducing the ITSE into the function and given as: From the above two optimization results, the time domain specifications are better for BFO (Table 9).