File conversion from CHEMKIN to YAML

518 views
Skip to first unread message

ste....@gmail.com

unread,
Jul 3, 2022, 1:03:34 PM7/3/22
to Cantera Users' Group
Dear all,

I am trying to convert the attached kinetic mechanism into YAML format, but I get the following error:

Traceback (most recent call last):
  File "/usr/local/bin/ck2yaml", line 8, in <module>
    sys.exit(script_entry_point())
  File "/usr/local/lib/python3.8/dist-packages/cantera/ck2yaml.py", line 2264, in script_entry_point
    main(sys.argv[1:])
  File "/usr/local/lib/python3.8/dist-packages/cantera/ck2yaml.py", line 2228, in main
    parser, surfaces = Parser.convert_mech(input_file, thermo_file,
  File "/usr/local/lib/python3.8/dist-packages/cantera/ck2yaml.py", line 2129, in convert_mech
    surface_names = parser.write_yaml(name=phase_name, out_name=out_name)
  File "/usr/local/lib/python3.8/dist-packages/cantera/ck2yaml.py", line 2027, in write_yaml
    emitter.dump(speciesMap, dest)
  File "/usr/lib/python3/dist-packages/ruamel/yaml/main.py", line 439, in dump
    return self.dump_all([data], stream, _kw, transform=transform)
  File "/usr/lib/python3/dist-packages/ruamel/yaml/main.py", line 453, in dump_all
    self._context_manager.dump(data)
  File "/usr/lib/python3/dist-packages/ruamel/yaml/main.py", line 801, in dump
    self._yaml.representer.represent(data)
  File "/usr/lib/python3/dist-packages/ruamel/yaml/representer.py", line 84, in represent
    node = self.represent_data(data)
  File "/usr/lib/python3/dist-packages/ruamel/yaml/representer.py", line 111, in represent_data
    node = self.yaml_representers[data_types[0]](self, data)
  File "/usr/lib/python3/dist-packages/ruamel/yaml/representer.py", line 1172, in represent_dict
    return self.represent_mapping(tag, data)
  File "/usr/lib/python3/dist-packages/ruamel/yaml/representer.py", line 1017, in represent_mapping
    node_value = self.represent_data(item_value)
  File "/usr/lib/python3/dist-packages/ruamel/yaml/representer.py", line 111, in represent_data
    node = self.yaml_representers[data_types[0]](self, data)
  File "/usr/lib/python3/dist-packages/ruamel/yaml/representer.py", line 349, in represent_list
    return self.represent_sequence(u'tag:yaml.org,2002:seq', data)
  File "/usr/lib/python3/dist-packages/ruamel/yaml/representer.py", line 933, in represent_sequence
    node_item = self.represent_data(item)
  File "/usr/lib/python3/dist-packages/ruamel/yaml/representer.py", line 111, in represent_data
    node = self.yaml_representers[data_types[0]](self, data)
  File "/usr/local/lib/python3.8/dist-packages/cantera/ck2yaml.py", line 196, in to_yaml
    ('composition', FlowMap(node.composition.items()))])
AttributeError: 'NoneType' object has no attribute 'items'

Could you help me understand which is the problem of my mechanism?

Bests

Stefano
surface.sur
thermo.tdc
kinetic.kin
transport.tra

Tomm

unread,
Oct 10, 2023, 6:25:15 AM10/10/23
to Cantera Users' Group

Hei, 

did you manage to solve this issue?
I'm trying to convert another mechanism and get the same error message.

Best,

Thomas
Apari_NH3_Ni_2011_CHEMKIN.txt
thermo_combined.dat
SanDiego_trans.dat
SanDiego_NH3-H2.inp

Tomm

unread,
Oct 10, 2023, 8:00:13 AM10/10/23
to Cantera Users' Group
I managed to get a bit further on this issue.
Modifying the start of the surface reaction mechanism file to:

SITE/NI_SURFACE/    SDEN/2.6E-9/
ELEMENTS
NI
END
SPECIES
NI(s) H2O(s) H(s) OH(s) O(s) NH3(s) N(s) NH2(s) NH(s)  
END
REACTIONS

makes the initial error message go away.
Running:
ck2yaml --input=SanDiego_NH3-H2.inp --thermo thermo_combined.dat --transport=SanDiego_trans.dat --surface=Apari_NH3_Ni_2011_CHEMKIN.txt --permissive --name=SDNH3_Surf_Apari.yaml --debug 

gives now following error message:

Traceback (most recent call last):
  File "C:\Users\thomasi\AppData\Local\anaconda3\envs\cantera-eng\Scripts\ck2yaml-script.py", line 10, in <module>
    sys.exit(script_entry_point())
             ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\thomasi\AppData\Local\anaconda3\envs\cantera-eng\Lib\site-packages\cantera\ck2yaml.py", line 2277, in script_entry_point
    main(sys.argv[1:])
  File "C:\Users\thomasi\AppData\Local\anaconda3\envs\cantera-eng\Lib\site-packages\cantera\ck2yaml.py", line 2241, in main

    parser, surfaces = Parser.convert_mech(input_file, thermo_file,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\thomasi\AppData\Local\anaconda3\envs\cantera-eng\Lib\site-packages\cantera\ck2yaml.py", line 2141, in convert_mech
    surface_names = parser.write_yaml(name=phase_name, out_name=out_name)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\thomasi\AppData\Local\anaconda3\envs\cantera-eng\Lib\site-packages\cantera\ck2yaml.py", line 2032, in write_yaml
    raise InputError('No thermo data found for '
cantera.ck2yaml.InputError: No thermo data found for species 'NI(s)'
Please check https://cantera.org/tutorials/ck2yaml-tutorial.html#debugging-common-errors-in-ck-files
for the correct Chemkin syntax.


This is quite weird because there is an entry for NI(s) in the thermo file. 

Does someone have an idea to solve this issue?

Archanaa Raghavan

unread,
Oct 10, 2023, 1:19:23 PM10/10/23
to Cantera Users' Group
Hi tomm 
As you mentioned the entry is given for species NI(s) in thermo file. however, if you check the transport data file, NI(s) is missing. this may be the reason for the error


regards
Archanaa

Tomm

unread,
Oct 11, 2023, 2:00:10 AM10/11/23
to Cantera Users' Group
Dear Archanaa,

thank you for your response.

I think it is actually possible to convert mechanisms without the transport file. From Cantera.org:
...and the user wishes to use a part of Cantera that relies on some transport properties,  --transport option must be used to specify the file containing all the transport data for the species.
However, the surface reaction part will not rely on transport properties. Please correct my if I'm wrong.

I actually tried to convert the mechanism by simply removing the --transport option and it gave me the same error. 
If I simply only restrict myself to the input and thermo option, the mechanism is converted. So the error lies somewhere in the surface mechanism part and/or the thermo file.

Ray Speth

unread,
Oct 20, 2023, 10:45:43 PM10/20/23
to Cantera Users' Group
Hi Stefano,

Thanks for reporting this error. It appears that ck2yaml doesn't currently handle the case where thermo data for surface phases are provided in a separate file. I've opened a PR with a fix that should resolve this problem (https://github.com/Cantera/cantera/pull/1637).

If you download the copy of ck2yaml.py from that PR, it should successfully convert your mechanism. Alternatively, you can move the surface species thermo data to a "THERMO ALL" section in the "surface.sur" input file.

Regards,
Ray
Reply all
Reply to author
Forward
0 new messages