Converting chemkin format input file to Cantera

2,286 views
Skip to first unread message

daveKing chavwuko

unread,
Jun 17, 2014, 4:59:15 AM6/17/14
to canter...@googlegroups.com
Hi every one, I am trying to convert a mechanism file in chemkin format to cantera . I copied the ck2cti application (executable) in bin folder to a folder in desktop and also copied my mechanism files to same folder on desktop. In command line, I simply navigate to the folder on my desktop containing ck2cti executable and chemkin input files and then run using the command: ck2cti -i mech -t therm but it writes an error message saying 'error encountered in input file mechanism'. I am not sure if the problem is from my chemkin input files or the command I am using. Please can anyone help on this. The chemkin format input files (mech.txt and therm.txt) are attached. Thanks a lot

Dave
mech.txt
therm.txt

Nick Curtis

unread,
Jun 17, 2014, 10:04:17 AM6/17/14
to canter...@googlegroups.com
  • First of all, the ck2cti.exe is depreciated.  You should be using the Python version instead (ck2cti.py)
  • Second, you have the common "missing E" rates (they show up like the plague).  Search mech.txt for 4.8749+04, and replace with 4.8749E+04
  • Additionally, the mechanism has 'hv' type reactions (i.e. a photon or the like is ejected).  Cantera doesn't support these, so comment them out (you can run a sensitivity analysis to show that they're generally pretty unimportant)
  • Additionally, you need to use the --permissive flag, as the thermo file has multiple entries for a single species
  • Finally, the hcchoh entry in the therm file is missing a "4" to end the last line before the ch2coh entry
The result:
284 species, 1898 reactions, attached as mech.cti

See here for a bunch of other things I've had to do while converting mechanisms

Nick
mech.cti
Message has been deleted

daveKing chavwuko

unread,
Jun 18, 2014, 7:29:05 AM6/18/14
to canter...@googlegroups.com
Hi Nick,

Thanks a lot for the helpful information. I tried to run at command line but species and reactions were not written to file as shown on log below. I also tried the permissive command (which I really don't understand how to use accurately) and an error message was generated as shown in log below. Is there something I am not doing right?

C:\Users\DAVE\Desktop\bin>python ck2cti2.py --input=mech.txt --thermo=thermo.tx
t
Wrote CTI mechanism file to 'mech.cti'.
Mechanism contains 0 species and 0 reactions.


C:\Users\DAVE\Desktop\bin>python ck2cti2.py --input=mech.txt --thermo=thermo.tx
t -- permissive -d
ck2cti.py: Error parsing arguments:
Unexpected command line option: 'permissive -d'
Run "ck2cti.py --help" to see usage help.

Dave

Bryan W. Weber

unread,
Jun 18, 2014, 7:52:52 AM6/18/14
to canter...@googlegroups.com
Hi Dave,

There should be no space between the -- and the permissive, this is why ck2cti tells you there is an error in the second case. Your command should be 

python ck2cti2.py --input=mech.txt --thermo=thermo.txt --permissive -d

Bryan

daveKing chavwuko

unread,
Jun 18, 2014, 8:15:43 AM6/18/14
to canter...@googlegroups.com

Hi Bryan
Thanks for your response. Even with the space removed, it says the command --permissive is not recognised. Did you try the command you suggested if it works on your machine?

Dave

Ray Speth

unread,
Jun 18, 2014, 9:56:23 AM6/18/14
to canter...@googlegroups.com
Dave,

What version of Cantera are you using? The --permissive option was added in Cantera 2.1.

Regards,
Ray

daveKing chavwuko

unread,
Jun 18, 2014, 12:05:37 PM6/18/14
to canter...@googlegroups.com
Hi Ray,
I use Cantera 2.0.2 version. Even when -- permission option is omitted, it writes output file without species and reaction included. Thanks

Regards
Dave

Ray Speth

unread,
Jun 18, 2014, 12:30:00 PM6/18/14
to canter...@googlegroups.com
Dave,

Then you should upgrade to Cantera 2.1.1. There are many improvements to ck2cti in that version.

Regards,
Ray

daveKing chavwuko

unread,
Jun 18, 2014, 12:34:31 PM6/18/14
to canter...@googlegroups.com
Ray,
Okay, I will do that and see how it turns out.
Thanks
Dave

daveKing chavwuko

unread,
Jun 19, 2014, 10:54:59 AM6/19/14
to canter...@googlegroups.com
Hi Ray,

 I just removed my previous cantera-python versions (cantera 2.0.1, python 2.7) and installed the following cantera python packages.

Python 3.3.2 amd64
Numpy MKL 1.71-win-amd64-py3.3
Cantera 2.1.0b3-X64
Cantera-Python 2.1.0b3-x64-py3.3

However I was not able to run any of my previous python scripts(which I run with cantera 2.0.1, python 2.7) as it always pops up a  syntax error message.
But the example scripts in the installed python package in  'C:\Python33\Lib\site-packages\cantera\examples' were able to run. I don't know why this is happening even after setting the environment variables to python33.  Any idea?

Kind regards

Dave

Ray Speth

unread,
Jun 19, 2014, 1:54:33 PM6/19/14
to canter...@googlegroups.com
Dave,

First, I was not suggesting that you change your Python version. Python 3.x has a number of changes that make it backwards incompatible with scripts written for Python 2.x, although the modifications are usually not that difficult. You can consult the Python documentation for a guide on porting to Python 3 (which will be necessary eventually, as Python 2.x is no longer under development).

Second, I suggested installing Cantera 2.1.1, which is the current version. I am not sure why you installed the older beta release of 2.1.0 instead. The Sourceforge download page for Cantera is linked to at the top of this Google Groups page and from the Google Code page for Cantera.

Finally, you should be aware that there are two versions of the Cantera Python module for Cantera 2.1 and Python 2.7. The new module requires some changes to user scripts/programs, which are described here: http://cantera.github.io/docs/sphinx/html/cython/migrating.html. If you don't want to update your scripts right now, you should install the 'legacy' Python module (for Python 2.7 only), but note that future versions of Cantera will only provide the new module syntax.

Regards,
Ray

daveKing chavwuko

unread,
Jun 22, 2014, 6:58:45 PM6/22/14
to canter...@googlegroups.com
Hi Ray,

I was able to get ck2cti.py to run and write .cti mechanism file by following your suggestions. Thanks a lot for the helpful input.

Dave

Roy

unread,
Sep 3, 2014, 12:05:48 AM9/3/14
to canter...@googlegroups.com
Hi all,

Sorry to intrude on this thread. But I am facing the exact same problem converting a h2-air chemkin mechanism file to cantera (.cti) format. Following the discussions on this thread the following is what I have tried:

1. First of all, to let you know I am using Python 2.7 installed using Anaconda package, and Cantera 2.1.1.

2. I have tried with different file formats for the mechanism file - .inp, .dat, .txt (originally .inp). But nothing worked.

3. First, I tried to use the Matlab function ck2cti.m - using 
f = ck2cti('chem.inp', 'therm.dat', 'tran.dat') - didn't work!! Don't know what else is required. 

4. Then opened up command prompt, copied the all files in the "C:\Program Files\Cantera\bin" location and tried 
python ck2cti.py --input=chem.txt --thermo=thermo.txt --transport=transport.txt --permissive -d

I have commented all species information from thermo.dat (or .txt) file that were not there in the mechanism file using notepad++. Here is the error


6. Only thing I could not figure out was how to edit the missing 4th row data in the link provided. How do I fill that out? May be this is the sole reason! The error I am getting in the command prompt is attached as screenshot. Attached the mechanism, thermo and transport file as well. 

Greatly appreciate any help to resolve this!! 

Thanks in advance
Roy
thermo.txt
transport.txt
chem.inp
chem.txt

Bryan W. Weber

unread,
Sep 3, 2014, 8:03:23 AM9/3/14
to canter...@googlegroups.com
Hi Roy,

Several notes:

1) Thank you for listing your Python and Cantera versions.

