RMG-Py
RMG-Py copied to clipboard
Create YAML file outputs in RMG for use in Cantera
Motivation or Problem
Previously, RMG created CHEMKIN files as outputs when generating a mechanism. The final CHEMKIN file for a mechanism is then converted to a CTI file, which can be used in Cantera simulations. When dealing with more complex mechanisms, RMG has a problem converting the final CHEMKIN file to a CTI file (because of numerous unmarked duplicate reactions in CHEMKIN file). To fix this issue, the CHEMKIN file has to be manually edited before file conversion can take place. This is time-consuming and tedious. Additionally, CTI input files are depreciated in Cantera 2.5 and will be removed in Cantera 3.0. For those using Cantera, it would be beneficial if RMG could directly output Cantera-formatted YAML files.
With the improvements proposed in this pull request, RMG can now directly output Cantera-formatted YAML files.
Description of Changes
These changes only work with Cantera 2.6 or greater.
- new file:
RMG-Py/rmgpy/cantera.pywhich creates a new Cantera-formatted YAML file each time another species is added to the mechanism, much like the CHEMKIN output files. Formats the YAML file depending on type of system (gas-phase v. catalysis). - changes to
RMG-Py/rmgpy/reaction.py: -to_cantera()method updated so that Cantera objects are correctly created for Troe, SurfaceArrhenius, StickingCoefficient, and Lindemann reactions. -fix_reaction()method added so the equations of StickingCoefficient reactions don't include the SMILES of the surface species. - changes to
rmgpy/kinetics/falloff.pyx: - edited/addedset_cantera_kinetics()andto_cantera_kinetics()in Lindemann and Troe classes - changes to
rmgpy/kinetics/surface.pyx: - edited/addedset_cantera_kinetics()andto_cantera_kinetics()in StickingCoefficient and SurfaceArrhenius classes - changes to
rmgpy/species.py: - editedto_cantera()to account for surface sites in surface reactions. changes tormgpy/rmg/main.py: - editedregister_listeners(), attached CanteraWriter
Testing
Tested yaml_writer_addition branch on the following examples:
- examples/rmg/catalysis/methane_steam
- examples/rmg/catalysis/ch4_o2
- examples/rmg/minimal
- examples/rmg/minimal_surface
Reviewer Tips
Please ensure this works on both gas-phase and catalysis. These updates create yaml files of the type 'chem{#}.yaml'. The yaml files named 'chem_annotated.yaml' are not generated in this update but somewhere else in the code, so please focus review on the yaml files that are individually numbered.
This pull request introduces 15 alerts when merging 6574356ae3ebf40b24f80a67910e45929480822c into 517b347e183bfe0cdb8fb5655e859827ade25750 - view on LGTM.com
new alerts:
- 9 for Unused import
- 2 for Wrong name for an argument in a class instantiation
- 1 for Module imports itself
- 1 for Unused local variable
- 1 for Except block handles 'BaseException'
- 1 for Module is imported with 'import' and 'import from'
This pull request introduces 17 alerts when merging 83a052ffe2c89bc8b863bf97f269e88e4a6ef71e into 517b347e183bfe0cdb8fb5655e859827ade25750 - view on LGTM.com
new alerts:
- 11 for Unused import
- 2 for Wrong name for an argument in a class instantiation
- 1 for Module imports itself
- 1 for Unused local variable
- 1 for Except block handles 'BaseException'
- 1 for Module is imported with 'import' and 'import from'
I think the test failing AttributeError: 'cantera._cantera.Species' object has no attribute 'input_data' might mean that we're using an older version of Cantera? Would need to update the environment file? and warn people this is a breaking change to the requirements.
This pull request introduces 17 alerts when merging 9673912bf8e2dcc7ab3a89d25dce1003eb471d19 into 517b347e183bfe0cdb8fb5655e859827ade25750 - view on LGTM.com
new alerts:
- 11 for Unused import
- 2 for Wrong name for an argument in a class instantiation
- 1 for Module imports itself
- 1 for Unused local variable
- 1 for Except block handles 'BaseException'
- 1 for Module is imported with 'import' and 'import from'
This pull request introduces 17 alerts when merging 4544828bd68f834cc0cb11e8f520de25dfafd91d into 517b347e183bfe0cdb8fb5655e859827ade25750 - view on LGTM.com
new alerts:
- 11 for Unused import
- 2 for Wrong name for an argument in a class instantiation
- 1 for Module imports itself
- 1 for Unused local variable
- 1 for Except block handles 'BaseException'
- 1 for Module is imported with 'import' and 'import from'
This pull request introduces 17 alerts when merging e26a648e993378a70cdd274977a94b8b139a269a into 517b347e183bfe0cdb8fb5655e859827ade25750 - view on LGTM.com
new alerts:
- 11 for Unused import
- 2 for Wrong name for an argument in a class instantiation
- 1 for Module imports itself
- 1 for Unused local variable
- 1 for Except block handles 'BaseException'
- 1 for Module is imported with 'import' and 'import from'
This pull request introduces 4 alerts when merging fe9af4aaca30e269c1c7b580637c78bf68f984be into 517b347e183bfe0cdb8fb5655e859827ade25750 - view on LGTM.com
new alerts:
- 1 for Except block handles 'BaseException'
- 1 for Unused import
- 1 for Module is imported with 'import' and 'import from'
- 1 for Wrong name for an argument in a class instantiation
This pull request introduces 3 alerts when merging c4cff4e27df226e95a07778cc93f64506775324e into 517b347e183bfe0cdb8fb5655e859827ade25750 - view on LGTM.com
new alerts:
- 1 for Except block handles 'BaseException'
- 1 for Module is imported with 'import' and 'import from'
- 1 for Wrong name for an argument in a class instantiation
This pull request introduces 1 alert when merging 7f91a018310f65a6c0d5d64e64b581cf1f8e9a3f into 517b347e183bfe0cdb8fb5655e859827ade25750 - view on LGTM.com
new alerts:
- 1 for Except block handles 'BaseException'
This pull request introduces 1 alert when merging f00c6e179907a06ae8724e4ad84dc9e17adb66f5 into 517b347e183bfe0cdb8fb5655e859827ade25750 - view on LGTM.com
new alerts:
- 1 for Except block handles 'BaseException'
This pull request introduces 1 alert when merging 02d84e0d6041ae2b4f797d085e1a0b84d27797bb into 517b347e183bfe0cdb8fb5655e859827ade25750 - view on LGTM.com
new alerts:
- 1 for Except block handles 'BaseException'
@xiaoruiDong this PR has a merge conflict from the fix you made to the Troe model, can you resolve it?
@Nora-Khalil this PR is no longer blocked since the merging of #2417.
This pull request is being automatically marked as stale because it has not received any interaction in the last 90 days. Please leave a comment if this is still a relevant pull request, otherwise it will automatically be closed in 30 days.
Adding this to the long-term board since we would eventually like to have this in, and a great deal of the work is already done.
@Nora-Khalil is reviving this PR
@Nora-Khalil please add some additional documentation updates to specify which versions of Cantera are supported after these changes.
@JacksonBurns This should be all set now, just would like the reviewers to take a second look when they have the time. Thanks!
@JacksonBurns This should be all set now, just would like the reviewers to take a second look when they have the time. Thanks!
@Nora-Khalil thanks for taking care of the rebasing, apologies for not helping out, have been swamped. I have re-started the CI to see if it passes this time (not sure why it failed last time on unrelated tests), may need a rebase to pass again.
@rwest @sevyharris @ChrisBNEU this should be ready for review!
@ntietje1 rebased this for us (thanks!). I just force pushed. let's see if it works.