Esempio n. 1
0
    def test_init(self):
        from pyscf.pbc import dft
        cell_u = cell.copy()
        cell_u.spin = 2
        self.assertTrue(isinstance(pscf.RKS  (cell  ), dft.rks.RKS    ))
        self.assertTrue(isinstance(pscf.RKS  (cell_u), dft.roks.ROKS  ))
        self.assertTrue(isinstance(pscf.UKS  (cell  ), dft.uks.UKS    ))
        self.assertTrue(isinstance(pscf.ROKS (cell  ), dft.roks.ROKS  ))
        self.assertTrue(isinstance(pscf.KS   (cell  ), dft.rks.RKS    ))
        self.assertTrue(isinstance(pscf.KS   (cell_u), dft.uks.UKS    ))
        self.assertTrue(isinstance(pscf.KRKS (cell  ), dft.krks.KRKS  ))
        self.assertTrue(isinstance(pscf.KRKS (cell_u), dft.krks.KRKS  ))
        self.assertTrue(isinstance(pscf.KUKS (cell  ), dft.kuks.KUKS  ))
        self.assertTrue(isinstance(pscf.KROKS(cell  ), dft.kroks.KROKS))
        self.assertTrue(isinstance(pscf.KKS  (cell  ), dft.krks.KRKS  ))
        self.assertTrue(isinstance(pscf.KKS  (cell_u), dft.kuks.KUKS  ))

        self.assertTrue(isinstance(pscf.RHF  (cell  ), pscf.hf.RHF     ))
        self.assertTrue(isinstance(pscf.RHF  (cell_u), pscf.rohf.ROHF  ))
        self.assertTrue(isinstance(pscf.KRHF (cell  ), pscf.khf.KRHF   ))
        self.assertTrue(isinstance(pscf.KRHF (cell_u), pscf.khf.KRHF   ))
        self.assertTrue(isinstance(pscf.UHF  (cell  ), pscf.uhf.UHF    ))
        self.assertTrue(isinstance(pscf.KUHF (cell_u), pscf.kuhf.KUHF  ))
        self.assertTrue(isinstance(pscf.GHF  (cell  ), pscf.ghf.GHF    ))
        self.assertTrue(isinstance(pscf.KGHF (cell_u), pscf.kghf.KGHF  ))
        self.assertTrue(isinstance(pscf.ROHF (cell  ), pscf.rohf.ROHF  ))
        self.assertTrue(isinstance(pscf.ROHF (cell_u), pscf.rohf.ROHF  ))
        self.assertTrue(isinstance(pscf.KROHF(cell  ), pscf.krohf.KROHF))
        self.assertTrue(isinstance(pscf.KROHF(cell_u), pscf.krohf.KROHF))
        self.assertTrue(isinstance(pscf.HF   (cell  ), pscf.hf.RHF     ))
        self.assertTrue(isinstance(pscf.HF   (cell_u), pscf.uhf.UHF    ))
        self.assertTrue(isinstance(pscf.KHF  (cell  ), pscf.khf.KRHF   ))
        self.assertTrue(isinstance(pscf.KHF  (cell_u), pscf.kuhf.KUHF  ))
Esempio n. 2
0
    def test_h4_fcc_k2_frozen_high_cost(self):
        '''Metallic hydrogen fcc lattice with frozen lowest lying occupied
        and highest lying virtual orbitals.  Checks versus a corresponding
        supercell calculation.

        NOTE: different versions of the davidson may converge to a different
        solution for the k-point IP/EA eom.  If you're getting the wrong
        root, check to see if it's contained in the supercell set of
        eigenvalues.'''
        cell = build_h_cell()

        nmp = [2, 1, 1]

        kmf = pbcscf.KRHF(cell)
        kmf.kpts = cell.make_kpts(nmp, scaled_center=[0.0, 0.0, 0.0])
        e = kmf.kernel()

        frozen = [[0, 3], []]
        mymp = pyscf.pbc.mp.kmp2.KMP2(kmf, frozen=frozen)
        ekmp2, _ = mymp.kernel()
        self.assertAlmostEqual(ekmp2, -0.022416773725207319, 6)
        self.assertAlmostEqual(mymp.e_tot, 2.155470531550681, 6)

        # Start of supercell calculations
        from pyscf.pbc.tools.pbc import super_cell
        supcell = super_cell(cell, nmp)
        supcell.build()
        mf = pbcscf.KRHF(supcell)
        e = mf.kernel()

        mysmp = pyscf.pbc.mp.kmp2.KMP2(mf, frozen=[0, 7])
        emp2, _ = mysmp.kernel()
        emp2 /= np.prod(nmp)
        self.assertAlmostEqual(emp2, -0.022416773725207319, 6)
