CHEMCHECK – A CANTERA DEBUGGING TOOL TO DETECT CHEMICAL AND SYNTAX ERRORS IN KINETIC MODELS
A Thesis Presented by
Chao Xu
to
The Department of Chemical Engineering
in partial fulfillment of the requirements for the degree of
Master of Science
in the field of
Chemical Engineering
Northeastern University Boston, Massachusetts
August 2020 ACKNOWLEDGMENTS
I would thank to my advisor, Dr. Richard West; this thesis work would never have been accomplished without his patient guidance and instructions. His support during my thesis helps me keep making progress and developing my research skills. The way he has tutored me is very flexible and efficient, and it encourages me to explore more knowledge fields. I would like to express my gratitude to the other members on my thesis committee, Dr. Bryan Weber and Dr. Benjamin Woolston, thanks for their time on reviewing my thesis. Especially Dr. Bryan Weber, who gave me excellent instructions and help at the beginning of this project in Google Summer of Code (GSOC) 2019. I would like to thank the Cantera steering committee for giving me a lot of insightful suggestions and answering my questions about Cantera. Thanks to the members in our lab, Nate, Krishna, Emily, David, Chris, Shenghui, and Zil for all the supportive conversation and intelligent advice. Thanks to my parents for supporting me on every decision in my life. Their support gives me the confidence to overcome any challenge in my life.
ii TABLE OF CONTENTS
ACKNOWLEDGMENTS ii
ABSTRACT vi
1 Introduction 1 1.1 Thesis Overview ...... 1 1.1.1 Thesis Introduction ...... 1 1.1.2 Thesis Objectives ...... 2 1.2 Detailed Kinetic Models (DKM) Application ...... 3 1.3 Overview of CHEMKIN Format ...... 5 1.3.1 NASA Polynomials ...... 7 1.3.2 Reaction Types ...... 7 1.4 Django For Web Development ...... 11 1.5 Cantera Application in Combustion Modeling ...... 13 1.6 Collision Violation For Bimolecular Reactions ...... 14
2 Methodology Design 18 2.1 Building Create, Retrieve, Update, Delete (CRUD) Operations ...... 18 2.2 Applying Syntax Check and Automatic Conversion ...... 20 2.3 Thermodynamic Discontinuity Check ...... 23 2.4 Collision Limit Violation Check ...... 25 2.5 Invalid Duplicate and Pressure Dependent Reactions Check ...... 27 2.6 CVODE Error Message Improvement ...... 32
3 Results And Discussion 35
4 Conclusions And Future Work 39
REFERENCES 41
iii LIST OF FIGURES
1.1 Experimental ignition delay times from Somers et al. [39] for 0.75 percent 2,5- dimethylfuran in argon at 1 atm pressure with 20 percent uncertainty bars...... 4 1.2 Catalytic reforming system ...... 5 1.3 Example CHEMKIN file ...... 6 1.4 Model View Controller (MVC) pattern ...... 12 1.5 Django web code structure ...... 13
2.1 User data structure ...... 19 2.2 File data structure in ChemCheck ...... 19 2.3 Design diagram of ChemCheck ...... 20 2.4 Web interface from where a reaction with mismatched reaction rate parameters was detected by ChemCheck ...... 22 2.5 Plots of thermodynamic properties of CO2 ...... 24 2.6 Web interface of thermal discontinuity check for Konnov’s detailed mechanism ver- sion 0.6 ...... 25 2.7 Web interface of collision violation check ...... 27 2.8 Logarithmic plot of reaction rate coefficients in a natural gas mechanism [26] . . . 28 2.9 Filtered logarithmic plot of reaction rate coefficients in a natural gas mechanism [26] 29 2.10 ChemCheck PLOG reaction validation page [23] ...... 31
3.1 Result of PLOG reaction check from work of Hashemi et al. [16] ...... 37
iv LIST OF TABLES
3.1 Syntax error found in published models...... 36 3.2 List of reactions and corresponding temperature ranges in which CLC violations were identified for AramcoMech 1.3 [31]. Reactions were only screened at temper- atures between 300 and 2000 K [45] ...... 38 3.3 List of reactions and corresponding temperature ranges in which ChemCheck vio- lations were identified for AramcoMech 1.3 [31]. Reactions were only screened at temperatures between 300 and 2000 K ...... 38
v ABSTRACT
ChemCheck – A Cantera Debugging Tool to Detect Chemical and Syntax Errors in Kinetic Models
by Chao Xu Master of Science in Chemical Engineering Northeastern University, August 2020 Dr. Richard H. West, Adviser
This thesis presents a new, open-source, software tool — ChemCheck — to help visual- ize, diagnose, and correct the errors often found in the CHEMKIN and Cantera input files used to describe detailed kinetic models when modeling combustion chemistry. Detailed kinetic models are widely used in combustion modeling. Since a detailed kinetic model could consist of hundreds of species and thousands of reactions, the models are described in a machine-readable format that can be loaded by simulation software. Most of the software for reaction modeling either uses a CHEMKIN file (invented for the CHEMKIN software package) or gathers the information from a CHEMKIN-compatible file and generates their own input file. However, CHEMKIN files can come from various sources, so multiple errors can exist in these files leading to a failure of input file conversion or an unsuccessful or incorrect computation. Debugging the errors in a CHEMKIN file is tricky and time-consuming in certain situations, so a debugging tool to help detect problems can save unnecessary efforts on resolving the bugs, and allow researchers to focus on the computation and the science. Many distributed CHEMKIN files have syntax errors and bugs that prevent them from be- ing interpreted by other software. More contain typos and mistakes that can alter the chemical mean- ing. More still contain parameters describing chemistry that is infeasible or non-physical. Chem- Check is a web application powered by the Django framework and Cantera, an open-source software to model kinetic, transport, and thermodynamic processes. It allows users to upload CHEMKIN files and generate a new Cantera input file in YAML format. Syntax errors that prevent conversion are diagnosed by ChemCheck with diagnostic messages to help fix common mistakes, such as missing digits from the end of a line, missing exponential signs, and missing comment signs. After conver- sion, ChemCheck looks for several physical and chemical errors. ChemCheck detects species with discontinuous NASA polynomial data and plots figures to help users visualize the discontinuity. Bimolecular reactions exceeding the collision limit (usually in the reverse direction) are detected and rendered in a list. Another error which can be detected is reaction rate expressions which lead to an overall negative reaction rate coefficient. Determining the chemical reasons behind failures of the ODE solver (eg. CVODES) is always an obstacle for debugging kinetic models in Cantera, so another goal of ChemCheck is to interpret the ODE solver error messages and provide suggestions to change the chemistry, usually reducing stiffness. ChemCheck has successfully detected syntax and chemical errors in many models during the development process, with more test files being collected and applied to evaluate and develop the software.
vii Chapter 1
Introduction
1.1 Thesis Overview
1.1.1 Thesis Introduction
Detailed kinetic modeling is a way to model the reaction mechanisms taking place during a chemical process by describing all the essential elementary reactions, with thermodynamic data for all the intermediate species. It is a widespread technique used in different engineering fields which include complex chemical processes with a large number of intermediates, for example, combustion simulation [44], battery simulation [10], and design of molecular catalysts [18]. The simulation results for the chemical kinetics, transport, and thermodynamic processes highly depend on the quality of detailed kinetic models. The data of a detailed kinetic model is typically arranged in CHEMKIN format [22] which is composed of data to describe the reaction mechanism in detail, so obtaining an accurate CHEMKIN file is a prerequisite of a successful simulation. CHEMKIN files can be acquired from computational software, manually building from scratch, and published papers, etc., so the quality of the data varies. It is not rare that some CHEMKIN files have syntax error or bugs that prevent them from being interpreted by other simulation software. To help detect, visualize, and correct the bugs, a debugging tool named ChemCheck was developed for Cantera, and the code is hosted on Github https://github.com/comocheng/ ChemCheck. Since Cantera converts CHEMKIN files to the YAML format as the input file, the CHEMKIN file should have strict compliance with the required format to ensure a successful con- version. The syntax errors can lead to a failure of conversion or an input file with misinterpreted data which causes a system crash in the later computation. However, CHEMKIN files without syntax
1 CHAPTER 1. INTRODUCTION errors could cause problems during computation as well. An additional problem that could cause problems during a simulation is parameters that contradict the fundamental principles of physics. One advantage of ChemCheck is that it can help users to find some of these syntax errors and data without chemical or physical sense to save the efforts and time on debugging work. Another ben- efit of ChemCheck is that it provides users a graphical user interface (GUI) to make a better user experience, especially for users without coding experience.
1.1.2 Thesis Objectives
Since this thesis work is designed for Cantera to provide a GUI to help users detect, visualize, and correct bugs and errors in CHEMKIN files to avoid input file conversion failure and computation crashes, the following objectives are met:
Build a web framework based on Django with Create, Read, Update, Delete (CRUD) features • to achieve human-machine interaction
Apply a CHEMKIN syntax check, based on the current syntax check feature of Cantera. The • new syntax check feature includes:
– Redundant or unrecognized sign
– Missing magnitude sign “E” for Arrhenius pre-exponential parameters
– Missing index at the end of lines of a thermal entry of a species
– Index alignment of a thermal entry of a species
– The reaction expression does not match to rate parameters so Cantera cannot distinguish the reaction type, such as a falloff reaction with a set of PLOG reaction rate parameters
– Species with extended elemental numbers
Automatically generate interactive plots about the thermal properties of species with thermal • discontinuities
Check for all invalid Arrhenius parameters for pressure dependent reactions and duplicate • reactions
Automatically generate interactive plots of kinetic rate constants for all reactions • Detect the reactions violating collision limits •
2 CHAPTER 1. INTRODUCTION
Generate more helpful error messages for the ODE solver in Cantera • The scientific value of this work is to propose possible reasons causing stiffness of ODE system during numerical simulation and to help improve the detailed kinetic model to avoid the integration failure, by diagnosing the errors in CHEMKIN files.
1.2 Detailed Kinetic Models (DKM) Application
As we introduced in Chapter 1.1.1, this thesis is aimed to provide a convenient interface for CHEMKIN file debugging. To illustrate the importance of this work, an introduction to the application of detailed kinetic models is necessary. Detailed kinetic models (DKMs) are used in simulations in different engineering fields, and it is critical to these industries to generate accu- rate computational results, especially in processes involved in complex chemistry such as catalytic reforming, pyrolysis, and combustion. The paper authored by Keran P. Somers et al. [39] is chosen to discuss because they show detailed procedures about how to build and validate a DKM for 2,5-dimethylfuran (25DMF) py- rolysis and oxidation in their paper. The mechanism is interpreted by CHEMKIN-Pro [35]. The unimolecular decomposition, fuel radical reactions, unimolecular and bimolecular consumption re- actions of 5-methyl-2-furanylmethyl radical, and sub mechanisms of furan derivatives are discussed in the paper and included in their model. The thermodynamic data and transport data in the model is directly taken from other published studies about 25DMF. They introduced several characteristics such as pyrolysis behavior (thermal decomposition), ignition delay times (IDT), oxidation behavior, and laminar burning velocities of 25DMF measured by experiments to validate their model. The computational results based on their detailed kinetic model show good compliance with the experi- mental data in their paper. Figure 1.1 shows the comparison of IDT calculated by the model made by Somers et al. [39] and the experimental data measured by Sirjean et al. [38], and it is clearly illustrated that the experimental data is reproduced well under all conditions. It also accurately sim- ulates that the IDT decreases with increased temperature and oxygen concentration. As well as the low pressure ignition delay times comparison, they plotted the shock tube decomposition profile, jet-stirred reactor profile, and laminar burning velocity profile, against the experimental data to val- idate the model from different aspects. Because of the good agreement with the measured data in other literature, the model can be used in prediction of other characteristics of 25DMF. The research conducted by Somers et al. [39] is a classic research process in combustion modeling, and it shows
3 CHAPTER 1. INTRODUCTION that the simulation results of a kinetic model play a critical role in combustion model validation and improvement.
Figure 1.1: Experimental ignition delay times from Somers et al. [39] for 0.75 percent 2,5- dimethylfuran in argon at 1 atm pressure with 20 percent uncertainty bars. Lines are modelling calculations from Somers et al. [39] (—) and Sirjean et al. (– –) [38]
Wei et al. in 2008 [43] published a DKM for catalytic reforming. In their research, they simulate the naphatha (C12) catalytic reforming process and compare with the literature data to validate their DKM, generated by computational software which automatically builds large DKM. The data for calibration is gained from reforming plants, and they use their model to simulate the unit reforming operations which are the same as those used within reforming plants. The reforming process happens in several adiabatic serial plug flow reactors (PFR) as shown in Figure 1.2. In the modeling, reaction families, energy balances on the whole reforming system, catalytic deactivation, and coke deposition are considered to construct and trim the model. The final DKM consists of 546 reactions and 116 species, and shows great compliance with the literature data in light ends yield, total aromatic yield, C5 yield, and paraffin yield. Therefore, the model is reliable to simulate the experimental data under the tested conditions, and it is able to be applied in industrial process to predict the product quality and system operation cost. Besides, other properties in catalytic reforming process such as mixture properties, optimal operation conditions leading to desirable
4 CHAPTER 1. INTRODUCTION
Figure 1.2: Catalytic reforming system [43] production etc., can be calculated based on this model. Other optimizations and their simulated results can be accessed instantly, which is very convenient for process development. This example also demonstrates the value of detailed kinetic modeling.
1.3 Overview of CHEMKIN Format
R.J. Kee et al. proposed a CHEMKIN data format in 1989 [22] to describe gas-phase detailed kinetic models. The CHEMKIN [22] format is based on the NASA file format published in 1971 [29], which includes element data, species data, species’ thermodynamic data, reaction data, and a set of transport data. The element data contains all the involved elements including isotopes in the model. Similarly, species data block consists of all the related species in the DKM. Thermodynamic data can be a data block in the mechanism file or a standalone file which consists of the parameters to apply in NASA polynomial parameterization for species’ thermal property calculations. Transport data of a kinetic model includes Lennard-Jones potential well depth [33], collision diameter, dipole moment, polarizability, and rotational relaxation collision number, which can be used to derive viscosity, thermal conductivity, and diffusion coefficients; it is only required for computations involving transport process such as flame simulations or gas-solid interactions. An example CHEMKIN file is shown in Figure 1.3. This file is only for illustration purpose, and it does
5 CHAPTER 1. INTRODUCTION
Figure 1.3: Example CHEMKIN file
6 CHAPTER 1. INTRODUCTION not necessarily make any physical sense. In this model, the elements involved in the model are C and H, and there are four species in the model which are written in ”SPECIES” block. Then the thermal data block describes the suitable temperature range for the model at the beginning following with thermodynamic data for each species mentioned in ”SPECIES” block. In the ”REACTIONS” block, reactions incorporate species in previous data block are described with Arrhenius parameters of every species.
1.3.1 NASA Polynomials
McBride et al. in 1993 [30] reported thermodynamic data for a total of 1130 species in the gas phase, liquid phase, and solid phase, and transport data for 155 gaseous species. In that paper, thermodynamic coefficients for each species are provided in the CHEMKIN or NASA polynomial form. These coefficients are used to calculate the thermodynamic properties of a species including heat capacity (Cp) for one mole of species at constant pressure, enthalpy (H), and entropy (S), versus temperature (T ). This data format is well accepted by other computational software such as the CHEMKIN package, Cantera [15] etc. NASA polynomial equations are shown below:
Cp = a + a T + a T 2 + a T 3 + a T 4 (1.1) R 1 2 3 4 5 H a a a a a = a + 2 T + 3 T 2 + 4 T 3 + 5 T 4 + 6 (1.2) RT 1 2 3 4 5 T S a a a = a log T + a T + 3 T 2 + 4 T 3 + 5 T 4 + a (1.3) R 1 2 2 3 4 7
As shown in Figure 1.3, the “THERMO” block has 14 coefficients for species CH3 because the NASA polynomial equations are usually fit in two intervals of temperature, with a typical break- point at 1000K. The first seven coefficients are for the high temperature interval, and the last seven coefficients in the “THERMO” block are for the low temperature range.
1.3.2 Reaction Types
There are various types of reactions that could be written into a CHEMKIN file, and the reaction rate coefficient calculations should be treated differently. The fundamental theory of reaction ration coefficient modeling is the modified Arrhenius equation:
b Ea k = AT e RT (1.4)
7 CHAPTER 1. INTRODUCTION where k is the forward reaction rate coefficient, T is the absolute temperature, A is the temperature- independent pre-exponential factor, Ea is the activation energy, R is the gas constant, and b is a temperature exponent. Activation energy (Ea), temperature exponent (b), and pre-exponential factor (A) are specified in CHEMKIN files, so computational software takes temperature as input to calculate forward rate constant for reactions. However, reactions should be treated differently based on different reaction types when reaction rate constants are calculated. Because the Arrhenius parameters are only given for the forward rate constant calculation, the reverse rate constant is calculated from
kreverse = kforward/Kequil (1.5)
where kforward is the forward rate coefficient, kreverse is the reverse rate coefficient, and Kequil is the equilibrium constant which is calculated from