Skip to content

Commit

Permalink
Merge pull request #128 from TheoChem-VU/125-warn-if-atom-belongs-to-…
Browse files Browse the repository at this point in the history
…multiple-fragments

ADFFragmentJob will now error if an atom is present in multiple fragments
  • Loading branch information
SEBeutick authored Feb 9, 2024
2 parents 29d2b86 + e19db2b commit af18d84
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/tcutility/job/adf.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@ def add_fragment(self, mol: plams.Molecule, name: str = None, charge: int = 0, s
mol = mol_.copy()
add_frag_to_mol = False

# check if the atoms in the new fragment are already present in the other fragments.
# if it is we should raise an error
for child in self.childjobs.values():
if any((atom.symbol, atom.coords) == (myatom.symbol, myatom.coords) for atom in child._molecule for myatom in mol):
log.error('An atom is present in multiple fragments.')
return

name = name or f'fragment{len(self.childjobs) + 1}'
self.childjobs[name] = ADFJob(test_mode=self.test_mode)
self.childjobs[name].molecule(mol)
Expand Down

0 comments on commit af18d84

Please sign in to comment.