Esempio n. 3
0
    def test_rccsd_t_hf_against_so(self):
        '''Tests restricted ccsd and ccsd_t for Hartree-Fock references against
        the general spin-orbital implementation.'''
        n = 7
        cell = make_test_cell.test_cell_n3([n] * 3)
        #import sys
        #cell.stdout = sys.stdout
        #cell.verbose = 7

        nk = [2, 1, 1]
        kpts = cell.make_kpts(nk)
        kpts -= kpts[0]
        kks = pbcscf.KRHF(cell, kpts=kpts)
        ekks = kks.kernel()

        khf = pbcscf.KRHF(cell)
        khf.__dict__.update(kks.__dict__)

        mycc = pbcc.KGCCSD(khf, frozen=None)
        eris = mycc.ao2mo()
        ekgcc, t1, t2 = mycc.kernel(eris=eris)
        ekgcc_t = mycc.ccsd_t(eris=eris)

        mycc = pbcc.KRCCSD(khf, frozen=None)
        eris = mycc.ao2mo()
        ekrcc, t1, t2 = mycc.kernel(eris=eris)
        ekrcc_t = mycc.ccsd_t(eris=eris)

        self.assertAlmostEqual(ekrcc_t, -0.0021667871077339, 6)
        self.assertAlmostEqual(ekrcc_t, ekgcc_t, 6)
Esempio n. 4
0
    def test_h4_fcc_k2_frozen(self):
        '''Metallic hydrogen fcc lattice with frozen lowest lying occupied
        and highest lying virtual orbitals.  Checks versus a corresponding
        supercell calculation.

        NOTE: different versions of the davidson may converge to a different
        solution for the k-point IP/EA eom.  If you're getting the wrong
        root, check to see if it's contained in the supercell set of
        eigenvalues.'''
        cell = pbcgto.Cell()
        cell.atom = [['H', (0.000000000, 0.000000000, 0.000000000)],
                     ['H', (0.000000000, 0.500000000, 0.250000000)],
                     ['H', (0.500000000, 0.500000000, 0.500000000)],
                     ['H', (0.500000000, 0.000000000, 0.750000000)]]
        cell.unit = 'Bohr'
        cell.a = [[1., 0., 0.], [0., 1., 0], [0, 0, 2.2]]
        cell.verbose = 7
        cell.spin = 0
        cell.charge = 0
        cell.basis = [
            [0, [1.0, 1]],
        ]
        cell.pseudo = 'gth-pade'
        cell.output = '/dev/null'
        cell.max_memory = 1000
        for i in range(len(cell.atom)):
            cell.atom[i][1] = tuple(
                np.dot(np.array(cell.atom[i][1]), np.array(cell.a)))
        cell.build()

        nmp = [2, 1, 1]

        kmf = pbcscf.KRHF(cell)
        kmf.kpts = cell.make_kpts(nmp, scaled_center=[0.0, 0.0, 0.0])
        e = kmf.kernel()

        frozen = [[0, 3], []]
        mymp = pyscf.pbc.mp.kmp2.KMP2(kmf, frozen=frozen)
        ekmp2, _ = mymp.kernel()
        self.assertAlmostEqual(ekmp2, -0.022416773725207319, 6)
        self.assertAlmostEqual(mymp.e_tot, 2.155470531550681, 6)

        # Start of supercell calculations
        from pyscf.pbc.tools.pbc import super_cell
        supcell = super_cell(cell, nmp)
        supcell.build()
        mf = pbcscf.KRHF(supcell)
        e = mf.kernel()

        mysmp = pyscf.pbc.mp.kmp2.KMP2(mf, frozen=[0, 7])
        emp2, _ = mysmp.kernel()
        emp2 /= np.prod(nmp)
        self.assertAlmostEqual(emp2, -0.022416773725207319, 6)
