Ind. Eng. Chem. Res. 1992,31,2681-2693
2681
PROCESS ENGINEERING AND DESIGN Nonlinear and Adaptive Control of pH Tore K. Gustafsson and Kurt V. Waller* Process Control Laboratory, Department of Chemical Engineering, Abo Akademi, SF-20500 Abo, Finland
Methods for continuous control of pH in process streams are treated. Nonlinear models for pH, valid for acid-base reactions in water solutions, are derived from first principles, and a nonparametrized model is introduced for processes with unknown composition. The two basic choices for continuous in-line feedback control of pH are between linear and nonlinear control and between fixed-parameter and adaptive control. A detailed simulation example illustrates properties of pH-control systems in oscillating mode, a common phenomenon in, e.g., wastewater pH-control systems. Use of a proper nonlinear process model for feedback control is shown to essentially eliminate the bias of the oscillations and to result in an average pH close to the setpoint, whereas standard linear feedback control does not. The main reason for the need of adaptation is changing buffering (titration curve). Advantages of adaptive control over nonadaptive control are illustrated with respect to robustness and performance, and convergence properties of nonlinear adaptive control compared to linear-model adaptive control are experimentally illustrated. Practical issues in the implementation of linear and nonlinear self-tuning control of pH are discussed.
Introduction In past years the control of pH has received considerable attention in the literature. One reason is the highly nonlinear character of some pH-control processes combined with a simple structure of the mathematical model, which makes pH control ideal for illustrating new methods for nonlinear control. The fact that only simple and inexpensive experimental equipment is needed for authentic experiments makes the pH-control process suitable as a test bench for nonlinear process-controlmethods. Another reason for the popularity of pH control in the literature is the fact that the practical pH-control problem is not yet finally solved. This is especially the case in pH control of industrial wastewater, where the lack of robustness and performance of accessible control methods has enforced design solutions with voluminous dilution tanks instead of compact in-line pH control. The problem of nonlinearity in pH control is generally recognized, and often overemphasized. The severe static nonlinearity, in terms of pH, of the process of neutralizing a strong acid with a strong base, or vice versa, is seldom present in industrial pH controL In practice small amounta of buffering species significantly decrease the severe nonlinearity of the theoretical process of mixing strong acids and basea. The remaining nonlinearity, however, still often deteriorates linear feedback control of pH. Nonlinear feedback control through inversion of the process nonlinearity can give superior performance compared to linear feedback of pH (Waller and Gustafsson, 1983). However, in this case the nonlinearity must be known with a high degree of accuracy. If the knowledge of the nonlinearity of the process is inaccurate, then feedback through the inverted nonlinearity must be relaxed in order to maintain robustness, and the superiority of nonlinear feedback is questionable. In practical control a well-tuned linear controller performs often quite as well as a nonlinear controller (Gustafsson, 1985). Unbuffered neutralization processes do, however, exist. High concentrations of strong acids remove, as pointed out
by Okey et al. (19781,all carbonate, which normally buffers pH in raw water. Okey et al. also point out that “many processes require the use of deionized water, which also often produces a waste stream devoid of buffers”. They recommend additional bicarbonate buffering for such highly sensitive neutralization processes. Adding chemicals so as to make the control problem simpler is, however, a less appealing philosophy than adding more knowledge and intelligence into the controller. Nonlinear feedback is advocated in the literature with better robustness and tighter control compared to linear feedback (Wright and Kravaris, 1991). This is the case if the controlled pH value makes an excursion over a broad pH interval. If the controlled pH is kept within a small pH interval, the nonlinearity within this pH interval is probably smaller than the inaccuracy in the estimate of this nonlinearity. There is, however, another and probably more important reason to use nonlinear control of pH and especially nonlinear modeling in combination with feedback control of pH. That reason is to obtain average pH values closer to the setpoint in oscillating pH-control systems. Occasional oscillations in the controlled pH are quite common in pH control of wastewater-an industrial example is given by Waller and Gustafsson (1983). In cases where the pHcontrolled stream is mixed in downstream reservoirs, it is important that the pH of the mixture is close to the setpoint. This can be achieved through nonlinear feedback of pH, but not through linear feedback of pH, since that can produce average pH values far from the setpoint. The main problem in pH control, especially in industrial wastewater treatment, is the adaptation to changing composition. Adaptive control is a necessity for compact in-line control of pH. The main weakness of many proposed adaptive control methods is the lack of robustness. This in turn is a result of inadequate information from the process. The robustness of adaptive control is tested when the buffering of the input stream is reduced. This is the reason
0888-5885/92/2631-2681$03.00/00 1992 American Chemical Society
2682 Ind. Eng. Chem. Res., Vol. 31, No. 12,1992
for occasional oscillations of nonadaptive control systems (Waller and Gustafsson, 1983). A robust adaptive pH control system should cope with a severe reduction of buffering with only a slight burst of limited oscillations. A performance test for adaptive pH control is, on the other hand, a considerable increase in buffering. A nonadaptive control system turns sluggish, while a robust adaptive system maintains a tight control during the period with increased buffering. Much has been written about pH control in past years. Nonlinear process control is a popular research topic, and pH control is a simple but demanding application process. We have found, however, that there is a need for a paper rigorously treating the modeling of acid-base reactions from first principles as well as rigorously dealing with some basic properties and problems of pH control. This paper treats the systematic modeling of neutralization procesees, including processes with unknown composition. A nonparametrized model is introduced for processes with unknown chemical composition. The superior properties of linearizing (nonlinear)control compared to linear feedback of pH in situations with violent oscillations are demonstrated. Finally, the paper investigates nonlinear adaptive pH control and discusses the need for adaptive control as well as advantages and disadvantages of linear versus nonlinear adaptive methods for practical pH control. Experimental results illustrate the discussion. Recent Studies of Nonlinear and/or Adaptive pH Control Nonlinear process control has received considerable attention in past years. Nonlinear methods have often been tested on pH control. Young and Rao (1986)present a variable structure controller ("sliding-modecontrol") for a neutralization process involving strong acids and bases. Considerable change in buffering is not treated in the article. Parrish and Brosilow (1988)tested nonlinear inferential control on a simple simulated neutralization process, using static estimation of the concentration of a single monoprotic weak acid. The simulations do not contain any robustness test of the type suggested above. The simulated slight increase of the concentration of a weak acid with pk = 3 does not significantly change the buffering at the setpoint, which is pH = 7. Hall and Seborg (1989)studied modeling and multiloop control of singletank and two-tank neutralization systems. The paper presents nonadaptive multiloop experimental pH control. Henson and Seborg (1992)present nonlinear adaptive pH control with simulation examples. Jayadeva et al. (1990) propose generic model control of pH utilizing local linearization of the titration curve, and Kulkami et al. (1991) present nonlinear internal model control for a simulated system of sodium hydroxide and hydrochloric acid. The case of varying titration curves is not considered. Li and Biegler (1990)and Li et al. (1990)present nonlinear feedback methods for simulated neutralization processes without changes in buffering. Wright and Kravaris (1991) and Wright et al. (1991)present experimental nonlinear pH feedback using the inverse of the static nonlinearity to linearize the control loop. Saint-Donat et al. (1991) modeled the nonlinearity of a neutralization process in a neural network. Gulaian and Lane (1990)estimate the titration curve as a linear combination of titration curves for monoprotic acids. Proportional integral (PI) feedback with gain scheduling based on the estimated titration curve is used for feedback. Experimental results with considerable buffer reduction are presented. Pajunen (1992)estimates the titration curve with spline functions in her adaptive
controller. Laboratory experiments with adaptive pH control have been made by Girardot (1989). Jutila and J d o l a (1986)present an experimental comparison of five adaptive pH-control methods in a severe laboratory test prams. The methods compared include two commercial adaptive controllers. Williams et al. (1990)have simulated adaptive nonlinear control of pH using generic model control for feedback and static curve fitting for nonlinear adaptation. The information about the process is increased by splitting the control stream and making use of pH measurements after both control stream inputs. In the example presented the authors claim that a highly buffered system is changed (in one step) to a system containing very little buffer when they reduce the concentration of weak acid with 30%. In this example the composition of the weak acid is simultaneously changed, resulting in fact in an increase of buffering at the setpoint. In their example the firat step change actually results in about 16 times as high buffering at the setpoint; the second step change results in about a 2.5 times reduction of buffering. With buffering we here mean the derivative of the titration curve, which is inversely proportional to the linearized process gain. Contrary to the description in the paper in question, this example etarte with a high process gain, which is considerably reduced and later somewhat increased. The method suggested in the paper seems only to adapt itself to the changing load, not to changing buffering. Modeling of pH in Neutralization Processes This presentation of the modeling of fast acid-base reactions is based on a paper by Gustafsson and Waller (19831,which contains the theoretical background. Our experience is, however, that the treatment in that paper is too opaque to be accessible to the research community. In this paper an alternative presentation is given with examples and an enhancement to nonparameterized modeling. As a basis for the model, we use the concept of reaction invariants, which was introduced by Fjeld and Asbj~rrnsen;see, e.g., Fjeld et al. (1974). A reaction invariant is a linear combination of concentrations of chemical speciea, with the property that, in a reactor, it behaves as an inert species. Consider for instance a neutralization reaction, where a strong acid (e.g., H2SO4) is neutralized by a strong base (e.g., NaOH) in a water solution in the presence of carbonate. The reactions are
+ OHH2C03 + H+ + HC03HC03- H+ + C032HzO + H+
By definition strong acids and strong bases are fully dissociated in water solutions;thus the species H 8 0 4 ,€BO4-, and NaOH are considered nonexistent in the system. The ions SOa2-and Na+ are present but they do not take part in the neutralization reactions. Gustafsson and Waller (1983)have derived general expreseions for reaction invariants. For this example we can by inspection derive, e.g., the following reaction invariant concentrations: [Na+], [S042-]and the sum [H2C031+ [HCOS-] + [C032-]. The electroneutrality condition, stating that the sum of the charges of all ions in the solution is zero, is [Na+] + [H+] = 2[S042-]
+ [HCOB-] + 2[C0s2-] + [OH-]
This equality can be rewritten as
Ind. Eng. Chem. Res., Vol. 31, No. 12,1992 2683 [H+]- [OH-] - [HCOB-] - 2[C0a2-] =
with 2[SO:-]
- [Na’]
The right-hand side of the equation is clearly a reaction invariant, and thus the leftihand side is, too. The leftihand side is a useful reaction invariant, called the charge invariant, which is a function of [H+]and thus also a function of pH, defined here as -log[H+]. The neutralization process can be described by a state vector of reaction invariants and the pH value, with a relation between pH and reaction invariants. This function is static if all reactions are considered to be at equilibrium at all instances, the usual assumption for “fast” acid-base reactions. Normally chemical reactors are modeled with a reaction-invariant part and a reaction-variant part, the latter containing the reaction rates. In the special case where all reactions are fast, that is, all reactions are considered to be at equilibrium at all instances, only the reaction-invariant part is needed to model the reactor. Gustafsson and Waller (1983) show that the thermodynamic state of an acid-base system involving strong acids and bases and a number of a mono-, di-, and triprotic weak acids as well as corresponding bases and ampholytes is completely defined by a + l linearly independent reaction-invariant variables, when temperature and pressure are considered constant. Reaction invariant is thus a fancy name for certaip sums of concentrations. For instance McAvoy et al. (1972) and Orava and Niemi (1974) used sums of concentrations in order to avoid reaction rates in the dynamic model. A review of the use of reaction invariants is given by Waller and Mdsilii (1981). The model for pH in a reactor involving fast acid-base reactions consists of a dynamic model for a set of reaction-invariant state variables and a static nonlinear relation between pH and the set of state variables. The dynamic model for the reaction-invariant state variables depends only on the flow characteristics of the reactor and on the dynamics of valvea, actuators, etc. For instance for an ideal continuous stirred tank reactor (CSTR) the reaction-invariant dynamic model is a first-order system, dw 1 - -(wf - w) dt 7 where w and wf are the vector of reaction invariants in the reactor output and the reactor input, respectively, and 7 is the time constant equal to the residence time. The elements of the reaction-invariant state vector w of eq 1 are selected in the following way. The first reaction-invariant state, wl, is selected to be the charge invariant, which gives the relation between pH and the state vector. The next a elements of the state vector are selected to be the total concentrations of the a weak acid-base systems. For the general system of mono-, di-, and triprotic weak acids we get
--
a
a
a
(3) wi+l = ci,l + ci,2 + ci,3 + q 4 i = 1, ..., a where c denotes concentration and subscript i , l denotes undissociated weak acid i; i,2,i,3, and i,4 denote one-, two-, and three-acidicampholytes or bases, respectively, of weak acid i. By including equilibrium conditions, cHcOH = 10-14, ki,lCi,l, cHci,3 = ki,$i,2, and cHci,4 e ki,3Ci,3, and incHc;,2 serting eq 3 into 2, the relation between pH and the state vector is obtained as a
~1
= g(pH) - Cwi+lai(pH) i=l
(4)
g(pH) =
(-)
10-pH L/mol
-
(-””)
L/mol
(5)
and where the function ai(pH) for each weak acid-base system i, i = 1, ..., a,is given by
pkC1,pkig and pki,3are the negative logarithms of the fmt, second, and third dissociation constants of weak acid i, respectively. That is, ~ k i=, -l~g[k~,~/(mol/L)], ~ etc. For diprotic acids the third dissociation constant is zero; for monoprotic acids both the second and the third dissociation constants are zero: we can consider the corresponding or pki,3values to be infinite. The terms including dissociation constants of zero value will then disappear from eq 6. Equations 4-6 are thus sufficient for the modeling of all fast systems of strong acids and bases and mono-, di-, and triprotic weak acids and the corresponding ampholytes and bases. For systems of only strong acids and bases a is zero and the state vector is of dimension 1. w1 is defined by the two first terms of the right-hand side of eq 2 or 4. The first term of the right-hand side of eq 4 equals the hydrogen ion concentration, and the second term equals the hydroxide ion concentration. Thus we can express the reaction invariant for solutions of strong acids and bases in terms of hydrogen and hydroxide ion concentration, w1 = [H+]- [OH-]. Because w1 is invariant through acid-base reactions, w1 equals the difference between the total concentration of hydrogen ions supplied with strong acids and the total concentration of hydroxide ions supplied with strong bases. For instance, for the feed stream of eq 1 it can be convenient to express the reaction invariant in terms of normality of strong acids and bases, wlf = c H -~ COH,f, where CH,f and COH,f denote total concentration (normality)of strong acids and strong bases, respectively. In a titration with a strong acid or base, the state w1 is increased, or respectively decreased, with the concentration of the acid or base added in the solution. Actually eqs 4-6 define the titration curve for the system, and below the function wl(pH) defined by eqs 4-6 will be called the titration-curve function. Further examples of the use of the model eqs 1-6 for simulation purposes are given in the section Linear versus Nonlinear Feedback Control of pH. Remark 1: The total concentration means total concentration of the dissolved material. If some chemicals taking part in the acid-base reactions are present in solid form, the dynamics of dissolving or precipitation must also be taken into account. Such cases are in fact common in wastewater treatment, where lime slurry or caustic soda is often used for pH control. One example of adaptive pH control using lime is described by KZisser (1981). Remark 2: The dynamic model above is limited to fast acid-base reactions. pH control is often used to control the extent of reaction of processes where the chemical component used for pH control is consumed in other than acid-base reactions. Such reactions must be included in a reaction-variant part of a dynamic model if the reaction rates cannot be considered high. Charge Invariance. For process-controlpurposes the absolute value of w1 is unimportant. Instead we work with relative values, for instance, the difference in w1 at the actual or measured pH value and at the set value. This is also the case when we work with solutions of unknown composition, i.e., with titration curves (see below). In this
2684 Ind. Eng. Chem. Res., Vol. 31, No. 12,1992
case the state is defined by a titration curve and either a pH value or the reaction-invariant variable w1 together with the definition of its zero point. In some cases we should, however, be able to calculate the pH of a solution based on the concentration of added chemicals. The value of w1 must then be determined from the total concentrations of acids and bases, after which the pH value can be determined from eqs 4-6. w1 was originally defined by Gustafsson and Waller (1983) as a "charge concentration". The "charge concentration"is obtained as a reaction invariant through an orthogonal transformation of the stoichiometry according to Fjeld et al. (19741, or directly by constructing an invariance matrix based on the electroneutrality condition according to Waller and Miikila (1981). In a solution of pure water H+ and OH- ions take part in acid-base reactions. The concentration of H+ ions equals the concentration of OH- ions, which means that a solution of pure water has w1 = 0. If a solution of strong (fully dissociated) acid is added, w1 increases directly with the concentration of H+ ions supplied with the acid. If a solution of strong (fully dissociated) base is added, w1 decreases directly with the concentration of OH- ions supplied with the base. This motivates the introduction of w1as the variable of the abscissa (amount or concentration of added strong acid or negative amount or concentration of added strong base) in a titration-curve plot. The value of w1 for the solution is obtained by adding the values of w1 for the original components according to eq 2. Consider, e.g., a solution of 0.010 mol/L NH4C1,0.005 mol/L NH3, 0.020 mol/L NaHC03, and 0.001 mol/L HzS04. HzSO4 is here considered to be fully dissociated, consequently CH = 2cH o4in eq 2. There is no strong base present, so cOH = 0. &&I is dissociated into NH4+ions, which represent an undissociated weak acid, the concentration of which is not included in eq 2. The concentration of the correaponding base, N H , is, however, included. The value of the first reaction invariant is then given by eq 2,
w1 = 2cH@,04- cNHs - cNaHC03 = -0.023 mol/L w2 and w3 are the total concentrations of ammonium and carbonate: w2 = CNH,C~ + c", = 0.015 mol/L
w3 = cNaHCO3 = 0.020 mol/L Inserting these values together with the dissociationconStants, PkNH4+= pk1,l = 9.4, P ~ H ~=c pkz,l o ~ = 6.3, and pkHco - = pk2,2= 10.1, into eqs 4-6 gives the pH value of the sohion, pH = 8.67. Processes with Unknown Composition. The reaction-invariant model is by no means restricted to systems with known compositions. Gustafsson (1982) has applied the model to systems with unknown compositions. If the number and nature of weak acid-base systems are unknown, the process can still be modeled by the charge invariant, wl, and a continuous timevarying titration-curve function, z(pH,t). Consider, for example, the CSTR modeled by eq 1, which can be partitioned into (7)
where wp = [wz,..., w , + ~ ] ~ The . titration-curve function
is defined by eqs 4-6, such that wl[pH(t)] = z(pH,t). The titration-curve function can be written
z(pH,t) = g(pH) - aT(pH)wdt)
(9)
where g(pH) is given by eq 5 and a(pH) is a vector of functions ai(pH). In eq 9 pH is a f o r d parameter. The functions g(pH) and a(pH) are time-invariant functions; the time variation of z(pH,t) is due only to the time-varying vector wz(t). Partial derivation of eq 9 with respect to time gives
Inserting eqs 9 and 10 into eq 8 gives together with eq 7 the model for unknown compositions,
The output variable is obtained from the output function PH,(t) = z-'(w,,t)
(12)
where pH = z-'(w1,t) is the inverse function of w1 = z(pH,t). The pH value in the CSTR is denoted pH, to distinguish it from the formal parameter pH in the notation for the titration-curve function in eq 11. An "Iustrative example of the use of the model eqs 7, 11, and 12 for the static (steady state) case is given by Gustafsson (1982). A graphical example of a solution of the model for a step change in zf(pH,t)is given by Waller and Gustafsson (1983; Figure 19). According to model eqs 7,11, and 12 the titration curve of a mixture of solutions is a linear combination of the titration curves of the separate solutions. The nonparametric model may be parametrized in, e.g., the following three ways. 1. Introduction of physical species gives CY parameters, wz, ...,w,+~. This is the case of the original model eqs 4-6. 2. Introduction of hypothetical species with suitable dissociation constants enables modeling of unknown compositions. The nonlinearity is modeled as a linear combination of fundamental titration curves, each modeling a small part of the complete titration-curvefunction. This parameterization is used by Gustafsson (1985) for adaptive control. 3. Discretization of the titration-curve function is convenient for simulation of processes characterized by titration curves. For simulation purposes it is convenient to discretize the titration curves and present them as a set of pairs, k ( t ) , p H J , (z2(t),pHz),...,(zn(t),PHn)l. Equation 11then turns into a system of ordinary differential equations:
and pH,(t) is interpolatedfrom the set of pairs {(zi(t),pHi)). Buffering. Buffering means that the presence of some components increases the absolute value of the derivative of the titration curve, dz(pH)/d(pH); that is, it decreases the process gain, which is inversely proportional to buffering. It should be noted that the effect of buffering is local in the pH scale, depending on the dissociation constant of the weak acid causing the buffering. The buffering of a weak acid is at ita maximum at pH = pk, and is reduced to 33% at 1pH unit away from pk and to 4% at 2 pH unita away from pk. A decrease of the total concentration of weak acid-base systems does not necessarily give any significant decrease of buffering, or increase in process gain,
I'ZF
Ind. Eng. Chem. Res., VoL 31, No. 12,1992 2686
%
w J 4
I
Ol
.-C
&
c
3
D
40
20 03
4
5
6
7
8
F i r m 2. Experimental and ~imulet8dpmeesa usually an adaptive controller into a short burst of oseil-
PH Figura 1. Buffering of acetic acid an a function of pH expressed in percent of maximum buffering at pH = pk,
in the vicinity of the set value. A simultaneow change in composition,80 that the concentration of a weak acid-base system with a pkl value close to the pH set value i n m a w while the concentrations of other weak acid-base systems decrease, might indeed cause an increased buffering. This was discussed in the Introduction. A significant change in the concentration of a weak acid in the process stream causes a significant change in process gain only if the pk value is close to the pH set value. Otherwise the concentration change can be interpreted as a load disturbance with small influence on the process gain around the set value. As an example, the buffering effect of acetic acid (pk = 4.7) is illustrated as a function of pH in Figure 1. At pH = 7 the buffering effect of acetic acid is only 2% of the effect at pH = pk. The buffering effect of acetic acid is small in the vicinity of pH = 7 in an experimental system, which has a natural content of carbonate and perhaps other weak acid-base systems. At pH = 7 the buffering of 0.1 mol/L acetic acid equals the buffering of 0.0035 mol/L carbonic acid. Feedback control. If the state of the system is known, eq 4, or eq 12, unambiguously determines pH, and inversely, pH uniquely determines w1 if the remaining state variables, or the titration-curvefunction z(pH), are !mown. Controlling w1to ita set value wl& implies the controlling of pH to ita corresponding set value p& if the same state variables wz, ...,wdl, or the same function z(pH,t), are used to transform both measurement value, pH, and set value, pH,, into reaction invariants w1 and wlLCt. respectively. This is the principle of reaction-invariant feedback. It should be noted that the reaction invarianta w,which are linear combinations of concentrations, are additive quantities in contrast to pH, which is not additive. One of the implications of this is that the reaction invariants can directly be averaged in a mixture while pH values mot. Linear vermus Nonlinear Feedback Control of pH In the Introduction we claim that in most cases linear feedback from pH is as good as nonlinear feedback. This is certainly the case for buffered systems which are not strongly nonlinear in the vicinity of the set value, and which do not experience severe variations in buffering and therefore can be tightly tuned. If, however, the control performance for some reason deteriorates, then nonlinear feedback, which approximately linearizes the feedback loop, can be advantageous. One common reason for the deterioration of control performance is reduction of buffering at the set value. Thii turns a tightly tuned nonadaptive controller into continuous oscillations and
latiom Another meon for low control performance is the use of a %bust" lked-gain controller, which for robustness reasons is tuned for a system with low buffering and consequently exhibits a sluggish performance a t high buffering. In this section the modeling of acid-base reaction profrom first principles is exempMed by the eimulation of two systems. The simulation results elucidate some DroDerties of nonlinear feedback comDared to h e a r feedback of pH. T w o svntems will ba modeled and simulated with linear lked-g& proportional integral derivative (PJD)feedback control of measured pH and with nonlinear feedback of pH. In the second case the measured pH value is filtered through the inverse of the static nonlinearity and fed back through a linear fmed-gain PID controller. Both systems describe the double-tank system of Figure 2. pH is controlled in the first tank. The second tank is a damping tank, the purpose of which is to damp cyclic upseta in pH in the effluent from the first tank. The flow dynamics of the first tank is modeled hy a second-order system with time constants of 5 min and 5 8, and a dead time of 10 s. The damping tank is for simplicity modeled through a first-order system with a time constant of 5 min. The pH-measurement system is modeled by a fhborder system, which is linear in pH. This simplified model is used to introduce a dynamic nonlinearity into the simulation model. This is by no means an accurate model of a pH-measurement system, which is nonlinear also in pH and in fact much more complicated (Waller and Gustafsson, 1983; Hershkovitch et al., 1978). System 1. The fust system contains only strong acids and bases. The reaction-invariant state vector contains onlv one element The definition is eiven bv eo 4 with w;*, ... = 6 for i 2 1, that is I
(
- .
)-(e) (14) L/mol
w1 = 10-pH L/mol
Because w 1is invariant through the acid-base reactions, w1 equala the difference between the total concentration of hydrogen ions supplied by strong acids and the total concentration of hydroxide ions supplied by strong bases. For the feed stream and the control stream we can also write the reaction invariant states as wlJ = cH,f
- cOH$ - C0H.e
(15)
= %.e (16) where % and COH denote total concentration (normality) of strong acid and strong base, respectively. Subscript f denotes feed stream, and c denotes control stream. The state equations are w1.e
2686 Ind. Eng. Chem. Res., Vol. 31, No. 12, 1992
The static model for the pH-measurement system is given by eq 14, which in explicit form gives pH, = -10g[w~,~/2 + (w1,22/4+ 10-14)1/2] (20)
+ (W1,s2/4+ 10-14)1/21
(21)
where subscript r stands for reactor tank and d stands for damping tank. The dynamic part of the pH-measurement system is modeled by
where subscript m stands for measurement and subscript a stands for averaged (damped). The feedback controller is a standard fiied-gain PID controller feeding back either pH, directly in linear pH feedback control or feeding back a variable R,, which is pH, filtered through an exact inverse of the static nonlinearity. R, is given by the right-hand side of eq 14. The initial conditions are W ~ , ~ ( O=) w1,,(0) = w1,3(0) and pH,(O) = pNa(0) = 9. The state of the feed stream is constant for t 2 0, wf(t) = 0.001 mol/L. This introduces a step disturbance at t = 0. System 2. The second system models the same physical system as in system 1, given in Figure 2. The chemical reactions involve strong acids and bases, but now the weak carbonic acid is added to the system. The carbonic acid system includes the species H2C03,HC03-, and C03*, with dissociation constants pkl,, = 6.3 and pkl,2 = 10.1. The first reaction invariant for this chemical system is obtained from eqs 4-6, wt =
(24) and the second reaction-invariant state variable equals the total concentration of carbonate: ~2
= [HZCO,]
+ [HCOS-] + [CO:-]
(25)
When the control stream also in this case contains only strong acid, the state equations will be
The state equations for the damping tank are
The pH values are
e *(~1,2~2,2)
(30)
F”d
=
(31)
*
The state equation for the damping tank is
P H ~= -iog[Wl,,/2
PHr
*(wl,3,w2,3)
where the function is implicitely defined by eq 24. The dynamic part of the pH-measurement system is the same as for system 1, eqs 22 and 23. The feedback controller is the same as in system 1,except that the variable R, is calculated as
%(t) wl[~Hrn(t),~~,2(0)1 (32) where the function w1 is defied by eq 24. Note that the nonlinear feedback filter (32) uses a constant value for the total concentration of carbonic acid, w ~ , This ~ . simulates the case with constant-parameter feedback control. Consequently, the reaction-invariant control scheme in this stimulation does not include an exact inversion of the nonlinearity. The simulated process is the following. At t < 0 the process is in a steady state, with the feed stream containing 0.025 mol/L sodium bicarbonate at pH 9. Thus we have w2(0)= 0.025 mol/L and eq 24 gives the initial state wl(0) = -0.0268 mol/L. The contribution to the charge invariant w1 from the HCO, ion is -0.029 mol/L, and the contribution from sodium hydroxide is (-0.0268 mol/L - (-0.025 mol/L)), i.e., -0.0018 mol/L. The initial concentration of NaOH is thus 0.0018 mol/L. At t = 0 the carbonate concentration of the feed stream is reduced to zero, while the concentration of strong base is increased to 0.0278 mol/L. This changes the first state variable of the feed to wlAO) = -0.0278 mol/L and the pH value to 12.4. At t = 10 min the carbonate concentration in the feed is increased to 0.010 mol/L while the concentration of strong base is reduced to 0.0178 mol/L, leaving the first state variable unchanged at wl,f = -0.0278 mol/L, while the pH value of the feed changes to 11.9. The state of the feed stream is thus wl,f(t) =
w2&) =
[
-0.0268molL for t c 0 -0.0278 mol& for t 2 0
1
0.025 m o m for t c 0 0 for 0 I: t 5 1 0 m i n 0.010 m o a for t > 10 min
Oscillations i n Nonadaptive pH Control. The following simulations illustrate the advantages of linearizing the control loop of control systems which occasionally turn into oscillations. Figure 3 shows simulations of system 1, with strong acids and bases only. The oecillations originate from an increased controller gain. The dotted line shows the pH measured in the first tank, that is, the pH value fed to the controller. The continuous line shows the pH measured in the second (damping) tank. The setpoint is at pH 9 in all cases. Figure 3a shows the response of system 1with conventional PID feedback of pH. The nonliiearities cause unsymmetrical oscillations with a large amplitude to appear. The averaged pH value of the damping tank shows a considerable deviation from the set value. In Figure 3b, the control stream is restricted to flows corresponding to 0.0005 mol/L Iwl,Jt) I0.0015 mol/L, causing a more irregular behavior. At first the oscillations are restricted by the control-stream restrictions, but later they increase. The system has not yet reached the final stationary OBcillating state at the end of the time scale. The bias in the damped pH value here seems to be smaller than in Figure 3a, but is, however, still significant. The corresponding simulations with nonlinear feedback control are shown in Figure 3c,d. The nonlinear feedback linearizes the static nonlinearity, but not the dynamic one,
Ind. Eng. Chem. Res., Vol. 31, No. 12, 1992 2687
9
PH
7
5
0
10
rnin
(b)
i
5 1
0
10
rnin
20
t
(4
20
t
0
10
m i n
20
t
(d 1
Figure 3. Oscillations in a pH-control system simulating the procees of Figure 2. Continuous line shows pH after the second tank;dotted line shows pH after the first tank. (a) Linear PID control without control signal constrainte. (b) Linear PID control with control signal constraints. (c) Nonlinear control without control signal constraints. (d) Nonlinear control with control signal Constraints. 11,
0
(a)
,
,
,
,
,
10
,
I
,
1
rnin
,
11,
20
0
t
(b)
,
,
,
,
,
10
,
,
,
,
m i n
(
20
t
Figure 4. Oscillations of the procees in Figure 2 resulting from a decrease in buffer concentration. (a) Linear PID control. (b) Nonlinear control.
which in this simulation model is attached to the pHmeasurement system. In Figure 3c the simulation is performed without control constraints. In Figure 3d the same control-stream constraints are used as in Figure 3b. The effect of nonlinear control is seen by comparison of Figure 3a and 3c,and Figure 3b and 3d, respectively. The main advantage of using nonlinear feedback of pH so as to linearize the control loop is the reduction of bias in the pH value of the damping tank. The small bias remaining in Figure 3c,d is c a d by the dynamic nonlinearity, which is not compensated for in the feedback loop, together with the inexact inversion of the static nonlinearity of the system. Another advantage of linearizing control can also be seen in the simulations. Nonlinear feedback results in tighter control with smaller amplitudes of the oscillations. Figure 4 shows the corresponding simulations for system 2, with strong acids and bases and carbonate buffering. The control loops are here stable for the initial system. The oscillations are caused by the increased process gain, c a d by decreasing carbonate concentration in the feed stream. Figure 4a with linear feedback of pH shows a considerable bias in the damped pH value. The bias is
practically eliminated in Figure 4b through nonlinear feedback. The amplitude of the pH oscillations is not decreased in this case by including nonlinear feedback. The pH oscillations have, however, moved to lower pH values with the introduction of the nonlinearity in the feedback loop. The offset in pH from the setpoint in the averaging tank can be much more pronounced than in Figures 3 and 4 and are by no means restricted to simulated systems. An experimental illustration is given in Gustafsson and Waller (19861,where the measured offset in the pH of the averaging tank is completely outside the measured oscillations in the control tank. Thus, use of a damping tank after an oscillating pH control system, as sometimes recommended in the literature, may result in a significant offset in pH. Adaptive versus Nonadaptive Control Adaptive control should adjust the feedback to varying process parameters. Usually, for reasons of robustness, adaptive controllers are designed for adaptation to slowly varying procew parameters only. In the case of pH control both slow and fast parameter variations are present. The
2688 Ind. Eng. Chem. Res., Vol. 31,No. 12, 1992
51 1 0
0
iv,
,
,
200
,
; ,
,
,
,
,
,
600
400
,
I , , eon
,
.
,
,
,
{
,
I
1000
c , . . . ' . . . . . . . ' . , . . . . . . ,
!
200
400
200
400
1000
600
0.7
0 7.
U
0.3 0.0
0
200
600
400
000
1000
k
Figure 5. Nonadaptive PID control of pH for the disturbance program given in Table I. The controller is tuned for the conditions afterk=800.
nature of parameter variations and the need for adaptation to them depend on the model used and the definition of the parameters as well as on the real process itself. In a neutralization process we can distinguish the following possible adaptation needs. (a) Varying chemical composition brings about varying parameter values of both linear and nonlinear models. This process variation is the most important argument for adaptive control. In linear models, varying chemical composition can normally and conveniently be described as variations in process gain. In nonlinear models the corresponding variations are found in the state vector or in the titration curve of eq 11. In a stirred tank reactor the speed of this variation is constrained by the retention time of the tank. It cannot be faster than the step response of an inert species. This should be considered in the tuning of adaptive controllers for procesa composition adaptation. (b) Setpoint changes bring about changes in the process parameters of linear models at the set value. These changes are abrupt, but in most cases severe setpoint changes are quite rare. Controllers based on linear models ought to adapt themselves to gain variations caused by setpoint changes. Controllers based on nonlinear models should have no need for adaptation, because a setpoint change does not induce parameter variations in a proper nonlinear model. (c) Varying pH brings about varying parameters of linear models. The gain of a locally linearized model is proportional to the inverse of buffering, d(pH)/dz(pH). In an oscillating system the gain of a linearized model is thus rapidly varying with pH. An adaptive controller should not adapt itself to such fast variations. These are coped with by relaxing a linear feedback controller or by using nonlinear feedback. Robustness and Performance of Adaptive pH Control. Robustness and performance are two important properties of adaptive control. We interpret these properties for practical pH control in the following way. In an adaptive pH-control system robustness is mainly the ability to keep oscillations in output pH value below an accepted amplitude during and after a decrease of buffering. Decrease of buffering can be caused by varying chemical composition or by setpoint changes. Demands on robustness can of course be different for different processes, and closed-loop stability may be demanded at all instances. Robustness means also stability of parameter estimates in periods of nonexistent disturbances to the process, resulting in poor information supply, or with slowly drifting calibration errors of sensors. Adaptation performance of pH-control systems is characterized by the ability of adaptation to increased buffering, caused either by varying chemical composition
0
600
BOO
1000
t
Figure 6. Adaptive nonlinear control for the disturbance program given in Table I. Table I. Step Disturbance Program for Control Experiments Coubonstaf COHZ, approx re1 k t. min mol/L mol/L gain at DH 7" 0 0.0 0.006 0.006 -520 50 12.5 0.001 0.002 100 25.0 0.001 0.006 200 50.0 0.001 0.009 -310 0.009 300 75.0 0.006 350 87.5 0.006 0.006 400 100.0 0.006 0.009 0.006 500 125.0 0.006 600 150.0 0.006 0.002 -520 700 175.0 O.OO0 0.002 0.004 850 212.5 O.OO0 950 237.5 O.OO0 0.006 -4000 a Approximate relative process gain is defied ae the inverse of buffering, d(pH)/dz.
or by changing setpoint. These process variations result in sluggish response of a nonadaptive feedback controller. If, however, load disturbances are small, the controller can keep the pH value close to the setpoint with resulting poor information supply to the estimator. This puts high demands on the alertness of an adaptive controller. These aspects on robustness and performance in pH control are illustrated in Figures 5 and 6, which show the results from two experiments, one using nonadaptive linear PID control and the other using adaptive nonlinear controL The linear feedback controller thus uses direct feedback of pH, whereas the nonlinear controller uses feedback (through a fixed-gain PID controller) of the reaction invariant wl,estimated by use of eqs 43-45 from measurementa of the pH in the tank and in the feed. The adaptation thus comes from the continuous estimation of wl, and the nonlinear controller is nonlinear with respect to pH but linear with respect to wl. The experiments and the controllers are described below. The feed composition varies stepwise according to Table I, which also contains an approximationof the resulting linear process gain at pH 7 at steady state. Both controllers are tuned to give tight control of the process at the end of the sequence when no buffer is added to the feed. It can be seen that the results for k 2 850 are quite similar for both controllers, because both controllers are tuned to this state of the process. A slight difference in the form of the oscillations shows the difference between linear feedback in Figure 5 and nonlinear feedback in Figure 6. The vertical dashed lines denote step changes in the buffer (carbonate) concentration in the feed. The periods are, from the left, high buffering, low buffering, high buffering, and extremely low buffering. The PID controller shows a sluggish response in all other periods, except in the last one for which it is tuned. The merit of
Ind. Eng. Chem. Res., Vol. 31, No. 12, 1992 2689 adaptive control is obvious from Figure 6, in which the tight control is maintained throughout the experiment. Both experiments include setpoint perturbation, which results in small oscillations throughout the experiments. Setpoint perturbation is essential for the self-tuning controller used in Figure 6. For the PID controller used in Figure 5 setpoint perturbation is of course of no use. The terms performance and robustness, as they are interpreted above, correspond in these experiments mainly in keeping the controller alert after k = 300 and in preventing large-amplitude oscillations after k = 700. Experimental Setup. The experimental setup for the experiments shown in Figures 5 and 6, and in the experiments below, is schematically shown in Figure 2. Only the first reactor tank is in use. An alkaline feed flow of sodium hydroxide and sodium bicarbonate in municipal water is neutralized by a control stream containing relatively concentrated sulfuric acid. The volume of the reactor tank is 5 L, and the constant feed flow is approximately 1 L/min. The flow model of the process was identified as a first-order system with a dead time of 8 s. The controller is a microcomputer with a sampling interval of 15 s. The actuator is a peristaltic pump with rotation-speed control. The normalized control variable u, shown in the figures, is proportional to the control stream. The lower and the upper control constraints are u = 0 and u = 1,respectively. The set value is pH 7. Identification of the complete reaction invariant process, including the pH-measurement system and the actuator gave the sampled model wi,,(k) = 0.7261~1,,(k - 1) + 0.1780W1,,(k - 2) + O.O751~l,~(k - 2) + 0.00WW1,Jk - 3) Due to unmodeled dynamic nonlinearities in the measurement system, somewhat differing models have been identified depending on the degree of excitation. Linear Adaptive Control. Linear adaptive control, utilizing linear process models and linear feedback of pH, is described below, The controller is based on the selftuning regulator (Astrcim and Wittenmark, 1989). The fundamental self-tuning regulator has been enhanced to meet robustness and performance criteria for the nonlinear process. The linear process model, used for linear adaptive control, represents a local linearization of the general nonlinear process model (Gustafsson, 1985). The model is A ( q - l )ApH(k) = b,q-dB(q-')Au(k)
(33)
where A(q-') and B(q-') are polynomials in the backward shift operator q-' of degrees m and n, respectively, A(q-') = 1 + a1q-l B(q-') = bo + blq-'
+ ... +
+ ... + b,q-"
k denotes discrete time. A is the difference operator, defined as A = (1- q-l), that is, ApH(k) = pH(k) - pH(k 1). b, is a gain factor and u is the control signal. The parameter d defines a time delay and is closely related to the dead time of the process. The special gain factor b, of the linear model enables adaptation to process gain only. This is useful if the dynamic part of the process model is considered to be known and constant. We can thus choose between two sets of parameters for adaptation, either the coefficients of the polynomials A&') and B(q-') with b, constant, if both flow dynamics and static gain of the process are considered unknown, or only b,, if only the process gain is considered unknown and varying. The estimator applies recursive
least squares on a linear model, which we denote v ( k ) = BTd(k)
(34) We have studied the following two sets of vectors for the estimator. (a) In the first case we define the parameter vector as BT = [al, ..., a,, bo, ..., b,]
(35)
From model 33 we then get v(k) = ApH(k)
(36)
and
dT(k) = [-ApH(k - l),..., -ApH(k - m), Au(k - d ) , ..., Au(k
- d - n)] (37)
This estimator model enables estimation of both reaction-invariant and -variant parameters; i.e., it enables adaptation to varying process composition and setpoint changes as well as to varying feed flow. This scheme implies a minimum of process knowledge; only the parameters d , m, and n must be selected in advance. (b) The fewer parameters an adaptive controller must estimate, the more robust the estimator will be. If only adaptation to varying buffering is needed, then only the process gain should be continuously estimated. In this case the parameter vector is defined as 8 = b,
(38)
v ( k ) = A(q-') ApH(k)
(39)
$(k) = B(q-') Au(k - d )
(40)
From model 33 we get and The two estimator modes a and b may be conveniently combined in one single adaptive control algorithm. Mode a may then be used for initial self-tuning and periodic retuning while mode b may be used for continuous adaptation. Such an algorithm was used for the experiments. The fundamental least-squares estimator for mpdel34 with exponential forgetting of old data is given by Astrom and Wittenmark (1989). In a practical algorithm for continuous adaptive control, the fundamental least-squares methqd must be supplied with "safety nets" (Wittenmark and Astrom, 1984). The covariance matrix of the recursive least-squares method determines the "alertness" of the estimator to process variations. Large elements in the covariance matrix make the estimator alert to variations, but also sensitive to unmodeled disturbances with erroneous estimates as a result. Small elements in the covariance matrix make the estimator slow in the adaptation to process variations. A directional forgetting scheme is needed to keep the elements of the covariance matrix within acceptable intervals in cases when, e.g., a nearly constant pH value of the reactor brings about poor information about some of the variables to be estimated. We use an algorithm which stops forgetting in one direction when the corresponding diagonal element of the covariance matrix has reached an upper limit. On the other hand, the forgetting rate is increased in one direction if the corresponding diagonal element of the covariance matrix reaches a lower limit. In order to provide continuous information to the estimator, all experimentsdescribed below have been performed using setpoint perturbation. At random intervals between one and five sampling intervals the pH setpoint has been changed between p k t + 5 and p b t - 5, where 5 has been in the range 0.025-0.05 pH unit.
2690 Ind. Eng. Chem. Res., Vol. 31, No. 12, 1992
Nonlinear Adaptive Control. The nonlinear adaptive controller used is based on a linear reaction-invariant dynamic model and the static nonlinear model for pH, eq 9, with a parametrization according to point 2 under Processes with Unknown Composition, i.e., use of hypothetical species. The linear dynamic model is considered known and constant. The model is A(q-')Aw,(k) = q-dB(q-')Au(k) + q-hD(q-')AWl,f(k) (41)
The corresponding models for w2,...,w,+~ are not explicitly used, Insertion of eq 9 gives the model for pH, A(q-')(&[pH(k)] - qTh[pH(k)]i = q-dB(q-')Au(k) + q-hD(q-l)(&[~Hf(k)l- ~ ~ A a [ p H f ( k )(42) lI where a[pH(k)] = [al[pH(k)], ..., aa[pH(k)]lT with the functions ai(pH) defined in eq 6. In eq 42 the reactioninvariant states w2, ...,w,+~are replaced by the parameters ql, ..., qardenoting the concentrations of a! hypothetical species, and gathered in a vector q. The control stream is considered to contain only strong acids and bases. Thus u equals the first reaction-invariantstate variable (wl) for the control stream. Remark: It should be recognized that all reaction-invariant states approximatively follow model 41. The state variables w2, ...,w,+~ are not included in the dynamic part of the model because they are estimated as slowly varying parameters in the recursive least-squares algorithm. A model for these states corresponding to eq 41 gives a maximum possible variation speed for these states, which is equal to the step response of eq 41. This knowledge has not been utilized in the experiments,but it could give some hints for tuning the estimation algorithm. Equation 42 contains two vectors of adaptable parameters, q and qf. In the following we will use the approximation Q q; e.g., the composition of the weak acid-base systems in the feed equals the composition in the reactor tank. This is certainly not the case when the composition of the feed is varying, but in practice it is hardly possible to estimate both sets of parameters. If pHf is well above or below the normal values of the controlled pH, and if q contains parameters describing the nonlinearity both at the normal value of the controlled pH and at pH values of the feed, then pH and pHf in eq 42 w i l l excite different parts of the nonlinearity and some elements of q will in fact describe Q. Therefore q and Q may well be combined into a single vector. Although pHf and consequently Q are not used in the feedback controller, they are used by the estimator to reduce disturbances caused by unmodeled disturbances. We consider the reaction-invariant flow dynamics to be known and invariant; that is, the polynomials A(q-'), B(q-l),and D(q-'), as well as the time delays d and h, are known and invariant. Model 42 is linear in the parameter vector q, which will be used for adaptation purposes. Equation 42 can be rewritten in the form (34)in order to estimate q using the recursive least-squares method. We get the following definitions: e=q (43)
~ ( k =) A(q-')&[pH(k)] - q-dB(q-l)Au(k)q-hD(q-')&[~Hf(k)l (44)
d(k) = A(q-')Aa[pH(k)l - q-hD(q-l)Aa[pHf(k)l (45) Model 42 still contains an important set of parameters, which are not included in 6, that is, the number and values of the dissociation constants of eq 6. Within the described estimation scheme these parameters must be fixed be-
forehand. This implies no restrictions in the adaptability of the model, because the input-output relations for any combination of acid-base systems can be modeled with a fixed set of dissociation constants. Gustafwn and Waller (1983)used seven pkl parameters, which enabled an accurate modeling of the upper part of the titration curve. Gustafsson (1985)used four or two pkl parameters to model the interesting parta of the titration curve around the set value and around the pH value of the feed. For processes with totally unknown composition this choice of pk, parameters can be described in the words of Gulaian and Lane (1990)as selecting *a set of building block curves that capture the entire range of process behavior". The theory does not accept negative values of the reaction invariant states w2, ...,w,+,. For robustnew reasons it is also in practice advantageous to restrict the elements of the estimate vector q to nonnegative values (Gustafmn, 1984). Theoretically we can also estimate the flow dynamics through a linear estimator by multiplying the terms in braces in eq 42 with the polynomials A&') and D(q-'), respectively. We then get a linear model in a new set of parameters. This model describes both the linear flow dynamics and the nonlinear chemical reactions. The number of parameters to be estimated will then be high and the estimator for this system can be expected to be quite ill-conditioned,except for restricted acid-base systems. Another drawback of such a model is that the two parameter sets of eq 42,the parameters of the flow dynamics and the parameters of the nonlinear statics, cannot be separated. The idea behind such a model is similar to the idea behind neural nets: a multitude of parameters combined with a set of standardized nonlinearites can model a wide class of nonlinear systems accurately. SainbDonat et al. (1991)use a set of 5 nonlinear functions and 37 parameters in their neural-net model for pH control. This seems unpractical for adaptive control because of the vast amount of information needed for adaptation, and it can be expected to result in slow adaptation and poor robustness because of insufficient information in practical cases. The neural-net model is nonlinear in the parameters, which demands a nonlinear estimation algorithm if applied to adaptive control. Equation 42 is more favorable for estimation of both flow dynamics and nonlinearities because a linear estimation algorithm can be used. Alternatively, model 42 may be used to estimate the flow dyanmics, that is, the parameters of the polynomialsA(q-'), B(q-'), and possibly D(q-'), when q is considered known. Model 42 is a special case of the Wiener model, which is a general model for modeling nonlinear systems. A Wiener model consists of a linear dynamic model followed by a static (memoryless)nonlinear function. General results for identification of Wiener models do exist, e.g., Wigren (1990).A more general model of the Wiener type than the one above has been used by Pajunen (1985,1992) for pH control. In Pajunen's model the static nonlinear function consists of piecewise polynomials in pH. Dumont et al. (1990)present a pH-control problem where the main problem is a long and varying time delay. The process is modeled by a Laguerre-polynomialmodel, which applied in a self-tuning controller is suited for adaptation to varying time delays. Both the model and the feedback controller are linear in pH. Feedback. For experimental feedback of pH or w1 according to eq 33 or eq 41 the following linear controller has been used. The feedback scheme is an internal model controller (IMC) that, except for the time delay which
Ind. Eng. Chem. Res., Vol. 31, No. 12, 1992 2691 1
"
11 .,.. .. .
'
. ... . : Li "
:
""'
'
'
"
'
"
'
9
4
"
-
'1
i
91
'
I
PHf DH
1
PH
7 5
r . . . . . i . . . , . . . 111
I
3 1 " 1.0
"
"
'
200
0 ,
,
,
,
"
"
1
1
1
J
1.0,
600
400 ,
0
1
1
200 ,
,
,
,
,
,
,
,
I
,
,
,
,
800
600
400 ,
I
I
,
,
-
1
I
I
,
.
.
,
.
.
I 1000
,
0.7
1
U
0.3
0. 7
0.0
0 0.0,.
0.0 0
Il!
,
,I ,k+
,
200
,
,
,
,
0
,
,
200
,
,
k
,
,
400
400 ,
,
,
.
600 1
,
I
,
1000
800 1
I
J
1 0
,
,
600
400
0.0 -1.0
-3.01,
200
,
,
,
. -*
__.__ -.+ 200
L-A--I
400
--'
'
'
'
600
800
1000
600
800
1000
'
1 600
Figure 7. Linear adaptive control during decreasing buffering.
cannot be inverted, utilizes an inversion of model 33 or 41, combined with a first-order damping filter. The second term on the right-hand side of eq 41 is also neglected: feedforward from pHf is thus not considered in these experiments. The controller is where x denotes input variable (pH or wl),xWtdenotes set value and the polynomials 8 and CP are given by
where circumflex (3 depotes estimate, 6, is the first parameter of polynomial B(q-'), and f is a damping parameter, 0 I f I1. f = 0 implies no damping; higher values off mean higher damping. The experimental resulta have been obtained using f = 0.45. Together with the nonlinear model 41 and 42, the feedback scheme implies an approximate inversion of the static nonlinearity. The nonlinear model could as well be used for a nonlinear feedback scheme such as generic model control (GMC) (Lee and Sullivan, 1988). The difference between GMC and the linear IMC combined with an approximate inverse of the nonlinearity is the following: GMC is designed to make the output (pH) of the closed loop follow a given trajectory toward the setpoint, while the IMC scheme is designed to give a desired linear transfer function (in concentrations) to the closed loop. Experimental Results. Experimental results with nonlinear adaptive control are shown in Figure 6. The step disturbances of the feed in this experiment are given in Table I. The experiment contains step changes in buffering (carbonate concentration) in both directions in order to test robustness and performance of the adaptation algorithm and load changes to test controller performance. The chemical process is in this experiment modeled with only one pkl value in eq 6,pkl,' = 6.8,which is close to the first dissociation constant of carbonic acid. The pH measurement in the feed, p H , is used only for estimation, not for control purposes. The good agreement between the nonlinear model and the process in the neutral region makes the performance of the nonlinear adaptive controller excellent even for this severe experiment where the feed
0
200
400
k
Figure 8. Linear adaptive pH control during decreasing buffering.
contains no added buffer after k = 700 sampling intervals. Results with more general models for nonlinear adaptive control are given by Gustafsson (1985). Figure 7 shows experimental results with linear adaptive control. The buffering conditions are the same as in Figure 6 after k = 600. An initial high-buffered feed with 0.006 mol/L carbonate is at k = 100 changed to a feed without added buffer. The municipal water used in the experiments contains approximately 0.0005 mol/L carbonate, resulting in a buffering of dz(pH)/d(pH) = 0.25 X at pH = 7. This equals the relative process gain of -4000 given in Table I. The process gain is estimated; that ij, eqs 38-40 are used by the estim-ator, The p a r e e t e r bo shown in Figure 7 is defined as bo = b,bo, where bo is the constant estimate of bo. The task of estimating only one parameter, the gain, is simple and performs very well in the experiment illustrated in Figure 7. The parameters of the linear process model (33) fit well if the pH of the process stays within a small interval. If, however, the pH value oscillates with a significantly larger amplitude than the one for which the linear process model is identified, then also the estimator based on the linear model might deteriorate. In the above description of the experimental setup, it was mentioned that identification of linear models for the process gave different models for different excitation levels. Figure 8 illustrates the dilemma of linear adaptive control of pH. An adaptive controller estimating only a gain factor is fast and reliable as long as the rest of the linear model (polynomialsA(q-') and B(q-')) is representive for the process. Estimation of all parameters of the polynomials A(q-') and B ( q - 9 is in general slower, especially when continuous disturbances caused by m o d e l e d static and dynamic nonlinearities disturb the estimation procedure. The experiment in Figure 8 starts with a highly buffered feed containing 0.006 mol/L carbonate. At k = 300 the addition of carbonate is reduced to zero. The experiments start with estimation of four parameters, a', a2, bo, and bl otthe polynomials A ( q - ' ) and J3jq-l) in_eq 33. In Figure 8 boq d bl denote the products b,bo and b,&, respectively,where b, is constant. At k = 2qP the estimate3 have converged to ril = -0.20,ciz = -0.27,bo = -0.52,and bl = -0.28,resulting in a proper model for the system at this oscillation level. At k = 200 the estimation mode is
2692 Ind. Eng. Chem. Res., Vol. 31, No. 12, 1992
"
0. I
0.3 0.01 0
0.51
-1.0
"
20 '
L
I
0
"
'
'
I
I
a
40
'
"
60
"
100
80
'
'
'
'
I
I
I
,
'
'
'
"
I'
'
____ 20
40
60
,
80
,
1
100
'
,'
120 min
8
120
'1
4j '
m*n
t
Figure 9. Linear adaptive control with_varying sampling intervals. The diagrams show estimated A and B coefficients.
changed to estimation of b, only. The response of the estimate of b, to the reduction of buffering after k = 300 is seen to be fast, but the oscillating process is not properly modeled by the earlier identified linear model and use of this estimator cannot stabilize the process. At about k = 540 the estimation mode is switched back to estimation of four parameters, which immediately stabilizes the system, Note the effect of the setpoint perturbation on u. For the highly buffered first part of the sequence the setpoint perturbation brings about a high-amplitude perturbation of u, while the same setpoint perturbation at the latter part of the sequence, because of the small controller gain, brings about only a small-amplitude perturbation of u. Varying Flow. The last experiment, Figure 9, shows some properties of linear adaptive control to changes in sampling times. The sampling time of the controller is changed from 15 s to 10 s,7.5 s , 5 s, and back to 10 s. A change in sampling time approximates a change in retention time of the reactor. The model is throughout the same, eq 33, with m = 2, n = 2, and d = 2, except for the interval with 5 s sampling time, where d = 3 was used. The feed stream contains 0.006 mol/L sodium bicarbonate and 0.006 mol/L sodium hydroxide, without disturbances. Setpoint perturbation is used to excite the system. Tbe adapiive contr_olleresJimates four parametp, el,itzr4, and bl, where bo and bl are the products of b,bo and b,bl, respectively. The coefficienb h1 and ci2 are highly correlated, which indicates that only one a coefficient would be sufficient for the model. The same is true for the experiment shown in Figure 8. Figure 9 shows that two b coefficients are needed to model the control delay, which has been identified to be 8 s in the process. Using d = 2 with a sampling time of 15 s means that the control delay is overestimated in the process model. An overestimationis not dangerous for the proper function of the adaptive controller as long as there are enough b coefficients in the model. An underestimation, however, of the control delay in the model will deteriorate the _adaptation process. The ratio bl/bo indicates an over--or-underestimated control delay. In Figure 9 the ratio bl/bo increases as it
should from about 0.5 to about 1 when the sampling time decreases from 15 to 7.5 s. At a sampling time of 5 s the parameter d, modeling the control delay, is therefore increased to 3 in order to avoid underestimation. The experiment shows a good adaptation to variations in the reaction-invariant part of the model. It illustrates the demands on the structure of the linear model, which should be adapted to varying dead times in a case with varying flow through the reactor. Summary and Conclusions The relative merits of linear and nonlinear continuous control of pH have been discussed and illustrated with simulations and experiments. Nonlinear control is superior if the process characteristics are well-known. In practical cases, where the process characteristics are usually not well-known,linear feedback from pH is often as good as nonlinear feedback. One case when nonlinear control can have significant advantages over linear control is, however, when the pH control system oscillates for shorter or longer periods of time, in practice a quite common situation. Then nonlinear control may eliminate or significantly reduce the bias of the average pH, a bias often obtained with linear feedback of pH. Varying buffering motivates often adaptive control. Adaptive pH control can be summarized as follows: A simple linear-gain adaptation is fast and robust as long as the linear model is representative. A traditional self-tuning regulator, with a necessary "safety net", estimating the parameters of a linear black-box model is appealing because it estimates both gain and flow-model parameters. The nonlinearities of the neutralization process can, however, cause robustness problems. Nonlinear adaptive control has better prerequisites for robust pH control than linear adaptive control. Adaptation of a nonlinear model is, however, far more demanding than the adaptation of a linear model. Nonlinear adaptive control demands information from the process at a variety of different states. If the greater information demand of nonlinear adaptive control cannot be satisfied,then nonlinear adaptive control can hardly be expected to be more robust than linear adaptive control. If the flow characteristics are constant and the main chemical species of the neutralization process are known, then a nonlinear controller with a few parameters for adaptation to the static nonlinearity performs well. Introducing more flexibility by increasing the number of estimated parameters makes the estimation problem more ill-conditioned with more severe demands on the information to the estimator. A general nonlinear adaptive controller with parameters for adaptation both to a general titration curve and to varying flow characteristics can be expected to request too many parameters for practical we. Nomenclature a, = system parameter a,(pH) = function of pH, eq 6 b, = gain b, = system parameter c = total concentration d = control delay f = controller tuning parameter F = flow g(pH) = function of pH, eq 5 h = feed delay k = sampling instance (discrete time) k,, = jth dissociation constant of weak acid i m = order of polynomial A n = order of polynomial B
Ind. Eng. Chem. Res., Vol. 31, No. 12, 1992 2693 p = negative logarithmic operator: px = -log x pH = -log[H+] q-' = backward shift operator t = time u = normalized control variable V = volume w = reaction-invariant state variable w = state vector (reaction invariant) x = controller input Greek Symbols a = number of modeled weak acid-base systems A = difference operator, eq 33 B = vector of estimates 6 = setpoint perturbation amplitude T
= time constant
Subscripts
c = control stream f = feed (process stream) m = measured value 0 = output set = set value Other Notations
[A] = concentration of species A, mol/L = estimate Literature Cited k t r b m , K. J.; Wittenmark, B. Adaptive Control; Addison-Wesley, Reading, MA, 1989. Dumont, G. A.; Zervos, C. C.; Pageau, G. L. Laguerre-based Adaptive Control of pH in an Industrial Bleach Plant Extraction Stage. Automatica 1990,26,781~787. Fjeld, M.; Asbjamsen, 0. A.; Astrbm, K. J. Reaction Invariants and Their Importance in the Analysis of Eigenvectors, State Observability and Controllability of the Continuous Stirred Tank Reactor. Chem. Eng. Sci. 1974,29,1917-1926. Girardot, D. M. Control of pH Based on Reaction Invariants. Master's Thesis. University of California, Santa Barbara, 1989. Gulaian, M.; Lane, J. Titration Curve Estimation for Adaptive pH Control. Proc. Am. Control Conf. 1990,1414-1419. Gustafsson, T. K. Calculation of the pH Value of a Mixture of Solutions-An Illustration of the Use of Chemical Reaction Invarianta. Chem. Eng. Sci. 1982,37,1419-1421. Gustafsson, T. K. A Study of Modeling and Control of pH in Fast Acid-Base Reaction Processes Based on Chemic4 Reaction Invariance. Academic Dissertation, Abo Akademi, Abo, Finland, 1984. Gustafsson, T. K. An Experimental Study of a Class of Algorithms for Adaptive pH Control. Chem. Eng. Sci. 1985,40, 827-837. Gustafsson, T. K.; Waller, K. V. Dynamic Modeling and Reaction Invariant Control of pH. Chem. Eng. Sci. 1983, 38, 389-398. Gu&afsson, T.K.;Waller, K. V. Myths about pH and pH Control. AZChE J. 1986,32,335-337. Hall, R. C.; Seborg, D. E. Modelling and Self-tuning Control of a Multivariable pH Neutralization Process. Proc. Am. Control Conf. 1989,1822-1827. Henson, M. A.; Seborg, D. E. Nonlinear Adaptive Control of a pH Neutralization Process. Roc. Am. Control Conf. 1992,2586-2590.
Hershkovitch, H. Z.;McAvoy, T. J.; Liapis, A. I. Dynamic Modeling of pH Electrodes. Can. J. Chem. Eng. 1978,56,346-353. Jayadeva, B.; Rao,Y.S. N. M.; Chidambaram, M.; Madhavan, K. P. Nonlinear Control for a pH Process. Comput. Chem. Eng. 1990, 14,917-920. Jutila, P.; Jaakola, P. Tests with Five Adaptive pH-Control Methods in Laboratory". Report 65,Control Engineering Laboratory, Helsinki University of Technology, 1986. KLser, R. Adaptive pH-Control of Wasted-water from Chemical Production. RTP, Regelungstech. h a r . 1981,23,321-328. Kulkami, B. D.; Tambe, S. S., Shukla, N. V.; Deshpande, P. B. Nonlinear pH Control. Chem. Eng. Sci. 1991,46,995-1003. Lee,P.L.;SulIivan, G. R. Generic Model Control (GMC). Comput. Chem. Eng. 1988,12,573-580. Li, W. C.; Biegler, L. T. Newton-Type Controllers for Constrained Nonlinear Processes with Uncertainty. Znd. Eng. Chem. Res. 1990,29,1647-1657. Li, W. C.; Biegler, L. T.; Economou, C. G.; Morari, M. A. Constrained Pseudo-Newton Control Strategy for Nonlinear Systems. Comput. Chem. Eng. 1990,14,451-468. McAvoy, T. J.; Hsu, E.; Lowenthal, S. Dynamics of pH in Controlled Stirred Tank Reactor. Znd. Eng. Chem. Process Des. Dev. 1972, 11, 68-70. Okey, R. W.; Chen, K. Y.; Sycip, A. Z. Neutralization of Acid Wastea by Enhanced Buffer. J. Water Pollut. Control Fed. 1978,50, 1841-1851. Orava, P.J.; Niemi, A. J. State Model and Stability Analysis of a pH Control Process. Znt. J. Control 1974,20,557-567. Pajunen, G. A. Comparation of Linear and Nonlinear Adaptive Control of pH-Process. R o c . Conf.Decision Control 1981,Mth, 850-852. Pajunen, G. A. Adaptive Control of Wiener ?Lpa Nonlinear Systems. Automatica 1992,28,781-785. Parrish, J. R.;Broeilow, C. B. Nonlinear Inferential Control. AIChE J. 1988,34,633-&U. Saint-Donat, J.; Bhat, N.; McAvoy, T. J. Neural Net Based Model Predictive Control. Int. J. Control 1991,54,1453-1468. Waller, K. V.; Mikill, P. M. Chemical Reaction Invariants and Variants and Their Use in Reactor Modeling, Simulation, and Control. Znd. Eng. Chem. Rocess Des. Dev. 1981,20,1-11. Waller, K. V.; Gustafsson, T. K. Fundamental Properties of Continuous pH Control. ZSA Trans. 1983,22(l),12-34. Wigren, T. Recursive Identification Based on the Nonlinear Wiener Model. Ph.D. Thesis, Acta Universitatis Upsaliensis, Uppsala, Sweden, 1990. Williams, G. L.; Rhinehart, R. R.; Riggs, J. B. In-Line ProcessModel-Based Control of Wastewater pH Using Dual Base Injection. Znd. Eng. Chem. Res. 1990,29,1254-1259. Wittenmark, B.; AstrBm, K. J. Practical Issues in the Implementation of Self-tuning Control. Automatica 1984,20,595-605. Wright, R. A.; Kravaris, C. Nonlinear Control of pH Proceases Using the Strong Acid Equivalent. Znd. Eng. Chem. Res. 1991, 30, 1561-1572. Wright, R. A.; Soroush, M.; Kravaris, C. Strong Acid Equivalent Control of pH Processes: An Experimental Study. Znd. Eng. Chem. Res. 1991,30,2437-2444. Young, G. E.;b o , S. Robust Control of a Nonlinear Process with System Uncertainty and Delay Using Variable Structure. Proc. Am. Control Conf. 1986,1210-1217.
Received for review April 28, 1992 Revised manuscript received September 21, 1992 Accepted September 30, 1992