Skip to content

Commit

Permalink
Update for modern Cantera
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanwweber committed Feb 20, 2022
1 parent 8cefc20 commit 17d6117
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 73 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.vscode/
*.nbconvert.ipynb
reactors/reaction_paths.*
input/*.yaml
130 changes: 57 additions & 73 deletions input/ck2yaml_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"\n",
"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). \n",
"\n",
"The YAML files produced with this notebook are close re-recreations of Cantera input files; `_demo` is added to differentiate from the original YAML files:\n",
"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:\n",
"\n",
"**GRI-Mech 3.0 derived:**\n",
" * `gri30_demo.yaml`\n",
Expand All @@ -34,44 +34,44 @@
"name": "stdout",
"output_type": "stream",
"text": [
"\r\n",
"ck2yaml.py: Convert Chemkin-format mechanisms to Cantera YAML input files\r\n",
"\r\n",
"Usage:\r\n",
" ck2yaml [--input=<filename>]\r\n",
" [--thermo=<filename>]\r\n",
" [--transport=<filename>]\r\n",
" [--surface=<filename>]\r\n",
" [--name=<name>]\r\n",
" [--extra=<filename>]\r\n",
" [--output=<filename>]\r\n",
" [--permissive]\r\n",
" [--quiet]\r\n",
" [--no-validate]\r\n",
" [-d | --debug]\r\n",
"\r\n",
"Example:\r\n",
" ck2yaml --input=chem.inp --thermo=therm.dat --transport=tran.dat\r\n",
"\r\n",
"If the output file name is not given, an output file with the same name as the\r\n",
"input file, with the extension changed to '.yaml'.\r\n",
"\r\n",
"An input file containing only species definitions (which can be referenced from\r\n",
"phase definitions in other input files) can be created by specifying only a\r\n",
"thermo file.\r\n",
"\r\n",
"For the case of a surface mechanism, the gas phase input file should be\r\n",
"specified as 'input' and the surface phase input file should be specified as\r\n",
"'surface'.\r\n",
"\r\n",
"The '--permissive' option allows certain recoverable parsing errors (e.g.\r\n",
"duplicate transport data) to be ignored. The '--name=<name>' option\r\n",
"is used to override default phase names (i.e. 'gas').\r\n",
"\r\n",
"The '--extra=<filename>' option takes a YAML file as input. This option can be\r\n",
"used to add to the file description, or to define custom fields that are\r\n",
"included in the YAML output.\r\n",
"\r\n"
"\n",
"ck2yaml.py: Convert Chemkin-format mechanisms to Cantera YAML input files\n",
"\n",
"Usage:\n",
" ck2yaml [--input=<filename>]\n",
" [--thermo=<filename>]\n",
" [--transport=<filename>]\n",
" [--surface=<filename>]\n",
" [--name=<name>]\n",
" [--extra=<filename>]\n",
" [--output=<filename>]\n",
" [--permissive]\n",
" [--quiet]\n",
" [--no-validate]\n",
" [-d | --debug]\n",
"\n",
"Example:\n",
" ck2yaml --input=chem.inp --thermo=therm.dat --transport=tran.dat\n",
"\n",
"If the output file name is not given, an output file with the same name as the\n",
"input file, with the extension changed to '.yaml'.\n",
"\n",
"An input file containing only species definitions (which can be referenced from\n",
"phase definitions in other input files) can be created by specifying only a\n",
"thermo file.\n",
"\n",
"For the case of a surface mechanism, the gas phase input file should be\n",
"specified as 'input' and the surface phase input file should be specified as\n",
"'surface'.\n",
"\n",
"The '--permissive' option allows certain recoverable parsing errors (e.g.\n",
"duplicate transport data) to be ignored. The '--name=<name>' option\n",
"is used to override default phase names (i.e. 'gas').\n",
"\n",
"The '--extra=<filename>' option takes a YAML file as input. This option can be\n",
"used to add to the file description, or to define custom fields that are\n",
"included in the YAML output.\n",
"\n"
]
}
],
Expand All @@ -91,9 +91,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.1 Input file `gri30.yaml`\n",
"\n",
"> **Notes:** `gri30.inp` uses the final version of GRI30.mech (slightly different from Cantera 2.4, and updated for 2.5), other CHEMKIN input is identical to files distributed with Cantera 2.4 (see `data` folder); output does not contain phases marked as `deprecated` in 2.5."
"### 1.1 Input file `gri30.yaml`"
]
},
{
Expand Down Expand Up @@ -121,9 +119,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.2 Input file `h2o2.yaml`\n",
"\n",
"> **Notes:** CHEMKIN input is identical to files distributed with Cantera 2.4 (see `data` folder)."
"### 1.2 Input file `h2o2.yaml`"
]
},
{
Expand All @@ -135,10 +131,10 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Wrote YAML mechanism file to 'h2o2_demo.yaml'.\r\n",
"Mechanism contains 9 species and 28 reactions.\r\n",
"Validating mechanism...\r\n",
"PASSED\r\n"
"Wrote YAML mechanism file to 'h2o2_demo.yaml'.\n",
"Mechanism contains 9 species and 28 reactions.\n",
"Validating mechanism...\n",
"PASSED\n"
]
}
],
Expand All @@ -154,7 +150,7 @@
"source": [
"### 1.3 Input file `air.yaml`\n",
"\n",
"> **Notes:** CHEMKIN input is identical to files distributed with Cantera 2.4 (see `data` folder); the default composition is not set. The `--quiet` option suppresses warnings about unexpected/unused species in thermo data)."
"**Notes:** The `--quiet` option suppresses warnings about unexpected/unused species in thermo data."
]
},
{
Expand All @@ -174,7 +170,7 @@
"source": [
"### 1.4 Input file `argon.yaml`\n",
"\n",
"> **Notes:** CHEMKIN input is identical to files distributed with Cantera 2.4 (see `data` folder); YAML output does not contain the `deprecated` field added in Cantera 2.5. The `--quiet` option suppresses warnings about unexpected/unused species in thermo data)."
"**Notes:** The `--quiet` option suppresses warnings about unexpected/unused species in thermo data."
]
},
{
Expand All @@ -199,9 +195,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### 2.1 Input file `nasa.yaml`\n",
"\n",
"> **Notes:** CHEMKIN input is identical to `data/thermo/nasathermo.dat` distributed with Cantera 2.4, except for moving the `THERMO` block to ensure correct parsing of the file description."
"### 2.1 Input file `nasa.yaml`"
]
},
{
Expand Down Expand Up @@ -233,9 +227,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### 2.2 Input file `airNASA9.yaml`\n",
"\n",
"> **Notes:** CHEMKIN input is identical to `data/thermo/airDataNASA9.dat` distributed with Cantera 2.4."
"### 2.2 Input file `airNASA9.yaml`"
]
},
{
Expand All @@ -247,30 +239,22 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Wrote YAML mechanism file to 'airNASA9_demo.yaml'.\r\n",
"Mechanism contains 11 species and 0 reactions.\r\n",
"Validating mechanism...\r\n",
"PASSED\r\n"
"Wrote YAML mechanism file to 'airNASA9_demo.yaml'.\n",
"Mechanism contains 11 species and 0 reactions.\n",
"Validating mechanism...\n",
"PASSED\n"
]
}
],
"source": [
"# options for airNASA9.yaml\n",
"! ck2yaml --input=chemkin/airNASA9.inp --thermo=chemkin/airDataNASA9.dat \\\n",
"--output=airNASA9_demo.yaml --name=airNASA9"
"! ck2yaml --input=chemkin/airNASA9.inp --thermo=chemkin/airDataNASA9.dat --output=airNASA9_demo.yaml --name=airNASA9"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -284,9 +268,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.9.10"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

0 comments on commit 17d6117

Please sign in to comment.