CHEMICAL ENGINEERING TRANSACTIONS VOL. 76, 2019 A publication of The Italian Association of Chemical Engineering Online at www.aidic.it/cet Guest Editors: Petar S. Varbanov, Timothy G. Walmsley, Jiří J. Klemeš, Panos Seferlis Copyright © 2019, AIDIC Servizi S.r.l. ISBN 978-88-95608-73-0; ISSN 2283-9216 Constrained Recursive Input Estimation of Blending and Mixing Systems Janos Abonyi MTA-PE Lendulet Complex Systems Monitoring Research Group University of Pannonia, Department of Process Engineering, University of Pannonia, Egyetem utca 10, 8200 Veszprém, Hungary janos@abonyilab.com Blending, mixing processes are often supported by advanced process control systems to maximise margins from available component and heat streams. Since these model-based solutions require accurate and reliable data, in weakly instrumented processes, the unknown inlet concentrations and temperatures should be estimated based on the measured outflows. This work presents a method for the reliable estimation of multiple input variables of process units. The key idea is that the input estimation problem is formulated as a constrained recursive estimation task. The applicability of the method is illustrated based on a benchmark model of a blending system. The performance of the method is compared to the moving window and Kalman Filter based solutions. The results show the superior performance of the proposed method and confirm that the apriori knowledge-based constraints improve the robustness of the estimates. 1. Introduction Model-based blending optimisation aims to find the optimal combination of component streams to satisfy several product specifications simultaneously (Razak et al., 2019). For example, modern gasoline should be blended to meet simultaneously 10 to 15 different quality specifications while taking to account several goals, like maximising the value of all components and products, minimising reblending, the amount of quality giveaway, and the deviation from a set of desired stock levels (Méndez et al., 2006). These optimisation tools and advanced process control accurate require real-time information about process streams. Thanks to the development of process analytical technology, online analysers become available to support real- time control and optimisation, and concentration measurements are widely employed in the refineries (Ribeiro et al., 2007) and pharmaceutical industry (Maluta et al., 2019), and used in monitoring and control of blending systems (Nakagawa et al., 2014). The primary goal of our research is to develop a soft-sensor for the estimation of the unmeasured input variables of weakly instrumented heat exchangers, blending, mixing units. Soft-sensors are models used to estimate product quality or critical variables based on readily available measurements (de Assis and Filho, 2000). The advantage of these inferential measurements compared to the lab analysis is that estimation happens in real-time, so information is continuously available for control and optimisation (Feil, 2004). The importance of the problem of input estimation in process optimisation is already recognised (D’Amato et al., 2013). Mostly approached as an extension of the state estimation task. From this interpretation, an asymptotic observer (Ha and Trinh, 2004), reduced-order and high order sliding mode observers (Zhu, 2012) were developed for input and state estimation. For hybrid systems, piecewise affine (PWA) model-based moving horizon estimation (MHE) algorithm was developed to handle input disturbances (Pina and Botto, 2006). An easily implementable and industrially applicable input estimation algorithm has been developed based on moving window based least squares regression, and the performance of the algorithm was improved by prior knowledge-based constraints representing the upper and lower limits of the concentrations (Murakami and Seborg, 2000). The moving window-based approach may contain insufficient information to identify the parameters and less flexible in the prompt detection of changes in the inputs. The key contribution of this paper is that the beneficial constrained identification is incorporated into a recursive estimation, which results in an DOI: 10.3303/CET1976122 Paper Received: 05/08/2019; Revised: 12/08/2019; Accepted: 13/08/2019 Please cite this article as: Abonyi J., 2019, Constrained Recursive Input Estimation of Blending and Mixing Systems, Chemical Engineering Transactions, 76, 727-732 DOI:10.3303/CET1976122 727 algorithm that integrates the benefits and concepts of the quadratic programming and state estimation based solutions. The details of this algorithm will be presented in Section 2. The improved technique is applied to a well-known blending benchmark process. The results are summarised in Section 3. Finally, Section 4 draws the conclusions. 2. The constrained recursive input estimation algorithm The proposed input estimation algorithm is based on the generalised dynamic model of a mixing process. As Figure 1 shows, the model assumes perfect mixing. By assuming that each process stream has the same constant (temperature-independent) density, the generalised balance equation of the unit can be written as: 𝑑𝑥(𝑡) 𝑑𝑡 = ∑ 𝑞𝑖 (𝑡) 𝑉 𝑢𝑖 (𝑡) − 𝑞(𝑡) 𝑉 𝑛 𝑖=1 𝑥(𝑡) = ∑ 𝑞𝑖 (𝑡) 𝑉 (𝑢𝑖 (𝑡) − 𝑥(𝑡)) 𝑛 𝑖=1 (1) where 𝑉 is the liquid volume in the tank, 𝑛 is the number of inlet streams, 𝑞 is the outlet and 𝑞𝑖 is the 𝑖th inlet volume flow rate. The volume in the unit is kept constant, so 𝑞(𝑡) = ∑ 𝑞𝑖 (𝑡) 𝑛 𝑖=1 . The 𝒖(𝑡) = [𝑢1(𝑡), … , 𝑢𝑛(𝑡)] 𝑇 , 𝑖 = 1, … , 𝑛 vectors contain the properties (concentrations or 𝜌𝑐𝑝 𝑇 values) of the inlet streams, while 𝑥(𝑡) represents the state of the unit equalling to the measured property of the outlet stream. The process is controlled by a digital control system with Δ𝑡 sampling time. Assuming piecewise constant changes in the inputs, the discrete-time nonlinear prediction model is linear in the 𝒖(𝑘) input variables, 𝑥(𝑘) = exp (− 𝑞(𝑘 − 1) 𝑉 Δ𝑡) 𝑥(𝑘 − 1) + 1 𝑞(𝑘 − 1) [1 − exp (− 𝑞(𝑘 − 1) 𝑉 Δ𝑡)] ∑ 𝑞𝑖 (𝑘 − 1)𝑢𝑖 (𝑘 − 1) 𝑛 𝑖=1 (2) that allows the formulation of a set of linear equations for the prediction of every , 𝑘 = 1, … , 𝑁 samples: 𝑦(𝑘) = [𝒙(𝑘) − 𝑎(𝑘 − 1)𝒙(𝑘 − 1)] [1 − 𝑎(𝑘 − 1)] 𝑞(𝑘 − 1) = ∑ 𝑞𝑖 (𝑘 − 1)𝑢𝑖 (𝑘 − 1) 𝑛 𝑖=1 + 𝜀(𝑘) (3) The input estimation is based on the minimisation of the modelling error: 𝜀(𝑘) = 𝑦(𝑘) − �̂�(𝑘) = 𝑦(𝑘) − ∑ 𝑞𝑖 (𝑘 − 1)𝑢𝑖 (𝑘 − 1) 𝑛 𝑖=1 (4) Figure 1: Flowsheet diagram of the generalised blending system The key idea is that the unmeasured 𝑢𝑖 (𝑘 − 1) inputs can be estimated based on the observed outputs by the recursive least squares algorithm, that minimises the prediction error: J(�̂�(𝑘 − 1)) = ∑ 𝜆𝑘−𝑙 (𝑦(𝑙) − φ𝑇 (𝑙 − 1)�̂�(𝑙 − 1)) 2𝑘 𝑙=1 (5) where �̂�(𝑙 − 1) represents the estimated input, 𝝋𝑇 (𝑘 − 1) = [𝑞1(𝑘 − 1), … , 𝑞𝑛(𝑘 − 1)] the vector of the known inputs of the model (the flow rates) and 𝜆 stands for a forgetting factor that controls the flexibility and robustness of the estimation. 728 Recursive estimation algorithm updates the estimate in every time instant based on the 𝑦(𝑘) − 𝝋𝑇 (𝑘 − 1)�̂�(𝑙 − 1) prediction error �̂�(𝑘) = �̂�(𝑘 − 1) + 𝑲(𝑘)(𝑦(𝑘) − 𝝋𝑇 (𝑘 − 1)�̂�(𝑙 − 1)) (6) where the Kalman filter gain is also updated in every k time instant 𝑲(𝑘) = 𝑷(𝑘)φ𝑇 (𝑘 − 1) (7) where 𝑷(𝑘) approximates the inverse of the weighted covariance matrix: 𝑷(𝑘) = 1 𝜆 [𝑷(𝑘 − 1) − 𝑷(𝑘 − 1)φ(𝑘 − 1)φ𝑇 (𝑘 − 1)𝑷(𝑘 − 1) 𝜆 + φ𝑇 (𝑘 − 1)𝑷(𝑘 − 1)φ(𝑘 − 1)φ𝑇 ] (8) When 𝑷(𝑘) does not contain enough information, 𝑡𝑟(𝑷(𝑘)) becomes a small value. The monitoring of the trace of the information matrix can highlight when the flow rates of inlet streams do not vary enough to provide appropriate excitation. In this case, the forgetting should be stopped, 𝜆 = 1 or a perturbation signal should be added to excite process dynamics. The robustness of the estimation can be highly improved by constraining the estimated values. Upper and lower limits or other prior knowledge about the estimated variables can be easily transformed into linear inequality and equality constraints: 𝑳�̂�(𝑘) ≤ 𝒄 (9) 𝑴�̂�(𝑘) = 𝒌 (10) The unconstrained estimates of the previously presented recursive algorithm can be optimally projected to these constraints �̂�𝑐 (𝑘) = �̂�(𝑘) − 𝑷(𝑘)𝑴𝑇 𝝁 − 𝑷(𝑘)𝑳𝑇 𝜼 (11) where 𝝁 and 𝜼 are vectors of Lagrange multipliers associated with the equality and inequality constraints are determined by solving the following quadratic program: 𝑚𝑖𝑛 𝝁,𝜼 {[ 𝝁 𝜼] 𝑇 𝑯 [ 𝝁 𝜼] + 𝒈 𝑇 [ 𝝁 𝜼] } (12) where 𝑯 = [ 𝑴𝑷(𝑘)𝑴𝑇 𝑴𝑷(𝑘)𝑳𝑇 𝑳𝑷(𝑘)𝑴𝑇 𝑳𝑷(𝑘)𝑳𝑇 ] (13) 𝒈 = [ 𝒌 − 𝑴𝒖(𝑘) 𝒄 − 𝑳𝒖(𝑘) ] (14) This formulation incorporates the quadratic programming (QP) into the recursive estimation. As QP can be solved easily, the method is easily implementable in most industrial control systems and mathematical and engineering software. 3. Results and discussion The performance of the proposed algorithm is demonstrated in a reproducible and well-documented benchmark problem defined in (Murakami and Seborg, 2000). In this example, the flow rates of the 𝑛 = 5 blended streams are assumed to be known, and the inlet stream compositions are estimated. The nominal values of the process are V = 1, qi = 0.06, ∀𝑖. To make a realistic study, non-stationary drifting and periodic disturbance were assumed: 𝜀(𝑘) = 0.001 {1.5 + ( 1 150 ) 𝑘 + sin ( 𝑘 13.6 ) + 𝜂(𝑘)} (15) The mean squared parameter estimation error is used to evaluate the methods: 729 𝐽 = ∑ √ 1 𝑁 ∑ ( �̂�𝑖 (𝑘) − 𝑢𝑖 (𝑘) 𝑢𝑖 (𝑘) ) 2𝑁 𝑘=1 𝑛 𝑖=1 (16) where 𝑢𝑖 (𝑘) represents the true value of the unmeasured concentration values of the 𝑖th input stream at the time, 𝑘. (b) (a) Figure 2: The estimated inlet concentrations of five input streams. Figure a.) shows the measured outlet concentration, while Figure b.) displays the estimated inlet concentrations in case of recursive least squares (green) and constrained estimation (red) 730 The results of the analysis are illustrated in Figure 2. As can be seen, based on a single time-series of the measured outlet concentration the algorithm gives almost perfect estimates of the inlet concentrations (the estimated concentrations represented by the red lines are in good alignment with the black dashed lines representing the unknown stepwise changing input concentrations). The comparison of performances of the recursive least squares (green) and constrained estimation (red) shows that the constrained estimates are much more robust and reliable. The upper and lower constraints were identical to the S1 constraint set of (Murakami and Seborg, 2000), which means the 0.8 and 1.2 times of the nominal values of the concentrations. The results are compared to the moving window based input estimation algorithms developed in (Murakami and Seborg, 2000) and Kalman filter-based estimation. As can be seen in Figure 3, the least-squares method produced the worst estimates. Better results can be obtained when the limits are incorporated into the estimation algorithm by linear constraints (LS-QP). The benefits of the recursive estimation are seen as recursive least squares (RLS) has better performance than LS. The Kalman-filter gives results that are similar to the performance of quadratic programming. Quadratic programming requires a longer running time and larger computing capacity. Although the running time is a few seconds for the whole simulation period, in this simple case study, the quadratic programming requires 28 times more running time then the Kalman filter. The best results are achieved by the proposed recursive constrained estimation algorithm (RLS-QP). This is not surprising since this method utilizes both model equations and knowledge about the limit values. Figure 3: Comparison of the performances of the least-squares (LS), the constrained least squares (LS-QP) and the recursive least squares (RLS) and the proposed recursive constrained (RLS-QP) algorithms and the Kalman Filter (KF) based input estimation 4. Conclusion Monitoring of blending and mixing processes require accurate information. A model-based soft sensor was designed to provide reliable estimates of inlet temperatures and concentrations. The fundamental idea was that more accurate results could be obtained when apriori knowledge-based constraints support the input estimation task. Based on the general model of the blending process, an extended Kalman filter was also designed. The results are reproducible easily since all the programs are downloadable from the website of our research group (ABONYILAB, 2019). The results confirm that the proposed constrained recursive algorithm can provide a robust and reliable estimate of the input variables, and this method has superior performance over the moving window based parameter and extended Kalman Filter based estimation algorithms. 731 Acknowledgements The research has been supported by the National Research, Development and Innovation Office – NKFIH, through the project OTKA – 116674 (Process mining and deep learning in the natural sciences and process development). References ABONYILAB, 2019. Complex systems monitoring research group. , accessed 07.08.2019. D'Amato A.M., Ali A.A., Ridley A., Bernstein D.S., 2013. Retrospective cost optimization for adaptive state estimation, input estimation, and model refinement, Procedia Computer Science, 18, 1919 – 1928. de Assis A.J., Filho R.M., 2000. Soft sensors development for on-line bioreactor state estimation, Computers and Chemical Engineering, 24, 1099 – 1103. Feil B., Abonyi J., Pach P., Nemeth S., Arva P., Nemeth M., Nagy G., 2004. Semi-mechanistic models for state- estimation–soft sensor for polymer melt index prediction. In: Proceeding of the International Conference on Artificial Intelligence and Soft Computing, Springer, Berlin, Heidelberg, 1111-1117, DOI: 10.1007/978-3-540- 24844-6_174. Ha Q.P., Trinh H., 2004. State and input simultaneous estimation for a class of nonlinear systems, Automatica, 40, 1179-1785. Maluta F., Montante G., Paglianti A., 2019. Analysis of Liquid Mixing and Solid Dissolution for Pharmaceutical Manufacturing in Stirred Tanks. Chemical Engineering Transactions, 74, 949-954. Méndez C.A., Grossmann I.E., Harjunkoski I., Kaboré P., 2006. A simultaneous optimization approach for off- line blending and scheduling of oil-refinery operations, Computers and Chemical Engineering, 30, 614-634. Murakami K., Seborg D.E., 2000. Constrained parameter estimation with applications to blending operations, Journal of Process Control, 10(2-3), 195 – 202. Nakagawa H., Kano M., Hasebe S., Miyano T., Watanabe T., Wakiyama N., 2014. Verification of model development technique for NIR-based real-time monitoring of ingredient concentration during blendings, International Journal of Pharmaceutics, 471, 264-275. Pina L., Botto L.A., 2006. Simultaneous state and input estimation of hybrid systems with unknown inputs, Automatica, 42, 755 – 762. Razak N.H., Hashim H., Yunus N.A., Klemeš J.J., Phoon L.Y., 2019. Optimization of ternary green diesel blends for diesel/palm methyl ester/alcohol using product design optimization. Chemical Engineering Transactions, 72, 391-396. Ribeiro N.M., Pinto A.C., Quintella C.M., da Rocha G.O., Teixeira L.S.G., Guarieiro L.L.N., Rangel M.C., Veloso M.C.C., Rezende M.J.C., da Cruz R.S., Oliveira A.M., Torres E.A., de Andrade J.B., 2007. The Role of Additives for Diesel and Diesel Blended (Ethanol or Biodiesel) Fuels: A Review, Energy and Fuels, 21(4), 2433 – 2445. Zhu F., 2012. State estimation and unknown input reconstruction via both reduced-order and high-order sliding mode observers, Journal of Process Control, 22(1), 296 – 302. 732