예제 #1
0
def test_electron_repulsion_cartesian_horton_custom_hhe():
    """Test electron_repulsion.electron_repulsion_cartesian against horton results.

    The test case is diatomic with H and He separated by 0.8 angstroms with basis set ANO-RCC
    modified. The basis set was modified to remove large exponent components to avoid overflow and
    some contractions for faster test.

    This test is also slow.

    """
    basis_dict = parse_nwchem(find_datafile("data_anorcc.nwchem"))
    coords = np.array([[0, 0, 0], [0.8, 0, 0]])
    basis = make_contractions(basis_dict, ["H", "He"], coords)
    basis = [HortonContractions(i.angmom, i.coord, i.coeffs[:, 0], i.exps) for i in basis[:8]]
    basis[0] = HortonContractions(
        basis[0].angmom, basis[0].coord, basis[0].coeffs[3:], basis[0].exps[3:]
    )
    basis[4] = HortonContractions(
        basis[4].angmom, basis[4].coord, basis[4].coeffs[4:], basis[4].exps[4:]
    )
    basis.pop(3)
    basis.pop(2)

    horton_elec_repulsion = np.load(find_datafile("data_horton_hhe_cart_elec_repulsion.npy"))
    assert np.allclose(
        horton_elec_repulsion, electron_repulsion_integral(basis, coord_type="cartesian")
    )
예제 #2
0
def test_electron_repulsion_mix():
    """Test gbasis.integrals.electron_repulsion.electron_repulsion_mix."""
    basis_dict = parse_nwchem(find_datafile("data_sto6g.nwchem"))
    basis = make_contractions(basis_dict, ["C"], np.array([[0, 0, 0]]))

    erep_obj = ElectronRepulsionIntegral(basis)
    assert np.allclose(
        erep_obj.construct_array_mix(["spherical"] * 3),
        electron_repulsion_integral(basis, notation="chemist", coord_type=["spherical"] * 3),
    )
    assert np.allclose(
        np.einsum("ijkl->ikjl", erep_obj.construct_array_mix(["spherical"] * 3)),
        electron_repulsion_integral(basis, notation="physicist", coord_type=["spherical"] * 3),
    )
    with pytest.raises(ValueError):
        electron_repulsion_integral(basis, notation="bad", coord_type=["spherical"] * 3)
예제 #3
0
    def two_electron_integrals(self):
        """Two electron integrals array

        Calculate and store the two electron integrals so that they are computed only once """
        if not isinstance(self._two_electron_integrals, np.ndarray):
            self._two_electron_integrals = electron_repulsion_integral(
                self._basis,
                transform=self._molecule.mo.coeffs.T,
                coord_type=self._coord_type,
                notation="chemist",
            )
        return self._two_electron_integrals
예제 #4
0
def test_electron_repulsion_cartesian_horton_sto6g_bec():
    """Test electron_repulsion.electron_repulsion_cartesian against horton results.

    The test case is diatomic with Be and C separated by 1.0 angstroms with basis set STO-6G. Note
    that ano-rcc was not used because it results in overflow in the _compute_two_electron_integrals.

    """
    basis_dict = parse_nwchem(find_datafile("data_sto6g.nwchem"))
    coords = np.array([[0, 0, 0], [1.0, 0, 0]])
    basis = make_contractions(basis_dict, ["Be", "C"], coords)
    basis = [HortonContractions(i.angmom, i.coord, i.coeffs, i.exps) for i in basis]

    horton_elec_repulsion = np.load(find_datafile("data_horton_bec_cart_elec_repulsion.npy"))
    assert np.allclose(
        horton_elec_repulsion, electron_repulsion_integral(basis, coord_type="cartesian")
    )
예제 #5
0
    rad_grid = BeckeTF(r0, Rad).transform_grid(onedgrid)
    molecule_at_grid = molecule_at_grid + [
        AtomicGrid.special_init(rad_grid, radii[i], degs=[deg], scales=[])
    ]
molgrid = MolGrid(molecule_at_grid, molecule.atnums)
alc_lda = Alchemical_tools(
    basis,
    molecule,
    point_charge_positions=R,
    point_charges_values=q,
    coord_type="cartesian",
    k="lda_x",
    molgrid=molgrid,
)
two_electron_int = electron_repulsion_integral(basis,
                                               transform=molecule.mo.coeffs.T,
                                               coord_type="cartesian",
                                               notation="chemist")
xc_function = pylibxc.LibXCFunctional("lda_x", "polarized")
a_dm = np.dot(molecule.mo.coeffsa * molecule.mo.occsa,
              molecule.mo.coeffsa.T.conj())
b_dm = np.dot(molecule.mo.coeffsb * molecule.mo.occsb,
              molecule.mo.coeffsb.T.conj())
a_density_values = evaluate_density(a_dm,
                                    basis,
                                    molgrid.points,
                                    coord_type="cartesian")
b_density_values = evaluate_density(b_dm,
                                    basis,
                                    molgrid.points,
                                    coord_type="cartesian")
inp = {"rho": np.array([a_density_values, b_density_values])}