2) In the future, please copy/paste the error message into your post instead of posting a screenshot.

3) The error message clearly states that the problem is in the transport data. By looking at the transport.txt, you have many lines that do not represent species. You need to comment all of these out or delete them, possibly including the blank lines. You also need to delete all of the text after the END keyword.

4) After you do this, you will find that Cantera complains that it cannot find transport data for species 'N'. This species is not present in the transport file, so you will need to get its transport data from somewhere else. The chem.inp and thermo.txt files seem fine to me, Cantera can generate a cti file when no transport data are included.

Hope it helps,
Bryan

Roy

unread,
Sep 3, 2014, 12:59:39 PM9/3/14
to canter...@googlegroups.com
Hi Brian,

Thanks for pointing the error in the transport file. The conversion worked finally. What I understood earlier reading all resources that the mechanism and thermo data are the only ones needs to be properly edited. Also, I will make sure to provide the error messages while posting about about any future issue.

So, I guess the lesson is for all mechanism conversions (chemkin to cantera) exactly those species need to be there in themo and transport database that are there in the mechanism file (while the transport file is optional). 

Regards,
Roy

Bryan W. Weber

unread,
Sep 3, 2014, 3:02:10 PM9/3/14
to canter...@googlegroups.com
Hi Roy,

Note that Nick's site is only about homogeneous kinetics, i.e. no transport files are necessary for his research (so far!). In the future, I would recommend to carefully read the error message you are actually getting. Cantera is usually pretty good about telling you what is wrong, and it gets better frequently.

>So, I guess the lesson is for all mechanism conversions (chemkin to cantera) exactly those species need to be there in themo and transport database that are there in the mechanism file (while the transport file is optional). 

Agreed, but note that this is also the case when you are processing the mechanism solely in Cantera (i.e. you write your own CTI file) or solely in CHEMKIN (you are processing the CHEMKIN format with CHEMKIN). It is a requirement that each species you specify be completely defined the input.

Bryan
Reply all
Reply to author
Forward
0 new messages