Skip to content

Commit

Permalink
Fix reaction degeneracy bug with keep_isomorphic argument
Browse files Browse the repository at this point in the history
In certain situations, we would call ensure_species with
keep_isomorphic=False, which would ultimately result in wrong
degeneracy values.

This fixes that oversight and makes sure that keep_isomorphic=True
when generating reactions.

A unit test is also added.
  • Loading branch information
mliu49 committed Apr 26, 2019
1 parent ce15695 commit 719f66b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rmgpy/data/kinetics/common.py
Expand Up @@ -198,7 +198,7 @@ def ensure_independent_atom_ids(input_species, resonance=True):
Modifies the list in place (replacing :class:`Molecule` with :class:`Species`).
Returns None.
"""
ensure_species(input_species, resonance=resonance)
ensure_species(input_species, resonance=resonance, keep_isomorphic=True)
# Method to check that all species' atom ids are different
def independent_ids():
num_atoms = 0
Expand Down
13 changes: 13 additions & 0 deletions rmgpy/data/kinetics/kineticsTest.py
Expand Up @@ -590,6 +590,19 @@ def test_degeneracy_multiple_resonance_different_template(self):

self.assertFalse(reaction_list[0].duplicate)

def test_degeneracy_resonance_keep_isomorphic(self):
"""Test that we get the correct degeneracy for [CH2]C=C[CH2] + [H].
Incorrect results would be obtained if isomorphic resonance structures are not kept."""
family_label = 'R_Recombination'
reactants = ['[CH2]C=C[CH2]', '[OH]']
products = ['[CH2]C(O)C=C']

correct_rxn_num = 1
correct_degeneracy = {2}

self.assert_correct_reaction_degeneracy(reactants, correct_rxn_num, correct_degeneracy, family_label, products)


class TestKineticsCommentsParsing(unittest.TestCase):

Expand Down

0 comments on commit 719f66b

Please sign in to comment.