Chemcheck: a Cantera Debugging Tool to Detect Chemical and Syntax
Total Page:16
File Type:pdf, Size:1020Kb
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