Beispiel #1
0
 def test_ragf2_outcore(self):
     # tests the out-of-core and chkfile support for AGF2 for H2O/cc-pvdz
     gf2 = agf2.RAGF2(self.mf)
     gf2.max_memory = 1
     gf2.incore_complete = False
     gf2.conv_tol = 1e-7
     gf2.run()
     e_ip, v_ip = self.gf2.ipagf2(nroots=1)
     e_ea, v_ea = self.gf2.eaagf2(nroots=1)
     v_ip = np.linalg.norm(v_ip)**2
     v_ea = np.linalg.norm(v_ea)**2
     self.assertAlmostEqual(gf2.e_1b, -75.89108074396137  , 6)
     self.assertAlmostEqual(gf2.e_2b, -0.33248785652834784, 6)
     self.assertAlmostEqual(e_ip,     0.45080222600137465 , 6)
     self.assertAlmostEqual(v_ip,     0.9704061235804103  , 6)
     self.assertAlmostEqual(e_ea,     0.15581330758457984 , 6)
     self.assertAlmostEqual(v_ea,     0.9903734898112396  , 6)
     gf2.dump_chk()
     gf2 = agf2.RAGF2(self.mf)
     gf2.__dict__.update(agf2.chkfile.load(gf2.chkfile, 'agf2'))
     e_ip, v_ip = self.gf2.ipagf2(nroots=1)
     e_ea, v_ea = self.gf2.eaagf2(nroots=1)
     v_ip = np.linalg.norm(v_ip)**2
     v_ea = np.linalg.norm(v_ea)**2
     self.assertAlmostEqual(gf2.e_1b, -75.89108074396137  , 6)
     self.assertAlmostEqual(gf2.e_2b, -0.33248785652834784, 6)
     self.assertAlmostEqual(e_ip,     0.45080222600137465 , 6)
     self.assertAlmostEqual(v_ip,     0.9704061235804103  , 6)
     self.assertAlmostEqual(e_ea,     0.15581330758457984 , 6)
     self.assertAlmostEqual(v_ea,     0.9903734898112396  , 6)
Beispiel #2
0
 def setUpClass(self):
     self.mol = gto.M(atom='O 0 0 0; H 0 0 1; H 0 1 0', basis='cc-pvdz', verbose=0)
     self.mf = scf.RHF(self.mol)
     self.mf.conv_tol = 1e-12
     self.mf.run()
     self.gf2 = agf2.RAGF2(self.mf)
     self.gf2.conv_tol = 1e-7
     self.gf2.run()
Beispiel #3
0
 def setUpClass(self):
     self.mol = gto.M(atom='O 0 0 0; H 0 0 1; H 0 1 0',
                      basis='cc-pvdz',
                      verbose=0)
     self.mf = scf.RHF(self.mol)
     self.mf.chkfile = tempfile.NamedTemporaryFile().name
     self.mf.conv_tol = 1e-12
     self.mf.run()
     self.gf2 = agf2.RAGF2(self.mf)
     self.gf2.conv_tol = 1e-7
     self.gf2.run()
Beispiel #4
0
    def test_ragf2_outcore(self):
        # tests the out-of-core and chkfile support for AGF2 for H2O/cc-pvdz
        gf2 = agf2.RAGF2(self.mf)
        gf2.max_memory = 1
        gf2.incore_complete = False
        gf2.conv_tol = 1e-7
        gf2.run()
        e_ip, v_ip = self.gf2.ipagf2(nroots=1)
        e_ea, v_ea = self.gf2.eaagf2(nroots=1)
        v_ip = np.linalg.norm(v_ip)**2
        v_ea = np.linalg.norm(v_ea)**2
        self.assertAlmostEqual(gf2.e_1b, -75.89108074396137, 6)
        self.assertAlmostEqual(gf2.e_2b, -0.33248785652834784, 6)
        self.assertAlmostEqual(e_ip, 0.45080222600137465, 6)
        self.assertAlmostEqual(v_ip, 0.9704061235804103, 6)
        self.assertAlmostEqual(e_ea, 0.15581330758457984, 6)
        self.assertAlmostEqual(v_ea, 0.9903734898112396, 6)
        gf2.dump_chk()
        with h5py.File(gf2.chkfile, 'r') as f:
            self.assertEqual(
                set(f['agf2'].keys()), {
                    'e_1b', 'e_2b', 'e_init', 'converged', 'mo_energy',
                    'mo_coeff', 'mo_occ', '_nmo', '_nocc', 'se', 'gf'
                })

        gf2 = agf2.RAGF2(self.mf)
        gf2.__dict__.update(agf2.chkfile.load(gf2.chkfile, 'agf2'))
        e_ip, v_ip = self.gf2.ipagf2(nroots=1)
        e_ea, v_ea = self.gf2.eaagf2(nroots=1)
        v_ip = np.linalg.norm(v_ip)**2
        v_ea = np.linalg.norm(v_ea)**2
        self.assertAlmostEqual(gf2.e_1b, -75.89108074396137, 6)
        self.assertAlmostEqual(gf2.e_2b, -0.33248785652834784, 6)
        self.assertAlmostEqual(e_ip, 0.45080222600137465, 6)
        self.assertAlmostEqual(v_ip, 0.9704061235804103, 6)
        self.assertAlmostEqual(e_ea, 0.15581330758457984, 6)
        self.assertAlmostEqual(v_ea, 0.9903734898112396, 6)
