pH-Control System Based on Artificial Neural Networks - Industrial

Nevertheless, the real applications in the concrete case of pH-control are ... of the process, and for remembering and adapting their experience. ... ...
0 downloads 0 Views 325KB Size
Ind. Eng. Chem. Res. 1998, 37, 2729-2740

2729

pH-Control System Based on Artificial Neural Networks Marı´a C. Palancar,* Jose´ M. Arago´ n, and Jose´ S. Torrecilla Department of Chemical Engineering, Universidad Complutense de Madrid, Madrid, Spain

A control system based on a combination of two artificial neural networks (ANN’s) was designed for the pH-neutralization of acidic liquid streams. The first ANN is a plant neural model that predicts future pH values from past/present values of pH and valve stem position and future values of valve stem position. The second ANN is a plant inverse neural model that calculates the future valve stem positions from present/past values of pH and valve stem position and future values of set point. The performance of the controller was studied first by numerical simulation. The controller was further implemented in a continuous stirred tank reactor in which the neutralization of acetic and propionic acids with sodium hydroxide was performed. The controller robustness and adaptive performance were tested under different perturbations of flow, composition, and set point and several buffering changes. Introduction The pH-control systems have scientific and industrial interest due to the following factors: (i) The control of pH plays an important role in several industrial processes such as wastewater treatment, coagulation and precipitation, ore flotation, and microbiological and electrochemical processes. (ii) Neutralization is problematic because of the inherent nonlinearity of pH, the measured variable. The acidity or alkalinity of a solution is expressed in pH units, defined in terms of the hydrogen ion concentration by the well-known nonlinear expression pH ) -log[H+]. Moreover, the pH of a solution is highly sensitive to small perturbations around the equivalence point. (iii) Both the equivalence point and the titration curve of each acid-base system depend on the type and concentration of the compounds involved. (iv) Sometimes, the streams which are being neutralized have a very complex nature and composition and their titration curves are unknown or poorly defined. Frequently, their flow rates and compositions suffer broad perturbations. (v) The behavior of real plants includes the effects of several elements, for example real stirred tanks with dead zones and short cuts, and instruments that can introduce lag, noise, and inaccuracy in the measurement, transmission, and manipulation of process variables. The controllers based on classical proportional, integral, derivative action (PID) cannot suppress pH oscillations of moderate or high amplitude and require additional strategies such as sequential neutralization, intermediate holding ponds, and back mixing operations that are costly because they require additional equipment and instrumentation (Piovoso and Williams, 1985; Rhinehart, 1990; Williams et al., 1990). Several alternatives to PID for pH-control consider different types of linear and nonlinear models (Buchholt and Ku¨mmel, 1979; Chan and Yu, 1995; Gustafsson and * To whom correspondence should be addressed. Postal address: Department of Chemical Engineering, Faculty of Chemistry, Universidad Complutense de Madrid, 28040 Madrid, Spain. Telephone: +34-91-394-4169. Fax: +34-91-394-4114. E-mail: [email protected].

Waller, 1992; Gustafsson et al., 1995; Jayadeva et al., 1990; Mahuli et al., 1991, 1993; Palancar et al., 1996; Seborg et al., 1986; Sung and Lee, 1995a, 1995b; Williams et al., 1990; Wright et al., 1991). One of the most important disadvantages of linear models is the difficulty of tuning them in the presence of lag, delay, and other real factors. In the particular case of pHcontrol, the pH electrodes can suffer aging and fouling that cause no well-known effects on the system dynamics (Brezinski, 1983; Giusti and Hougen, 1961; Hershkovitch et al., 1978), and the controllers work well in numerical simulations but they have to be readjusted when they are implemented in a real process. For processes not well-known, the tuning by simulation could not be possible and it would only be possible to tune the controller experimentally (Martı´n-Sa´nchez and Rodellar, 1996; Palancar et al., 1996). The controllers based on nonlinear models are more robust and have better adaptation performance than the controllers based on linear ones. Nevertheless, the nonlinear models require precise information about the process and several real factors, and consequently the controller performance depends on the accuracy of the model on which it is based. The use of controller models based on artificial neural networks (ANN’s) is relatively recent. The potential of ANN’s to solve several problems, which were difficult and troublesome for traditional methods, has been recognized by different authors (Bhagat, 1990; Bhat and McAvoy, 1990; Hosking and Himmelblau, 1988; Song and Park, 1993; Thibault and Grandjean, 1991). Some examples of application to industrial problems are diagnosis and detection of faults, modeling and control of processes, and sensor data analysis. Nevertheless, the real applications in the concrete case of pH-control are very scarce and there is a lack of information about experimental validation of the controller adaptation and robustness under buffering perturbations and with systems with delay time. An ANN is an algorithm that computes a series of output data from a set of input ones. The main difference with respect to other input/output algorithms is that the ANN has the capacity of learning by means of input/output sets of pattern data (learning mode). A well-trained ANN is able to predict output data from sets of input data never seen before (generalization

S0888-5885(97)00718-5 CCC: $15.00 © 1998 American Chemical Society Published on Web 05/20/1998

2730 Ind. Eng. Chem. Res., Vol. 37, No. 7, 1998

mode). The ANN’s have the following advantages (Bhat and McAvoy, 1990; Hosking and Himmelblau, 1988; Thibault and Grandjean, 1991): (i) Their structure is relatively simple and with several connections in parallel. This means a short computing time and a high potential of robustness and adaptive performance. (ii) They do not require a deep knowledge about the process or system to be treated (the ANN’s are rather like black-box models). (iii) The ANN’s have a great capacity for expressing the nonlinear dynamics and complexity of the process, and for remembering and adapting their experience. (iv) A direct ANN can be easily inverted for applications on inverse plant control. (v) The implementation is easy and can be made with low-cost computers, electronic boards, and integrated circuits. The ANN’s are usually based on the perceptron model (Rumelhart et al., 1986), that consists of two or more layers of a number of single units (nodes) with interconnections. The connections have weights that amplify or attenuate the output of every node before inputting its numerical content to a node of the following layer. All the inputs arriving to a node are summed, and the result is transformed by a transfer function (sigmoidal, hyperbolic tangent, etc.) to give the output of the node. During the ANN training, a learning algorithm adjusts and updates the weights until the pattern of data is reproduced within a minimal error. A detailed description of the selection of network topology and the algorithms involved in the learning of perceptrons can be found in several references (Bhat and McAvoy, 1992; Psaltis et al., 1988; Thibault and Grandjean, 1991; Van Breusegem et al., 1991; Venkatasubramanian and Chan, 1989). The papers describing applications of ANN’s on process identification and/or control report diverse network topologies, learning algorithms, and strategies of control. The ANN’s have been used as adaptivepredictive algorithms to predict the output variables of a system and/or the control action to reach the set point or the output of a reference model. Following the nomenclature for neural network models used in Thibault and Grandjean (1991), a direct ANN refers to a plant neural model that predicts the future output of the plant from a number of current and past values of the input and output variables; similarly, an inverse ANN refers to a plant inverse neural model that predicts one or more inputs of the plant from a number of current and past inputs and outputs and a number of future desired outputs. The direct ANN does not need precise analytical details about the process dynamics; this is particularly useful in processes with variable delay time and in processes which are very complex or not wellknown. The inverse ANN has similar advantages and avoids the need of making complex analytical inversions. Saint-Donat et al. (1991) have used a direct ANN to identify and predict the process output in an optimization-based predictive control system; they have developed analytical expressions that can be implemented in parallel to allow a high computing rate. Cheng et al. (1995) have developed and simulated an identification model based on a recurrent neural network that serves to predict the pH dynamics of systems with long and variable delay times. Some authors have used a

