Skip to content

Commit

Permalink
Fix Reaction.get_element_mass() (#609)
Browse files Browse the repository at this point in the history
The `get_element_mass` method in Reaction iterates through the elements
of the reactants and returns the mass of the respective elements.
However, it doesn't take into account that when a reaction has two
identical reactant (e.g., `OH + OH <=> H2O2`), ARC only stores one
instance of the reactant species to avoid running duplicate identical QM
jobs.
This method was fixed and it uses now the `get_reactants_and_products`
method that considers identical reactants/products.
A test was added.
  • Loading branch information
kfir4444 committed Mar 12, 2023
2 parents b7fc76f + e6628a0 commit 9f02dd3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arc/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,10 +907,10 @@ def get_element_mass(self) -> List[float]:
Get the mass of all elements of a reaction. Uses the atom order of the reactants.
Returns:
List[float]: The RMS of the normal mode displacements.
List[float]: The masses of all elements in the reactants.
"""
masses = list()
for reactant in self.r_species:
for reactant in self.get_reactants_and_products()[0]:
for atom in reactant.mol.atoms:
masses.append(get_element_mass(atom.element.symbol)[0])
return masses
Expand Down
3 changes: 3 additions & 0 deletions arc/reaction_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1708,6 +1708,9 @@ def test_get_element_masses(self):
self.assertTrue(almost_equal_lists(self.rxn3.get_element_mass(),
[12.0, 12.0, 14.00307400443, 1.00782503224, 1.00782503224, 1.00782503224,
1.00782503224, 1.00782503224, 1.00782503224]))
self.assertTrue(almost_equal_lists(self.rxn5.get_element_mass(),
[14.00307400443, 1.00782503224, 1.00782503224,
14.00307400443, 1.00782503224, 1.00782503224]))

def test_get_bonds(self):
"""Test the get_bonds() method."""
Expand Down

0 comments on commit 9f02dd3

Please sign in to comment.