@@ -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 (
@@ -464,13 +468,18 @@ def _regenerate_topology_from_bound_to(self, ff):
464
468
for atom in self .atoms .values ():
465
469
impropers = self ._get_atom_improper_dihedrals (atom .nr , ff )
466
470
for key , improper in impropers :
467
- self .improper_dihedrals [key ] = Dihedral (
468
- improper .atom1 ,
469
- improper .atom2 ,
470
- improper .atom3 ,
471
- improper .atom4 ,
471
+ self .improper_dihedrals [key ] = MultipleDihedrals (
472
+ * key ,
472
473
"4" ,
473
- improper .cq ,
474
+ dihedrals = {
475
+ "" : Dihedral (
476
+ * key ,
477
+ "4" ,
478
+ c0 = improper .c0 ,
479
+ c1 = improper .c1 ,
480
+ periodicity = improper .c2 ,
481
+ )
482
+ },
474
483
)
475
484
476
485
def reindex_atomnrs (self ) -> dict [str , str ]:
@@ -1256,11 +1265,12 @@ def bind_bond(
1256
1265
atompair_nrs [0 ], self .ff
1257
1266
) + reactive_moleculetype ._get_atom_improper_dihedrals (atompair_nrs [1 ], self .ff )
1258
1267
for key , value in dihedral_k_v :
1268
+ if value .c2 is None :
1269
+ value .c2 = ""
1259
1270
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
1271
+ reactive_moleculetype .improper_dihedrals [key ] = MultipleDihedrals (
1272
+ * key , "4" , dihedrals = {}
1266
1273
)
1274
+ reactive_moleculetype .improper_dihedrals [key ].dihedrals [value .c2 ] = (
1275
+ Dihedral (* key , "4" , c0 = value .c0 , c1 = value .c1 , periodicity = value .c2 )
1276
+ )
0 commit comments