direct ANN as plant neural model, but they used other types of controllers. Song and Park (1993) have used a controller based on successive quadratic programming (SQP). Bhat and McAvoy (1990) have controlled a neutralization process by a back-propagation modelbased control (BPMC) which is essentially the same as that used in dynamic matrix control (DMC) except that the direct ANN is used in place of the linear convolution model. Chan (1995) has used a direct ANN for tuning a self-tuning control system. Ishida and Zhan (1995) have used an ANN to optimize the control of a distributed parameter crystal growth process. Nahas et al. (1992) have designed a nonlinear internal model controller (NIMC) for a process in which there is delay time and the input stream is a mixture of acidic, buffer, and alkaline streams; they have realized that the controller is much better than conventional PID controllers. Some researchers have reported data about the simultaneous application of two ANN’s for prediction and control of pH. The strategies of using and combining direct and inverse ANN’s are diverse. Some authors (Ungar et al., 1990) have proposed a strategy in which the weights of the inverse ANN are calculated by means of a direct ANN which is optimized by the backpropagation of the identification error; with this strategy, the updating of the inverse ANN weights is relatively fast in systems with lag and delay. Narendra and Parthasarathy (1990) have implemented a model reference adaptive control (MRAC) based on two ANN’s; one ANN represents the transfer function of the plant, and the other ANN acts as controller. Ishida and Zhan (1993) have developed a complex system for controlling a multiple input, multiple output (MIMO) process which has interactions and delay time; the system consists of two direct ANN’s which predict the controlled variables and two inverse ANN’s which provide the regulation of two manipulative variables. Psaltis et al. (1988) have made the identification and control by two inverse ANN’s; the weights of each ANN are updated independently but using the same back-propagated error (defined as the difference between the actual value of the manipulated variable and the value predicted by the first ANN). The disadvantage of this strategy is that the loop can loose stability because the minimum value of the back-propagated error is not always equal to the minimum control error. The aim of this work is to study, by simulation and experimentally, a control system based on two ANN’s. More concretely, the objectives are to evaluate the controller performance for pH-control purposes and to validate experimentally the controller adaptation and robustness in systems with delay time, under buffering changes and other perturbations, topics scarcely reported in the literature. The process used for testing the real implementation of the controller is the continuous neutralization of an aqueous solution of acetic and propionic acids with an aqueous solution of sodium hydroxide. The reactor is a continuous stirred tank (CSTR). The robustness and adaptation of the controller were studied under the following conditions: startup, acid flow rate perturbations, acid composition perturbations, and acid-buffering perturbations. The paper is organized as follows. First, the models of the controller, ANN’s, and neutralization process are given. Next, the experimental setup and procedure are described. Then, the study of the controller by numerical simulation is presented. Finally, the most representa-

Ind. Eng. Chem. Res., Vol. 37, No. 7, 1998 2731

Figure 1. Inputs and outputs and flow of information in the controller based on a direct and an inverse ANN.

tive results of the experimental implementation of the controller are reported and discussed. Controller Model The control system is a closed loop. The measured variable is the pH of the reactor exit stream, and the manipulated variable is the flow rate of the alkaline stream. The controller is an inverse model controller based on a combination of a direct ANN with an inverse ANN; the direct ANN is a plant identifier that predicts the output pH; the other ANN is a plant inverse neuronal model that provides the control action. The diagram of the controller, with the flow of information between the two ANN’s, is shown in Figure 1. The description of the ANN’s, the learning method, and the sequence of operations are given in the following paragraphs. (a) Description of the ANN’s. The two ANN’s are multilayered feed-forward neural networks with a prediction horizon. Each ANN is formed by three layers (input, hidden, and output), a topology widely used to treat several control problems (Cybenko, 1989; Hornick et al., 1989; Bhat and McAvoy, 1992; Van Breusegem et al., 1991; Venkatasubramanian and Chan, 1989). The transfer function is the sigmoid function

nj(k) )

1 1 + e-mj(k)

(1)

where nj is the output of a node and mj is the sum of inputs of the same node:

mj(k) )

∑i wij(k) ni(k)

(2)

where the subscript i denotes the nodes located in the layer that precedes the layer of the nodes with subscript j. The transfer function defined by eq 1 is bounded between 0 and 1; this is well suited because the output variables, pH and valve stem position, can be bounded between 0 and 1 (Herna´ndez and Arkum, 1992; Song and Park, 1993).

