From bc95e5b15708b84b020b784c6d455c6a26383f34 Mon Sep 17 00:00:00 2001 From: Yuman Hordijk Date: Thu, 8 Feb 2024 16:03:12 +0100 Subject: [PATCH] ADFFragmentJob will now error if an atom is present in multiple fragments --- src/tcutility/job/adf.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tcutility/job/adf.py b/src/tcutility/job/adf.py index 96cfad76..def6be92 100644 --- a/src/tcutility/job/adf.py +++ b/src/tcutility/job/adf.py @@ -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.') + return + name = name or f'fragment{len(self.childjobs) + 1}' self.childjobs[name] = ADFJob(test_mode=self.test_mode) self.childjobs[name].molecule(mol)