Пример #1
0
 def test_nr_kuks_lda(self):
     mf = dft.KUKS(cell, cell.make_kpts([2,1,1]))
     mf.xc = 'lda,'
     mf = scf.newton(mf)
     mf.conv_tol_grad = 1e-4
     mf.kernel()
     self.assertAlmostEqual(mf.e_tot, -10.307756038726733, 8)
Пример #2
0
 def test_nr_uks_gga(self):
     mf = dft.UKS(cell)
     mf.xc = 'b88'
     mf = scf.newton(mf)
     mf.conv_tol_grad = 1e-4
     mf.kernel()
     self.assertAlmostEqual(mf.e_tot, -9.9355341416893559, 8)
Пример #3
0
 def test_nr_uks_lda(self):
     mf = dft.UKS(cell)
     mf.xc = 'lda'
     mf = scf.newton(mf)
     mf.conv_tol_grad = 1e-4
     mf.kernel()
     self.assertAlmostEqual(mf.e_tot, -9.7670882971475663, 8)
Пример #4
0
 def test_nr_kuks_gga(self):
     mf = dft.KUKS(cell, cell.make_kpts([2, 1, 1]))
     mf.xc = 'b88'
     mf = scf.newton(mf)
     mf.conv_tol_grad = 1e-4
     mf.kernel()
     self.assertAlmostEqual(mf.e_tot, -10.446717855794008, 8)
Пример #5
0
 def test_nr_rhf_k1(self):
     kpts = cell.make_kpts([2,1,1,])
     mf = scf.RHF(cell)
     mf.kpt = kpts[1]
     mf = scf.newton(mf)
     mf.conv_tol_grad = 1e-4
     mf.kernel()
     self.assertAlmostEqual(mf.e_tot, -11.336879498930173, 8)
Пример #6
0
 def test_uks_gen_g_hop(self):
     mf = dft.KUKS(cell, cell.make_kpts([2,1,1]))
     mf.xc = 'b3lyp'
     nao = cell.nao_nr()
     numpy.random.seed(1)
     mo = numpy.random.random((2,2,nao,nao)) + 0j
     mo_occ = numpy.zeros((2,2,nao))
     mo_occ[:,:,:5] = 1
     nocc, nvir = 5, nao-5
     dm1 = numpy.random.random(4*nvir*nocc) + .1j
     mf = scf.newton(mf)
     mf.grids.build()
     g, hop, hdiag = mf.gen_g_hop(mo, mo_occ, [mf.get_hcore()]*2)
     self.assertAlmostEqual(numpy.linalg.norm(hop(dm1)), 28.01954683540594, 7)
Пример #7
0
 def test_rks_gen_g_hop(self):
     mf = dft.KRKS(cell, cell.make_kpts([2,1,1]))
     mf.xc = 'b3lyp'
     nao = cell.nao_nr()
     numpy.random.seed(1)
     mo = numpy.random.random((2,nao,nao)) + 0j
     mo_occ = numpy.zeros((2,nao))
     mo_occ[:,:5] = 2
     nocc, nvir = 5, nao-5
     dm1 = numpy.random.random(2*nvir*nocc) + .1j
     mf = scf.newton(mf)
     mf.grids.build()
     g, hop, hdiag = mf.gen_g_hop(mo, mo_occ, mf.get_hcore())
     self.assertAlmostEqual(numpy.linalg.norm(hop(dm1)), 37.967972033738519, 7)
Пример #8
0
                    [numpy.dot(mo, u[k]) for k, mo in enumerate(mo_coeff)])

        return KRHF()


if __name__ == '__main__':
    import pyscf.pbc.gto as pbcgto
    import pyscf.pbc.scf as pscf
    cell = pbcgto.Cell()
    cell.atom = '''
    He 0 0 1
    He 1 0 1
    '''
    cell.basis = 'ccpvdz'
    cell.a = numpy.eye(3) * 4
    cell.gs = [8] * 3
    cell.verbose = 4
    cell.build()
    nks = [2, 1, 1]
    mf = pscf.KRHF(cell, cell.make_kpts(nks))
    mf.max_cycle = 2
    mf.kernel()
    mf.max_cycle = 5
    pscf.newton(mf).kernel()

    mf = pscf.KUHF(cell, cell.make_kpts(nks))
    mf.max_cycle = 2
    mf.kernel()
    mf.max_cycle = 5
    pscf.newton(mf).kernel()