The inputs and outputs of each ANN (Figure 1) are different past/present/future values of pH, valve stem position, and set point. The numerical values of the input and output variables used by the ANN’s are normalized values in the range 0-1; the normalization is made by dividing each actual variable by its maximum range, that is to say, y ) pH/14, Xv ) (percent valve stem position)/100, and ysp ) (pH set point)/14. The number of nodes in each layer depends on the delay time of the plant, the sampling time, and the prediction horizon. For both ANN’s, the input layer has 13 nodes, the hidden layer has 7 nodes, and the output layer has 5 nodes. The design criteria applied to select the variables used as input and output of each ANN and to set the number of nodes in each layer were based on the experience obtained by studying the off-line training of the direct ANN, that is described later, and on the following considerations: (i) The purpose of the controller is to maintain the pH of the exit stream of a neutralization tank as close as possible to a given set point value. The measured variable is the pH inside or in the exit of the tank, and the manipulated variable is the stem position of a valve which regulates the input flow rate of an alkaline stream. Therefore, the controller model must be able to relate pairs of values of pH and valve stem position and it is reasonable to assume that both ANN’s have at least one input node with the present value of pH and another with the present value of the valve stem position, y(k) and Xv(k) in Figure 1. Several variables that can lead to pH variations are not measured and can be considered as free perturbations, for example the flow rate, concentration, and composition (buffering) of the acidic stream. (ii) For systems with delay time, all past data inside a period of time equal to the delay time are relevant. Several ways have been used by different authors to allow for the sequential order of events. When the delay time is not very long, the most used way is inputting past data of a number of sampling periods corresponding to the pure delay (Thibault et al., 1990; Ramasamy et al., 1995; Ungar et al., 1990; Cheng et al., 1995). For long delays, it is better to use recurrent networks (Ungar et al., 1990). As the experimental system under study has a small delay, we have selected the first way. For a maximum delay of 6 s and a sampling time ∆t ) 2 s (measured and selected as described later in the experimental setup), we need three past data of each measured variable. Therefore, six input nodes of both ANN’s contain three past values of pH and three past values of valve stem position, y(k - 1), y(k - 2), y(k 3), Xv(k - 1), Xv(k - 2), and Xv(k - 3) in Figure 1. (iii) The amplitude of the prediction horizon should not be overdimensioned, since the number of nodes required to manage too many future values would increase excessively. The prediction horizon is assumed equal to five sampling times (i.e. a total period of 10 s), enough to allow for the maximum delay of 6 s and fast gain changes or peaks within 4 s. Consequently, five input nodes of the direct ANN contain five future values of the valve stem position; these values are predicted by the inverse ANN, Xv(k + 1), ..., Xv(k + 5) in Figure 1. Similarly, five input nodes of the inverse ANN contain five future values of the set point, ysp(k + 1), ..., ysp(k + 5) in Figure 1. (iv) The number of nodes in the hidden layer was selected by using a trial and error method that consists

2732 Ind. Eng. Chem. Res., Vol. 37, No. 7, 1998

of selecting an overdimensioned number of hidden nodes and studying the evolution of some performance index as the number of nodes is decreased. The process of selection finishes when a topology is reached that gives a minimum value of the performance index. The criterion used consists of selecting the number of nodes which gives a minimum square identification error in a minimal number of iterations during the off-line training of the direct ANN. The flow of information between the two ANN’s is as follows. The output layer of the inverse ANN has five nodes which contain the five future values of valve stem position that are used as input by the direct ANN, Xv(k + 1), ..., Xv(k + 5) in Figure 1. The first value, Xv(k + 1), is multiplied by 100 (because it was normalized) and implemented in the control loop (in the experiments, it is sent to the D/A converter to manipulate the real valve, Xv in Figure 4). The output layer of the direct ANN has five nodes which contain the five future values of pH that are used by the inverse ANN to optimize its weights in the next sampling time, y(k + 1), ..., y(k + 5) in Figure 1. (b) Learning. The algorithms of learning, used to update the weights, are diverse: back-propagation (Rumelhart et al., 1986); modified back-propagation (Leonard and Kramer, 1990); conjugated gradient (Nahas et al., 1992); quasi-Newton algorithm (Van Breusegem et al., 1991); and reinforcement learning (Hosking and Himmelblau, 1992). We use here the back-propagation algorithm, that has been used in several industrial applications of ANN’s due to its simplicity and short computing time required. It is an iterative process which involves the changing of the weights, by means of a gradient descent method, to minimize the learning error. The back-propagated errors used here are different for each ANN and depend, in the case of the direct ANN, on the type of learning used (off-line learning or on-line updating). They are defined by

direct ANN, learning ed(k) ) y(k + p|k) - y(k + p) (3a) direct ANN, updating ed(k + p) ) y(k - p + 1|k - f) - y(k - p + 1) (3b) inverse ANN ez(k + p) ) y(k + p|k - 1) - ysp(k + p) (4) where f is the number of future values predicted (prediction horizon) and p varies from 1 to f. The expression of weight updating is

wij(k) ) wij(k - 1) + µninj(1 - nj)βj

(5)

where µ is the learning coefficient, which gives the rate of change of the weights, and βj is given by the following expressions:

for the output layer of the direct ANN for the output layer of the inverse ANN

βj ) ed

(6)

β j ) ez (7)

for the hidden layer of both ANN’s βj ) wjhnh(1 - nh)βh (8)

∑h

where the subscript h denotes the node of the next layer to which the node j is connected. The direct ANN is first trained by using a preliminary off-line learning. This off-line training is made by simulating the process in open loop. In this simulation, the data patterns used for the learning are obtained from several pH-t curves which are generated under different perturbations of the flow rate of the alkaline stream. The back-propagated error is given by eq 3a. The number of patterns of data presented to the ANN depends on the number of weights of the ANN (each learning pattern consists of 10 pairs of values of valve stem position and pH for each weight included in the ANN). The on-line updating of the direct ANN is made only during the closed-loop operation. It serves to adapt better the ANN for situations rather different from the ones used during the first rough off-line training. The existence of this on-line updating simplifies the work required for the off-line training and increases the accuracy of the ANN during the closed-loop operation. The on-line updating is made once at each sampling time, the back-propagated error is given by eq 3b, and the window of pH data used consists of the series y(k|k - 5), ..., y(k - 4|k - 5) in Figure 1. Due to the structure of the control loop here used, the inverse ANN must be trained always on-line during the closed loop operation. The updating is made once at each sampling time, the back-propagated error is given by eq 4, and the set point and pH data used during the updating are ysp(k + 1), ..., ysp(k + 5) and y(k + 1|k 1), ..., y(k + 5|k - 1) in Figure 1. The learning coefficient, µ in eq 5, can be either constant or time-variant. In any case, it should be set at some adequate value giving fast convergence of the objective function, for example fast decreasing of the back-propagated error. The updating rate can be critical during the actual operation, since the changes of the process gain can be frequent, strong, and fast. The information about the selection and implementation of the law of variation of the learning coefficient is scarce in the literature (Chen, 1990). The coefficient can be decreased gradually following some criteria based, for example, on the number of iterations and the identification error. We have examined empirically different criteria and methods to define a variable learning coefficient. The best empirical relation found is

