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

Species names with a colon (:) can cause problems in parseCompString #525

Closed
rwest opened this issue Apr 11, 2018 · 1 comment
Closed

Species names with a colon (:) can cause problems in parseCompString #525

rwest opened this issue Apr 11, 2018 · 1 comment

Comments

@rwest
Copy link
Member

rwest commented Apr 11, 2018

Cantera version

2.3.0 (via Anaconda)

Operating System

MacOS X
Darwin-16.7.0-x86_64-i386-64bit

Python version

2.7.11 |Anaconda custom (x86_64)| (default, Dec 6 2015, 18:57:58)
[GCC 4.2.1 (Apple Inc. build 5577)]

Preamble

In [1]: import cantera as ct

In [2]: ct.__version__
Out[2]: '2.3.0'

Expected Behavior

In [3]: ct.Solution('cantera-working.cti')
< some warnings and then...>
Out[3]: <cantera.composite.Solution at 0x109ffbb90>

Actual Behavior

In [4]: ct.Solution('cantera-broken.cti')
< some warnings and then...>
---------------------------------------------------------------------------
CanteraError                              Traceback (most recent call last)
<ipython-input-12-556309c8f232> in <module>()
----> 1 ct.Solution('cantera-broken.cti')

interfaces/cython/cantera/base.pyx in cantera._cantera._SolutionBase.__cinit__ (interfaces/cython/cantera/_cantera.cpp:7873)()

interfaces/cython/cantera/base.pyx in cantera._cantera._SolutionBase._init_cti_xml (interfaces/cython/cantera/_cantera.cpp:8556)()

CanteraError: 
***********************************************************************
CanteraError thrown by parseCompString:
Duplicate key: 'CF2'.
***********************************************************************

The difference between the two .cti files is that the -broken.cti one contains some species with : in their names, such as CH2:CHF and CH2:CF2, generated using ck2cti on the attached chemkin files, and the working one had all the : replaced with # in the chemkin files (also attached) before they were converted to the -working.cti file.

I think the offending line is
https://github.com/Cantera/cantera/blob/master/src/base/stringUtils.cpp#L85
but I wasn't able to figure out on what occasion it was being called to cause this problem.

My guess, from just staring at the code, is that the checks and work-arounds for colons occurring around line 91 of that file (stringUtils.cpp) should happen before the duplicate key check on line 83, which is currently using the uncorrected name that is only what appears before the first colon.
But I can't easily test my theory, so am just reporting it here.

The chemkin and cantera input files are in this Archive.zip

@rwest rwest changed the title Species names with a colon (:) can cause problems. Species names with a colon (:) can cause problems in parseCompString Apr 11, 2018
@speth speth closed this as completed in d091617 Apr 14, 2018
@speth
Copy link
Member

speth commented Apr 14, 2018

Thanks, Richard. Your diagnosis was exactly correct.

srikanthallu pushed a commit to srikanthallu/cantera that referenced this issue Sep 17, 2020
The check was being done at a stage where the token being checked could be just
a part of a key (if the key contained a colon), where this partial key could
correspond to another valid key.

Fixes Cantera#525
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants