Artificial Neural Networks Based Modeling and Control of Continuous Stirred Tank Reactor

: Continuous Stirred Tank Reactor (CSTR) is one of the common reactors in chemical plant. Problem statement: Developing a model incorporating the nonlinear dynamics of the system warrants lot of computation. An efficient control of the product concentration can be achieved only through accurate model. Approach: In this study, attempts were made to alleviate the above mentioned problem using “Artificial Intelligence” (AI) techniques. One of the AI techniques namely Artificial Neural Networks (ANN) was used to model the CSTR incorporating its non-linear characteristics. Two nonlinear models based control strategies namely internal model control and direct inverse control were designed using the neural networks and applied to the control of isothermal CSTR. Results: The simulation results for the above control schemes with set point tracking were presented. Conclusion: Results indicated that neural networks can learn accurate models and give good non-linear control when model equations are not known.


INTRODUCTION
The Continuous Stirred Tank Reactor system (CSTR) is a complex nonlinear system. Due to its strong nonlinear behavior, the problem of identification and control of CSTR is always a challenging task for control systems engineer. Usually the industrial reactors are controlled using linear PID control configurations and the tuning of controller parameters is based on the linearization of the reactor models in a small neighborhood around the stationary operating points. If the process is subjected to larger disturbance and/or it operates at conditions of higher state sensitivity, the state trajectory can considerably deviate from the aforementioned neighborhood and consequently deteriorates the performance of the controller.
The economic objectives generally require the reactor design for operation in the area of its higher state sensitivity and in some cases even at the borders of its stability or in the vicinity of an unstable stationary point, which might even induce the periodic oscillations. As a result, the nonlinear nature of the reactor acquires more relevance in control systems and creates difficult control problems. If severe nonlinearity is involved in the controlled process, a nonlinear control scheme will be more useful. Nowadays, neural networks have been proved to be a promising approach to solve complex nonlinear control problems.
The use of neural networks in chemical engineering field offers potentially effective means of handling three difficult problems: Complexity, non linearity and uncertainties. The variety of available neural network architectures permits us to deal with a wide range of process control problems in comparison to other empirical models. Neural networks are relatively less sensitive to noise and incomplete information and deal with higher levels of uncertainty when applied in process control problems [1] .The multilayer feed forward neural networks offer interesting possibilities for modeling any nonlinear process without a priori knowledge [2] . Thus, selflearning ability of neural networks eliminates the use of complex and difficult mathematical analyses, which is dominant in traditional modeling methods. Based on the gradient descent optimization, back propagation is probably the most popular training algorithm for feed forward networks in the field of chemical engineering [3] . The basic back propagation algorithm has several drawbacks. The most critical one's are slow convergence, the possibility of becoming struck in local minima and computational complexity. Many variation of the basic algorithm that improves its performance have been suggested by Bhat [4] .The use of momentum term generally speeds up the convergence and smoothes the trajectory of the weights during the update procedure. During training both learning rate and momentum can be modified in order to improve convergence.
This study describes the modeling and control of a isothermal CSTR using neural networks. Multilayer feed forward neural networks with back propagation algorithm have been used for modeling. Comparison of ANN based control schemes are illustrated using error analysis.

CSTR modeling: The Continuous Stirred Tank
Reactor with single input and single output is shown in Fig. 1. Here isothermal series -parallel reaction (Van de vusse reaction) is considered to study the steady state and dynamic behavior of CSTR. The two reactions are: A: Cyclopentaddiene B: Cyclopentenol C: Cyclopentanediol D: Dicyclopendtadiene The desired product in the reaction is spices B, the intermediate product in the primary reaction, which increases the difficulty to control.
The rates of formation of A and B are assumed to be: where, k 1 , k 2 ,k 3 are the reaction rate constants. The feed stream consists of pure A. The mass balances for A and B are given by the following Eq. 2 and 3: These modeling equations assume a constant volume. The equations for C C and C D are neglected because C B is not dependent on them. The manipulated input in this system is dilution rate. The parameters of the reactor are given in Table 1.
The steady state equations are: 2 s s 3 s 1 1 These results lead to the steady-state response of the CSTR as shown in the Fig. 2. For an isothermal CSTR steady state input-output can be obtained by relating dilution rate and concentration of component B.   Fig. 2 it is clear that a nonlinear relationship exists between steady-state dilution rate (F/V) and the steady-state concentration of B. The reactor cannot be controlled at maximum point because the process gain is zero. The steady-state concentration of B of 1.117 gmol L −1 can be obtained from F s /V = 0.5714 or F s /V = 2.8744 min −1 , showing the presence of input multiplicity [5] .
The Complexity involved in conventional modeling of CSTR increases due to the presence of nonlinearities like input multiplicity, gain sign change, asymmetric response and transformation from minimum to non-minimum phase behavior and time lag in measuring instruments forcing to make many assumptions, sacrificing the accuracy due to the negligence of uncertainty. Inaccuracy in the modeling due to various assumptions gives degraded performance of controller. In the present work Artificial neural network is used to develop better and more efficient non linear model of CSTR.
Neural network modeling: An artificial neural network is massive, parallel interconnected network of simple elements whose hierarchical are reminiscent of biological neural systems. By looking only at the input and output data a neural network can model non linear systems. ANNs provide an analytical alternative to conventional techniques, which are often limited by strict assumptions of normality, linearity and variable independence The three steps involved in the ANN model development are (1) Generation of input-output data (2) Network Architecture selection (3) Model validation Generation of input-output data: The data generated to train the network should contain all the relevant information about the dynamics of the CSTR. The input was given to the conventional model of the CSTR and from the conventional model, the input and output were sampled for 0.01 sampling instants and the required sampled data are obtained to train the network.
Network Architecture selection: The feed forward network topology with sigmoidal activation function was chosen based on the trials with different structures of multilayer perceptron. The variation of error with number of hidden neurons is shown in Fig. 3. The lowest error corresponds to 4 neurons in the hidden layer. Hence it is selected as optimal architecture of ANN. The ANN selected here consists of 3 neurons in the input layer, 4 neurons in the hidden layer and one neuron in the output layer. The ANN architecture used in the present work is shown in Fig. 4.
The training algorithm used in the CSTR modeling is back propagation algorithm. Before training the process weights are initialized to small random numbers. The weights are adjusted till error gets minimized for all training sets. When the error for the entire set is acceptably low, the training is stopped. Table 2 shows the parameters used in developing the ANN model for the CSTR Model validation: The final step in developing the model is validation of the model. Validation is performed by evaluating the model performance using trained data and test data. The input and target were presented to the network and the network was trained using Levenburg-Marquardt algorithm. The goal was set at 10 −8 and the same was achieved in 9478 iterations.  The ANN model was first validated using the trained data which is shown in Fig. 5. The ANN model validation with test data is shown in the Fig. 6. From the Fig. 5 and 6, It is seen that there is a perfect overlap between actual output and neural network output. Inverse ANN model: Inverse models are basically the neural net structure representing the inverse of the system dynamics at the completion of training .The training procedure in this case is called inverse modeling. The principle of this is that if the process can be described by: y(n) = g(y(n-1), y(n-2), u(n-1), u(n-2)) (8) A network is trained as the inverse of the process: u(n) = g-1(y(n+1), y(n), y(n-1),u(n-1)) (9) The validation of the inverse ANN model with train data and test data is shown in the Fig. 7 and 8. In Fig. 8, the error between the actual output and the output obtained from test data is very less.

