Hybrid Neuro-Fuzzy Network-Priori Knowledge Model in Temperature Control of a Gas Water Heater System J. A. Vieira1, F. Morgado Dias2 and A. M. Mota3 1 Department of Electrotecnica of the Escola Superior de Tecnologia, Av. Empresário, 600-767 Castelo Branco, Portugal 2 Department of Electrotecnica of the Escola Superior de Tecnologia, Campus do IPS, Estefanilha, 2914-508 Setúbal, Portugal 3 Department of Electrónica e Telecomunicações of the Universidade de Aveiro, Campus Santiago, 3810 Aveiro, Portugal 1
[email protected],
[email protected] and
[email protected] Abstract This paper presents an hybrid neuro-fuzzy networkpriori knowledge model in temperature control of a gas water heater system. The hybrid model consists in a cascade connection of two blocks: an approximate First Principles Model (FPM) and an unknown block. The first principles model is constructed based in the balance equations of the system and in a priori knowledge. The unknown part of the global model is modeled with a neuro-fuzzy structure which is based in a priori knowledge and identified with input/output data of the system. The Neuro-Fuzzy Hybrid Model (NFHM) of the gas water gas heater consists in a cascade connection of a neuro-fuzzy model with a first principles model. The proposed hybrid model is tuned using gradient decent combined with least square algorithm off-line. A Smith predictive controller is constructed based in the water heater hybrid model. Due to the characteristics of the model, the Smith predictive control structure is simplified, linearizing the system relatively to the input gas flow and it presents a special configuration for multiple input with different time delays. Finally, the control of the output water temperature results are shown and discussed.
1. Introduction Recently, for non-linear modeling, neural networks and neuro-fuzzy modeling approaches [3] have received a great deal of attention. The drawbacks are the complexity and the darkness of theirs structures, specially, in modeling complex nonlinear systems. To create model structures with small complexity and, especially, with high interpretability degree, the models structure should be constructed based on the
first principles equations and include all possible and available a priori knowledge. This is exactly what is made in the hybrid model approaches. They consist in the parallel or cascade connection of two blocks to implement a global interpretable model: an approximate first principles model and the unknown block modeled using a grey or black-box model strategy. This modeling methodology maximizes the use of a priori knowledge. The approximate first principles model is constructed based in the balance equations of the system (energy, momentum, mass balances). For the unknown block, there are several model methods that can be used like: artificial neural networks, NARX, polynomial approximation, neuro-fuzzy networks, etc. In general, for complex nonlinear systems, there are some parts in the first principles equations that are less known or even unknown, so the solution is to use in serial or in parallel a grey or black-box model to approximate these unknown parts. The hybrid models approaches that use a neural network for modeling the unknown block are very popular [9], [6], because there is no need to know nothing about the unknown block to model it, but they create complex structures. If there is some knowledge about the unknown block it is possible to use another king of modeling techniques that implement transparent and interpretable models. The interpretability of the models facilitates the understanding of the system behavior and its integration in control schemes. It has been shown that many types of nonlinearities in industry processes are effectively modeled with hybrid models, like heating and cooling processes, fermentation [7], solid drying processes [2], continues stirred tank reactor (CSTR) [1]. This work presents the neuro-fuzzy hybrid model that uses a zero-order Takagi-Sugeno neuro-fuzzy
model in cascade with an approximated first principles model. In this paper, a domestic gas water heater is modeled with the proposed algorithm. Finally, the output water temperature is controlled using a Smith predictive controller based on a direct and inverse neuro-fuzzy hybrid model with some special characteristics.
2. Hybrid Model The hybrid models can be designed in two different configurations [2]: in parallel and in cascade, as can be seen in figure 1.
equations like the one defined in equation 1, where xi is a certain quantity, for example mass, energy or momentum. accomulati on of x i within the system flow of into the
The parallel hybrid model (figure 1 a)) is used when the unknown part of the first principles equations is completely unknown. The solution is to model the error between the output of the t first principles model and the output of the real system. The cascade hybrid model (Figure 1 b)) is used when the unknown part of the first principles equations is a specific reaction parameter or a small part of the balance equations that is less known. In this case, there is some knowledge about the specific unknown part and it is completely isolated from the known part of the first principles equations. The presented hybrid model will be cascade hybrid models where the designer has some a priori knowledge about the specific less known part. With the cascade hybrid model, the global model stays more interpretable and transparent.
2.1. First Principles Model A system can be described based on macroscopic balances, for instance, mass, energy or momentum balances. These balances are formulated based on conservation a principle that leads to differential
flow of x xi i − + system out of the system
amount of x genereted amount of x consumed i i − within the system within the system
(1) In most of the cases, no all the terms in equation 1 are exactly or even partially known. In hybrid models the grey-box models are used to represent the other-wise difficult to model parts of the model. These hybrid models can be formulated as expressed in equation 2, where f(x,u) and g(x) represents the first principles functions, fGB(x,u, θ ) represents the grey-box part of the model and θ represents the unknown parameter vector [1] . x = f x,u,fGB(x,u,θ) (2) y = g( x )
(
Fig. 1. Hybrid Models – a) Parallel hybrid model b) Cascade hybrid model.
=
)
The reaction rates (amount of generated and consumed materials in chemical reactions) and thermal effects (reaction heat) are specially difficult to model, however, the first two transport terms in equation 1 (inlet and out let flows) can be obtained more easily and accurately. Hence, in the modelling phase it turns out which parts of this model structure are easier and which are more difficult to obtain. A particular case of a first principles equations model formulated in equation 2 is presented in equation 3 [1]. This case appears very frequently in real world applications, it separates, in a simple way, the known part from the unknown part of the first principles equations. . x = f(x,u) + fGB(x,u ,θ) y = g( x )
(3)
2.2. Neuro-Fuzzy Cascade Hybrid Model Identification The NFHM consists of a series connection of a zero or zero-order Takagi-Sugeno neuro-fuzzy model (NFM) with the approximate first principles model as shown in figure 2, where u is the input variable, y is the output variable and z is an internal variable.
1.0
A1 A2
Ar
A3 ...
d1
0.5
u(k)
µA1
Σ µAi
0.0 Umin
Umax
...
1.0
A1 A2
A3
z(k) SUM
Aproximate First Principles Model
y(k)
Ar ...
Fig. 3. NFHM Model Identification. dr
0.5
With a vector of N elements of input and output data from the system (train data set), it is possible to calculate the approximate output of the unknown model f NF (x,u ,θ) and then, after testing several
µAr
0.0 Umin
Σ µAi Umax
Fig. 2. NFHM Model. The unknown part of the first principles model, fGB(x,u, θ ), in equation 3, is modelled using a NFM, called fNF(x,u, θ ). In the cascade hybrid modelling, the unknown part of the model is not completely unknown, there is some knowledge about it, as the input and output variables that are involved on it or even its dynamics. The choice of the regressors is based in the a priori knowledge. With the unknown part fNF(x,u, θ ) modelled with a NFM and isolating it in the first principles equation (equation 3) the output of the unknown model is calculated through equation 4. f NF (x,u ,θ) = (
∂x − f(x,u)) ∂t
(4)
Transforming equation 4 from the state domain to the discrete domain, it is possible to have the approximate output of the unknown model f NF (x,u ,θ) , so the identification of the NFM, using input and output data from the system is possible. The identification of the parameters θ of the unknown model is made minimizing the cost function Mean Square Error, J, between the approximate output of the unknown part from the first principles equations f NF (x,u ,θ) and output estimation of the neuro-fuzzy ^
model f NF (x,u ,θ) presented in equation 5.
J ={
T ^ ^ 1 N f NF − f NF } − f f ∑ NF NF N t t t t t = 1
(5)
The identification block diagram is illustrated in figure 3.
significant regressors, the structure of the unknown NFM is chosen and identified. The procedure of identification of the NFHM is illustrated in figure 3, where the zero-order TakagiSugeno neuro-fuzzy model, is identified using an iterative learning procedure based in gradient decent algorithm combined with least squares algorithm using the input and output data from the system. The identification procedure ends when the cost function reach a predefined small number or the testing data error stops decreasing or after M iterations.
3. The Gas Water Heater The global system has three main blocks: the gas water heater, a micro-controller board and a personal computer. The micro-controller board has three modules, all controlled by the flash-type microcontroller PHILIPS 89C51RD. The sensor and actuator module has the electronic interface to the sensors and actuators of the system. The Security module is used for the supervision and control of the security conditions of the water heater. The Communication module is used for acquisition, monitoring and controlling all system variables in the personal computer. This connection is made by a serial communication using RS232C. The personal computer is responsible for executing the control algorithm. A detailed description of this system can be found in previous work [10]. After this small description of the global system, the first principles equations and the identification of the neuro-fuzzy hybrid model of the gas heater is presented.
3.1. System Description The water gas heater is a multiple input single output (MISO) system. The controlled output water
temperature will be called hot water temperature (hwt). This variable depends of the cold water temperature (cwt), water flow (wf), gas flow (gf) and of the gas water heater dynamics. To hot and cold water temperature difference is called delta water temperature ( ∆ t). The water gas heater is physically composed by a gas burner, a permutation chamber, a ventilator, two gas valves and several sensors used for control and security as shown on figure 4. Exaution Sensor
Over Heat Sensor
Hot Water Temperature Sensor NTC
Ventilator Permutation Chamber
Water Flow Sensor
Gas
period
h=1
second
and
with
discrete domain is presented in equation 8.
Hot Water
Fig. 4. Schematic of the water gas heater system Operating range of the hwt is from 30ºC to 60ºC. Operating range of the cwt is from 5ºC to 25ºC. Operating range of the wf is from 3 to 15 litters / minute. Operating range of the gf is from 23% to 100% of the opening of the valve.
Heater
sampling
td τ d = int( ) + 1 , the final transfer function in the h
Spark
On-Off gas valve
3.2. Gas Water Equations
wf(s) 1 1 wf(s)Ce M ∆t(s) wf(s)Ce − s td = e e − s td (7) = wf(s) M Qe(s) s +1 s+ wf(s) M
With
Burner Cold Water Temperature Sensor Ionization Controlled gas NTC Sensor valve
Cold Water
The absorbed energy per second (Qe) is equal to the given energy to the system (Qg) subtracted to the lost energy from the system (Ql) per second. On each utilization of the water heater it was considered that cwt(k) is constant, it could change from utilization to utilization, but in each utilization it remains approximately constant. Its dynamics does not affect the dynamics of the output energy variation because its variation is too slow. Writing equation 6 in to the Laplace domain, it gives equation 7.
First Principles
Applying the principle of energy conservation in the gas water heater system, equation 6 could be written. dEs(t) = Qe(t − td) − wf(t)Ce(hwt(t) − cwt(t)) (6) dt Where dEs/dt is the energy variation of the system, Qe is the input gas flow absorbed energy per second, wf Ce cwt is the water energy per second that enters in the system, wf Ce hwt is the water energy per second that leaves the system, and Ce is the specific heat of the water, M is the water mass inside of the permutation chamber and td is the system time-delay.
wf(k) wf(k) − − 1 M ∆t(k + 1) = e ∆t(k) + 1 − e M . wf(k)Ce (8) (Qe(k − τ d))
Observing the real data of the system, the absorbed energy (Qe) is a non-linear static function that depends mainly of the gas flow (gf) applied to the burner. This is the unknown part of the first principles equations, in this particular case, which will be modelled with a neuro-fuzzy system. The unknown function fNF(.) is dependent in a static way of the gas flow as expressed in equation 9. Qe(k − τ d) = f NF (gf ( k − τ d);θ ) (9) Finally, the global transfer function is given by equation 10. wf(k) wf(k) − − 1 1 − e M ∆t(k + 1) = e M ∆t(k) + wf(k)Ce (10) f NF (gf ( k − τ d);θ )
(
)
If K1 and K2 are defined as expressed in equation 11, the final discrete transfer function is given as defined in equation 12.
K1(k) = e
−
wf(k) M ; K (k) = 2
wf(k) − 1 M − 1 e wf(k)Ce
(
(11)
)
∆ t(k + 1) = K 1 (k)∆ t(k) + K 2 (k) f NF (gf ( k − τ d);θ ) (12) Where M=0,42 Kg or litters is the mass of water inside of the permutation chamber (measured value) and Ce=4186 J/(KgK) is the specific heat of the water (tabled value). This final discrete transfer function of the domestic water gas heater has an unknown part fNF(.) that will be identify in the next section using a neuro-fuzzy model. Fig.. 5. Train and test data sets.
4. Neuro Fuzzy Hybrid Model Identification
parameters are identified with a train mean square error MSE of 0,52 and test of 0,55 ºC2
4.1. Identification Data For the identification of the neuro-fuzzy model, it is necessary to have open loop data of the real system. This data has been defined to respect two important requirements: frequency and amplitude spectrum wide enough [7]. The collect data was made to the PC and is illustrated in figure 5. The train data set are from iteration 1 to 2450 and the test data set are from 2451to 2980.
4.2. Neuro-Fuzzy Hybrid Model Identification
5. Control Structure 5.1. Smith Predictive Control The Neuro-Fuzzy Hybrid Smith Predictive Controller (NFHSPC) is based in the Internal Model Controller architecture using a neuro -fuzzy hybrid model, as illustrated in figure 6. cwt(k) r(k) +
e(k)
The zero-order TS neuro-fuzzy model was implemented using the anfis function of the fuzzy toolbox of Matlab [4]. This neuro-fuzzy structure has three rules with Gaussian shaped membership functions in the antecedents and with constant functions in the consequents. The NFHM structure is initialized using the subtractive clustering and then the final parameters are identified using the gradient decent algorithm alternated with the least squares algorithm. In the identification, the unknown output vector is approximated solving equation 12 in order to fFN(.) as expressed in equation 14. f NF (gf ( k − τ d) )) =
∆ t(k + 1) − K1(k)∆ t(k) K 2 (k)
(13)
The error between the output of the NFM and the approximated fNF(.) (equation 13) is minimized as shown in figure 3 minimizing the cost function defined in equation 5. After several iterations of the hybrid learning algorithm it reaches the test error minimum and the final 15
∆ t(k)-e(k) lgf(k-1)
-
Physical Inverse M odel
"Linearization" of the plant gf(k-1)
f NF
hwt(k)
W ater Heater
-1 (.)
+
-
-
Z -1
Physical Direct M odel Z -1 -td (k)
Z wf(k-1)
Physical Direct Model
Time Delay Function
Fig. 6: NFHMSPC constituent blocks. As can be seen, the neuro fuzzy hybrid model is not used as it was identified, because the fNF(.) can be separated and used just to linearize the water hater relatively of the gas flow input. The Smith predictive control structure has a special configuration, because the systems has two inputs with two deferent time delays so it uses two direct models, one model with the time delays and another with out the time delays. The NFHMSPC separates the time-delay of the plant from the model, so it is possible to predict the ∆t(.) τd
steps earlier (τd = digital time-delay), avoiding the negative effect of the time-delay in the control results. The time delay is a known function of the water flow (wf). The incorrect prediction of the time delay may lead to aggressive control if the time-delay is under estimated or conservative control if the timedelay is over estimated [8].
5.2. NFHMSPC Results The final control results are shown in figure 7. It can be seen, that r-hwt is around zero excepted in the input transitions. Through the e feedback signal, it is clear that the model is very close to the real system.
Fig. 7. NFHMSPC results. The mean square errors are expressed in table 1, with and with out the delay of the water hater for results evaluation. NFHMSPC error MSE [ºC2] r(k)-hwt(k) 3,7 r(k)-hwt(k-td(k)) 1,8 Table 1. Mean square errors of the NFHMSPC From the results expressed in table I, the NFHMSPC achieved very good control results.
6. Conclusions This work presents, identify the non-linear neurofuzzy hybrid model approach applied in to a gas water heater. The proposed hybrid model consists in the cascade of an approximate first principles model with a neuro-fuzzy model. The hybrid modelling technique can be used in many applications when there are a priori knowledge available and when the first principles equations are reasonably known. These models have a good generalization capacity and have a very good interpretability degree.
Finally, the gas water heater was controlled using a Smith predictive controller based in the neuro-fuzzy hybrid model. The interpretability of the hybrid models facilitates the understanding of the system behaviour and its integration in control schemes. Only this understanding of the system behaviour allows the simplification of the Smith predictive controller presented in figure 6. The created model is interpretable and it help the designer to understand the unknown part of the first principles equations of the system.
7. References [1] J. Abonyi, J. Madar and F. Szeifert, “Combining First Principles Models and Neural Networks for Generic Model Control”, Soft Computing in Industrial Applications - Recent Advances, Eds. R. Roy, M. Koppen, S. O., T. F., F. Homann Springer Engineering Series, 2002, pp.111-122. [2] F. A. Cubillos, P. I. Alvarez, J. C. Pinto, E. L. Lima. “Hybrid-neural modelling for particulate solid drying processes”. Power Thecnology, 1996, vol. 87, pp. 153-160. [3] J. S. R. Jang, C.-T. Sun, E. Mizutani, “Neuro-Fuzzy and Soft Computing A Computation Approach to Learning and Machine Intelligence”, Matlab Curriculum Series, Prentice Hall, 1997. [4] Fuzzy Logic Toolbox for MATLAB, MathWorks, Technical Report, 1996. [5] E. P. Nahas, M. A. Henson, D. E. Seborg, “Nonlinear Internal Model Control Strategy for Neural Network Models”, Comp Chem. Eng., 1992, pp. 1039-1057. [6] R. Oliveira, “Combining first principles modelling and artificial neural networks: a general framework”, Computers and Chemical Engineering, 2004, vol. 28, pp. 755-766. [7] D. C. Psichogios and L. H. Ungar, “A hybrid neural network-first principles approach to process modelling”, AIChE Journal, 1992, vol. 38(10), pp. 1499-1511. [8] Y. Tan, M. Nazmul Karim, “Smith Predictor Based Neural Controller with Time Delay Estimation”, Proceedings of 15th Triennial World Congress, IFAC, 2002 [9] M. L. Tompson. And M. A. Kramer, “Modelling chemical processes using prior knowledge and neural networks”, A. I. Ch. E. Journal, 1994, vol. 40(8), pp. 13281340. [10] J. Vieira, A. Mota, “Water Gas Heater Non-Linear Physical Model: Optimisation With Genetic Algorithms”, Proceedings of IASTED 23rd Int. Conference MIC, 2004, vol. 1, pp. 122-127. [11] Q. Xiang and A. Jutan. “Grey box modelling and control of chemical processes”, Chemical Eng. Science, 2002, vol.57, pp. 1027-1039.