@@ -72,7 +72,7 @@ def __init__(
72
72
self .pairs : dict [tuple [str , str ], Pair ] = {}
73
73
self .angles : dict [tuple [str , str , str ], Angle ] = {}
74
74
self .proper_dihedrals : dict [tuple [str , str , str , str ], MultipleDihedrals ] = {}
75
- self .improper_dihedrals : dict [tuple [str , str , str , str ], Dihedral ] = {}
75
+ self .improper_dihedrals : dict [tuple [str , str , str , str ], MultipleDihedrals ] = {}
76
76
self .position_restraints : dict [str , PositionRestraint ] = {}
77
77
self .dihedral_restraints : dict [tuple [str , str , str , str ], DihedralRestraint ] = (
78
78
{}
@@ -183,7 +183,11 @@ def _parse_dihedrals(self):
183
183
dihedral = Dihedral .from_top_line (l )
184
184
key = (dihedral .ai , dihedral .aj , dihedral .ak , dihedral .al )
185
185
if dihedral .funct == "4" :
186
- self .improper_dihedrals [key ] = dihedral
186
+ if self .improper_dihedrals .get (key ) is None :
187
+ self .improper_dihedrals [key ] = MultipleDihedrals (
188
+ * key , dihedral .funct , dihedrals = {}
189
+ )
190
+ self .improper_dihedrals [key ].dihedrals [dihedral .periodicity ] = dihedral
187
191
else :
188
192
if self .proper_dihedrals .get (key ) is None :
189
193
self .proper_dihedrals [key ] = MultipleDihedrals (
@@ -263,7 +267,11 @@ def _update_atomics_dict(self):
263
267
attributes_to_list (x )
264
268
for dihedrals in self .proper_dihedrals .values ()
265
269
for x in dihedrals .dihedrals .values ()
266
- ] + [attributes_to_list (x ) for x in self .improper_dihedrals .values ()]
270
+ ] + [
271
+ attributes_to_list (x )
272
+ for dihedrals in self .improper_dihedrals .values ()
273
+ for x in dihedrals .dihedrals .values ()
274
+ ]
267
275
self .atomics ["position_restraints" ] = [
268
276
attributes_to_list (x ) for x in self .position_restraints .values ()
269
277
]
@@ -464,13 +472,18 @@ def _regenerate_topology_from_bound_to(self, ff):
464
472
for atom in self .atoms .values ():
465
473
impropers = self ._get_atom_improper_dihedrals (atom .nr , ff )
466
474
for key , improper in impropers :
467
- self .improper_dihedrals [key ] = Dihedral (
468
- improper .atom1 ,
469
- improper .atom2 ,
470
- improper .atom3 ,
471
- improper .atom4 ,
475
+ self .improper_dihedrals [key ] = MultipleDihedrals (
476
+ * key ,
472
477
"4" ,
473
- improper .cq ,
478
+ dihedrals = {
479
+ "" : Dihedral (
480
+ * key ,
481
+ "4" ,
482
+ c0 = improper .c0 ,
483
+ c1 = improper .c1 ,
484
+ periodicity = improper .c2 ,
485
+ )
486
+ },
474
487
)
475
488
476
489
def reindex_atomnrs (self ) -> dict [str , str ]:
@@ -1256,11 +1269,12 @@ def bind_bond(
1256
1269
atompair_nrs [0 ], self .ff
1257
1270
) + reactive_moleculetype ._get_atom_improper_dihedrals (atompair_nrs [1 ], self .ff )
1258
1271
for key , value in dihedral_k_v :
1272
+ if value .c2 is None :
1273
+ value .c2 = ""
1259
1274
if reactive_moleculetype .improper_dihedrals .get (key ) is None :
1260
- # TODO: fix this
1261
- c2 = ""
1262
- if value .q0 is not None :
1263
- c2 = "1"
1264
- reactive_moleculetype .improper_dihedrals [key ] = Dihedral (
1265
- key [0 ], key [1 ], key [2 ], key [3 ], "4" , value .q0 , value .cq , c2
1275
+ reactive_moleculetype .improper_dihedrals [key ] = MultipleDihedrals (
1276
+ * key , "4" , dihedrals = {}
1266
1277
)
1278
+ reactive_moleculetype .improper_dihedrals [key ].dihedrals [value .c2 ] = (
1279
+ Dihedral (* key , "4" , c0 = value .c0 , c1 = value .c1 , periodicity = value .c2 )
1280
+ )
0 commit comments