Esempio n. 5
0
    def test_kmp2_with_cderi(self):
        nk = (1, 1, 1)
        abs_kpts = cell.make_kpts(nk, wrap_around=True)
        kmf = pbcscf.KRHF(cell, abs_kpts).density_fit()
        kmf.conv_tol = 1e-12
        ekpt = kmf.scf()
        kmf2 = pbcscf.KRHF(cell, abs_kpts).density_fit()
        kmf2.conv_tol = 1e-12
        kmf2.with_df._cderi = kmf.with_df._cderi
        ekpt2 = kmf2.scf()
        mp = pyscf.pbc.mp.kmp2.KMP2(kmf2).run()

        self.assertAlmostEqual(ekpt2, -1.2053666821021261, 9)
        self.assertAlmostEqual(mp.e_corr, -6.9881475423322723e-06, 9)
Esempio n. 6
0
    def test_n3_ee(self):
        n = 15
        cell_n3 = make_test_cell.test_cell_n3([n] * 3)
        kmf_n3 = pbcscf.KRHF(cell_n3,
                             cell_n3.make_kpts([2, 1, 1]),
                             exxdiv=None)
        kmf_n3.kernel()
        kmf_n3_ewald = pbcscf.KRHF(cell_n3,
                                   cell_n3.make_kpts([2, 1, 1]),
                                   exxdiv='ewald')
        kmf_n3_ewald.kernel()
        ehf_bench = [-8.651923514149, -10.530905169078]
        ecc_bench = [-0.155298299344, -0.093617975270]

        ekrhf = kmf_n3.e_tot
        self.assertAlmostEqual(ekrhf, ehf_bench[0], 3)
        ekrhf = kmf_n3_ewald.e_tot
        self.assertAlmostEqual(ekrhf, ehf_bench[1], 3)

        mycc = pbcc.KRCCSD(kmf_n3)
        ekrcc, t1, t2 = mycc.kernel()
        self.assertAlmostEqual(ekrcc, ecc_bench[0], 3)
        mycc_ewald = pbcc.KRCCSD(kmf_n3_ewald)
        mycc_ewald.keep_exxdiv = True
        ekrcc, t1, t2 = mycc_ewald.kernel()
        self.assertAlmostEqual(ekrcc, ecc_bench[1], 3)

        # EOM-EE-KRCCSD singlet
        from pyscf.pbc.cc import eom_kccsd_rhf as eom_krccsd
        nroots = 2  # number of roots requested

        myeomee = eom_krccsd.EOMEESinglet(mycc)
        myeomee.max_space = nroots * 10
        eee, vee = myeomee.kernel(nroots=nroots, kptlist=[0])
        self.assertAlmostEqual(eee[0][0], 0.267867075425, 3)
        self.assertAlmostEqual(eee[0][1], 0.268704338187, 3)
        eee, vee = myeomee.kernel(nroots=nroots, kptlist=[1])
        self.assertAlmostEqual(eee[0][0], 0.389795492091, 3)
        self.assertAlmostEqual(eee[0][1], 0.407782858154, 3)

        myeomee = eom_krccsd.EOMEESinglet(mycc_ewald)
        myeomee.max_space = nroots * 10
        eee, vee = myeomee.kernel(nroots=nroots, kptlist=[0])
        self.assertAlmostEqual(eee[0][0], 0.707047835495, 3)
        self.assertAlmostEqual(eee[0][1], 0.707047835495, 3)
        eee, vee = myeomee.kernel(nroots=nroots, kptlist=[1])
        self.assertAlmostEqual(eee[0][0], 0.815872164169, 3)
        self.assertAlmostEqual(eee[0][1], 0.845417271088, 3)
Esempio n. 7
0
    def test_rdm1(self):
        cell = pbcgto.Cell()
        cell.atom = '''Al 0 0 0'''
        cell.basis = 'gth-szv'
        cell.pseudo = 'gth-pade'
        cell.a = '''
        2.47332919 0 1.42797728
        0.82444306 2.33187713 1.42797728
        0, 0, 2.85595455
        '''
        cell.unit = 'angstrom'
        cell.spin = 1
        cell.build()
        cell.verbose = 4
        cell.incore_anyway = True

        abs_kpts = cell.make_kpts((2, 1, 1), scaled_center=(.1, .2, .3))
        kmf = pbcscf.KRHF(cell, abs_kpts)
        kmf.conv_tol = 1e-12
        kmf.kernel()
        mp = pyscf.pbc.mp.kmp2.KMP2(kmf)
        mp.kernel(with_t2=True)
        self.assertAlmostEqual(mp.e_corr, -0.00162057921874043, 6)
        dm = mp.make_rdm1()
        np.testing.assert_allclose(np.trace(dm[0]) + np.trace(dm[1]), 6)
        for kdm in dm:
            np.testing.assert_allclose(kdm, kdm.conj().T)
