Skip to content

Commit

Permalink
Merge pull request #50 from ReactionMechanismGenerator/symmetry
Browse files Browse the repository at this point in the history
Updated symmetry calculations
  • Loading branch information
davidfarinajr authored Dec 18, 2019
2 parents e417241 + 8238aa5 commit 25067c7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
11 changes: 10 additions & 1 deletion autotst/reactionTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,16 @@ def test_ase_molecule(self):
def test_symmetry_number(self):
self.assertEquals(self.ts.symmetry_number, 1)
self.assertEquals(self.ts2.symmetry_number, 1)
os.remove("./CC.[O]O.symm")

reactions_to_test = {
"[CH3]+[OH]_C+[O]" : 3,
# TODO add other reactions here
}
for reaction_string, expected_symmetry in reactions_to_test.items():
rxn = Reaction(reaction_string)
rxn.get_labeled_reaction()
ts = rxn.ts["forward"][0]
self.assertEquals(ts.symmetry_number, expected_symmetry)

def test_bounds_matrix(self):

Expand Down
36 changes: 12 additions & 24 deletions autotst/species.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,28 +1062,16 @@ def set_chirality(self, chiral_center_index, stero="R"):
return self

def calculate_symmetry_number(self):
from rmgpy.qm.symmetry import PointGroupCalculator
from rmgpy.qm.qmdata import QMData

atom_numbers = self.ase_molecule.get_atomic_numbers()
coordinates = self.ase_molecule.get_positions()

qmdata = QMData(
groundStateDegeneracy=1, # Only needed to check if valid QMData
numberOfAtoms=len(atom_numbers),
atomicNumbers=atom_numbers,
atomCoords=(coordinates, str('angstrom')),
energy=(0.0, str('kcal/mol')) # Only needed to avoid error
)
settings = type(str(''), (), dict(symmetryPath=str(
'symmetry'), scratchDirectory="."))() # Creates anonymous class
pgc = PointGroupCalculator(settings, self.smiles, qmdata)
pg = pgc.calculate()
#os.remove("{}.symm".format(self.smiles))

if pg is not None:
symmetry_number = pg.symmetry_number
else:
symmetry_number = 1

return symmetry_number
numbers = self.ase_molecule.numbers
positions = self.ase_molecule.positions

mol = RMGMolecule()
mol.from_xyz(numbers, positions)
try:
species = RMGSpecies(molecule=[mol])
self._symmetry_number = species.get_symmetry_number()
except ValueError:
self._symmetry_number = mol.get_symmetry_number()

return self._symmetry_number
7 changes: 5 additions & 2 deletions autotst/speciesTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ def test_get_geometries(self):
self.assertIsInstance(geometries[3],list)
self.assertIsInstance(geometries[4],list)
def test_calculate_symmetry_number(self):
self.assertTrue(self.conformer.calculate_symmetry_number() in [1,2])
os.remove("./CC.symm")
species_to_test = {
"CC" : 18.0,

}
self.assertEquals(self.conformer.calculate_symmetry_number(), 18.0)
def test_get_xyz_block(self):
xyz_block = self.conformer.get_xyz_block()
positions = self.conformer.ase_molecule.arrays["positions"]
Expand Down

0 comments on commit 25067c7

Please sign in to comment.