µ)

µm2 1 + e-µm

(9)

where µm is a moving value of the learning coefficient given by

µm ) µ0 + (|S(k)|‚|Erc(k)|)

(10)

where µ0 is a constant value greater than zero and S(k) and Erc(k) are defined by

y(k) - y(k - 1) ∆t

(11)

Erc(k) ) y(k|k) - ysp(k)

(12)

S(k) )

Ind. Eng. Chem. Res., Vol. 37, No. 7, 1998 2733

The justification of eqs 9-12 is as follows. On one hand, the learning coefficient gives the rate of learning/ forgetting of the ANN. A high value of µ allows the ANN a quick learning of situations never seen, but it causes also a quick forgetting of old patterns. On the other hand, the main problem of neutralization processes is that the gain of the process depends on the slope of the titration curve. Consequently, the gain is very high inside a narrow range of pH when the system is near the equivalence point and is low inside a wide range of pH when the system is far from that point. From the above considerations, it is reasonable to choose high values of µ when the system is near the equivalence point and low values in other cases. This type of change is well performed by including (a) the slope of the pH-t curve, term S(k) in eqs 10-11, that is high when the process is near the equivalence point; (b) the sigmoidal relation given by eq 9, that ensures that the maximum and minimum values and the rate of change of the learning coefficient between successive iterations will remain within adequate ranges; and (c) the term Erc in eqs 10 and 12, that allows for the control error, which can also be high when the system is near the equivalence point. (c) Sequence of Calculations and Operation. During the operation of the control system, the two ANN’s are working in series and alternatively in generalization mode (predicting future pH outputs and valve stem positions) and in learning mode (updating their weights). The detailed sequence of measurements and calculations at each sampling time is as follows (see Figure 1 for more details): (1) Measuring the actual pH and valve stem position and normalizing both values to obtain y(k) and Xv(k). (2) Predicting five future values of the valve stem position by the inverse ANN. There are used eqs 1-2 with the updated weights obtained in the instant k 1, the present and three past values of actual pH and valve stem position, and five values of the set point trajectory. (3) Updating the weights of the inverse ANN by applying eqs 1, 2, 4, 5, 7, and 8. The error, eq 4, is calculated by using five differences between the set point and the pH predicted by the direct ANN in the instant k - 1. (4) Predicting five future values of pH by the direct ANN. There are used eqs 1-2 with the five future values of the valve stem position predicted by the inverse ANN, and the present and three past values of actual pH and valve stem position. (5) Updating the weights of the direct ANN by using eqs 1, 2, 3b, 5, 6, and 8. The errors, eq 3b, are calculated by using the differences between the pH predicted before by the direct ANN five sampling times and the actual pH. (6) Converting and transmitting to the real valve the first value of the valve stem position predicted by the inverse ANN, Xv(k + 1|k). Description of the Neutralization Process The basic process under study is the neutralization of aqueous solutions of acetic and propionic acids with sodium hydroxide in a single CSTR. In some runs, the acidic stream contains also a strong acid (sulfuric) and common-ion salts (sodium acetate, sodium carbonate, and sodium sulfate) to provide buffering changes.

The equilibrium reactions taking place in an aqueous mixture of acetic acid, propionic acid, and sodium hydroxide are

AcH S Ac- + H+

(13a)

PrH S Pr- + H+

(13b)

NaOH S Na+ + OH-

(13c)

H2O S H+ + OH-

(13d)

The theoretical model of the neutralization process for numerical simulation purposes is easily obtained by solving the charge and material balances. Thus, the pH of the reacting mixture, assuming a dilute ideal solution at 25 °C, is calculated from the following charge balance equation:

CAcH -pH

10 1+ KAcH

+

CPrH 10-pH 1+ KPrH

+ 10(pH-14) ) CNaOH + 10-pH (14)

where KAcH and KPrH are the dissociation constants of the acids (at 25 °C, pKAcH ) 4.75; pKPrH ) 4.87). CAcH, CPrH, and CNaOH are the respective concentrations inside the CSTR. These concentrations are calculated from the material balances of the components. Such balances are given by the following transient state equations

QAC0AcH ) QCAcH + V

dCAcH dt

(15a)

QAC0PrH ) QCPrH + V

dCPrH dt

(15b)

QBC0NaOH ) QCNaOH + V

dCNaOH dt

(15c)

where QA and QB are the flow of acidic and alkaline streams, respectively, and Q is the total flow (Q ) QA + QB). The concentrations C0AcH, C0PrH, and C0NaOH are the feed concentrations before mixing inside the reactor. For streams which include sulfuric acid and salts, the balances are similar to those of eqs 14-15 and can be solved easily. The titration curves of the chemical systems used in the control study are shown in Figure 2. The composition of each system is given in Table 1. The relevance of nonlinearity is evident from these curves, which have slopes that vary with pH and type of acidic stream and show how the pH responses to the same amount of added alkali may differ so much from system to system and from pH to pH (Gustaffson et al., 1995). The buffering or buffer capacity, defined as the inverse of the titration curve slope (Gustaffson et al., 1995), gives a measure of the amount of base that must be added to an acidic solution for producing a given change of pH. The change of buffering with pH of the systems under study is shown in Figure 3 (the buffering was calculated from the slope of the titration curves of Figure 2). The change of buffering with pH and the significant differences of the buffering curves from system to system in

2734 Ind. Eng. Chem. Res., Vol. 37, No. 7, 1998

Figure 2. Titration curves of the acidic solutions (see composition in Table 1).

Figure 3. Buffering curves of the acidic solutions (see composition in Table 1).

Table 1. Chemical Composition of the Acidic Stream and Buffers concn (mol/L) type of acetic propionic sulfuric sodium sodium sodium stream acid acid acid acetate sulfate carbonate B#0 B#1 B#2 B#3 B#4 B#5 B#6

0.10 0.02 0.02 0.02 0.02 0.02 0

0.05 0 0 0 0 0 0

0 0.02 0 0.01 0.02 0.02 0.02

0 0.02 0.02 0.02 0 0.01 0.02

0 0.01 0.01 0.01 0 0.005 0.01

