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

ADFFragmentJob will now error if an atom is present in multiple fragments #128

Merged
merged 2 commits into from
Feb 9, 2024
Merged
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
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
Loading