Skip to content

Commit

Permalink
Fixed missing function
Browse files Browse the repository at this point in the history
  • Loading branch information
Bas van Beek committed Dec 3, 2018
1 parent 4df4431 commit 94dbfc2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 19 additions & 4 deletions src/qmflows/components/qd_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def get_bond_index(self):


@add_to_class(Atom)
def in_ring(self):
def atom_in_ring(self):
"""
Check if this |Atom| is part of a ring. Returns a boolean.
"""
Expand All @@ -170,6 +170,21 @@ def in_ring(self):
return False


@add_to_class(Bond)
def bond_in_ring(self):
"""
Check if this |Atom| is part of a ring. Returns a boolean.
"""
mol = self.mol.copy()
self = mol[self.get_bond_index()]
before = len(mol.separate())
self.mol.delete_bond(self)
after = len(mol.separate())
if before != after - 1:
return True
return False


@add_to_class(Molecule)
def separate_mod(self):
"""
Expand Down Expand Up @@ -262,8 +277,8 @@ def split_mol(plams_mol):
plams_mol.atoms.remove(atom)
plams_mol.bonds.remove(bond)

bond_list = [bond for bond in plams_mol.bonds if not bond.atom1.in_ring() and not
bond.atom1.in_ring()]
bond_list = [bond for bond in plams_mol.bonds if not bond.atom1.atom_in_ring() and not
bond.atom1.atom_in_ring()]

# Remove even more undesired bonds
for bond in reversed(bond_list):
Expand Down Expand Up @@ -361,7 +376,7 @@ def set_dihed(self, angle, unit='degree'):
"""
angle = Units.convert(angle, unit, 'degree')
bond_list = [bond for bond in self.bonds if bond.atom1.atnum != 1 and bond.atom2.atnum != 1
and bond.order == 1 and not bond.in_ring()]
and bond.order == 1 and not bond.bond_in_ring()]

for bond in bond_list:
n1, n2 = self.neighbors_mod(bond.atom1), self.neighbors_mod(bond.atom2)
Expand Down
2 changes: 1 addition & 1 deletion src/qmflows/qd.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def prep_qd_1(core, ligand, qd_folder):
return <plams.Molecule>: The quantum dot (core + n*ligands).
"""
# Rotate and translate all ligands to their position on the core.
indices = [(dummy.get_index(), -1, ligand.properties.dummies.get_index(), -1) for
indices = [(dummy.get_atom_index(), -1, ligand.properties.dummies.get_atom_index(), -1) for
i, dummy in enumerate(core.properties.dummies)]
core = core.copy()
ligand.add_atom(Atom(atnum=0, coords=ligand.get_center_of_mass()))
Expand Down

0 comments on commit 94dbfc2

Please sign in to comment.