diff --git a/rmgpy/molecule/molecule.py b/rmgpy/molecule/molecule.py index bbd8da2431e..4ba70b63028 100644 --- a/rmgpy/molecule/molecule.py +++ b/rmgpy/molecule/molecule.py @@ -410,6 +410,7 @@ def increment_radical(self): where `radical` specifies the number of radical electrons to add. """ # Set the new radical electron count + if self.is_surface_site(): return # do nothing self.radical_electrons += 1 if self.radical_electrons <= 0: raise gr.ActionError('Unable to update Atom due to GAIN_RADICAL action: ' @@ -421,6 +422,7 @@ def decrement_radical(self): where `radical` specifies the number of radical electrons to remove. """ cython.declare(radical_electrons=cython.short) + if self.is_surface_site(): return # do nothing # Set the new radical electron count radical_electrons = self.radical_electrons = self.radical_electrons - 1 if radical_electrons < 0: @@ -443,6 +445,7 @@ def increment_lone_pairs(self): Update the lone electron pairs pattern as a result of applying a GAIN_PAIR action. """ # Set the new lone electron pairs count + if self.is_surface_site(): return # do nothing self.lone_pairs += 1 if self.lone_pairs <= 0: raise gr.ActionError('Unable to update Atom due to GAIN_PAIR action: ' @@ -453,6 +456,7 @@ def decrement_lone_pairs(self): """ Update the lone electron pairs pattern as a result of applying a LOSE_PAIR action. """ + if self.is_surface_site(): return # do nothing # Set the new lone electron pairs count self.lone_pairs -= 1 if self.lone_pairs < 0: diff --git a/rmgpy/molecule/moleculeTest.py b/rmgpy/molecule/moleculeTest.py index 40a998bba73..36c872ec123 100644 --- a/rmgpy/molecule/moleculeTest.py +++ b/rmgpy/molecule/moleculeTest.py @@ -312,7 +312,10 @@ def test_apply_action_gain_radical(self): atom = atom0.copy() atom.apply_action(action) self.assertEqual(atom0.element, atom.element) - self.assertEqual(atom0.radical_electrons, atom.radical_electrons - 1) + if element.symbol == 'X': + self.assertEqual(atom0.radical_electrons, atom.radical_electrons) + else: + self.assertEqual(atom0.radical_electrons, atom.radical_electrons - 1) self.assertEqual(atom0.charge, atom.charge) self.assertEqual(atom0.label, atom.label) @@ -326,7 +329,10 @@ def test_apply_action_lose_radical(self): atom = atom0.copy() atom.apply_action(action) self.assertEqual(atom0.element, atom.element) - self.assertEqual(atom0.radical_electrons, atom.radical_electrons + 1) + if element.symbol == 'X': + self.assertEqual(atom0.radical_electrons, atom.radical_electrons) + else: + self.assertEqual(atom0.radical_electrons, atom.radical_electrons + 1) self.assertEqual(atom0.charge, atom.charge) self.assertEqual(atom0.label, atom.label)