def nuclear_attraction(gaussian_1, gaussian_2, nuclei): a_1 = gaussian_1.exponent a_2 = gaussian_2.exponent l_1 = gaussian_1.integral_exponents l_2 = gaussian_2.integral_exponents r_a = gaussian_1.coordinates r_b = gaussian_2.coordinates r_c = nuclei.coordinates r_p = gaussian_product_coordinate(a_1, r_a, a_2, r_b) r_ab = coordinate_distance(r_a, r_b) r_pc = coordinate_distance(r_p, r_c) r_p_a = vector_minus(r_p, r_a) r_p_b = vector_minus(r_p, r_b) r_p_c = vector_minus(r_p, r_c) g = a_1 + a_2 ans = 0 for l in range(l_1[0] + l_2[0] + 1): for r in range(int(l / 2) + 1): for i in range(int((l - 2 * r) / 2) + 1): out1 = a_function(l, r, i, l_1[0], l_2[0], r_p_a[0], r_p_b[0], r_p_c[0], g) for m in range(l_1[1] + l_2[1] + 1): for s in range(int(m / 2) + 1): for j in range(int((m - 2 * s) / 2) + 1): out2 = a_function(m, s, j, l_1[1], l_2[1], r_p_a[1], r_p_b[1], r_p_c[1], g) for n in range(l_1[2] + l_2[2] + 1): for t in range(int(n / 2) + 1): for k in range(int((n - 2 * t) / 2) + 1): out3 = a_function( n, t, k, l_1[2], l_2[2], r_p_a[2], r_p_b[2], r_p_c[2], g) v = (l + m + n) - 2 * (r + s + t) - (i + j + k) out4 = boys_function(v, g * r_pc**2) out5 = out1 * out2 * out3 * out4 ans += out5 ans *= ((2 * pi) / g) * exp(-(a_1 * a_2 * r_ab**2) / g) return ans
def test_input_of_nu_0_and_u_0_returns_1(self): output = boys_function(0, 0) testing.assert_approx_equal(output, 1, 6)
def test_input_of_nu_2_and_u_4_4757221852728435_returns_0_0139425(self): output = boys_function(2, 4.4757221852728435) testing.assert_approx_equal(output, 0.0139425, 6)
def test_input_of_nu_2_and_4_802164876034457e_minus_31_returns_0_200000( self): output = boys_function(2, 4.802164876034457e-31) testing.assert_approx_equal(output, 0.200000, 6)
def test_input_of_nu_2_and_0_minus_31_returns_0_200000(self): output = boys_function(2, 0) testing.assert_approx_equal(output, 0.200000, 6)
def test_input_of_nu_1_and_u_130_80051761256559_returns_0_00029621(self): output = boys_function(1, 130.80051761256559) testing.assert_approx_equal(output, 0.000296210, 6)
def test_input_of_nu_1_and_u_12_0769452374367_returns_0_01055(self): output = boys_function(1, 12.0769452374367) testing.assert_approx_equal(output, 0.0105576, 6)
def test_input_of_nu_1_and_4_802164876034457e_minus_31_returns_0_333333( self): output = boys_function(1, 4.802164876034457e-31) testing.assert_approx_equal(output, 0.333333, 6)
def test_input_of_nu_0_and_u_130_80051761256559_returns_0_077489(self): output = boys_function(0, 130.80051761256559) testing.assert_approx_equal(output, 0.077489, 6)
def test_input_of_nu_1_and_0_minus_31_returns_0_333333(self): output = boys_function(1, 0) testing.assert_approx_equal(output, 0.333333, 6)
def test_input_of_nu_0_and_u_12_0769452374367_returns_0_2550(self): output = boys_function(0, 12.0769452374367) testing.assert_approx_equal(output, 0.255015, 6)
def test_input_of_nu_0_and_u_4_4757221852728435_returns_0_417742(self): output = boys_function(0, 4.4757221852728435) testing.assert_approx_equal(output, 0.417742, 6)
def integrate(self, basis_i, basis_j, basis_k, basis_l): l_1 = basis_i.integral_exponents l_2 = basis_j.integral_exponents l_3 = basis_k.integral_exponents l_4 = basis_l.integral_exponents l_total = sum(l_1) + sum(l_2) + sum(l_3) + sum(l_4) r_1 = basis_i.coordinates r_2 = basis_j.coordinates r_3 = basis_k.coordinates r_4 = basis_l.coordinates primitives_i = basis_i.primitive_gaussian_array primitives_j = basis_j.primitive_gaussian_array primitives_k = basis_k.primitive_gaussian_array primitives_l = basis_l.primitive_gaussian_array n_i = basis_i.normalisation n_j = basis_j.normalisation n_k = basis_k.normalisation n_l = basis_l.normalisation n = n_i * n_j * n_k * n_l ans = 0.0 for g1, g2, g3, g4 in itertools.product(primitives_i, primitives_j, primitives_k, primitives_l): c_1 = g1.contraction c_2 = g2.contraction c_3 = g3.contraction c_4 = g4.contraction n_1 = g1.normalisation n_2 = g2.normalisation n_3 = g3.normalisation n_4 = g4.normalisation contraction = c_1 * c_2 * c_3 * c_4 * n_1 * n_2 * n_3 * n_4 * n a_1 = g1.exponent a_2 = g2.exponent a_3 = g3.exponent a_4 = g4.exponent a_5 = a_1 + a_2 a_6 = a_3 + a_4 self.a_7 = (a_5 * a_6) / (a_5 + a_6) r_5 = gaussian_product_coordinate(a_1, r_1, a_2, r_2) r_6 = gaussian_product_coordinate(a_3, r_3, a_4, r_4) self.r_7 = gaussian_product_coordinate(a_5, r_5, a_6, r_6) r_12 = coordinate_distance(r_1, r_2) r_34 = coordinate_distance(r_3, r_4) r_56 = coordinate_distance(r_5, r_6) boys_x = (a_5 * a_6 * r_56**2) / (a_5 + a_6) boys_out1 = (2 * pi**(5 / 2)) / (a_5 * a_6 * sqrt(a_5 + a_6)) boys_out2 = exp(((-a_1 * a_2 * r_12**2) / a_5) - ((a_3 * a_4 * r_34**2) / a_6)) boys_out3 = boys_function(l_total, boys_x) self.end_dict = {l_total: boys_out1 * boys_out2 * boys_out3} m = l_total while m >= 1: boys_out3 = boys_function_recursion(m, boys_x, boys_out3) m -= 1 self.end_dict[m] = boys_out1 * boys_out2 * boys_out3 ans += contraction * self.os_begin(0, g1, g2, g3, g4) return ans
def test_input_of_nu_2_and_u_12_0769452374367_returns_0_00131107(self): output = boys_function(2, 12.0769452374367) testing.assert_approx_equal(output, 0.00131106, 6)
def test_input_of_nu_1_and_u_4_4757221852728435_returns_0_045396(self): output = boys_function(1, 4.4757221852728435) testing.assert_approx_equal(output, 0.045396, 6)
def test_input_of_nu_2_and_u_130_80051761256559_returns_3_3969e_minus_6( self): output = boys_function(2, 130.80051761256559) testing.assert_approx_equal(output, 3.39689e-6, 6)
def integrate(self, basis_i, basis_j, basis_k, basis_l): primitives_i = basis_i.primitive_gaussian_array primitives_j = basis_j.primitive_gaussian_array primitives_k = basis_k.primitive_gaussian_array primitives_l = basis_l.primitive_gaussian_array l_1 = basis_i.integral_exponents l_2 = basis_j.integral_exponents l_3 = basis_k.integral_exponents l_4 = basis_l.integral_exponents r_1 = basis_i.coordinates r_2 = basis_j.coordinates r_3 = basis_k.coordinates r_4 = basis_l.coordinates n_i = basis_i.normalisation n_j = basis_j.normalisation n_k = basis_k.normalisation n_l = basis_l.normalisation norm = n_i * n_j * n_k * n_l ans = 0.0 for g1, g2, g3, g4 in itertools.product(primitives_i, primitives_j, primitives_k, primitives_l): self.end_dict = {} c_1 = g1.contraction c_2 = g2.contraction c_3 = g3.contraction c_4 = g4.contraction n_1 = g1.normalisation n_2 = g2.normalisation n_3 = g3.normalisation n_4 = g4.normalisation contraction = c_1 * c_2 * c_3 * c_4 * n_1 * n_2 * n_3 * n_4 * norm g5 = gaussian_product(g1, g2) g6 = gaussian_product(g3, g4) a_1 = g1.exponent a_2 = g2.exponent a_3 = g3.exponent a_4 = g4.exponent a_5 = g5.exponent a_6 = g6.exponent r_5 = g5.coordinates r_6 = g6.coordinates r_12 = coordinate_distance(r_1, r_2) r_34 = coordinate_distance(r_3, r_4) r_56 = coordinate_distance(r_5, r_6) l_5 = g5.integral_exponents l_6 = g6.integral_exponents delta = (1 / (4 * a_5)) + (1 / (4 * a_6)) out_5 = 0 for l in range(l_5[0] + 1): for r in range(int(l / 2) + 1): for ll in range(l_6[0] + 1): for rr in range(int(ll / 2) + 1): for i in range( int((l + ll - 2 * r - 2 * rr) / 2) + 1): out1 = self.b_function(l, ll, r, rr, i, l_1[0], l_2[0], r_1[0], r_2[0], r_5[0], a_5, l_3[0], l_4[0], r_3[0], r_4[0], r_6[0], a_6) for m in range(l_5[1] + 1): for s in range(int(m / 2) + 1): for mm in range(l_6[1] + 1): for ss in range(int(mm / 2) + 1): for j in range( int((m + mm - 2 * s - 2 * ss) / 2) + 1): out2 = self.b_function( m, mm, s, ss, j, l_1[1], l_2[1], r_1[1], r_2[1], r_5[1], a_5, l_3[1], l_4[1], r_3[1], r_4[1], r_6[1], a_6) for n in range(l_5[2] + 1): for t in range( int(n / 2) + 1): for nn in range( l_6[2] + 1): for tt in range( int(nn / 2 ) + 1): for k in range( int(( n + nn - 2 * t - 2 * tt ) / 2 ) + 1): out3 = self.b_function( n, nn, t, tt, k, l_1[2], l_2[2], r_1[2], r_2[2], r_5[2], a_5, l_3[2], l_4[2], r_3[2], r_4[2], r_6[2], a_6 ) v = l + ll + m + mm + n + nn - 2 * ( r + rr + s + ss + t + tt ) - ( i + j + k) if v in self.end_dict: out4 = self.end_dict[ v] else: out4 = boys_function( v, (r_56 ** 2 / (4 * delta ) ) ) self.end_dict[ v] = out4 out_5 += out1 * out2 * out3 * out4 out_5 *= self.gaussian_product_factor(a_1, a_2, a_3, a_4, a_5, a_6, r_12, r_34) ans += contraction * out_5 return ans