@@ -46,6 +46,14 @@ def __init__(self, **kwarg):
4646 # while being small enough for the Taylor approximation to remain highly accurate.
4747 self .THETA_CUT = 1e-3
4848 self .EPSILON_PARAM = 1e-8
49+
50+ self .COEFFS = [
51+ 128.0 / 1575.0 ,
52+ 4.0 / 35.0 ,
53+ 8.0 / 45.0 ,
54+ 1.0 / 3.0 ,
55+ 2.0
56+ ]
4957
5058 def calc_energy (self , geom_num_list , bias_pot_params = []):
5159 """
@@ -115,11 +123,11 @@ def theta_sq_taylor_at_0(u_val):
115123 """
116124 delta = 1.0 - u_val
117125 # Horner's method for efficiency and precision
118- term = 128.0 / 1575.0
119- term = 4.0 / 35.0 + delta * term
120- term = 8.0 / 45.0 + delta * term
121- term = 1.0 / 3.0 + delta * term
122- term = 2.0 + delta * term
126+ term = self . COEFFS [ 0 ]
127+ term = self . COEFFS [ 1 ] + delta * term
128+ term = self . COEFFS [ 2 ] + delta * term
129+ term = self . COEFFS [ 3 ] + delta * term
130+ term = self . COEFFS [ 4 ] + delta * term
123131 return delta * term
124132
125133 def theta_sq_taylor_at_pi (u_val ):
@@ -129,11 +137,11 @@ def theta_sq_taylor_at_pi(u_val):
129137 """
130138 delta = 1.0 + u_val
131139 # Horner's method
132- term = 128.0 / 1575.0
133- term = 4.0 / 35.0 + delta * term
134- term = 8.0 / 45.0 + delta * term
135- term = 1.0 / 3.0 + delta * term
136- term = 2.0 + delta * term
140+ term = self . COEFFS [ 0 ]
141+ term = self . COEFFS [ 1 ] + delta * term
142+ term = self . COEFFS [ 2 ] + delta * term
143+ term = self . COEFFS [ 3 ] + delta * term
144+ term = self . COEFFS [ 4 ] + delta * term
137145 return delta * term
138146
139147 # ==============================================
@@ -273,6 +281,14 @@ def __init__(self, **kwarg):
273281 # Thresholds
274282 self .THETA_CUT = 1e-3
275283 self .EPSILON_PARAM = 1e-8
284+
285+ self .COEFFS = [
286+ 128.0 / 1575.0 ,
287+ 4.0 / 35.0 ,
288+ 8.0 / 45.0 ,
289+ 1.0 / 3.0 ,
290+ 2.0
291+ ]
276292
277293 def calc_energy (self , geom_num_list , bias_pot_params = []):
278294 """
@@ -340,22 +356,22 @@ def theta_sq_taylor_at_0(u_val):
340356 """5th-order Taylor expansion of theta^2 near 0 (u=1)."""
341357 delta = 1.0 - u_val
342358 # Horner's method
343- term = 128.0 / 1575.0
344- term = 4.0 / 35.0 + delta * term
345- term = 8.0 / 45.0 + delta * term
346- term = 1.0 / 3.0 + delta * term
347- term = 2.0 + delta * term
359+ term = self . COEFFS [ 0 ]
360+ term = self . COEFFS [ 1 ] + delta * term
361+ term = self . COEFFS [ 2 ] + delta * term
362+ term = self . COEFFS [ 3 ] + delta * term
363+ term = self . COEFFS [ 4 ] + delta * term
348364 return delta * term
349365
350366 def theta_sq_taylor_at_pi (u_val ):
351367 """5th-order Taylor expansion of (pi-theta)^2 near 180 (u=-1)."""
352368 delta = 1.0 + u_val
353369 # Horner's method
354- term = 128.0 / 1575.0
355- term = 4.0 / 35.0 + delta * term
356- term = 8.0 / 45.0 + delta * term
357- term = 1.0 / 3.0 + delta * term
358- term = 2.0 + delta * term
370+ term = self . COEFFS [ 0 ]
371+ term = self . COEFFS [ 1 ] + delta * term
372+ term = self . COEFFS [ 2 ] + delta * term
373+ term = self . COEFFS [ 3 ] + delta * term
374+ term = self . COEFFS [ 4 ] + delta * term
359375 return delta * term
360376
361377 def get_quad_params (th_cut ):
0 commit comments