Esempio n. 8
0
def make_cell(d, kmesh):
    a = np.eye(3)
    a[0,0] = 10
    a[1,1] = 10
    a[2,2] = 2*d
    atoms = [['H',[5,5,0.25*a[2,2]+0.5]],['H',[5,5,0.75*a[2,2]-0.5]]]
    cell = gto.Cell()
    cell.atom = atoms
    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.a = a
    cell.verbose = 5
    cell.build()

    kpts = cell.make_kpts(kmesh,wrap_around=True)
    krhf = scf.KRHF(cell, kpts).density_fit()
    gdf = df.GDF(cell, kpts)
    gdf._cderi_to_save = 'gdf.h5'
    gdf.build()
    krhf.with_df._cderi = 'gdf.h5'
    krhf.exxdiv = None
    krhf.run()

    num_wann =2
    keywords = \
    '''
    begin projections
    H:s
    end projections
    num_iter = 100 
    '''
    w90 = pywannier90.W90(krhf, cell, kmesh, num_wann, other_keywords = keywords)
    w90.kernel()
    w90.plot_wf(grid=[20,20,20], supercell=kmesh)
    return cell, krhf, w90
Esempio n. 9
0
    def setUpClass(cls):
        cls.cell = gto.Cell()
        cls.cell.atom = '''Al 0 0 0'''
        cls.cell.basis = 'gth-szv'
        cls.cell.pseudo = 'gth-pade'
        cls.cell.a = '''
        2.47332919 0 1.42797728
        0.82444306 2.33187713 1.42797728
        0 0 2.85595455
        '''
        cls.cell.unit = 'angstrom'
        cls.cell.build()
        cls.cell.verbose = 4
        cls.cell.incore_anyway = True
        cls.cell.max_memory = 20e3

        cls.mf = scf.KRHF(cls.cell, kpts=cls.cell.make_kpts([2, 2, 2], scaled_center=(.1, .2, .3)))
        cls.mf.chkfile = 'test_kgf_proper_rhf_al2_chk.dat'
        if os.path.exists(cls.mf.chkfile):
            cls.mf.update()
        else:
            cls.mf.kernel()

        cls.ccsd = cc.KRCCSD(cls.mf)
        cls.ccsd.kernel()
        # TODO: lambda iterations
        cls.ccsd.l1 = cls.ccsd.t1
        cls.ccsd.l2 = cls.ccsd.t2
        cls.eip, cls.ip_vecs = cls.ccsd.ipccsd(nroots=2)
        cls.eea, cls.ea_vecs = cls.ccsd.eaccsd(nroots=2)

        cls.energies = numpy.linspace(-1, 1.3, 100)
        cls.eta = 0.04
        cls.title = "Al-2"
        cls.options = ("td",)
Esempio n. 10
0
    def test_rccsd_t_non_hf_against_so_frozen(self):
        '''Tests rccsd_t with gccsd_t with frozen orbitals.'''
        n = 7
        cell = make_test_cell.test_cell_n3([n] * 3)
        #import sys
        #cell.stdout = sys.stdout
        #cell.verbose = 7

        nk = [2, 1, 1]
        kpts = cell.make_kpts(nk)
        kpts -= kpts[0]
        kks = pbcscf.KRKS(cell, kpts=kpts)
        ekks = kks.kernel()

        khf = pbcscf.KRHF(cell)
        khf.__dict__.update(kks.__dict__)

        mycc = pbcc.KGCCSD(khf, frozen=[[], [0, 1]])
        eris = mycc.ao2mo()
        ekgcc, t1, t2 = mycc.kernel(eris=eris)
        ekgcc_t = mycc.ccsd_t(eris=eris)

        mycc = pbcc.KRCCSD(khf, frozen=[[], [0]])
        eris = mycc.ao2mo()
        ekrcc, t1, t2 = mycc.kernel(eris=eris)
        ekrcc_t = mycc.ccsd_t(eris=eris)

        self.assertAlmostEqual(ekrcc_t, -0.0018712836246782309, 6)
        self.assertAlmostEqual(ekrcc_t, ekgcc_t, 6)
