Esempio n. 1
0
    def test_get_eri_gamma_1(self):
        odf = mdf.MDF(cell1)
        odf.auxbasis = df.aug_etb(cell1, 1.8)
        odf.mesh = [6] * 3
        odf.eta = 0.1
        eri0000 = odf.get_eri()
        self.assertTrue(eri0000.dtype == numpy.double)
        self.assertAlmostEqual(eri0000.real.sum(), 27.271885446069433, 6)
        self.assertAlmostEqual(finger(eri0000), 1.0614085634080137, 6)

        eri1111 = kmdf1.get_eri((kpts[0], kpts[0], kpts[0], kpts[0]))
        self.assertTrue(eri1111.dtype == numpy.double)
        self.assertAlmostEqual(eri1111.real.sum(), 27.271885446069433, 6)
        self.assertAlmostEqual(eri1111.imag.sum(), 0, 7)
        self.assertAlmostEqual(finger(eri0000), 1.0614085634080137, 6)
        self.assertAlmostEqual(abs(eri1111 - eri0000).max(), 0, 12)
Esempio n. 2
0
def setUpModule():
    global cell, cell1, mf0, kmdf, kmdf1, kpts
    L = 5.
    n = 11
    cell = pgto.Cell()
    cell.a = numpy.diag([L,L,L])
    cell.mesh = numpy.array([n,n,n])

    cell.atom = '''C    3.    2.       3.
                   C    1.    1.       1.'''
    cell.basis = 'ccpvdz'
    cell.verbose = 0
    cell.rcut = 17
    cell.build(0,0)

    mf0 = pscf.RHF(cell)
    mf0.exxdiv = 'vcut_sph'


    numpy.random.seed(1)
    kpts = numpy.random.random((5,3))
    kpts[0] = 0
    kpts[3] = kpts[0]-kpts[1]+kpts[2]
    kpts[4] *= 1e-5

    kmdf = mdf.MDF(cell)
    kmdf.linear_dep_threshold = 1e-7
    kmdf.auxbasis = 'weigend'
    kmdf.kpts = kpts
    kmdf.mesh = (11,)*3
    kmdf.eta = 0.154728892598

    cell1 = pgto.Cell()
    cell1.a = numpy.eye(3) * 3.
    cell1.mesh = [10]*3
    cell1.atom = '''C    3.    2.       3.
                   C    1.    1.       1.'''
    cell1.basis = [[0, (3.5, 1)], [0, (1.0, 1)], [1, (0.6, 1)]]
    cell1.rcut = 9.5
    cell1.build(0,0)

    kmdf1 = mdf.MDF(cell1)
    kmdf1.linear_dep_threshold = 1e-7
    kmdf1.auxbasis = df.aug_etb(cell1, 1.8)
    kmdf1.kpts = kpts
    kmdf1.mesh = [6]*3
    kmdf1.eta = 0.1
Esempio n. 3
0
    def test_get_eri_gamma_1(self):
        odf = mdf.MDF(cell1)
        odf.linear_dep_threshold = 1e-7
        odf.auxbasis = df.aug_etb(cell1, 1.8)
        odf.mesh = [6]*3
        odf.eta = 0.1
        eri0000 = odf.get_eri()
        self.assertTrue(eri0000.dtype == numpy.double)
        self.assertAlmostEqual(eri0000.real.sum(), 27.271885446069433, 6)
        self.assertAlmostEqual(finger(eri0000), 1.0614085634080137, 6)

        eri1111 = kmdf1.get_eri((kpts[0],kpts[0],kpts[0],kpts[0]))
        self.assertTrue(eri1111.dtype == numpy.double)
        self.assertAlmostEqual(eri1111.real.sum(), 27.271885446069433, 6)
        self.assertAlmostEqual(eri1111.imag.sum(), 0, 7)
        self.assertAlmostEqual(finger(eri0000), 1.0614085634080137, 6)
        self.assertAlmostEqual(abs(eri1111-eri0000).max(), 0, 12)
Esempio n. 4
0
    def test_cell_with_cart(self):
        cell = pgto.M(
            atom='Li 0 0 0; H 2 2 2',
            a=(numpy.ones([3, 3]) - numpy.eye(3)) * 2,
            cart=True,
            basis={'H': '''
H   S
0.5    1''',
                   'Li': '''
Li  S
0.8    1
0.4    1
Li  P
0.8    1
0.4    1'''})

        eri0 = df.FFTDF(cell).get_eri()
        eri1 = mdf.MDF(cell).set(auxbasis=df.aug_etb(cell)).get_eri()
        self.assertAlmostEqual(abs(eri1-eri0).max(), 0, 5)
Esempio n. 5
0
kmdf.kpts = kpts
kmdf.mesh = (11, ) * 3
kmdf.eta = 0.154728892598

cell1 = pgto.Cell()
cell1.a = numpy.eye(3) * 3.
cell1.mesh = [10] * 3
cell1.atom = '''C    3.    2.       3.
               C    1.    1.       1.'''