0 0.005 0.005 0.005 0 0.0025 0.005

certain ranges of pH give another evidence of the nonlinearity of the neutralization process under study. Experimental Setup The diagram of the experimental setup is shown in Figure 4. The neutralization reactor is a continuous stirred tank (1.75 L) with a mean residence time (V/Q) of the liquid between 5 and 30 min. The runs are carried out at room temperature (around 25 °C). The feed concentrations in steady state are C0AcH ) 0.10 mol/ L, C0PrH ) 0.05 mol/L, and C0NaOH ) 0.20 mol/L. The feed flow rate of the acidic stream in steady state is 3 × 10-3 L/s. The pH electrode is an Ag-AgCl electrode with internal reference, saturated with a 4 M KCl solution. In a series of runs, the electrode was inserted in a small tubular device connected at the exit of the vessel (point 2 in Figure 4). The device has a weir (overflow outlet) that provides a constant volume of reacting mixture in the tank. When the electrode is inside this device, there is a delay time that depends on the total flow rate of the liquid. The delay was measured experimentally from the pH response curve obtained by feeding the reactor with pure water and injecting steps of sodium hydroxide. For a total flow rate from 3 × 10-3 to 9 × 10-3 L/s, the delay ranges between 2 and 6 s. When the electrode is located inside the tank (point 1 in Figure 4), the measured delay time is negligible (about 0.1-0.3 s). The dynamics of the actual electrode, measured in previous experiments, is

Figure 4. Experimental setup.

a first-order lag. The electrode response is asymmetric; it has a time constant of 1 s for acidic perturbations and 5 s for alkaline perturbations. The control loop includes the on-line implementation of the algorithms involved in the controller model, ANN’s, and the process described above. The pH measured with the pH meter is transmitted to the computer through an A/D interface (ADC Data Translation, Board Model 2811, input (2.5 V). The computer code was implemented in a PC-386 computer. The time required to compute the algorithms is approximately 1 s. The sampling time was set at ∆t ) 2 s. This value is adequate under the wide range of conditions studied. It was obtained by trying values over the range 1-20 s and according to the estimating criteria given in A° stro¨m and Wittenmark (1984). The computer manages the digital input and normalization of pH and the output signal transmitted to the valve. This output signal is converted by a D/A interface (ADC Data Translation,

Ind. Eng. Chem. Res., Vol. 37, No. 7, 1998 2735

Board Model 2815, output 4-20 mA). The valve is a pneumatic control valve (Badger Meter, Inc., model D-Research, ATO, equal percentage trim, coefficient 0.8) fitted with an I/P converter (Bellofram 1000; input 4-20 mA, output 3-15 psi). Procedure The procedure assumed in the simulation and actually used in the experimental study comprises the following operations: (a) start-up of the continuous reactor. The run starts by loading the reactor with acetic and propionic acids and sodium hydroxide. The proportions of acids and alkali are adjusted manually to give an initial desired pH; (b) continuous feeding of reagents and turning-on the automatic control; (c) completion of a steady state in which the pH is around the set point; and (d) studying the pH output responses to different types of perturbations. The perturbations of the set point are of two types: (1) successive steps of 0.5 pH units and (2) square wave of amplitude equal to 1 pH unit and centered at pH ) 7. The perturbations of flow and/or concentration of acetic and propionic acids are (1) steps of flow, (10% to (50% of the initial steady-state flow, and (2) steps of concentration, (10% to (50% of the initial concentration. The buffering changes modify the titration curve (process gain). The two types of perturbations are as follows: (1) With the process under steady state (a stream of acetic acid, propionic acid, and sodium hydroxide) and pH ) 7, the acidic stream is substituted by a stream of B#5 (Table 1). Some time after, the buffer B#5 is substituted by a stream of pure sulfuric acid of concentration 0.02 mol/L. Successive substitutions between sulfuric acid and B#5 are repeated several times. (2) With the process under steady state (a stream of acetic acid, propionic acid, and sodium hydroxide) and pH ) 7, the acidic stream is substituted by a stream of one of the buffers given in Table 1. These buffers are different mixtures of acetic acid, a strong acid, and three common-ion salts. The concentration of each compound is adjusted independently and over the following ranges: acetic acid, 0-0.02 mol/L; sulfuric acid, 0-0.01 mol/L; sodium acetate, 0-0.02 mol/L; sodium sulfate, 0-0.01 mol/L; sodium carbonate, 0-0.005 mol/L. The procedure consists of substituting alternatively the acidic stream, B#0, by one of the buffers; that is to say, the input stream follows the sequence B#0-B#1-B#0B#2-B#0-B#3 and so on. The performance of the controller was evaluated quantitatively by measuring and comparing the ITSE (integral time quadratic error), the OS (maximum overshoot), and the settling time of the pH-t curves. The ITSE is defined by g

ITSE )

k[measured pH - set point]k2∆t ∑ k)1

(16)

where g is the number of time steps over which the calculation of the ITSE is extended. The maximum overshoot in the pH-t response curve, OS, is measured in pH units with respect to the set point; that is, OS )

Figure 5. Numerical simulation of the start up from an initial pH ) 6 to a set point of pH ) 7.

maximum overshoot - set point. The settling time is taken as the time required to reach a pH equal to or less than (5% of the set point. Numerical Simulation The simulation was used to estimate the limits of application and robustness of the controller. The simulation gives the pH-t curves in the controlled CSTR. The simulation computer code includes the controller model, the neutralization process, the calculation of the ITSE, and a simple algorithm for detecting and measuring the OS and the settling time. The off-line training of the direct ANN was made assuming a maximum delay time of 6 s. The learning is performed well with a constant learning coefficient µ ) 0.35. When the direct ANN is updated on-line in the closed loop, it is assumed that the elements of the plant (valve, pH meter, etc.) have a transfer function equal to 1. The variable learning coefficient for on-line updating of the direct ANN gives a settling time shorter than the one obtained with the constant learning coefficient but produces lower relative stability. Therefore, we decided that µ can be set at a constant value, µ ) 0.35, to give a minimum identification error of the direct ANN in less than 100 iterations and a stable performance of the control loop under all the situations explored. In the case of the inverse ANN, the relative stability of the closed loop is almost the same with either constant or variable learning coefficients, but the settling time is shorter with the variable learning coefficient. Therefore, the learning coefficient actually implemented in the on-line updating of the inverse ANN was the one given by the sigmoidal relation of eq 9, with µ0 ) 0.1 in eq 10. Some representative examples of the results reached in the simulation of several perturbations in the closed loop are shown in Figures 5-8. The pH-t curve of a typical start-up is shown in Figure 5. The OS is only 0.1 pH unit, and the settling time is about 30 s. The pH-t curve of step perturbations of the set point is shown in Figure 6. The OS is less than 0.5 pH units, even near the neutralization point, which is about 8.5 for the mixture of acetic acid, propionic acid, and sodium hydroxide. When the concentration of the acidic stream is perturbed (Figure 7), the shape of the pH-t curve depends on the sign of the perturbation or, more precisely, on the tendency of the system to its equivalence point. A very similar behavior was obtained in

