Beispiel #1
0
    def test_cgf_overlap(self):
        """
        Test kinetic integrals for contracted Gaussians

        Sij = <cgf_i | cgf_j>
        """

        # construct integrator object
        integrator = PyQInt()

        # build hydrogen molecule
        mol = Molecule("H2")
        mol.add_atom('H', 0.0, 0.0, 0.0)
        mol.add_atom('H', 0.0, 0.0, 1.4)
        cgfs, nuclei = mol.build_basis('sto3g')

        S = np.zeros((2, 2))
        S[0, 0] = integrator.overlap(cgfs[0], cgfs[0])
        S[0, 1] = S[1, 0] = integrator.overlap(cgfs[0], cgfs[1])
        S[1, 1] = integrator.overlap(cgfs[1], cgfs[1])

        S11 = 1.0
        S12 = 0.65931845
        np.testing.assert_almost_equal(S[0, 0], S11, 4)
        np.testing.assert_almost_equal(S[1, 1], S11, 4)
        np.testing.assert_almost_equal(S[0, 1], S12, 4)
Beispiel #2
0
def calculate_force_finite_difference(mol, nuc_id, cgf_id1, cgf_id2, coord):
    # build integrator object
    integrator = PyQInt()

    # distance
    diff = 0.00001

    mol1 = deepcopy(mol)
    mol1.atoms[nuc_id][1][coord] -= diff / 2
    mol2 = deepcopy(mol)
    mol2.atoms[nuc_id][1][coord] += diff / 2

    # build hydrogen molecule
    cgfs1, nuclei = mol1.build_basis('sto3g')
    left = integrator.overlap(cgfs1[cgf_id1], cgfs1[cgf_id2])
    cgfs2, nuclei = mol2.build_basis('sto3g')
    right = integrator.overlap(cgfs2[cgf_id1], cgfs2[cgf_id2])

    return (right - left) / diff