ck2yaml_demo.ipynb (Source)

Conversion of CHEMKIN Data

This notebook illustrates the conversion of CHEMKIN input files to Cantera YAML input files. The conversion utility ck2yaml is run as a shell command (using the exclamation mark ! magic shortcut).

The YAML files produced with this notebook are close re-recreations of input files that are already included with Cantera; _demo is added to differentiate from the original YAML files:

GRI-Mech 3.0 derived:

  • gri30_demo.yaml
  • h2o2_demo.yaml
  • air_demo.yaml
  • argon_demo.yaml

NASA derived:

  • airNASA9_demo.yaml
  • nasa_demo.yaml

All CHEMKIN input files are stored in the chemkin subfolder; the --extra flag is used to update file descriptions to match YAML files from Cantera 2.5.

Requires: cantera >= 2.5.0

In [1]:
# display ck2yaml help text
! ck2yaml --help
ck2yaml.py: Convert Chemkin-format mechanisms to Cantera YAML input files

Usage:
    ck2yaml [--input=<filename>]
            [--thermo=<filename>]
            [--transport=<filename>]
            [--surface=<filename>]
            [--name=<name>]
            [--extra=<filename>]
            [--output=<filename>]
            [--permissive]
            [--quiet]
            [--no-validate]
            [-d | --debug]

Example:
    ck2yaml --input=chem.inp --thermo=therm.dat --transport=tran.dat

If the output file name is not given, an output file with the same name as the
input file, with the extension changed to '.yaml'.

An input file containing only species definitions (which can be referenced from
phase definitions in other input files) can be created by specifying only a
thermo file.

For the case of a surface mechanism, the gas phase input file should be
specified as 'input' and the surface phase input file should be specified as
'surface'.

The '--permissive' option allows certain recoverable parsing errors (e.g.
duplicate transport data) to be ignored. The '--name=<name>' option
is used to override default phase names (i.e. 'gas').

The '--extra=<filename>' option takes a YAML file as input. This option can be
used to add to the file description, or to define custom fields that are
included in the YAML output.

1. YAML files based on GRI-Mech 3.0

1.1 Input file gri30.yaml

In [2]:
! ck2yaml --input=chemkin/gri30.inp --thermo=chemkin/gri30_thermo.dat --transport=chemkin/gri30_tran.dat \
--extra=chemkin/gri30_extra.yaml --output=gri30_demo.yaml --name=gri30
Wrote YAML mechanism file to 'gri30_demo.yaml'.
Mechanism contains 53 species and 325 reactions.
Validating mechanism...
PASSED

1.2 Input file h2o2.yaml

In [3]:
# options for h2o2.yaml
! ck2yaml --input=chemkin/h2o2.inp --transport=chemkin/gri30_tran.dat \
--extra=chemkin/h2o2_extra.yaml --output=h2o2_demo.yaml --name=ohmech
Wrote YAML mechanism file to 'h2o2_demo.yaml'.
Mechanism contains 9 species and 28 reactions.
Validating mechanism...
PASSED

1.3 Input file air.yaml

Notes: The --quiet option suppresses warnings about unexpected/unused species in thermo data.

In [4]:
# options for air.yaml
! ck2yaml --input=chemkin/air.inp --thermo=chemkin/gri30_thermo.dat --transport=chemkin/gri30_tran.dat \
--extra=chemkin/air_extra.yaml --output=air_demo.yaml --name=air --quiet

1.4 Input file argon.yaml

Notes: The --quiet option suppresses warnings about unexpected/unused species in thermo data.

In [5]:
# options for argon.yaml
! ck2yaml --input=chemkin/argon.inp --thermo=chemkin/gri30_thermo.dat --transport=chemkin/gri30_tran.dat \
--extra=chemkin/argon_extra.yaml --output=argon_demo.yaml --quiet

2. YAML files based on NASA Thermodynamic databases

2.1 Input file nasa.yaml

In [6]:
# options for nasa.yaml (the --permissive suppresses an error due to duplicate thermo entries)
! ck2yaml --thermo=chemkin/nasathermo.dat --output=nasa_demo.yaml --permissive
Found additional thermo entry for species (HCOOH)2. If --permissive was given, the first entry is used.
Found additional thermo entry for species Br2(L). If --permissive was given, the first entry is used.
Found additional thermo entry for species Cr(cr). If --permissive was given, the first entry is used.
Found additional thermo entry for species Fe(a). If --permissive was given, the first entry is used.
Found additional thermo entry for species Ni(cr). If --permissive was given, the first entry is used.
Found additional thermo entry for species ZnSO4(a). If --permissive was given, the first entry is used.
Wrote YAML mechanism file to 'nasa_demo.yaml'.
Mechanism contains 1130 species and 0 reactions.

2.2 Input file airNASA9.yaml

In [7]:
# options for airNASA9.yaml
! ck2yaml --input=chemkin/airNASA9.inp --thermo=chemkin/airDataNASA9.dat --output=airNASA9_demo.yaml --name=airNASA9
Wrote YAML mechanism file to 'airNASA9_demo.yaml'.
Mechanism contains 11 species and 0 reactions.
Validating mechanism...
PASSED