2736 Ind. Eng. Chem. Res., Vol. 37, No. 7, 1998

Figure 6. Numerical simulation of successive steps of the set point.

Figure 7. Numerical simulation of positive and negative steps of the acid concentration.

the simulation of perturbations of the acidic stream flow rate. Under the operating conditions assumed in the simulation, the pH decreases and goes far from the equivalence point when the perturbations are positive steps; consequently, the pH response curve is more damped for positive steps of concentration of the acidic stream than for negative ones. In both cases, the maximum OS is low, about 0.3 pH unit. For buffering changes consisting of successive substitutions between sulfuric acid and B#5, the system is well controlled, with low OS and settling time. Nevertheless, the response of the system is poor, with large OS and settling times, for the successive substitutions B#0-B#1-B#0-B#2B#0-B#3 and so on (Figure 8). We think that this bad controller behavior can be due to the fact that the direct ANN was trained off-line using only perturbations of the alkaline stream flow rate, that is, using low buffering changes. Therefore, the controller works well if the change from stream to stream means a low change of buffering (e.g. the successive changes between sulfuric acid and B#5), but it is not able to update on-line its weights against strong changes of the buffering (e.g. the changes between B#0 and B#1 to B#6). The controller here studied consists of two ANN’s with 127 weights each, and as the on-line adaptive controller is updated continuously with closed-loop data, these

