RMG-Py
RMG-Py copied to clipboard
KineticsError: Unable to calculate degeneracy for Surface_Dissociation_to_Bidentate reaction
When adding the Surface_Dissociation_to_Bidentate family
*1--*2--*3 *1--*2 *3
| ----> | | |
~*4~ + ~*5~ + ~*6 ~*4~~*5 + ~*6~~
in the new bidentate_reaction_data branch and testing the reaction template with RMG, I got the following warning and error messages:
Warning: No reactions matched the specified template, frozenset({'VacantSite1', 'VacantSite2', 'Combined'})
Error: Reactant: Species(label="", molecule=[Molecule(smiles="OC[Pt]")], molecular_weight=(31.034,'amu'))
Error: Reactant: Species(label="", molecule=[Molecule(smiles="[Pt]")], molecular_weight=(0,'amu'))
Error: Reactant: Species(label="", molecule=[Molecule(smiles="[Pt]")], molecular_weight=(0,'amu'))
Error: Product: Molecule(smiles="[Pt]CO[Pt]")
Error: Product: Molecule(smiles="[Pt]")
Traceback (most recent call last):
File "/home/kblondal/Miniconda/miniconda3/envs/rmg_env/lib/python3.7/site-packages/julia/pseudo_python_cli.py", line 308, in main
python(**vars(ns))
File "/home/kblondal/Miniconda/miniconda3/envs/rmg_env/lib/python3.7/site-packages/julia/pseudo_python_cli.py", line 59, in python
scope = runpy.run_path(script, run_name="__main__")
File "/home/kblondal/Miniconda/miniconda3/envs/rmg_env/lib/python3.7/runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "/home/kblondal/Miniconda/miniconda3/envs/rmg_env/lib/python3.7/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/home/kblondal/Miniconda/miniconda3/envs/rmg_env/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/kblondal/Code/Main/RMG-Py/rmg.py", line 118, in <module>
main()
File "/home/kblondal/Code/Main/RMG-Py/rmg.py", line 112, in main
rmg.execute(**kwargs)
File "/home/kblondal/Code/Main/RMG-Py/rmgpy/rmg/main.py", line 707, in execute
self.initialize(**kwargs)
File "/home/kblondal/Code/Main/RMG-Py/rmgpy/rmg/main.py", line 516, in initialize
self.load_database()
File "/home/kblondal/Code/Main/RMG-Py/rmgpy/rmg/main.py", line 440, in load_database
family.add_rules_from_training(thermo_database=self.database.thermo)
File "/home/kblondal/Code/Main/RMG-Py/rmgpy/data/kinetics/family.py", line 1303, in add_rules_from_training
new_degeneracy = self.calculate_degeneracy(item)
File "/home/kblondal/Code/Main/RMG-Py/rmgpy/data/kinetics/family.py", line 1948, in calculate_degeneracy
'but generated {2}').format(reaction, self.label, len(reactions)))
rmgpy.exceptions.KineticsError: Unable to calculate degeneracy for reaction OC[Pt] + [Pt] + [Pt] <=> <Molecule "[Pt]CO[Pt]"> + <Molecule "[Pt]"> in reaction family Surface_Dissociation_to_Bidentate. Expected 1 reaction but generated 0
I think this ultimately caused by the fix in rmgpy/data/family.py where already adsorbed species are not allowed to adsorb again, however it seems to also be wrongly applied to this new family. I tried making a small modification (currently in line 2204):
if adsorbate_molecules[0].contains_surface_site(): -> if adsorbate_molecules[0].contains_surface_site() and not 'dissociation' in self.label.lower():
and that worked to get rid of this error and the reaction template was applied correctly. This kind of fix for this may not be the best option though, because it is yet another hard-coding of the reaction family name. Therefore I have not made a PR yet suggesting adding this to the code. Thoughts on this or alternative solution suggestions would be appreciated!
Our _match_reactant_to_template method is more robust now when dealing with adsorbates, so we may be able to get rid of some of these hard codings for surface reactions. I'm not sure, but it might be worth trying removing this if block entirely.
I think you've identified the problem correctly.
As for the solution, if David's idea doesn't work and you do have to add a special case, I would try to make it easier for the next person to understand. That's more important than minimizing your changes.
Update all the comments and docstrings (e.g. line 2174) and perhaps even variable names if needed. And I think and 'adsorption' in self.label.lower()
is possibly better than and not 'dissociation' in self.label.lower()
, as the point of the check is to prevent adsorption happening when it shouldn't.
My only other suggestion was to read the commit message of the commit that added the check, to see if there is more context for why it is needed, and suggestions of hazards. In general, commit messages should spell out why something was done. In this case, however (95d48ca3fdc3acfe40306c1f1e99a65874dd218f), there's not much of a clue for this specific test (probably the commit was merged with some others during the year-long rebasing project of merging RMG-Cat)
If I remember correctly, we had an issue before where empty surface sites groups in the template (which we want to only match an empty site) would match any adsorbate with an X in it (any adsorbate) since its hard to specify the absence of something in a group (X - not bonded to anything else). So we needed to manually match empty surface sites like this . However, after this code was written we added this to _match_group_to_template
so I'm thinking/hoping we no longer need that if block
I tried generating katrin's model (see below) without the check that a surface site matches only a surface site in the template. I did that by commenting out this if
statement and this if
statement. It doesn't make the tridentate/multidentate vdw species expect without such a check, or reactions with an empty site where I would expect a molecule to be, so I think that means that the _match_group_to_template
method is working for that particular issue. I also compared it to a model that had the additional check of seeing if the template had 2 sites in one of the products (i.e. a bidentate family), but the models were the same. I'd like to test it a little more and see if it is actually working properly but I can open up a PR once I do.
I think there was a specific PR with the issue David was talking about. I am having a little trouble finding it, so if anyone comes across that would be helpful. I attached the resulting model here. 2022_03_11_bidentate_troubles.zip
This issue 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 issue, otherwise it will automatically be closed in 30 days.