def test_overlap_construct_array_contraction(): """Test gbasis.integrals.overlap.Overlap.construct_array_contraction.""" test_one = GeneralizedContractionShell( 1, np.array([0.5, 1, 1.5]), np.array([1.0, 2.0]), np.array([0.1, 0.01]) ) test_two = GeneralizedContractionShell( 2, np.array([1.5, 2, 3]), np.array([3.0, 4.0]), np.array([0.2, 0.02]) ) answer = np.array( [ [ _compute_multipole_moment_integrals( np.array([0, 0, 0]), np.array([[0, 0, 0]]), np.array([0.5, 1, 1.5]), np.array([angmom_comp_one]), np.array([0.1, 0.01]), np.array([[1], [2]]), np.array( [ [ (2 * 0.1 / np.pi) ** (3 / 4) * (4 * 0.1) ** (1 / 2) / np.sqrt(np.prod(factorial2(2 * angmom_comp_one - 1))), (2 * 0.01 / np.pi) ** (3 / 4) * (4 * 0.01) ** (1 / 2) / np.sqrt(np.prod(factorial2(2 * angmom_comp_one - 1))), ] ] ), np.array([1.5, 2, 3]), np.array([angmom_comp_two]), np.array([0.2, 0.02]), np.array([[3], [4]]), np.array( [ [ (2 * 0.2 / np.pi) ** (3 / 4) * (4 * 0.2) ** (2 / 2) / np.sqrt(np.prod(factorial2(2 * angmom_comp_two - 1))), (2 * 0.02 / np.pi) ** (3 / 4) * (4 * 0.02) ** (2 / 2) / np.sqrt(np.prod(factorial2(2 * angmom_comp_two - 1))), ] ] ), ) for angmom_comp_two in test_two.angmom_components_cart ] for angmom_comp_one in test_one.angmom_components_cart ] ) assert np.allclose( np.squeeze(Overlap.construct_array_contraction(test_one, test_two)), np.squeeze(answer) ) with pytest.raises(TypeError): Overlap.construct_array_contraction(test_one, None) with pytest.raises(TypeError): Overlap.construct_array_contraction(None, test_two)
def assign_norm_cont(self): r"""Store the normalization constants of the contractions. .. math:: \int \phi_i(\mathbf{r}) \phi_i(\mathbf{r}) d\mathbf{r} &= N\\ \frac{1}{N} \int \phi_i(\mathbf{r}) \phi_i(\mathbf{r}) d\mathbf{r} &= 1\\ \int (\frac{1}{\sqrt{N}} \phi_i(\mathbf{r})) (\frac{1}{\sqrt{N}} \phi_i(\mathbf{r})) d\mathbf{r} &= 1\\ where :math:`\phi_i` is a contraction and :math:`N` is the norm of the contraction (without normalization). Notes ----- Since the `overlap` module also depends on this (`contractions`) module, if the `overlap` module is imported at the start of this module, there is a circular import error. Therefore, the overlap module must be imported within this method. """ from gbasis.integrals.overlap import Overlap # pylint: disable=R0401 self.norm_cont = np.einsum( "ijij->ij", Overlap.construct_array_contraction(self, self)) self.norm_cont **= -0.5