From bc95e5b15708b84b020b784c6d455c6a26383f34 Mon Sep 17 00:00:00 2001 From: Yuman Hordijk Date: Thu, 8 Feb 2024 16:03:12 +0100 Subject: [PATCH 1/2] 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) From e19db2b1503da01654f9f26c32aad5ed580763d4 Mon Sep 17 00:00:00 2001 From: Yuman Hordijk Date: Thu, 8 Feb 2024 16:10:06 +0100 Subject: [PATCH 2/2] Removed empty f-string --- src/tcutility/job/adf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tcutility/job/adf.py b/src/tcutility/job/adf.py index def6be92..1efb64da 100644 --- a/src/tcutility/job/adf.py +++ b/src/tcutility/job/adf.py @@ -273,7 +273,7 @@ def add_fragment(self, mol: plams.Molecule, name: str = None, charge: int = 0, s # 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.') + log.error('An atom is present in multiple fragments.') return name = name or f'fragment{len(self.childjobs) + 1}'