Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid chemkin thermo block generated for an adsorbate with 5 elements #1634

Closed
rwest opened this issue Jun 19, 2019 · 4 comments
Closed

Invalid chemkin thermo block generated for an adsorbate with 5 elements #1634

rwest opened this issue Jun 19, 2019 · 4 comments

Comments

@rwest
Copy link
Member

rwest commented Jun 19, 2019

Bug Description

When running a surface chemistry job, this ended up in my chem_annotated-surface.inp chemkin file

! Gas phase thermo from Thermo library: thermo_DFT_CCSDTF12_BAC. Adsorption correction: + Thermo group additivity estimation: adsorptionPt((NRO)*)
! Binding energy corrected by LSR.
SX(8582)                                    G   100.000  5000.000  948.83      1&
X   1H   3C   1O   2N   1
 8.75901373E+00 7.66223340E-03-2.06362528E-06 4.02513189E-10-3.39045287E-14    2
-2.23373310E+04-3.74620293E+01 3.45624020E+00 3.20307213E-04 5.64909893E-05    3
-7.37256390E-08 2.81889462E-11-1.99942728E+04-5.11341806E+00                   4

which then obviously crashed the cantera conversion, leading to the error message

Warning: 
ERROR: Unable to parse '/Users/rwest/Dropbox (CoMoChEng)/Northeastern/Papers/2019-02 RMG-Cat Pt database franklin/rmgcat-pt-supporting-info/RMG_CH4catcombust_Pt_coupled/chemkin/chem-surface.inp' near line 195:

Error: Could not generate Cantera files for some reason.
Traceback (most recent call last):
  File "/Users/rwest/Code/Cat/RMG-Py/rmgpy/rmg/main.py", line 923, in execute
    surfaceFile=(os.path.join(self.outputDirectory, 'chemkin', 'chem-surface.inp')))
  File "/Users/rwest/Code/Cat/RMG-Py/rmgpy/rmg/main.py", line 1407, in generateCanteraFiles
    parser.convertMech(chemkinFile, transportFile=transportFile, outName=outName, quiet=True, permissive=True, **kwargs)
  File "/Users/rwest/anaconda/envs/rmg230/lib/python2.7/site-packages/cantera/ck2cti.py", line 2183, in convertMech
    self.loadChemkinFile(surfaceFile, surface=True)
  File "/Users/rwest/anaconda/envs/rmg230/lib/python2.7/site-packages/cantera/ck2cti.py", line 1736, in loadChemkinFile
    label, thermo, comp, note = self.readThermoEntry(thermo, TintDefault)
  File "/Users/rwest/anaconda/envs/rmg230/lib/python2.7/site-packages/cantera/ck2cti.py", line 1039, in readThermoEntry
    composition[comp[i].capitalize()] = int(comp[i+1])
ValueError: invalid literal for int() with base 10: '1H'

To (hopefully) reproduce it without running the full simulation (which took ~6 hours) the species in question is

SX(8582)
1 O u0 p3 c-1 {3,S}
2 O u0 p2 c0 {3,D}
3 N u0 p0 c+1 {1,S} {2,D} {4,S}
4 C u0 p0 c0 {3,S} {5,S} {6,S} {7,S}
5 H u0 p0 c0 {4,S}
6 H u0 p0 c0 {4,S}
7 H u0 p0 c0 {4,S}
8 X u0 p0 c0

My guess is that this is perhaps the first time we've run across a species with five different elements (X, H, C, O, N) and our chemin-writing code isn't set up to do. (The fifth element count block should go in that gap at the end of line 1, if I recall correctly).

How To Reproduce

I'm guessing here, but try writing a chemkin thermo block for the species mentioned above.

Expected Behavior

It'd make a valid chemkin file.

Installation Information

Describe your installation method and system information.

  • Mac OS X
  • built from source, in an anaconda environment, using the 2.4.0 tagged commits from github
The current git HEAD for RMG-Py is:
	caebd4895dfaee296b6562b28f89e6c350422cca
	Fri Jun 14 18:30:27 2019 -0400
The current git HEAD for RMG-database is:
	08b8214e8b4c869411f498cb50acb76b012520b4
	Fri Jun 14 18:15:05 2019 -0400
@mliu49
Copy link
Contributor

mliu49 commented Jun 19, 2019

I think RMG's behavior may be somewhat correct. We have explicit handling for molecules with more than 4 elements, which (according to the comments) is supported by Chemkin 4 and later.

I confirmed the syntax with the input manual for our current version of Chemkin Pro. The & indicates line continuation and the elements are specified on the following line(s).

I think you are correct that Chemkin II supports a 5th element in the gap between the last temperature and the 1. Perhaps we could update our Chemkin writer to prefer doing that for molecules with 5 elements.

Additionally, new Chemkin also supports additional elements directly after the 1 (i.e. no & or line break). You could test to see if ck2cti can parse that properly.

I do feel like it the ck2cti converter should be able to handle the line continuation form as well though.

@rwest
Copy link
Member Author

rwest commented Jun 19, 2019

OK, thanks Max. I was not familiar with the new Chemkin 4 syntax, and it appears that the version of ck2cti that it was using is not either (I guess this is one that was distributed with RMG, but perhaps I'm in a conda environment made for RMG 2.3.0).

I suggest

  • for 5 elements, use the Chemkin2 syntax (as long as it is also supported by Chemkin 4+ and Cantera)
  • for 6 or more elements, use the current (Chemkin4+) syntax.
  • ensure that the ck2cti version required by or distributed with RMG can read the Chemkin4+ syntax
  • ensure that Cantera's ck2cti converter can read the Chemkin4+ syntax (send a pull request if needed, including a unit test)

?

Anyway, at the end of the day, RMG shouldn't crash converting its own files.

@mliu49
Copy link
Contributor

mliu49 commented Jun 19, 2019

I looked into it some more, and it turns out that we are actually writing it wrong. 😓

The new line syntax is not column based and should be whitespace delimited instead:

X 1 H 3 C 1 O 2 N 1

instead of

X   1H   3C   1O   2N   1

So we should definitely fix that.

While I was digging around, I found out that the ct2cti script originated as a port of RMG's Chemkin module. 😄

@mliu49
Copy link
Contributor

mliu49 commented Dec 4, 2019

Fixed by #1636.

@rwest rwest closed this as completed Dec 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants