예제 #1
0
    def test_cgf_kinetic(self):
        """
        Test kinetic integrals for contracted Gaussians

        Tij = <cgf_i | -1/2 nabla^{2} | 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')

        T = np.zeros((2, 2))
        T[0, 0] = integrator.kinetic(cgfs[0], cgfs[0])
        T[0, 1] = T[1, 0] = integrator.kinetic(cgfs[0], cgfs[1])
        T[1, 1] = integrator.kinetic(cgfs[1], cgfs[1])

        T11 = 0.7600315809249878
        T12 = 0.2364544570446014
        np.testing.assert_almost_equal(T[0, 0], T11, 4)
        np.testing.assert_almost_equal(T[1, 1], T11, 4)
        np.testing.assert_almost_equal(T[0, 1], T12, 4)
예제 #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.kinetic(cgfs1[cgf_id1], cgfs1[cgf_id2])
    cgfs2, nuclei = mol2.build_basis('sto3g')
    right = integrator.kinetic(cgfs2[cgf_id1], cgfs2[cgf_id2])

    return (right - left) / diff