Conventional internal model control scheme:
Internal Model Control (IMC) scheme is one of the control strategies emanating from model based control schemes. The classical design technique for the IMC scheme uses a process model (Gm) and the plant (Gp) as shown in Fig. 9. The model mismatch (Gp-Gm) is compensated using the tuning parameter f λ . In the IMC scheme the controller is the process inverse model if with the filter.
In the conventional IMC control scheme the differential equation model of CSTR is taken as the process and the process model is the linearized transfer function. The IMC controller with the proper tuning parameter is used to track the desired set point change in concentration of component B. The transfer function model of the CSTR is given as: The inversion of the process model is the controller, but the inversion of GM leads to an unrealizable predictor or an unstable controller which will violate the stability requirement. Therefore, it is not feasible to use the exact inversion of the process model, GM to design G c (s). Instead, the 'GM' is split into two parts: one, G +, containing zeroes in the right half of splane and other, G -, containing the remaining terms of The IMC controller is given as:  Fig. 9: Block diagram representation of IMC scheme A step change in concentration of B from 1.26-1.115 mol L −1 is given as the set point and the corresponding closed-loop response is shown in the Fig. 10. Figure 11 shows the controller output that indicates the change in dilution rate to track the desired set point. The closed-loop response shows the existence of peak overshoot during the transition from 1.26-1.115 mol L −1 that can be reduced in ANN based IMC (AIMC) control scheme.

ANN based IMC scheme (AIMC):
The control signal is synthesized by a forward model of the process and an inverse model. An attractive property of this design is that it provides an off-set free response if the process is affected by a constant disturbance. The ANN based IMC scheme is shown in the Fig. 12.
The first order filter is used in the control scheme with the filter tuning parameter as 2.44 s. The corresponding closed loop response is shown in the Direct inverse control: The most fundamental neural network based controllers are probably those using the "inverse" of the process as the controller. The simplest concept is called direct inverse control. The block diagram of direct inverse co nt r o l is s ho wn in the Fig. 15. The inverse model is subsequently applied as the controller for the process by inserting the desired output, the reference r(t+1), instead of the output y(t+1).
The process output tracks the set point for a step change in concentration of B with less settling time and reaches 1.115 mol L −1 from 1.26 mol L −1 in the Fig. 16.  The corresponding manipulated variable in the Fig. 17 changes from 1.11-0.568 min −1 instantly at the 50th second. The quantitative comparison using performance indices is shown in Table 3.
Though the direct inverse control has less integral square error in the simulation work, the controller is not robust in the real time process. If the process parameter varies, the controller cannot be tuned accordingly and introduces steady state error. In the case of AIMC the filter tuning parameter can be adjusted so that the controller is tuned to adapt to the new process parameter. Similarly the load disturbances can be effectively overcome in the AIMC.

CONCLUSION
In this study modeling of Isothermal CSTR has been implemented using artificial neural networks. The neural model has been trained using data set obtained from component balance equations. Feed forward back propagation neural network has been used to model the isothermal CSTR. The neural model has been designed as a black box model. The simulation results from conventional model and the neural model were compared for the given input variations and the results have been found satisfactory. This study has also developed a method to design two neural network based robust control schemes namely AIMC, ANN based direct inverse control and applied it to the non-linear CSTR control system .The simulation shows that implementation of the NN based advanced controllers for the set-point tracking case were able to force process output variables to their target values smoothly and within reasonable rise and settling times. It is evident from the Fig. 13 that the inverse behavior is not present in the AIMC control scheme and the change in the manipulated variable is smooth by adjusting the filter tuning parameter.