Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated symmetry calculations #50

Merged
merged 4 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small clarification, is mol different from self.rmg_molecule? can we just use self.rmg_molecule instead of making a new object that might need more memory!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ‘self.rmg_molecule’ has coords, I think we should use that. If not, maybe use the ‘update_coords_from’ method to create rmg mol from ase mol?

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