Exemplo n.º 1
0
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)
Exemplo n.º 2
0
def test_overlap_cartesian():
    """Test gbasis.integrals.overlap.overlap_cartesian."""
    basis_dict = parse_nwchem(find_datafile("data_sto6g.nwchem"))
    basis = make_contractions(basis_dict, ["Kr"], np.array([[0, 0, 0]]))
    overlap_obj = Overlap(basis)
    assert np.allclose(
        overlap_obj.construct_array_cartesian(), overlap_integral(basis, coord_type="cartesian")
    )
Exemplo n.º 3
0
def test_overlap_lincomb():
    """Test gbasis.integrals.overlap.overlap_lincomb."""
    basis_dict = parse_nwchem(find_datafile("data_sto6g.nwchem"))
    basis = make_contractions(basis_dict, ["Kr"], np.array([[0, 0, 0]]))
    overlap_obj = Overlap(basis)
    transform = np.random.rand(14, 18)
    assert np.allclose(
        overlap_obj.construct_array_lincomb(transform, "spherical"),
        overlap_integral(basis, transform=transform, coord_type="spherical"),
    )
Exemplo n.º 4
0
def test_overlap_cartesian_norm_anorcc():
    """Test the norm of gbasis.integrals.overlap_cartesian on the ANO-RCC basis set.

    The contraction coefficients in ANO-RCC is such that the cartesian contractions are normalized.

    """
    basis_dict = parse_nwchem(find_datafile("data_anorcc.nwchem"))

    basis = make_contractions(basis_dict, ["Kr"], np.array([[0, 0, 0]]))
    overlap_obj = Overlap(basis)
    assert np.allclose(np.diag(overlap_obj.construct_array_cartesian()), 1)
Exemplo n.º 5
0
def test_overlap_cartesian_norm_sto6g():
    """Test the norm of gbasis.integrals.overlap_cartesian on the STO-6G basis set.

    The contraction coefficients in STO-6G is such that the Cartesian contractions are not
    normalized to past 3rd decimal places.

    """
    basis_dict = parse_nwchem(find_datafile("data_sto6g.nwchem"))

    basis = make_contractions(basis_dict, ["Kr"], np.array([[0, 0, 0]]))
    overlap_obj = Overlap(basis)
    assert np.allclose(np.diag(overlap_obj.construct_array_cartesian()), 1)
Exemplo n.º 6
0
    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