hyuancombustion的个人博客分享 http://blog.sciencenet.cn/u/hyuancombustion

博文

How to run CHEMKIN through MATLAB

已有 8790 次阅读 2014-2-19 09:09 |系统分类:科研笔记

CHEMKIN is a powerful software tool for solving complex chemical kinetics problems. Comparing
with other similar software, CHEMKIN-Pro has a much faster calculation speed. The GUI of
CHEMKIN makes it easy for people to use as long as the inputs are simple. However, when
encountering complex and numerous input parameters, or a huge number of cases to be simulated,
or maybe both mentioned above, using GUI would take an annoyingly long time to input every
parameter and make the user fall into repeatedly physical work, which de nitely will generate a
lot of mistakes.

As most commercial software, CHEMKIN can be executed through windows commands with
existed input le made by user. In this case, Windows command and input le act as the
bridge between CHEMKIN and Matlab, since Matlab is capable of executing batch le containing
windows commands. Not just Matlab, other programming languages, such as Python, C, Fortran
and etc. serve as alternatives to achieve the goal using exactly the same principle.
It is quite useful and sometimes necessary to rstly run the simulation in GUI mode, if change
the calculation to "debug" model, CHEMKIN will create the input le and two batch les as well.
The input le includes the settings that user speci ed in the GUI mode, while two batch les are
for pre-process and run-processor, which contains all windows command needed for calculation.
The physical meaning of each command line in the input le can be found in Input.pdf tutorial. If
the user hopes to run everything automatically, it is suggested to create the same input le using
script, which doesn't require the user to manually change parameters for every input le. Taking
the two batch les created by GUI for reference, it is easy to make a user-de ned batch le. An
example batch le containing pre-process, run-processor and post-process will be explained and
discussed thoroughly below.

CALL "C:nProgram FilesnReactionnchemkin15131 win64nbinnrun chemkinpro env setup.bat"

When the CHEMKIN-PRO Interface is run, it uses a combination of registry settings, environment
variables, and batch les to establish its operational environment. Since the environment is
established in this way, all CHEMKIN jobs need to be launched from a DOS window and within
that window the run chemkin env setup.bat le must be called before running the job.
cd C:nChemkin work menunAVL single zonentest matlab
The working directory need to be speci ed at rst. CHEMKIN will take this directory as default,
once the user calls an application, it searched the default directory for the input, unless another
input path is provided.

COPY "C:nChemkin work menunLLNL NOnLLNL NO mech.inp" "C:nChemkin work menun
AVL single zonentest matlab"
COPY "C:nChemkin work menunLLNL NOnLLNL NO thermo.dat" "C:nChemkin work menun
AVL single zonentest matlab"

The pre-process part requires two input les: chemical kinetics input le and thermodynamics
data le. These les need to be copied to working directory before starting pre-process.

CALL "%REACTION DIR%nchemkin15131 win64nbinnchem" -i LLNL NO mech.inp -o test
_matlab.out -d LLNL NO thermo.dat

The pre-process of simulation is realized by calling chem.exe with chemical kinetics input le and
thermodynamics data le as input. The result of pre-process is stored in *.out le. If something is
wrong during the pre-process, the error information can be found in *.out. Flags in the command
line tell pre-processor the types of input and output les.

COPY "C:nUsersnhyuan1nGoogle DrivenMatlabnAVL simulationnE0n1546nE0 1546 median.inp"

CHEMKIN requires the input le in order to know what kind of problem it will solve and how
the problem is de ned. It would be quick and straightforward if the input le is created by script,
especially when input parameters are numerous. If the input le is created manually, please
ignore this command.

COPY "%REACTION DIR%nchemkin15131 win64ndatanchemkindata.dtd"

Copy the CHEMKIN solution template le into the local working directory. Although this tem-
plate le doesn't have any inputs, it is indispensable for run-processor.

SET CHEMKIN MODE=Pro

It is recommended that all calculation should be carried out in CHEMKIN Pro mode as long as
the license is available. CHEMKIN-Pro not only contains more features than normal CHEMKIN,
but also has a extremely fast calculation speed, which is 25 times of normal version.

CKReactorGenericClosed -i E0 1546 median.inp -o chemkin.out

The executables that run particular Reactor Models are found in the CHEMKIN BIN directory.
The naming for the program executables generally contains the pre x CKReactor and then a sux
describing the particular Reactor Model that will be run. The data le ReactorModels.csv lists the
Reactor Models and their associated program names. Since the path of CKReactorGenericClosed
has already been set as an environment variable, CHEMKIN can nd the application directly,
which is the case for the two commands below.

GetSolution

After executing run-processor, CHEMKIN stores result data in a XMLdata.zip le, which is
the input for the powerful post-processor of CHEMKIN. GetSolution converts XMLdata.zip to
a row-based CKSoln.ckcsv le, but this application is limited by 1.5GB memory with a 32-
bit CHEMKIN. It is better to use a 64-bit CHEMKIN-Pro, by setting environment variable
CKJAVAMEMORY=-Xmx4096M, the memory limit of which can be increased to 4GB.

CKSolnTranspose

Since most commonly used data le has a limitation of column number, the row-based CK-
Soln.ckcsv le is not ideal for third-party software to process. CKSolnTranspose converts the
row-based *.ckcsv le to the column-based *.csv le. By default, this application will create
many *csv le, and each one with 100 columns.

All commands above added together form a batch le, which can be executed in Matlab using
command dos('*.bat'). Running CHEMKIN through Matlab accelerates and simpli es the whole
process, and the e ects are more evident for complex simulation with abundant input parameters.



https://wap.sciencenet.cn/blog-1253082-768798.html


下一篇:The blend of gasoline surrogate mechanism and NO mechanism
收藏 IP: 128.250.118.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-14 20:10

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部