Пример #1
0
    def test_cgf_repulsion(self):
        """
        Test two-electron integrals for contracted Gaussians

        (ij|kl) = <cgf_i cgf_j | r_ij | cgf_k cgf_l>
        """

        # 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')

        T1111 = integrator.repulsion(cgfs[0], cgfs[0], cgfs[0], cgfs[0])
        T1122 = integrator.repulsion(cgfs[0], cgfs[0], cgfs[1], cgfs[1])
        T1112 = integrator.repulsion(cgfs[0], cgfs[0], cgfs[0], cgfs[1])
        T2121 = integrator.repulsion(cgfs[1], cgfs[0], cgfs[1], cgfs[0])
        T1222 = integrator.repulsion(cgfs[0], cgfs[1], cgfs[1], cgfs[1])
        T2211 = integrator.repulsion(cgfs[1], cgfs[1], cgfs[0], cgfs[0])

        np.testing.assert_almost_equal(T1111, 0.7746056914329529, 4)
        np.testing.assert_almost_equal(T1122, 0.5696758031845093, 4)
        np.testing.assert_almost_equal(T1112, 0.4441076656879812, 4)
        np.testing.assert_almost_equal(T2121, 0.2970285713672638, 4)

        # test similarity between two-electron integrals
        np.testing.assert_almost_equal(T1222, T1112, 4)
        np.testing.assert_almost_equal(T1122, T2211, 4)
Пример #2
0
def calculate_force_finite_difference(mol, nuc_id, cgf_id1, cgf_id2, cgf_id3,
                                      cgf_id4, 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.repulsion(cgfs1[cgf_id1], cgfs1[cgf_id2], cgfs1[cgf_id3],
                                cgfs1[cgf_id4])
    cgfs2, nuclei = mol2.build_basis('sto3g')
    right = integrator.repulsion(cgfs2[cgf_id1], cgfs2[cgf_id2],
                                 cgfs2[cgf_id3], cgfs2[cgf_id4])

    return (right - left) / diff