Esempio n. 11
0
 def test_aft_bands(self):
     mf = scf.KRHF(cell)
     mf.with_df = df.AFTDF(cell)
     mf.kpts = cell.make_kpts([2]*3)
     mf.kernel()
     self.assertAlmostEqual(finger(mf.get_bands(kband[0])[0]), -0.32214958122356513, 9)
     self.assertAlmostEqual(finger(mf.get_bands(kband)[0]), -0.64207984898611348, 9)
Esempio n. 12
0
def run_kcell(cell, nk):
    abs_kpts = cell.make_kpts(nk, wrap_around=True)
    kmf = pbchf.KRHF(cell, abs_kpts, exxdiv=None)
    kmf.conv_tol = 1e-12
    ekpt = kmf.scf()
    mp = pyscf.pbc.mp.kmp2.KMP2(kmf).run()
    return ekpt, mp.e_corr
Esempio n. 13
0
def KRHF(cell, OEI, TEI, nelectron, kpts, DMguess, verbose=0, max_cycle=10):
    '''KRHF wrapper to solve for 1RDM with a certain umat'''

    from pyscf.pbc import gto, scf
    import warnings
    nkpts = kpts.shape[0]

    def get_veff(cell=None, dm_kpts=None, *args):
        '''Function to compute veff from ERI'''
        delta = np.eye(nkpts)
        weight = 1 / nkpts
        vj = weight * lib.einsum('ijkpqrs,ksr,ij->ipq', TEI, dm_kpts, delta)
        vk = weight * lib.einsum('ijkpqrs,jqr,jk->ips', TEI, dm_kpts, delta)
        veff = vj - 0.5 * vk
        return veff

    nao = OEI.shape[1]
    cell.atom = [['He', (0.5, 0.5, 0.5)]]
    cell.incore_anyway = True
    cell.nelectron = nelectron
    kmf = scf.KRHF(cell, kpts, exxdiv=None)
    kmf.get_hcore = lambda *args: OEI
    kmf.get_ovlp = lambda *args: np.array([np.eye(nao)] * nkpts)
    kmf.get_veff = get_veff
    kmf.max_cycle = max_cycle
    kmf.run(DMguess)
    dms = kmf.make_rdm1()

    return dms
Esempio n. 14
0
def run_kcell(cell, ngs, nk):
    #############################################
    # Do a k-point calculation                  #
    #############################################
    abs_kpts = cell.make_kpts(nk, wrap_around=True)

    #############################################
    # Running HF                                #
    #############################################
    #    print ""
    #    print "*********************************"
    #    print "STARTING HF                      "
    #    print "*********************************"
    #    print ""
    kmf = pbchf.KRHF(cell, abs_kpts, exxdiv=None)
    kmf.conv_tol = 1e-14
    #kmf.verbose = 7
    ekpt = kmf.scf()
    #    print "scf energy (per unit cell) = %.17g" % ekpt

    #############################################
    # Running CCSD                              #
    #############################################
    #    print ""
    #    print "*********************************"
    #    print "STARTING CCSD                    "
    #    print "*********************************"
    #    print ""

    cc = pyscf.pbc.cc.kccsd_rhf.RCCSD(kmf)
    cc.conv_tol = 1e-8
    cc.verbose = 7
    ecc, t1, t2 = cc.kernel()
    #    print "cc energy (per unit cell) = %.17g" % ecc
    return ekpt, ecc
Esempio n. 15
0
 def test_aft_bands(self):
     mf = scf.KRHF(cell)
     mf.with_df = df.AFTDF(cell)
     mf.kpts = cell.make_kpts([2,1,1])
     mf.kernel()
     self.assertAlmostEqual(finger(mf.get_bands(kband[0])[0]), 1.968506055533682, 8)
     self.assertAlmostEqual(finger(mf.get_bands(kband)[0]), 1.0538585525613609, 7)