Beispiel #5
0
 def test_ragf2_frozen(self):
     # test the frozen implementation
     mf = scf.RHF(self.mol)
     mf.conv_tol = self.mf.conv_tol
     mf.run()
     gf2 = agf2.RAGF2(mf)
     gf2.conv_tol = 1e-7
     gf2.frozen = [2]
     gf2.run()
     e_ip, v_ip = gf2.ipagf2(nroots=1)
     e_ea, v_ea = gf2.eaagf2(nroots=1)
     v_ip = np.linalg.norm(v_ip)**2
     v_ea = np.linalg.norm(v_ea)**2
     self.assertAlmostEqual(gf2.e_1b, -75.90803303224045, 6)
     self.assertAlmostEqual(gf2.e_2b, -0.2378736532302642, 6)
     self.assertAlmostEqual(e_ip, 0.45937490994065694, 6)
     self.assertAlmostEqual(v_ip, 0.9726061540589924, 6)
     self.assertAlmostEqual(e_ea, 0.15201672352177295, 6)
     self.assertAlmostEqual(v_ea, 0.988560730917133, 6)
Beispiel #6
0
    def test_moments(self):
        # tests conservation of moments with compression
        mol = gto.M(atom='Li 0 0 0; H 0 0 1', basis='cc-pvdz', verbose=0)
        mf = scf.RHF(mol)
        mf.conv_tol = 1e-12
        mf.run()

        gf2 = agf2.RAGF2(mf, nmom=(3, 4)).run(max_cycle=3)
        eri = gf2.ao2mo()
        gf = gf2.gf
        gf_occ, gf_vir = gf.get_occupied(), gf.get_virtual()
        se_occ = agf2.ragf2_slow.build_se_part(gf2, eri, gf_occ, gf_vir)
        se_vir = agf2.ragf2_slow.build_se_part(gf2, eri, gf_vir, gf_occ)
        se = agf2.aux.combine(se_occ, se_vir)

        def count_correct_moms(a, b, tol=1e-9):
            n = 0
            while True:
                ma = a.moment(n)
                mb = b.moment(n)
                dif = (ma - mb) / np.mean(np.absolute(0.5 * (ma + mb)))
                err = np.linalg.norm(dif)
                if err < tol:
                    n += 1
                else:
                    break
            return n

        se_s3 = se.compress(phys=None, n=(None, 3))
        self.assertEqual(count_correct_moms(se, se_s3), 8)

        se_s4 = se.compress(phys=None, n=(None, 4))
        self.assertEqual(count_correct_moms(se, se_s4), 10)

        gf = se_s4.get_greens_function(eri.fock)
        se_g3 = se_s4.compress(phys=eri.fock, n=(3, None))
        gf_g3 = se_g3.get_greens_function(eri.fock)
        self.assertEqual(count_correct_moms(gf, gf_g3), 8)

        gf = se_s4.get_greens_function(eri.fock)
        se_g4 = se_s4.compress(phys=eri.fock, n=(4, None))
        gf_g4 = se_g4.get_greens_function(eri.fock)
        self.assertEqual(count_correct_moms(gf, gf_g4), 10)
Beispiel #7
0
 def test_ragf2_frozen_outcore(self):
     # test the frozen implementation with outcore QMOs
     mf = scf.RHF(self.mol)
     mf.conv_tol = self.mf.conv_tol
     mf.incore_complete = True
     mf.run()
     gf2 = agf2.RAGF2(mf)
     gf2.conv_tol = 1e-7
     gf2.frozen = [2]
     eri = gf2.ao2mo()
     gf2.max_memory = 1
     gf2.incore_complete = False
     gf2.kernel(eri=eri)
     e_ip, v_ip = gf2.ipagf2(nroots=1)
     e_ea, v_ea = gf2.eaagf2(nroots=1)
     v_ip = np.linalg.norm(v_ip)**2
     v_ea = np.linalg.norm(v_ea)**2
     self.assertAlmostEqual(gf2.e_1b, -75.90803303224045, 6)
     self.assertAlmostEqual(gf2.e_2b, -0.2378736532302642, 6)
     self.assertAlmostEqual(e_ip, 0.45937490994065694, 6)
     self.assertAlmostEqual(v_ip, 0.9726061540589924, 6)
     self.assertAlmostEqual(e_ea, 0.15201672352177295, 6)
     self.assertAlmostEqual(v_ea, 0.988560730917133, 6)