@@ -97,25 +97,31 @@ def mol2file(request):
9797
9898
9999def parmed2trappe (val ):
100+ # convert kcal/mol (parmed units) to K/k_B (trappe units)
100101 return val * calorie / (k * N_A / 1000. )
101102
102103def angle_parmed2trappe (val ):
104+ # trappe angle units need doubling
103105 return 2 * parmed2trappe (val )
104106
105107def assert_dihedrals_match (foyer_d , reference_params ):
108+ # Check that a dihedral from foyer matches the text in the csv file
109+ # foyer_d - parmed rb_torsion
110+ # reference_params - dihedral parameters from trappe csv file
106111 def conv1 (t ):
107- # convert RB to Trappe#1
108- raise ValueError
112+ # convert RB to original Trappe dihedral form:
113+ # V = c0 + c1(1 + cos phi) + c1(1 - cos 2phi) + c3(1 + cos 3phi)
109114 R0 , R1 , R2 , R3 = t .c0 , t .c1 , t .c2 , t .c3
110- c0 = R0 - R1 + R2 - R3
111- c1 = R1 + 3 / 4. * R3
112- c2 = - 0.5 * R2
113- c3 = 1 / 4. * R3
115+ c0 = - R0 + R1 + R2 + R3
116+ c1 = - R1 - 3 / 4. * R3
117+ c2 = - 0.5 * R2
118+ c3 = - 1 / 4. * R3
114119
115120 return c0 , c1 , c2 , c3
116121
117122 def conv2 (t ):
118- # convert RB to Trappe#2
123+ # convert RB to second Trappe dihedral form:
124+ # V = c0 + c1 cos phi + c2 cos 2phi + c3 cos 3phi + c4 cos 4phi
119125 R0 , R1 , R2 , R3 , R4 = t .c0 , t .c1 , t .c2 , t .c3 , t .c4
120126 print (list (map (lambda x : x * calorie , [R0 , R1 , R2 , R3 , R4 ])))
121127 c0 = - R0 + 0.5 * R2 + 3 / 8. * R4
@@ -130,9 +136,9 @@ def conv2(t):
130136 # check parameters in *foyer_d* match the raw text from trappe
131137 # trappe's params are in one of two functional forms.....
132138 if len (reference_params ) == 5 :
133- # using later form
139+ # using later form, has an extra column
134140 foyer_params = conv2 (foyer_d .type )
135- else :
141+ elif len ( reference_params ) == 4 :
136142 # using original dihedral form
137143 foyer_params = conv1 (foyer_d .type )
138144
0 commit comments