Esempio n. 16
0
    def test_ccsd_t_high_cost(self):
        n = 14
        cell = make_test_cell.test_cell_n3([n] * 3)

        kpts = cell.make_kpts([1, 1, 2])
        kpts -= kpts[0]
        kmf = pbcscf.KRHF(cell, kpts=kpts, exxdiv=None)
        ehf = kmf.kernel()

        mycc = pbcc.KGCCSD(kmf)
        eris = mycc.ao2mo()
        ecc, t1, t2 = mycc.kernel(eris=eris)

        eris.mo_energy = [eris.fock[i].diagonal() for i in range(len(kpts))]
        energy_t = kccsd_t.kernel(mycc, eris=eris)
        energy_t_bench = -0.00191440345386
        self.assertAlmostEqual(energy_t, energy_t_bench, 6)

        mycc = pbcc.KGCCSD(kmf, frozen=2)
        eris = mycc.ao2mo()
        ecc, t1, t2 = mycc.kernel(eris=eris)

        #eris.mo_energy = [eris.fock[i].diagonal() for i in range(len(kpts))]
        energy_t = kccsd_t.kernel(mycc, eris=eris)
        energy_t_bench = -0.0006758542603695721
        self.assertAlmostEqual(energy_t, energy_t_bench, 6)
Esempio n. 17
0
 def test_mdf_bands_high_cost(self):
     mf = scf.KRHF(cell)
     mf.with_df = df.MDF(cell).set(auxbasis='weigend')
     mf.with_df.kpts_band = kband
     mf.kpts = cell.make_kpts([2,1,1])
     mf.kernel()
     self.assertAlmostEqual(finger(mf.get_bands(kband[0])[0]), 1.9685060546389677, 7)
     self.assertAlmostEqual(finger(mf.get_bands(kband)[0]), 1.0538585514926302, 8)
Esempio n. 18
0
 def test_mdf_bands(self):
     mf = scf.KRHF(cell)
     mf.with_df = df.MDF(cell)
     mf.with_df.kpts_band = kband
     mf.kpts = cell.make_kpts([2]*3)
     mf.kernel()
     self.assertAlmostEqual(finger(mf.get_bands(kband[0])[0]), -0.32205954835271078, 9)
     self.assertAlmostEqual(finger(mf.get_bands(kband)[0]), -0.64209375063268592, 9)
Esempio n. 19
0
    def test_khf_stability(self):
        kmf = pscf.KRHF(cell, kpts, exxdiv='ewald').run(conv_tol=1e-12)
        mo_i, mo_e = kmf.stability(internal=True, external=True)
        self.assertAlmostEqual(abs(kmf.mo_coeff[0]-mo_i[0]).max(), 0, 9)

        hop2, hdiag2 = stability._gen_hop_rhf_external(kmf)
        self.assertAlmostEqual(lib.fp(hdiag2), 18.528134783454508, 7)
        self.assertAlmostEqual(lib.fp(hop2(hdiag2)), 108.99683506471919, 5)
Esempio n. 20
0
 def test_fft_bands(self):
     mf = scf.KRHF(cell)
     mf.kpts = cell.make_kpts([2] * 3)
     mf.kernel()
     self.assertAlmostEqual(finger(mf.get_bands(kband[0])[0]),
                            -0.26538705237640059, 8)
     self.assertAlmostEqual(finger(mf.get_bands(kband)[0]),
                            -0.65622644106336381, 8)
Esempio n. 21
0
 def test_df_bands(self):
     mf = scf.KRHF(cell)
     mf.with_df = df.DF(cell)
     mf.with_df.kpts_band = kband
     mf.kpts = cell.make_kpts([2]*3)
     mf.kernel()
     self.assertAlmostEqual(finger(mf.get_bands(kband[0])[0]), -0.32200476157045782, 9)
     self.assertAlmostEqual(finger(mf.get_bands(kband)[0]), -0.64216552168395347, 9)
Esempio n. 22
0
def run_kcell(cell, nk):
    abs_kpts = cell.make_kpts(nk, wrap_around=True)
    kmf = pbcscf.KRHF(cell, abs_kpts)
    kmf = remove_linear_dep_(kmf, threshold=1e-5, lindep=1e-6)
    kmf.conv_tol = 1e-12
    ekpt = kmf.scf()
    mp = pyscf.pbc.mp.kmp2.KMP2(kmf).run()
    return ekpt, mp.e_corr
Esempio n. 23
0
def run_kcell_complex(cell, nk):
    abs_kpts = cell.make_kpts(nk, wrap_around=True)
    kmf = pbcscf.KRHF(cell, abs_kpts)
    kmf.conv_tol = 1e-12
    ekpt = kmf.scf()
    kmf.mo_coeff = [kmf.mo_coeff[i].astype(np.complex128) for i in range(np.prod(nk))]
    mp = pyscf.pbc.mp.kmp2.KMP2(kmf).run()
    return ekpt, mp.e_corr