cell1.basis = [[0, (3.5, 1)], [0, (1.0, 1)], [1, (0.6, 1)]]
cell1.rcut = 9.5
cell1.build(0, 0)

kmdf1 = mdf.MDF(cell1)
kmdf1.linear_dep_threshold = 1e-7
kmdf1.auxbasis = df.aug_etb(cell1, 1.8)
kmdf1.kpts = kpts
kmdf1.mesh = [6] * 3
kmdf1.eta = 0.1


def finger(a):
    w = numpy.cos(numpy.arange(a.size))
    return numpy.dot(a.ravel(), w)


class KnowValues(unittest.TestCase):
    def test_vbar(self):
        auxcell = df.df.make_modrho_basis(cell, 'ccpvdz', 1.)
        vbar = mdf.MDF(cell).auxbar(auxcell)
        self.assertAlmostEqual(finger(vbar), -0.00438699039629, 9)
Esempio n. 6
0
#
# By assigning the argument auxbasis of density_fit method, the DF calculation
# can use the assigned auxiliary basis. For example, in the statement below,
# the auxiliary basis is weigend Coulomb fitting basis augmented with one set
# of polarized d functions.
#
auxbasis = {'C': ('weigend', [[2, (0.5, 1)]])}
mf = scf.RHF(cell).density_fit(auxbasis=auxbasis)
mf.kernel()

#
# df.aug_etb is a shortcut function to create even-tempered gaussian basis
# based on the orbital basis.  The following example produces a dense etb
# basis spectrum.
#
auxbasis = df.aug_etb(cell, beta=1.6)
mf = scf.RHF(cell).density_fit(auxbasis=auxbasis)
mf.kernel()

#
# Another straightforward way to input even-tempered Gaussian basis (for
# better resolution of auxiliary basis) is the use of function gto.expand_etbs.
#
# Note the PBC Gaussian DF module will automatically remove diffused Gaussian
# fitting functions. It is controlled by the parameter eta.  The default value is
# 0.2 which removes all Gaussians whose exponents are smaller than 0.2.
# When your input DF basis has diffused functions, you need to reduce the
# value of  mf.with_df.eta  to reserve the diffused functions.  However,
# keeping diffused functions occasionally lead numerical noise in the GDF
# method.
#
Esempio n. 7
0
kmdf.kpts = kpts
kmdf.mesh = (11,)*3
kmdf.eta = 0.154728892598

cell1 = pgto.Cell()
cell1.a = numpy.eye(3) * 3.
cell1.mesh = [10]*3
cell1.atom = '''C    3.    2.       3.
               C    1.    1.       1.'''
cell1.basis = [[0, (3.5, 1)], [0, (1.0, 1)], [1, (0.6, 1)]]
cell1.rcut = 9.5
cell1.build(0,0)

kmdf1 = mdf.MDF(cell1)
kmdf1.linear_dep_threshold = 1e-7
kmdf1.auxbasis = df.aug_etb(cell1, 1.8)
kmdf1.kpts = kpts
kmdf1.mesh = [6]*3
kmdf1.eta = 0.1


def finger(a):
    w = numpy.cos(numpy.arange(a.size))
    return numpy.dot(a.ravel(), w)

class KnowValues(unittest.TestCase):
    def test_vbar(self):
        auxcell = df.df.make_modrho_basis(cell, 'ccpvdz', 1.)
        vbar = mdf.MDF(cell).auxbar(auxcell)
        self.assertAlmostEqual(finger(vbar), -0.00438699039629, 9)
Esempio n. 8
0
# By assigning the argument auxbasis of density_fit method, the DF calculation
# can use the assigned auxiliary basis. For example, in the statement below,
# the auxiliary basis is weigend Coulomb fitting basis augmented with one set
# of polarized d functions.
#
auxbasis = {'C': ('weigend', [[2, (0.5, 1)]])}
mf = scf.RHF(cell).density_fit(auxbasis=auxbasis)
mf.kernel()


#
# df.aug_etb is a shortcut function to create even-tempered gaussian basis
# based on the orbital basis.  The following example produces a dense etb
# basis spectrum.
#
auxbasis = df.aug_etb(cell, beta=1.6)
mf = scf.RHF(cell).density_fit(auxbasis=auxbasis)
mf.kernel()


#
# Another straightforward way to input even-tempered Gaussian basis (for
# better resolution of auxiliary basis) is the use of function gto.expand_etbs.
#
# Note the PBC Gaussian DF module will automatically remove diffused Gaussian
# fitting functions. It is controlled by the parameter eta.  The default value is
# 0.2 which removes all Gaussians whose exponents are smaller than 0.2.
# When your input DF basis has diffused functions, you need to reduce the
# value of  mf.with_df.eta  to reserve the diffused functions.  However,
# keeping diffused functions occasionally lead numerical noise in the GDF
# method.