Пример #1
0
    def test_integrals_h2(self):
        """
        Test automatic integral evaluation for hydrogen molecule
        """

        # construct integrator object
        integrator = PyQInt()

        # build hydrogen molecule
        mol = Molecule()
        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')

        # evaluate all integrals
        ncpu = multiprocessing.cpu_count()
        S, T, V, teint = integrator.build_integrals(cgfs,
                                                    nuclei,
                                                    npar=ncpu,
                                                    verbose=False)

        # overlap integrals
        S_result = np.matrix([[1.0, 0.65931845], [0.65931845, 1.0]])

        # kinetic integrals
        T_result = np.matrix([[0.7600315809249878, 0.2364544570446014],
                              [0.2364544570446014, 0.7600315809249878]])

        # nuclear attraction integrals
        V1_result = np.matrix([[-1.2266135215759277, -0.5974172949790955],
                               [-0.5974172949790955, -0.6538270711898804]])
        V2_result = np.matrix([[-0.6538270711898804, -0.5974172949790955],
                               [-0.5974172949790955, -1.2266135215759277]])
        V_result = V1_result + V2_result

        # two-electron integrals
        T1111 = 0.7746056914329529
        T1122 = 0.5696758031845093
        T1112 = 0.4441076219081878
        T1212 = 0.2970285713672638

        # perform tests
        np.testing.assert_almost_equal(S, S_result, 4)
        np.testing.assert_almost_equal(T, T_result, 4)
        np.testing.assert_almost_equal(V, V_result, 4)
        np.testing.assert_almost_equal(teint[integrator.teindex(0, 0, 0, 0)],
                                       T1111, 4)
        np.testing.assert_almost_equal(teint[integrator.teindex(0, 0, 1, 1)],
                                       T1122, 4)
        np.testing.assert_almost_equal(teint[integrator.teindex(0, 0, 0, 1)],
                                       T1112, 4)
        np.testing.assert_almost_equal(teint[integrator.teindex(0, 1, 0, 1)],
                                       T1212, 4)
Пример #2
0
    def test_two_electron_indices(self):
        """
        Test unique two-electron indices
        """
        integrator = PyQInt()

        np.testing.assert_almost_equal(integrator.teindex(1, 1, 2, 1),
                                       integrator.teindex(1, 1, 1, 2), 4)
        np.testing.assert_almost_equal(integrator.teindex(1, 1, 2, 1),
                                       integrator.teindex(2, 1, 1, 1), 4)
        np.testing.assert_almost_equal(integrator.teindex(1, 2, 1, 1),
                                       integrator.teindex(2, 1, 1, 1), 4)
        np.testing.assert_almost_equal(integrator.teindex(1, 1, 1, 2),
                                       integrator.teindex(1, 1, 2, 1), 4)
        self.assertNotEqual(integrator.teindex(1, 1, 1, 1),
                            integrator.teindex(1, 1, 2, 1))
        self.assertNotEqual(integrator.teindex(1, 1, 2, 1),
                            integrator.teindex(1, 1, 2, 2))