Esempio n. 24
0
 def test_fft_bands(self):
     mf = scf.KRHF(cell)
     mf.kpts = cell.make_kpts([2] * 3)
     mf.kernel()
     self.assertAlmostEqual(lib.fp(mf.get_bands(kband[0])[0]),
                            1.758544475679261, 8)
     self.assertAlmostEqual(lib.fp(mf.get_bands(kband)[0]),
                            0.76562781841701533, 7)
Esempio n. 25
0
 def test_df_bands(self):
     mf = scf.KRHF(cell)
     mf.with_df = df.DF(cell).set(auxbasis='weigend')
     mf.with_df.kpts_band = kband
     mf.with_df.exp_to_discard = mf.with_df.eta
     mf.kpts = cell.make_kpts([2,1,1])
     mf.kernel()
     self.assertAlmostEqual(finger(mf.get_bands(kband[0])[0]), 1.9648945030342437, 8)
     self.assertAlmostEqual(finger(mf.get_bands(kband)[0]), 1.0455025876245683, 7)
Esempio n. 26
0
    def test_krhf_grad(self):
        g_scan = scf.KRHF(cell, kpts, exxdiv=None).nuc_grad_method().as_scanner()
        g = g_scan(cell)[1]
        self.assertAlmostEqual(finger(g), 0.11476575559553441, 6)

        mfs = g_scan.base.as_scanner()
        e1 = mfs([['C', [0.0, 0.0, 0.0]], ['C', [1.685068664391,1.685068664391,1.685068664391+disp/2.0]]])
        e2 = mfs([['C', [0.0, 0.0, 0.0]], ['C', [1.685068664391,1.685068664391,1.685068664391-disp/2.0]]])
        self.assertAlmostEqual(g[1,2], (e1-e2)/disp, 6)
Esempio n. 27
0
 def test_small_system(self):
     mol = pbcgto.Cell(atom='He 0 0 0;',
                       a=[[3, 0, 0], [0, 3, 0], [0, 0, 3]],
                       basis=[[0, [1, 1]]],
                       verbose=7,
                       output='/dev/null')
     mf = pscf.KRHF(mol, kpts=[[0., 0., 0.]])
     mf.run()
     self.assertAlmostEqual(mf.e_tot, -2.2719576422665635, 8)
Esempio n. 28
0
 def test_df_bands(self):
     mf = scf.KRHF(cell)
     mf.with_df = df.DF(cell).set(auxbasis='weigend')
     mf.with_df.kpts_band = kband
     mf.kpts = cell.make_kpts([2, 1, 1])
     mf.kernel()
     self.assertAlmostEqual(finger(mf.get_bands(kband[0])[0]),
                            1.9630519740658308, 8)
     self.assertAlmostEqual(finger(mf.get_bands(kband)[0]),
                            1.04461751922109, 8)
Esempio n. 29
0
 def test_mdf_bands(self):
     mf = scf.KRHF(cell)
     mf.with_df = df.MDF(cell).set(auxbasis='weigend')
     mf.with_df.kpts_band = kband
     mf.kpts = cell.make_kpts([2] * 3)
     mf.kernel()
     self.assertAlmostEqual(finger(mf.get_bands(kband[0])[0]),
                            -0.32205949082575414, 7)
     self.assertAlmostEqual(finger(mf.get_bands(kband)[0]),
                            -0.6420939191777898, 8)
Esempio n. 30
0
 def test_khf(self):
     with lib.light_speed(2) as c:
         mf = scf.KRHF(cell).sfx2c1e()
         mf.with_df = df.AFTDF(cell)
         mf.kpts = cell.make_kpts([3,1,1])
         dm = mf.get_init_guess()
         h1 = mf.get_hcore()
         self.assertAlmostEqual(numpy.einsum('ij,ji', dm[0], h1[0]),-0.47578184212352159+0j, 8)
         self.assertAlmostEqual(numpy.einsum('ij,ji', dm[1], h1[1]),-0.09637799091491725+0j, 8)
         self.assertAlmostEqual(numpy.einsum('ij,ji', dm[2], h1[2]),-0.09637799091491725+0j, 8)