Figure 8. Numerical simulation of the pH response to successive buffering changes with different buffers (B#0 to B#6, see composition in Table 1).

weights change in time due to adaptation. To evaluate the adaptation of the controller and to know if the logicless noise of the measurements can produce a random walk of the model parameter away from meaningful values, we have explored the on-line adaptation of the controller and the effects of noise in the model parameters when the process is under good control. Some illustrative examples are shown in Figures 9 and 10. The pH response curves in Figure 9a and b were obtained by simulating the neutralization of acetic and propionic acids with sodium hydroxide under successive steps of the set point from 7 to 7.5, 7.5 to 6.5, and 6.5 to 7 (a quiet period of about 15 h between each series of set point perturbations was assumed to study later the effects of noise). In the first case (Figure 9a), the manipulation of the flow rate of the sodium hydroxide stream was exactly the one calculated by the inverse ANN; in the second case (Figure 9b), this flow rate was artificially affected by a random noise of (5% of the actual value. Although in both cases the control is achieved, the ITSE increases significantly in the presence of noise. The changes in time of all the 127 × 2 weights do not follow any predictable or systematic patterns. Every weight can increase or decrease arbitrarily with the set point perturbations and noise. For example (Figure 9c), the weights 1-10-2-2 (the weight that connects the 10th node of the input layer with the 2nd node of the hidden layer) and 1-10-2-4 (the weight that connects the 10th node of the input layer with the 4th node of the hidden layer) decrease with pH and do not recover their old values when the process is well controlled. The changes of the same weights in the run with noise (Figure 9d) are quite different. Both weights change with pH, as in the process without noise, but they suffer small oscillations due to noise. In the case of the weight 1-10-2-4, the global effect of noise is surprising, since the long time tendency is decreasing instead of increasing. The changes of three weights of the direct ANN during the buffering perturbations are shown in Figure 10 (the pH response curve is shown in Figure 8). In this case, we have also selected a second layer weight, the weight connecting the third hidden

Ind. Eng. Chem. Res., Vol. 37, No. 7, 1998 2737

Figure 9. Adaptation of the controller and effect of noise: (a) pH and ITSE without noise; (b) pH and ITSE with noise; (c) two weights without noise; (d) two weights with noise.

node with the fifth node of the output layer (2-3-35). As in the former example, the adaptation of the weights does not follow any predictable or systematic pattern. Experimental Validation of the Controller The controller has been implemented in the experimental system, and several runs were made under the same conditions and perturbations as the ones assumed in the numerical simulation. An additional set of runs were made to study the effects of real delay time by modifying the location of the electrode. The comparison of simulated and real results as well as the experimental behavior of the controlled plant are discussed in the following paragraphs. Comparing the results obtained in the simulation with the experimental ones, we observed that in general the responses of the experimental system have longer settling times and lower relative stability than the ones obtained in the simulation. The differences are well illustrated, for example, by comparing the curves of Figures 6-8 with the ones of Figures 12, 13, and 15. The disagreement between theoretical and experimental

results can be attributed to several factors, which were already discussed in a previous work (Palancar et al., 1996). However, the most important differences between the real plant and the simulated one refer to the delay time and the electrode dynamics. The delay time of the real plant is time-variable, but it is assumed constant in the simulation. The real electrode has a different time constant for acidic and for alkaline perturbations, but it is assumed constant in the simulation. The effects of the electrode location on the controller performance were studied by comparing runs in which the pH electrode was inserted either inside the tank or in the tubular device connected to the exit of the tank (positions 1 and 2 in Figure 4). The results show that the system behavior is practically the same with the electrode in every location. By way of example, two pH-t curves obtained with the electrode located inside and outside the tank are shown in Figure 11. The controller is able to adapt itself when the electrode is outside the tank and can dominate the existence of delay time. This good performance against delay time can be attributed to the input of past values of the variables into the ANN’s. However, these past values do not

2738 Ind. Eng. Chem. Res., Vol. 37, No. 7, 1998

Figure 12. Response of the real plant to positive steps of the set point.

Figure 10. Adaptation of three weights of the controller during six buffering changes (see the pH curve in Figure 8).

Figure 11. Experimental start up of the real plant. (a) Electrode inside the tank; (b) electrode outside the tank.

affect the good controller performance if the delay time is less than the maximum expected one. The pH-t curve for step perturbations of the set point is shown in Figure 12. The system is well-controlled (OS less than 0.5 and rapid adaptation) when the set point is lower than 8. However, the control becomes worse as the set point approaches the neutralization point of the acidic stream (pH ) 8.5 in the run of Figure 12). The controller performance against perturbations of the concentrations of acids was tested by using steps of concentration of (10%, (25%, and (50% of the initial steady-state concentration. The response curves are always underdamped (Figure 13) with an OS which depends on the magnitude of the perturbation, that is, OS ) 3 for steps of (50%, OS ) 1 for steps of (25%, and OS ) 0.5 for steps of (10%. The controller

efficiency is better when the same type of concentration perturbations are made successively; for example, the inverse ANN learns adequately this type of perturbations (Figure 13a). For perturbations of the acidic stream flow, the response of the system and controller learning are qualitatively the same as those for the perturbations of concentration mentioned above. Therefore, both the OS and the settling time are lower and the OS depends little on the magnitude of the perturbation. The response of the system for buffering changes of the type B#5-sulfuric acid-B#5-sulfuric acid-B#5 and so on is shown in Figure 14. The good on-line learning of the inverse ANN is evidenced by the decreasing OS as the number of the same perturbations increases. Nevertheless, the controller works poorly for the successive perturbations of the type B#0-B#1-B#0-B#2B#0-B#3 and so on (Figure 15). The OS and settling time can reach respectively values of 4 pH units and 10 min. This bad controller behavior can be due to the fact that the direct ANN was trained off-line using only perturbations of the alkaline stream flow rate, that is, using low buffering changes. Therefore, the on-line learning of the inverse ANN during each new perturbation is not enough for controlling the buffering perturbation, probably due also to the strong differences between the buffering of each stream (Table 1 and Figures 2 and 3). Conclusions The applicability of a controller based on two ANN’s was discussed and illustrated with numerical simulations and experiments involving different types of perturbations in the process of neutralization of acetic and propionic acids with sodium hydroxide. The controller requires off-line and on-line learning of the direct ANN and on-line learning of the inverse ANN. The off-line training of the direct ANN was accomplished by numerical simulation of the neutralization process in open-loop conditions. The adaptive properties of the controller were evidenced by means of the changes in time of the network weights. The effect of adaptation of weights when noise is present was explored and, for the range of conditions studied, the controller keeps its capacity of control at least during 100 h.

Ind. Eng. Chem. Res., Vol. 37, No. 7, 1998 2739

Figure 14. Response of the real plant to successive buffering changes between two buffers (sulfuric acid and B#5).

Figure 15. Response of the real plant to successive buffering changes with different buffers (B#0 to B#6, Table 1).

adequately under frequent and strong buffering changes of very different buffers. Allowing for these limitations, the proposed controller could be useful only for processes in which the expected perturbations and buffering changes were small.

Figure 13. Response of the real plant to positive and negative steps of the acid concentration: (a) steps of (10%; (b) steps of (25%; (c) steps of (50%.

The controller can be applied to processes with short delay time. The input layer of each ANN should contain enough nodes to take into account the number of past values necessary to cover the maximum delay time expected for the plant. If a maximum delay is assumed in the model but the actual delay time of the plant is zero or shorter than this maximum, the controller has practically the same performance as in the system with an actual delay equal to the maximum assumed. The experimental validation of the controller shows that the control efficiency is good only for perturbations which do not involve strong buffering changes (e.g. for small perturbations of set point, flow, and concentration of acids). Under these conditions, the ANN’s are able to adapt on-line their weights and to control perturbations never seen before. The controller performance is also good after successive buffering changes between two buffers. Nevertheless, the ANN’s cannot learn

Nomenclature C ) concentration inside the tank, mol/L C0 ) concentration in the feed stream, mol/L Erc ) predicted control error, dimensionless e ) back-propagated error, dimensionless ITSE ) integral time squared error, (s‚pH units)2 k ) discrete time, k (integer) = t/∆t K ) ionization constant of weak acid m ) sum of inputs to a node, dimensionless n ) node output, dimensionless OS ) maximum overshoot, pH units Q ) total flow rate, L/s QA ) flow rate of the acidic stream, L/s QB ) flow rate of the alkaline stream, L/s S ) slope of the pH-t curve, s-1 t ) time, s ∆t ) sampling time, s V ) reactor volume, L w ) weight of a node input, dimensionless Xv ) normalized valve stem position, dimensionless y ) normalized pH, dimensionless ysp ) normalized pH set point, dimensionless

2740 Ind. Eng. Chem. Res., Vol. 37, No. 7, 1998 Greek Symbols β ) back-propagated error, dimensionless µ ) learning coefficient, dimensionless

