Skip to content

Commit

Permalink
ADFFragmentJob will now error if an atom is present in multiple fragm…
Browse files Browse the repository at this point in the history
…ents
  • Loading branch information
YHordijk committed Feb 8, 2024
1 parent a0fe942 commit bc95e5b
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(f'An atom is present in multiple fragments.')

Check failure on line 276 in src/tcutility/job/adf.py

View workflow job for this annotation

GitHub Actions / build (3.8)

Ruff (F541)

src/tcutility/job/adf.py:276:27: F541 f-string without any placeholders

Check failure on line 276 in src/tcutility/job/adf.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Ruff (F541)

src/tcutility/job/adf.py:276:27: F541 f-string without any placeholders
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 bc95e5b

Please sign in to comment.