11
11
import MDAnalysis as mda
12
12
import numpy as np
13
13
14
- from kimmdy .constants import DEFAULT_EDISSOC , REACTIVE_MOLECULEYPE , FFFUNC
14
+ from kimmdy .constants import DEFAULT_EDISSOC , FFFUNC
15
15
from kimmdy .parsing import read_plumed , write_plumed
16
16
from kimmdy .recipe import Place
17
17
from kimmdy .tasks import TaskFiles
@@ -209,6 +209,7 @@ def merge(self) -> MoleculeType:
209
209
self .merge_bonds ()
210
210
self .merge_angles ()
211
211
self .merge_dihedrals ()
212
+ self .merge_exclusions ()
212
213
213
214
if not self .morse_only :
214
215
self .merge_pairs ()
@@ -221,6 +222,14 @@ def merge(self) -> MoleculeType:
221
222
key = lambda item : (int (item [0 ][0 ]), int (item [0 ][1 ])),
222
223
)
223
224
)
225
+ # sort exclusions after adding helper pairs because they
226
+ # come with their own exclusions
227
+ self .mol_b .exclusions = dict (
228
+ sorted (
229
+ self .mol_b .exclusions .items (),
230
+ key = lambda item : [int (i ) for i in item [0 ]],
231
+ )
232
+ )
224
233
else :
225
234
# same as in (keysA - keysB) in v1
226
235
for key in self .affected_interactions .bonds .removed :
@@ -936,6 +945,11 @@ def merge_pairs(self):
936
945
self .mol_b .pairs = {}
937
946
for key , pair in new_pairs .items ():
938
947
self .mol_b .pairs [key ] = pair
948
+
949
+ def merge_exclusions (self ):
950
+ """Merge exclusions by adding the exclusions from the A state to the B state"""
951
+ logger .info ("Merging exclusions" )
952
+ for key in self .mol_a .exclusions .keys ():
939
953
self .mol_b .exclusions [key ] = Exclusion (* key )
940
954
941
955
def add_helper_pairs (self ):
@@ -950,7 +964,6 @@ def add_helper_pairs(self):
950
964
# pairs that stem from bonds breaking or forming
951
965
# collected by looking at the changing bonds, angles and dihedrals (=higher order interactions)
952
966
self .helper_pairs : dict [tuple [str , str ], Pair ] = {}
953
- self .helper_exclusions : set [tuple [str , str ]] = set ()
954
967
955
968
# a bond is either added or removed, but can't be both.
956
969
# but for higher order interactions the end-atoms (of the angle or dihedral) can be involved
@@ -996,10 +1009,6 @@ def add_helper_pairs(self):
996
1009
morphing_dihedrals = self .affected_interactions .dihedrals .morphed
997
1010
998
1011
for pair_key in added_bonds :
999
- if pair_key in removed_angles :
1000
- # the bond is added, but the atoms where in an angle in A
1001
- # so they where excluded before and will be excluded again
1002
- self .helper_exclusions .add (pair_key )
1003
1012
if pair_key in removed_dihedrals :
1004
1013
# the bond is added, but the atoms where in a dihedral in A
1005
1014
# so they had 1-4 interactions in A and will be excluded in B
@@ -1040,9 +1049,6 @@ def add_helper_pairs(self):
1040
1049
self .helper_pairs [pairkey ] = self ._make_pair (
1041
1050
* pairkey , transition = PairTransition .Vanish , from_1_4 = True
1042
1051
)
1043
- if pairkey in removed_bonds :
1044
- # atoms where in a bond together and will be in an angle together, so they are just excluded
1045
- self .helper_exclusions .add (pairkey )
1046
1052
if (
1047
1053
pairkey
1048
1054
not in removed_bonds
@@ -1067,11 +1073,6 @@ def add_helper_pairs(self):
1067
1073
* pairkey , transition = PairTransition .Create
1068
1074
)
1069
1075
1070
- # atoms involved in angles that stay involved in angles but the parameters or atomtypes my change
1071
- for pairkey in swapping_angles | morphing_angles :
1072
- # we just want the exclusion
1073
- self .helper_exclusions .add (pairkey )
1074
-
1075
1076
# atoms that end up with a dihedral between them where there was none before
1076
1077
for pairkey in added_dihedrals :
1077
1078
if pairkey in removed_bonds | removed_angles :
@@ -1128,11 +1129,6 @@ def add_helper_pairs(self):
1128
1129
# add general exclusions for each pair
1129
1130
self .mol_b .exclusions [key ] = Exclusion (* key )
1130
1131
1131
- # add additional exclusions for atoms we know should be excluded
1132
- # just in case
1133
- for key in self .helper_exclusions :
1134
- self .mol_b .exclusions [key ] = Exclusion (* key )
1135
-
1136
1132
1137
1133
def merge_top_slow_growth (
1138
1134
top_a : Topology ,
0 commit comments