CHEMICAL ENGINEERING TRANSACTIONS VOL. 81, 2020 A publication of The Italian Association of Chemical Engineering Online at www.cetjournal.it Guest Editors: Petar S. Varbanov, Qiuwang Wang, Min Zeng, Panos Seferlis, Ting Ma, Jiří J. Klemeš Copyright © 2020, AIDIC Servizi S.r.l. ISBN 978-88-95608-79-2; ISSN 2283-9216 A Combination of Dynamic Simulation and Dynamic Time Warping for Fault Diagnosis of Chemical Process Startups Suli Suna, Xiaoyun Songb, Zhiguo Liuc, Wende Tianc,*, Chuankun Lid aCollege of Marine Science and Biological Engineering, Qingdao University of Science & Technology, Qingdao 266042, China bHexagon PPM Qingdao, Qingdao 266000, China cCollege of Chemical Engineering, Qingdao University of Science & Technology, Qingdao 266042, China dState Key Laboratory of Safety and Control for Chemicals, SINOPEC Qingdao Research Institute of Safety Engineering, Qingdao 266071, China tianwd@qust.edu.cn Unsteady state startup of chemical processes has such characters as nonlinearity, large variation of parameters, multiple abnormal states, etc., which failures may cause serious damage to the atmospheric environment due to uncontrolled pollutant emissions. Fault diagnosis facilitates early detection of abnormal symptoms and timely determination of abnormal reasons during startup procedure. This paper proposed a hybrid fault diagnosis strategy based on dynamic simulation and dynamic time warping (DTW) to probe transient degradation of startup performance. It calculates serial residuals between dynamic simulation values and online measured ones using DTW method to represent process development trend. The residual vector under normal conditions is used to develop principal component analysis (PCA) model. Measurements in startup process pretreated by DTW are input into the PCA model to perform fault detection and isolation work at last. The proposed method was applied to a penicillin fermentation simulator to verify its feasibility in unit operations. Case studies demonstrate that the fault diagnosis strategy allows a fast and effective supervision of abnormal state during chemical process startups. 1. Introduction Startup is one complex and important step in chemical plant operations. Unlike steady-state production process, startup process usually involves a wide range of operator intervention and manual control, so its operating conditions and variables will fluctuate greatly when facing external disturbances. The startup failures of chemical plant may result in hazardous environmental concerns (Meddeb et al., 2017). A regional air pollutant like VOCs, NOx, and partially oxygenated hydrocarbons (Ge et al., 2019), might be formed during abnormal chemical plant startup due to process vessel depressurization, purging and venting (Ge et al., 2016). Fault diagnosis is of great importance in guaranteeing safe startups and minimising possible adverse air-quality impacts. At present, fault diagnosis study for chemical process startup is mainly focused on multivariate statistical methods such as partial least square (PLS) regression (Mei et al., 2018), principal component analysis (PCA) (Deng and Tian, 2013), etc. These methods use Euclidean distance to calculate dissimilarity between PCA model and measurement. But these two sets of data for one same variable may be different in length during startup, leading to a misleading dissimilarity for really similar data sequence. With local transfer, compression and expansion means, dynamic time warping method (DTW), however, can give correct dissimilarity without calculation error caused by unequal lengths (Srinivasan et al., 2005). For example, combining with variable moving windows, a dissimilarity analysis method for batch process was given with contribution plots of dissimilarity index to identify the variables contributing significantly to the out-of-control state (Zhao et al., 2007). These methods mainly focus on the target attributes analysis, excelling in quickness and simplicity instead of analytical depth and accuracy. As a priori knowledge of chemical processes would facilitate an effective mapping from the measurement space to the discriminating fault feature space, quantitative model-based diagnosis method has been developed to improve the analytical depth and accuracy of fault diagnosis through state DOI: 10.3303/CET2081051 Paper Received: 30/01/2020; Revised: 25/02/2020; Accepted: 07/03/2020 Please cite this article as: Sun S., Song X., Liu Z., Tian W., Li C., 2020, A Combination of Dynamic Simulation and Dynamic Time Warping for Fault Diagnosis of Chemical Process Startups, Chemical Engineering Transactions, 81, 301-306 DOI:10.3303/CET2081051 301 identification, parameter estimation and parity relation (Bhagwat et al., 2003). Motivated by the definite presentation of faults in process model (Sun et al., 2020), a dynamic simulation and DTW based fault diagnosis method for chemical process startups was proposed in this work, in which the residual between simulation and measured values is calculated by DTW and PCA model for fault detection and isolation purposes. The purpose of this work is to evaluate the feasibility of dynamic simulation integration into fault diagnosis for transient startup process. In the following sections, the proposal is described in detail at first. Then its implementation is illustrated using a fed-batch penicillin production benchmark process simulator. The major conclusions reached from analysis of the application results are given at last. 2. Description of dynamic simulation and DTW based fault diagnosis scheme Figure 1a depicts fault diagnosis scheme using dynamic simulation and DTW. A set of sample in normal working conditions are employed for modeling. In chemical processes, noise usually exists in monitoring data due to instrument measurement error, data transmission delay or chemical reaction fluctuations. If a process was modeled correctly, dynamic simulation result minus collected data will leave noises only. However, the simulation data and measured data are often not same in length, so DTW is more suitable to represent the residual than Euclidean distance. The obtained residuals are input into PCA model for fault diagnosis purposes. Dynamic simulation data Standard residual error matrix DTW calcuation PCA model Online DCS data Detection of residual error matrix Score matrix and residual error matrix T 2 , SPE Diagnosis results Start T 2 , SPE>threshold? End Yes No Variable contribution analysis Normal sampling Abnormal sampling Acid Base Cold Water Hot water FC FC Air Substrate Tank Fermentor pH T Figure 1: Fault diagnosis scheme and application case with dynamic simulation, DTW and PCA The main diagnostic steps are as follows: (1) Build mechanistic model and then obtain simulation results for measured variables using dynamic simulation; (2) DTW is used to calculate the residual between simulation data and distributed control system (DCS) data; (3) Use the residual data obtained under normal operating conditions to develop PCA model; (4) Calculate online T2 and squared prediction error (SPE) by PCA model for fault detection; (5) Calculate the contribution of process variables to monitored statistics to analyse the root cause of failure. The fault diagnosis scheme depicted in Figure 1a is composed of three components. Dynamic simulation utilises the time-varying mechanistic relationship between control, state and output variables to simulate the dynamic startup process. DTW uses dynamic programming to nonlinearly dislocate two trajectories of dynamic simulation and real data to obtain their minimum difference degree. PCA constructs statistics to monitor process state based on the linearly independent principal components or hidden variables extracted from multivariate data. Generally, PCA establishes T2 statistic in the principal subspace and SPE statistic in the residual subspace for statistical test. If any statistic exceeds the control limit, a fault or exception is indicated in the process. By analysing the contribution of each process variable to the statistic, the process variable that causes the process change or failure can be determined. In a word, the contribution of the proposed scheme lies in the transformation of the DTW processed difference to develop PCA linear variables for fault diagnosis, reducing the modeling difficulty and improving the speed and accuracy of diagnosis. 3. Case studies The proposed dynamic simulation and DTW based fault diagnosis scheme is applied to a batch penicillin process simulator to test its feasibility. a b 302 3.1 Description of penicillin process The case study is carried out based on penicillin simulator (PenSim) (Birol et al., 2002). PenSim was specially designed for the penicillin fermentation process and can easily implement a series of penicillin fermentation simulations (Birol et al., 2002). Figure 1b shows the process flow diagram of PenSim process. Penicillin fermentation is a process of penicillin production about bacteria growth and synthesis of antibiotics with appropriate medium, pH, temperature, air flow rate, and stirring speed. It can be generally divided into two steps. The first step is the substrate consumption and rapid biomass growth process. The second step is the synthetic phase of penicillin during which fermentation process tends to be stable. In the whole process, some conditions are requisite to promote the production of penicillin, such as continuous air flow and stirring, pH control using acid and alkaline, a certain temperature and pressure, continuous or intermittent addition of ammonium salt and glucose. PenSim simulator gives a nonlinear and unsteady state process and is suitable for fault diagnosis study on startup process. Variables in PenSim are composed of input variables like air flow, stirring power, substrate feed rate, etc. and output variables like the substrate concentration, bacterium concentration, CO2 concentration, dissolved O2 concentration, reaction volume, etc. PenSim can simulate not only normal penicillin fermentation process but also three abnormal states about air flow, stirring power and bottom stream rate. Fault can be set with step and ramp type, disturbance amplitude, start time and end time. The variable importance in PenSim was comprehensively evaluated by the complex network theory to find the key variables using basic centrality data obtained from the adjacency matrix and topology structure of the process network (Cui et al., 2018). In this work, ten key variables were selected to carry out fault diagnosis, as shown in Table 1. Table 1: Key variable list for fault diagnosis No. Variable No. Variable 1 Air flow rate 6 Cooling water flow 2 Dissolved O2 concentration 7 Bacterium concentration 3 CO2 concentration 8 Heat 4 Reaction volume 9 Stirring power 5 pH 10 Bottom stream rate 3.2 Dynamic simulation of penicillin fermentation process First principles model of penicillin fermentation process plays an important role in guaranteeing the accuracy of dynamic simulation and DTW based startup fault diagnosis method. A number of mechanistic models have appeared in the penicillin fermentation study. Bajpai model is a typical non-structural model that can comprehensively describe the actual process of penicillin fermentation (Birol et al., 2002). It includes not only the effect of pH, temperature, air flow, stirring power, bottom stream rate, etc. on penicillin production, but also other factors such as the cell growth, carbon dioxide, penicillin production, substrate consumption, the heat of reaction, etc. The dynamic equations in it are shown in Eqs(1) - (6). (1) Cell growth equation: dX x dV X dt V dt = − (1) (2) Penicillin metabolites growth equation: pp dp p dV X KP dt V dt = − − (2) The variable μpp in Eq(2) denotes the penicillin product-specific production rate which can be expressed as: pp p 2 S = p L p p i OP L C K S S K K X C   + + + (3) (3) Substrate consumption equation: pp X X S P S dS S dV X X F dT Y Y V dt  = − − + − (4) (4) Dissolved O2 concentration equation: ( )*1 ppL L O a L L X O P O dC C dV X X K C C dt Y Y V dt  = − − − + − − (5) 303 (5) CO2 production equation: 2 1 2 3 dCO dX X dt dt   = + + (6) The boundary values and kinetic parameters of Eqs(1) - (6) are listed in Tables 2 and 3 (Birol et al., 2002). Table 2: The boundary values of penicillin fermentation model Variable Boundary value Unit Variable Boundary value Unit Bacterium concentration (variable 7) 15 L Fermenter temperature 298 K Biomass concentration 0.1 g/L pH (variable 5) 5 Dissolved O2 concentration (variable 2) 1.16 g/L Air flow rate (variable 1) 8.6 L/h Penicillin concentration 0 g/L Stirring power (variable 9) 29.9 W Reaction volume (variable 4) 100 L Bottom stream rate (variable 10) 0.0426 L/h CO2 concentration (variable 3) 0.5 g/L Table 3: The kinetic parameters of penicillin fermentation model Parameter Value Unit Parameter Value Unit Inhibition constant, Kp 0 g/L Yield constant of cell to O2, YX/O 0.04 g(biomass)/g(O2) Inhibition constant for product formation, Ki 0.1 g/L Yield constant of product to O2, YP/O 0.2 g(penicillin)/ g(O2) Oxygen limitation constant, KOP 5×10-4 Maintenance coefficient on O2, μO 0.47 1/h Yield constant of bacterial to substrate, YX/S 0.45 g(biomass)/ g(glucose) Constant relating CO2 to growth, α1 0.14 mmole(CO2)/ g(biomass) Yield constant of product to substrate, YP/S 0.9 g(penicillin)/ g(glucose) Constant relating CO2 to maintenance energy, α2 4×10-7 mmole(CO2)/ [g(biomass).h] Maintenance coefficient on substrate, μX 0.01 1/h Constant relating CO2 to penicillin production, α3 10-4 mmole(CO2)/ (L.h) To verify the model accuracy of penicillin fermentation process for fault diagnosis, a dynamic simulation at normal state was performed based on Eqs(1) - (6) with data listed in Tables 2 and 3 to check its coincidence with actual data obtained from PenSim simulator, using fourth-order Runge-Kutta method as the integration algorithm. In this procedure, the model was elaborately calibrated to guarantee the later detected anomaly coming from a fault occurring in the process other than an error of the model. Figure 2 compares simulated data with actual data (obtained from PenSim) using the beginning three variables in Table 1 as examples. Figure 2: Dynamic simulation data comparison with actual data It can be seen from Figure 2 that bacterial fermentation consumes large amounts of O2 at the early reaction stage, leading to a striking decline in dissolved O2 and rise in CO2. Thereafter, all variables gradually stabilise. The unsteady characteristics of these variable curves induce the difficulty of fault diagnosis significantly. As it can be seen from the comparison result of key variables, simulated data and actual data coincide with each other. So the dynamic simulation approach can provide standard sample data for fault diagnosis. 0 100 200 300 400 1.06 1.08 1.10 1.12 1.14 1.16 D is s o lv e d O x y g e n C o n c e n tr a ti o n ( g /L ) Time/h Actual data Simulated data 0 100 200 300 400 8.5 8.6 8.7 8.8 8.9 A e ra ti o n R a te (L /h ) Time/h Autual data simulated data 0 100 200 300 400 0.5 1.0 1.5 2.0 2.5 3.0 C a rb o n D io x id e C o n c e n tr a ti o n ( g /L ) Time/h Autual data Simulated data a b c 304 3.3 Fault diagnosis process and result discussion A series of batch fermentation simulation experiments under normal conditions were executed based on PenSim simulator to give offline normal sample data. Fermentation time and sampling interval were set as 400 h and 0.25 h. So the total number of samples is 1,600. In this process, two typical faults, as shown in Table 4, were introduced independently. Table 4: Fault sample settings in penicillin fermentation Type Fault 1: Agitator power Fault 2: Substrate feed rate Ramp +5 % -5 % Introduction Time, h 150 90 Termination Time, h 400 400 First, DTW method was used to calculate the residual of normal sample data between dynamic simulation and PenSim output with moving window length of 10. Figure 3 shows the residual curve after DTW processing, using the first 3 variables listed in Table 1 as examples. It can be seen that residuals fluctuate within a small range (relative error is less than 20 %), indicating an overall stable trend for normal data. Figure 3: Residual variation after DTW processing Second, PCA model was established based on the residual matrix. The monitoring statistics and their control limits were calculated using the normal sample with a size of 1,600 as well. After DTW treatment, the test sample data including fault signals were input into PCA model to construct T2 and SPE statistics for fault detection. Figure 4 shows the diagnosis result for the stirring power fault. A disturbance was introduced into the system at 150 h (the 600th sample), causing the stirring power increased by 5 %. As it can be seen from Figure 4a, T2 statistic runs smoothly before the 600th sample, with only small-scale fluctuations within threshold. So stirring power in penicillin fermentation process is controllable within the normal range in spite of certain bias. After 700 samples (175 h), T2 gradually increases and exceeds its threshold. SPE in Figure 4b has a similar tendency. In this way, the fault was detected and variable 9 (stirring power) was identified as the root variable from the maximum contribution plot given in Figure 4c. Figure 4: Diagnosis result in case of stirring power fault Figure 5 shows the diagnosis result of bottoms stream fault. Step disturbance is added on the bottoms stream at 90 h with -5 % amplitude. It can be seen from Figure 5b that SPE statistic suddenly increases and quickly exceeds its threshold after the first 400 samples (100 h). Subsequently, T2 statistic exceeds its threshold in 0 100 200 300 400 0.20 0.22 0.24 0.26 0.28 0.30 D is s o lv e d O x y g e n C o n c e n tr a ti o n ( g /L ) Time/h 0 100 200 300 400 -0.1 0.0 0.1 0.2 0.3 A e ra ti o n R a te ( L /h ) Time/h 0 100 200 300 400 0.0 0.1 0.2 0.3 C a rb o n D io x id e C o n c e n tr a ti o n (g /L ) Time/h 0 200 400 600 800 1000 1200 1400 0 100 200 300 400 500 600 700 T 2 Samples 99% control limit T 2 statistics 0 200 400 600 800 1000 1200 1400 0 500 1000 1500 2000 S P E Samples 99% control limit SPE statistics 1 2 3 4 5 6 7 8 9 10 0 20 40 60 80 C o n tr ib u ti o n r a te ,% Variables a b c a b c 305 Figure 5a. The fault was detected and its root cause variable 10 (bottom stream rate) was identified by contribution plot in Figure 5c. Figure 5: Diagnosis result in case of bottoms stream rate fault 4. Conclusions In this study, a dynamic simulation and dynamic time warping based fault diagnosis method for unsteady state startup processes were proposed. The following are the conclusions based on the results. The method has been successfully applied in troubleshooting of penicillin fermentation process. In normal conditions, the relative error of dynamic simulation result processed by DTW from real measurements is lower than 20 %. In abnormal situation of stirring power, the T2 and SPE statistics derived from above relative errors run out of their thresholds after 175 h, 25 h lagging behind the actual fault injection time. At this time point, the ninth variable, that is, stirring power was correctly identified as the variable that mostly contributes to the fault. Similar situation goes for the bottoms stream fault but its lagging time is 10 h. So the case studies prove that this fault diagnosis strategy can well recognise abnormal symptom and effectively identify the root cause variable. However, the method does not consider fault magnitude which plays an important effect on accurate fault diagnosis and is still limited to single fault occasion. This work will take into consideration the quantitative fault diagnosis problem for multiple faults in the future research. Acknowledgements The authors gratefully acknowledge the financial support provided by Shandong Provincial Key Research and Development Program (Grant No. 2018YFJH0802). References Bhagwat A., Srinivasan R., Krishnaswamy P.R., 2003, Fault detection during process transitions: a model-based approach, Chemical Engineering Science, 58, 309-325. Birol G., Ündey C., Çinar A., 2002, A modular simulation package for fed-batch fermentation: penicillin production, Computers & Chemical Engineering, 26, 1553-1565. Cui Z., Tian W.D., Qin H., Wang X., Zhao W.Y., 2018, Optimal design and control of Eastman organic wastewater treatment process, Journal of Cleaner Production, 198, 333-350. Deng X., Tian X., 2013, Nonlinear process fault pattern recognition using statistics kernel PCA similarity factor, Neurocomputing, 121, 298-308. Ge S.J., Wang S.J., Xu Q., Ho T., 2016, Air-quality considered study for multiple olefin plant startups, Industrial & Engineering Chemistry Research, 55, 9698-9710. Ge S.J., Zhang J., Wang S.J., Xu Q., Ho T., 2019, New insight of ozone pollution impact from flare emissions of chemical plant start-up operations, Environmental Pollutions, 245, 873-882. Meddeb Z., Hajjem H., Mabrouk A., Hajjaji N., Hajji N., 2017, Idea, process and analyses of hydrogen production from atmospheric pollutant, International Journal of Hydrogen Energy, 42, 8602-8610. Mei C.L., Ding Y.H., Chen X., Chen Y., Cai J.P., 2018, Soft sensor modelling based on just-in-time learning and bagging-PLS for fermentation processes, Chemical Engineering Transactions, 70, 1435-1440. Srinivasan R., Viswanathan P., Vedam H., Nochur A., 2005, A framework for managing transitions in chemical plants, Computers & Chemical Engineering, 29, 305-322. Sun S.L., Cui Z., Zhang X., Tian W.D., 2020, A hybrid inverse problem approach to model-based fault diagnosis of distillation column, Processes, 8(1), 55. Zhao C., Wang F., Jia M., 2007, Dissimilarity analysis based batch process monitoring using moving windows, AIChE Journal, 53, 1267-1277. 0 200 400 600 800 1000 1200 1400 1600 0 200 400 600 800 1000 T 2 Samples 99% control limit T 2 statistics 0 200 400 600 800 1000 1200 1400 1600 0 50 100 150 200 250 300 350 S P E Samples SPE statistics 99% control limit 1 2 3 4 5 6 7 8 9 10 0 20 40 60 80 C o n tr ib u ti o n r a te ,% Variables a b c 306