Пример #9
0
              C     1.7834  1.7834  0.    
              C     2.6751  2.6751  0.8917
              C     1.7834  0.      1.7834
              C     2.6751  0.8917  2.6751
              C     0.      1.7834  1.7834
              C     0.8917  2.6751  2.6751''',
    basis='gth-szv',
    pseudo='gth-pade',
    gs=[10] * 3,
    verbose=4,
)

nk = [4, 4, 4]  # 4 k-poins for each axis, 4^3=64 kpts in total
kpts = cell.make_kpts(nk)

kmf = scf.KRHF(cell, kpts)
kmf.kernel()

kmf = dft.KRKS(cell, kpts)
# Turn to the atomic grids if you like
kmf.grids = dft.gen_grid.BeckeGrids(cell)
kmf.xc = 'm06'
kmf.kernel()

#
# Second order SCF solver (which is defined in pbc module) should be used
# in the k-point calculations
#
mf = scf.newton(scf.KRHF(cell, kpts))
mf.kernel()
Пример #10
0
    basis = '6-31g',
    verbose = 4,
)

mf = scf.RHF(cell).density_fit()
mf.kernel()

# Mixed density fitting is another option for all-electron calculations
mf = scf.RHF(cell).mix_density_fit()
mf.with_df.gs = [5]*3  # Tune #PWs in MDF for performance/accuracy balance
mf.kernel()

# Or use even-tempered Gaussian basis as auxiliary fitting functions.
# The following auxbasis is generated based on the expression
#    alpha = a * 1.7^i   i = 0..N
# where a and N are determined by the smallest and largest exponets of AO basis.
import pyscf.df
auxbasis = pyscf.df.aug_etb(cell, beta=1.7)
mf = scf.RHF(cell).density_fit(auxbasis=auxbasis)
mf.kernel()

#
# Second order SCF solver can be used in the PBC SCF code the same way in the
# molecular calculation
#
mf = dft.RKS(cell).density_fit(auxbasis='weigend')
mf.xc = 'bp86'
mf = scf.newton(mf)
mf.kernel()

Пример #11
0
        return KRHF()

if __name__ == '__main__':
    import pyscf.pbc.gto as pbcgto
    import pyscf.pbc.scf as pscf
    cell = pbcgto.Cell()
    cell.atom = '''
    He 0 0 1
    He 1 0 1
    '''
    cell.basis = 'ccpvdz'
    cell.a = numpy.eye(3) * 4
    cell.gs = [8] * 3
    cell.verbose = 4
    cell.build()
    nks = [2,1,1]
    mf = pscf.KRHF(cell, cell.make_kpts(nks))
    mf.max_cycle = 2
    mf.kernel()
    mf.max_cycle = 5
    pscf.newton(mf).kernel()

    mf = pscf.KUHF(cell, cell.make_kpts(nks))
    mf.max_cycle = 2
    mf.kernel()
    mf.max_cycle = 5
    pscf.newton(mf).kernel()


Пример #12
0
        [
            1,
            (0.4823830, 1.0000000),
        ],
    ],
}
cell.exp_to_discard = 0.1
cell.build()
cf = dft.RKS(cell)
cf.xc = 'pbe,pbe'
cf = cf.mix_density_fit()
cf.grids.level = 0

#gdf = df.GDF(cell)
#cf.with_df = gdf
cf.with_df.auxbasis = 'def2-universal-jkfit'
cf.diis_space = 10
cf.conv_tol = 0.0033
cf.conv_tol_grad = 1e-2
cf.level_shift = 0.25
cf.damp = 0.7
cf.kernel()
print("Switching to SOSCF and shutting down damping & levelshift")
cf.conv_tol = 1e-9
cf.conv_tol_grad = 1e-5
cf.level_shift = 0.0
cf.damp = 0.0
cf = scf.newton(cf)
ener = cf.kernel()
with open('CaF_Ag3.wfn', 'w') as f1:
    write_wfn(f1, cell, cf.mo_coeff, cf.mo_energy, cf.mo_occ, ener)
Пример #13
0
 def test_nr_uhf(self):
     mf = scf.UHF(cell)
     mf = scf.newton(mf)
     mf.conv_tol_grad = 1e-4
     mf.kernel()
     self.assertAlmostEqual(mf.e_tot, -10.137043711032916, 8)
Пример #14
0
 def test_nr_kuhf(self):
     mf = scf.KUHF(cell, cell.make_kpts([2, 1, 1]))
     mf = scf.newton(mf)
     mf.conv_tol_grad = 1e-4
     mf.kernel()
     self.assertAlmostEqual(mf.e_tot, -10.5309059210831, 8)
Пример #15
0
cell.basis = 'gth-szv'
cell.pseudo = 'gth-pade'
cell.gs = [10]*3  # 10 grids on postive x direction, => 21^3 grids in total
cell.verbose = 4
cell.build()

mf = scf.RHF(cell)
ehf = mf.kernel()
print("HF energy (per unit cell) = %.17g" % ehf)

mf = dft.RKS(cell)
mf.xc = 'm06'
edft = mf.kernel()
print("DFT energy (per unit cell) = %.17g" % edft)

#
# By default, DFT use uniform cubic grids.  It can be replaced by atomic grids.
#
mf = dft.RKS(cell)
mf.grids = dft.gen_grid.BeckeGrids(cell)
mf.xc = 'bp86'
mf.kernel()

#
# Second order SCF solver can be used in the PBC SCF code the same way in the
# molecular calculation
#
mf = scf.newton(scf.RHF(cell))
mf.kernel()

Пример #16
0
 def test_nr_krhf(self):
     mf = scf.KRHF(cell, cell.make_kpts([2, 1, 1]))
     mf = scf.newton(mf)
     mf.conv_tol_grad = 1e-4
     mf.kernel()
     self.assertAlmostEqual(mf.e_tot, -10.683267257972522, 8)