Literature Cited A° stro¨m, K. J.; Wittenmark, B. Analogic Design Conversion. In Computer Controller Systems; Prentice Hall Englewood Cliffs, NJ, 1984; Chapter 8. Bhagat, P. An Introduction to Neural Nets. Chem. Eng. Prog. 1990, Aug., 55. Bhat, N. V.; McAvoy, T. J. Use of Neural Nets for Dynamic Modeling and Control of Chemical Process Systems. Comput. Chem. Eng. 1990, 14 (4/5), 573. Bhat, N. V.; McAvoy, T. J. Determining Model Structure for Neural Models by Network Stripping. Comput. Chem. Eng. 1992, 16 (4), 271. Brezinski, D. P. Kinetic, Static and Error of Liquid Junction Reference Electrodes. Analyst 1983, 108, 510. Buchholt, F.; Ku¨mmel, M. Self-Tuning Control of a pH-Neutralization Process. Automatica 1979, 15 (6), 665. Chan, H. Ch.; Yu, Ch. Ch. Autotuning of Gain-Scheduled pH Control: An Experimental Study. Ind. Eng. Chem. Res. 1995, 34, 1718. Chen, F. C. Back-Propagation Neural Networks for Nonlinear SelfTuning Adaptive Control. IEEE Control Syst. Magazine 1990, 10 (3), 44. Cheng, Y.; Karjala, T. W.; Himmelblau, D. M. Identification of Nonlinear Dynamic Processes With Unknown and Variable Dead Time Using an Internal Recurrent Neural Network. Ind. Eng. Chem. Res. 1995, 34, 1735. Cybenko, G. Approximations by Superpositions of a Sigmoidal Function. Math. Control Signal Syst. 1989, 2, 303. Giusti, A. L.; Hougen, J. O. Dynamics of pH Electrodes. Control Eng. 1961, 8, 136. Gustafsson, T. K.; Waller, K. V. Nonlinear and Adaptive Control of pH. Ind. Eng. Chem. Res. 1992, 31, 2681. Gustafsson, T. K.; Skrifvars, B. O.; Sandstro¨m, K. V.; Waller, K. V. Modeling of pH for Control. Ind. Eng. Chem. Res. 1995, 34, 820. Herna´ndez, E.; Arkun, Y. Study of the Control-Relevant Properties of Back-propagation Neural Network Models of Nonlinear Dynamical Systems. Comput. Chem. Eng. 1992, 16 (4), 227. Hershkovitch, H. Z.; McAvoy, T. J.; Liapis, A. I. Dynamic Modeling of pH Electrodes. Can. J. Chem. Eng. 1978, 56 (2), 346. Hornick, K.; Stinchcombe, M.; White, H. Multilayered Feedforward are Universal Approximators. Neural Networks 1989, 2, 359. Hosking, J. C.; Himmelblau, D. M. Artificial Neural Network Models of Knowledge Representation in Chemical Engineering. Comput. Chem. Eng. 1988, 12 (9/10), 881. Hosking, J. C.; Himmelblau, D. M. Process Control Via Artificial Neural Networks and Reinforcement Learning. Comput. Chem. Eng. 1992, 16 (4), 241. Ishida, M.; Zhan, J. Neural Network Control for a MIMO Process with Time Delay. J. Chem. Eng. Jpn. 1993, 26 (3), 337. Ishida, M.; Zhan, J. Neural Model-Predictive Control of Distributed Parameter Crystal Growth Process. AIChE J. 1995, 41, 1 (10), 2333. Jayadeva, B.; Rao, S. N. M.; Chidambaram, M.; Madhavan, K. P. Nonlinear Controller for a pH Process. Comput. Chem. Eng. 1990, 14 (8), 917. Leonard, J.; Kramer, M. A. Improvement of the Back-propagation Algorithm for Training Neural Networks. Comput. Chem. Eng. 1990, 14 (3), 337.

Mahuli, S. K.; Rhinehart, R. R.; Riggs, J. B. Nonlinear ModelBased Control of pH. Proceedings of AIChE Annual Meeting, Los Angeles, CA, 1991; AIChE: New York, 1991; paper 149g, p 17. Mahuli, S. K.; Rhinehart, R. R.; Riggs, J. B. pH Control Using a Statistical Technique for Continuous On-Line Model Adaptation. Comput. Chem. Eng. 1993, 17 (4), 309. Martı´n-Sa´nchez, J. M.; Rodellar, J. Adaptive Predictive Control. From the Concepts to Plant Optimization; Prentice Hall International: New York, 1996. Nahas, E. P.; Henson, M. A.; Seborg, D. E. Nonlinear Internal Model Control Strategy for Neural Network Models. Comput. Chem. Eng. 1992, 16 (12), 1039. Narendra, K. S.; Parthasarathy, K. Identification and Control of Dynamical Systems Using Neural Networks. IEEE Trans. Neural Networks 1990, 1 (1), 4. Palancar, M. C.; Arago´n, J. M.; Migue´ns, J. A.; Torrecilla, J. S. Application of a Model Reference Adaptive Control System to the pH-Control. Effects of Lag and Delay Time. Ind. Eng. Chem. Res. 1996, 35 (11), 4100. Piovoso, M. J.; Williams, J. M. Self-Tuning pH Control: A Difficult Problem, An Effective Solution. Intech 1985, May, 45. Psaltis, D.; Sideris, A.; Yamamura, A. A. A Multilayered Neural Network Controller. IEEE Control Syst. Magazine 1988, 8 (2), 17. Ramasamy, S.; Deshpande, P. B.; Paxton, G. E.; Hajare, R. P. Consider Neural Networks for Process Identification. Hydrocarbon Proc. 1995, Jun., 59. Rhinehart, R. R. Wastewater pH Control. Intech 1990, Jul., 42. Rumelhart, D. E.; Hinton, G. E.; Willians, R. J. Learning Representations by Back-Propagating Errors. Nature 1986, 323, 533. Saint-Donat, J.; Bhat, N.; McAvoy, T. J. Neural Net Based Model Predictive Control. Int. J. Control 1991, 54, 1453. Seborg, D. E.; Edgar, T. F.; Shah, S. L. Adaptive Control Strategies for Process Control: A Survey. AIChE J. 1986, 32 (6), 881. Song, J. J.; Park, S. Neural Model Predictive Control for Nonlinear Chemical Processes. J. Chem. Eng. Jpn. 1993, 26 (4), 347. Sung, S. V.; Lee, I. B. pH Control Using a Simple Set Point Change. Ind. Eng. Chem. Res. 1995a, 34, 1730. Sung, S. V.; Lee, I. B. pH Control Using an Identification Reactor. Ind. Eng. Chem. Res. 1995b, 34, 2418. Thibault, J.; Grandjean, B. P. A. Neural Networks In Process Control. A Survey. Proc. IFAC Symp. ADCHEM91, Toulouse, France, 1991; Pergamon Press: New York, 1991; p 295. Ungar, L. H.; Powell, B. A.; Kamens, S. N. Adaptive Networks for Fault Diagnosis and Process Control. Comput. Chem. Eng. 1990, 14 (4/5), 561. Van Breusegem, V.; Thibault, J. T.; Che´ruy, A. Adaptive Neural Models for On-Line Prediction in Fermentation. Can. J. Chem. Eng. 1991, 69, 481. Venkatasubramanian, V.; Chan, K. A Neural Network Methodology for Process Fault Diagnosis. AIChE J. 1989, 35 (12), 1993. Williams, G. L.; Rhinehart, R. R.; Riggs, J. B. In-Line ProcessModel-Based Control of Wastewater pH Using Dual Base Injection. Ind. Eng. Chem. Res. 1990, 29 (7), 1254. Wright, R. A.; Soroush, M.; Kravaris, C. Strong Acid Equivalent Control of pH Processes: An Experimental Study. Ind. Eng. Chem. Res. 1991, 30 (11), 2437.

Received for review October 15, 1997 Revised manuscript received March 20, 1998 Accepted March 23, 1998 IE970718W