Esempio n. 1
0
 def test_k_kpts_2(self):
     cell = pgto.Cell()
     cell.atom = 'He 1. .5 .5; He .1 1.3 2.1'
     cell.basis = {'He': [(0, (2.5, 1)), (0, (1., 1))]}
     cell.a = numpy.eye(3) * 2.5
     cell.mesh = [11] * 3
     cell.build()
     kpts = cell.get_abs_kpts([[-.25,-.25,-.25],
                               [-.25,-.25, .25],
                               [-.25, .25,-.25],
                               [-.25, .25, .25],
                               [ .25,-.25,-.25],
                               [ .25,-.25, .25],
                               [ .25, .25,-.25],
                               [ .25, .25, .25]])
     mydf = rsdf.RSDF(cell).set(auxbasis='weigend')
     mydf.linear_dep_threshold = 1e-7
     mydf.kpts = kpts
     mydf.auxbasis = {'He': [(0, (4.096, 1)), (0, (2.56, 1)), (0, (1.6, 1)), (0, (1., 1))]}
     mydf.exxdiv = None
     mydf.omega = 0.3
     mydf.exp_to_discard = 0.3
     nao = cell.nao_nr()
     numpy.random.seed(1)
     dm = numpy.random.random((8,nao,nao))
     dm = dm + dm.transpose(0,2,1)
     vk = df_jk.get_k_kpts(mydf, dm, 1, mydf.kpts)
     self.assertAlmostEqual(lib.fp(vk[0]), (1.0940331326660724 -0.01474246983191657j ), 7)
     self.assertAlmostEqual(lib.fp(vk[1]), (0.72106828546205248+0.008683360062569572j), 7)
     self.assertAlmostEqual(lib.fp(vk[2]), (0.89868267009698988-0.011091489111877838j), 7)
     self.assertAlmostEqual(lib.fp(vk[3]), (1.2604941401190835 +0.015979544115384041j), 7)
     self.assertAlmostEqual(lib.fp(vk[4]), (1.0492129520812594 -0.012424653667344821j), 7)
     self.assertAlmostEqual(lib.fp(vk[5]), (0.99271107721956797+0.012696925711370165j), 7)
     self.assertAlmostEqual(lib.fp(vk[6]), (0.92184754518871648-0.012035727588110348j), 7)
     self.assertAlmostEqual(lib.fp(vk[7]), (0.8518483148628242 +0.010084767506077213j), 7)
Esempio n. 2
0
def get_k_kpts(mydf, dm_kpts, hermi=1, kpts=numpy.zeros((1,3)), kpts_band=None,
               exxdiv=None):
    if mydf._cderi is None or mydf.auxcell is None or not mydf.has_kpts(kpts_band):
        mydf.build(kpts_band=kpts_band)
    vk_kpts = aft_jk.get_k_kpts(mydf, dm_kpts, hermi, kpts, kpts_band, exxdiv)
    vk_kpts += df_jk.get_k_kpts(mydf, dm_kpts, hermi, kpts, kpts_band, None)
    return vk_kpts
Esempio n. 3
0
    def get_jk(self,
               dm,
               hermi=1,
               kpts=None,
               kpts_band=None,
               with_j=True,
               with_k=True,
               omega=None,
               exxdiv=None):
        if omega is not None:  # J/K for RSH functionals
            return _sub_df_jk_(self, dm, hermi, kpts, kpts_band, with_j,
                               with_k, omega, exxdiv)

        if kpts is None:
            if numpy.all(self.kpts == 0):
                # Gamma-point calculation by default
                kpts = numpy.zeros(3)
            else:
                kpts = self.kpts
        kpts = numpy.asarray(kpts)

        if kpts.shape == (3, ):
            return df_jk.get_jk(self, dm, hermi, kpts, kpts_band, with_j,
                                with_k, exxdiv)

        vj = vk = None
        if with_k:
            vk = df_jk.get_k_kpts(self, dm, hermi, kpts, kpts_band, exxdiv)
        if with_j:
            vj = df_jk.get_j_kpts(self, dm, hermi, kpts, kpts_band)
        return vj, vk
Esempio n. 4
0
    def get_jk(self,
               dm,
               hermi=1,
               kpts=None,
               kpts_band=None,
               with_j=True,
               with_k=True,
               exxdiv='ewald'):
        if kpts is None:
            if numpy.all(self.kpts == 0):
                # Gamma-point calculation by default
                kpts = numpy.zeros(3)
            else:
                kpts = self.kpts
        kpts = numpy.asarray(kpts)

        if kpts.shape == (3, ):
            return df_jk.get_jk(self, dm, hermi, kpts, kpts_band, with_j,
                                with_k, exxdiv)

        vj = vk = None
        if with_k:
            vk = df_jk.get_k_kpts(self, dm, hermi, kpts, kpts_band, exxdiv)
        if with_j:
            vj = df_jk.get_j_kpts(self, dm, hermi, kpts, kpts_band)
        return vj, vk
Esempio n. 5
0
    def test_k_kpts_1(self):
        cell = pgto.Cell()
        cell.atom = 'He 1. .5 .5; He .1 1.3 2.1'
        cell.basis = {'He': [(0, (2.5, 1)), (0, (1., 1))]}
        cell.a = numpy.eye(3) * 2.5
        cell.gs = [5] * 3
        cell.build()
        kpts = cell.get_abs_kpts([[-.25,-.25,-.25],
                                  [-.25,-.25, .25],
                                  [-.25, .25,-.25],
                                  [-.25, .25, .25],
                                  [ .25,-.25,-.25],
                                  [ .25,-.25, .25],
                                  [ .25, .25,-.25],
                                  [ .25, .25, .25]])

        numpy.random.seed(1)
        nao = cell.nao_nr()
        dm = numpy.random.random((8,nao,nao))
        mydf = df.DF(cell)
        mydf.kpts = kpts
        mydf.auxbasis = 'weigend'
        mydf.exxdiv = None
        vk = df_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
        self.assertAlmostEqual(finger(vk[0]), (0.54015197313324537-0.0079752072085274676j), 9)
        self.assertAlmostEqual(finger(vk[1]), (0.3582520398839657 +0.0036801628264896014j), 9)
        self.assertAlmostEqual(finger(vk[2]), (0.46108289884408604-0.0066080922040621061j), 9)
        self.assertAlmostEqual(finger(vk[3]), (0.63466063181822774+0.0075857948337662746j), 9)
        self.assertAlmostEqual(finger(vk[4]), (0.53482612780118588-0.0077463092279198443j), 9)
        self.assertAlmostEqual(finger(vk[5]), (0.49433633153410605+0.0061326611410119211j), 9)
        self.assertAlmostEqual(finger(vk[6]), (0.45244565342177845-0.0069645425083198157j), 9)
        self.assertAlmostEqual(finger(vk[7]), (0.41675926649079686+0.0051848485986134649j), 9)
Esempio n. 6
0
    def test_k_kpts_1(self):
        cell = pgto.Cell()
        cell.atom = 'He 1. .5 .5; He .1 1.3 2.1'
        cell.basis = {'He': [(0, (2.5, 1)), (0, (1., 1))]}
        cell.a = numpy.eye(3) * 2.5
        cell.mesh = [11] * 3
        cell.build()
        kpts = cell.get_abs_kpts([[-.25,-.25,-.25],
                                  [-.25,-.25, .25],
                                  [-.25, .25,-.25],
                                  [-.25, .25, .25],
                                  [ .25,-.25,-.25],
                                  [ .25,-.25, .25],
                                  [ .25, .25,-.25],
                                  [ .25, .25, .25]])

        numpy.random.seed(1)
        nao = cell.nao_nr()
        dm = numpy.random.random((8,nao,nao))
        mydf = df.DF(cell).set(auxbasis='weigend')
        mydf.kpts = kpts
        mydf.auxbasis = {'He': [(0, (4.096, 1)), (0, (2.56, 1)), (0, (1.6, 1)), (0, (1., 1))]}
        mydf.exxdiv = None
        mydf.mesh = cell.mesh
        mydf.eta = 0.3
        vk = df_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
        self.assertAlmostEqual(finger(vk[0]), (0.54220010040518218-0.00787204295681934j  ), 9)
        self.assertAlmostEqual(finger(vk[1]), (0.35987105007103914+0.0036047438452865574j), 9)
        self.assertAlmostEqual(finger(vk[2]), (0.46287057223452965-0.0065045318150024475j), 9)
        self.assertAlmostEqual(finger(vk[3]), (0.63677390788341914+0.0075132081533213447j), 9)
        self.assertAlmostEqual(finger(vk[4]), (0.53680188658523353-0.0076414750780774933j), 9)
        self.assertAlmostEqual(finger(vk[5]), (0.49613855046499666+0.0060603767383680838j), 9)
        self.assertAlmostEqual(finger(vk[6]), (0.45430752211150049-0.0068611602260866128j), 9)
        self.assertAlmostEqual(finger(vk[7]), (0.41856931218763038+0.0051073315205987522j), 9)
Esempio n. 7
0
def get_k_kpts(mydf, dm_kpts, hermi=1, kpts=numpy.zeros((1,3)),
               kpts_band=None, exxdiv=None):
    if rank != 0:  # to apply df_jk._ewald_exxdiv_for_G0 function once
        exxdiv = None
    vk = df_jk.get_k_kpts(mydf, dm_kpts, hermi, kpts, kpts_band, exxdiv)
    vk = mpi.reduce(vk)
    return vk
Esempio n. 8
0
 def test_k_kpts_2(self):
     cell = pgto.Cell()
     cell.atom = 'He 1. .5 .5; He .1 1.3 2.1'
     cell.basis = {'He': [(0, (2.5, 1)), (0, (1., 1))]}
     cell.a = numpy.eye(3) * 2.5
     cell.gs = [5] * 3
     cell.build()
     kpts = cell.get_abs_kpts([[-.25,-.25,-.25],
                               [-.25,-.25, .25],
                               [-.25, .25,-.25],
                               [-.25, .25, .25],
                               [ .25,-.25,-.25],
                               [ .25,-.25, .25],
                               [ .25, .25,-.25],
                               [ .25, .25, .25]])
     mydf = df.DF(cell)
     mydf.kpts = kpts
     mydf.auxbasis = 'weigend'
     mydf.exxdiv = None
     nao = cell.nao_nr()
     numpy.random.seed(1)
     dm = numpy.random.random((8,nao,nao))
     dm = dm + dm.transpose(0,2,1)
     vk = df_jk.get_k_kpts(mydf, dm, 1, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]), (1.0898939666590253 -0.014906612874026948j), 9)
     self.assertAlmostEqual(finger(vk[1]), (0.71766985010790085+0.008841808731355736j), 9)
     self.assertAlmostEqual(finger(vk[2]), (0.89500717500394655-0.011255970881451824j), 9)
     self.assertAlmostEqual(finger(vk[3]), (1.2561632091272155 +0.016131846517374523j), 9)
     self.assertAlmostEqual(finger(vk[4]), (1.0452056696649636 -0.012591023244846416j), 9)
     self.assertAlmostEqual(finger(vk[5]), (0.98906700489431287+0.012847978938583308j), 9)
     self.assertAlmostEqual(finger(vk[6]), (0.91811462227257712-0.012200120679750136j), 9)
     self.assertAlmostEqual(finger(vk[7]), (0.84819570235790342+0.010245262542632964j), 9)
Esempio n. 9
0
    def test_k_kpts_1(self):
        cell = pgto.Cell()
        cell.atom = 'He 1. .5 .5; He .1 1.3 2.1'
        cell.basis = {'He': [(0, (2.5, 1)), (0, (1., 1))]}
        cell.a = numpy.eye(3) * 2.5
        cell.gs = [5] * 3
        cell.build()
        kpts = cell.get_abs_kpts([[-.25,-.25,-.25],
                                  [-.25,-.25, .25],
                                  [-.25, .25,-.25],
                                  [-.25, .25, .25],
                                  [ .25,-.25,-.25],
                                  [ .25,-.25, .25],
                                  [ .25, .25,-.25],
                                  [ .25, .25, .25]])

        numpy.random.seed(1)
        nao = cell.nao_nr()
        dm = numpy.random.random((8,nao,nao))
        mydf = df.DF(cell)
        mydf.kpts = kpts
        mydf.auxbasis = {'He': [(0, (4.096, 1)), (0, (2.56, 1)), (0, (1.6, 1)), (0, (1., 1))]}
        mydf.exxdiv = None
        vk = df_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
        self.assertAlmostEqual(finger(vk[0]), (0.5420051395935308 -0.0078629895406937093j), 9)
        self.assertAlmostEqual(finger(vk[1]), (0.35967745300781129+0.0036013741011200534j), 9)
        self.assertAlmostEqual(finger(vk[2]), (0.46267875636311051-0.0064934210041723787j), 9)
        self.assertAlmostEqual(finger(vk[3]), (0.63657133813146305+0.0075058298866949071j), 9)
        self.assertAlmostEqual(finger(vk[4]), (0.53658686350689644-0.0076348273858712692j), 9)
        self.assertAlmostEqual(finger(vk[5]), (0.49596594079072709+0.0060524166304689085j), 9)
        self.assertAlmostEqual(finger(vk[6]), (0.45414482973739956-0.0068539768439524994j), 9)
        self.assertAlmostEqual(finger(vk[7]), (0.41836048318983377+0.0051095605455669692j), 9)
Esempio n. 10
0
def get_k_kpts(mydf,
               dm_kpts,
               hermi=1,
               kpts=numpy.zeros((1, 3)),
               kpts_band=None,
               exxdiv=None):
    vk_kpts = aft_jk.get_k_kpts(mydf, dm_kpts, hermi, kpts, kpts_band, exxdiv)
    vk_kpts += df_jk.get_k_kpts(mydf, dm_kpts, hermi, kpts, kpts_band, None)
    return vk_kpts
Esempio n. 11
0
def get_k_kpts(mydf,
               dm_kpts,
               hermi=1,
               kpts=numpy.zeros((1, 3)),
               kpts_band=None,
               exxdiv=None):
    if rank != 0:  # to apply df_jk._ewald_exxdiv_for_G0 function once
        exxdiv = None
    vk = df_jk.get_k_kpts(mydf, dm_kpts, hermi, kpts, kpts_band, exxdiv)
    vk = mpi.reduce(vk)
    return vk
Esempio n. 12
0
def get_k_kpts(mydf,
               dm_kpts,
               hermi=1,
               kpts=numpy.zeros((1, 3)),
               kpts_band=None,
               exxdiv=None):
    if exxdiv is not None and exxdiv != 'ewald':
        logger.warn(
            mydf, 'MDF does not support exxdiv %s. '
            'exxdiv needs to be "ewald" or None', exxdiv)
        raise RuntimeError('GDF does not support exxdiv %s' % exxdiv)
    vk_kpts = aft_jk.get_k_kpts(mydf, dm_kpts, hermi, kpts, kpts_band, exxdiv)
    vk_kpts += df_jk.get_k_kpts(mydf, dm_kpts, hermi, kpts, kpts_band, None)
    return vk_kpts
Esempio n. 13
0
    def get_jk(self,
               dm,
               hermi=1,
               kpts=None,
               kpts_band=None,
               with_j=True,
               with_k=True,
               omega=None,
               exxdiv=None):
        if omega is not None:  # J/K for RSH functionals
            cell = self.cell
            # * AFT is computationally more efficient than GDF if the Coulomb
            #   attenuation tends to the long-range role (i.e. small omega).
            # * Note: changing to AFT integrator may cause small difference to
            #   the GDF integrator. If a very strict GDF result is desired,
            #   we can disable this trick by setting
            #   LONGRANGE_AFT_TURNOVER_THRESHOLD to 0.
            # * The sparse mesh is not appropriate for low dimensional systems
            #   with infinity vacuum since the ERI may require large mesh to
            #   sample density in vacuum.
            if (omega < LONGRANGE_AFT_TURNOVER_THRESHOLD
                    and cell.dimension >= 2
                    and cell.low_dim_ft_type != 'inf_vacuum'):
                mydf = aft.AFTDF(cell, self.kpts)
                mydf.ke_cutoff = aft.estimate_ke_cutoff_for_omega(cell, omega)
                mydf.mesh = tools.cutoff_to_mesh(cell.lattice_vectors(),
                                                 mydf.ke_cutoff)
            else:
                mydf = self
            return _sub_df_jk_(mydf, dm, hermi, kpts, kpts_band, with_j,
                               with_k, omega, exxdiv)

        if kpts is None:
            if numpy.all(self.kpts == 0):
                # Gamma-point calculation by default
                kpts = numpy.zeros(3)
            else:
                kpts = self.kpts
        kpts = numpy.asarray(kpts)

        if kpts.shape == (3, ):
            return df_jk.get_jk(self, dm, hermi, kpts, kpts_band, with_j,
                                with_k, exxdiv)

        vj = vk = None
        if with_k:
            vk = df_jk.get_k_kpts(self, dm, hermi, kpts, kpts_band, exxdiv)
        if with_j:
            vj = df_jk.get_j_kpts(self, dm, hermi, kpts, kpts_band)
        return vj, vk
Esempio n. 14
0
    def test_k_kpts_1(self):
        cell = pgto.Cell()
        cell.atom = 'He 1. .5 .5; He .1 1.3 2.1'
        cell.basis = {'He': [(0, (2.5, 1)), (0, (1., 1))]}
        cell.a = numpy.eye(3) * 2.5
        cell.gs = [5] * 3
        cell.build()
        kpts = cell.get_abs_kpts([[-.25, -.25, -.25], [-.25, -.25, .25],
                                  [-.25, .25, -.25], [-.25, .25, .25],
                                  [.25, -.25, -.25], [.25, -.25, .25],
                                  [.25, .25, -.25], [.25, .25, .25]])

        numpy.random.seed(1)
        nao = cell.nao_nr()
        dm = numpy.random.random((8, nao, nao))
        mydf = df.DF(cell).set(auxbasis='weigend')
        mydf.kpts = kpts
        mydf.auxbasis = {
            'He': [(0, (4.096, 1)), (0, (2.56, 1)), (0, (1.6, 1)),
                   (0, (1., 1))]
        }
        mydf.exxdiv = None
        mydf.gs = cell.gs
        mydf.eta = 0.3
        vk = df_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
        self.assertAlmostEqual(finger(vk[0]),
                               (0.54220010040518085 - 0.0078720429568215483j),
                               9)
        self.assertAlmostEqual(finger(vk[1]),
                               (0.35987105007103337 + 0.0036047438452914572j),
                               9)
        self.assertAlmostEqual(finger(vk[2]),
                               (0.46287057223452033 - 0.0065045318150074175j),
                               9)
        self.assertAlmostEqual(finger(vk[3]),
                               (0.63677390788341892 + 0.007513208153323357j),
                               9)
        self.assertAlmostEqual(finger(vk[4]),
                               (0.53680188658523043 - 0.0076414750780819194j),
                               9)
        self.assertAlmostEqual(finger(vk[5]),
                               (0.49613855046498667 + 0.006060376738372739j),
                               9)
        self.assertAlmostEqual(finger(vk[6]),
                               (0.45430752211148873 - 0.0068611602260907067j),
                               9)
        self.assertAlmostEqual(finger(vk[7]),
                               (0.41856931218761884 + 0.0051073315206036857j),
                               9)
Esempio n. 15
0
 def test_k_kpts(self):
     numpy.random.seed(1)
     nao = cell.nao_nr()
     dm = numpy.random.random((4,nao,nao))
     dm = dm + dm.transpose(0,2,1)
     mydf = df.DF(cell)
     mydf.kpts = numpy.random.random((4,3))
     mydf.gs = numpy.asarray((5,)*3)
     mydf.exxdiv = None
     mydf.auxbasis = 'weigend'
     vk = df_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]), (-2.8338631448322422 -1.0571235846726912j ), 9)
     self.assertAlmostEqual(finger(vk[1]), (-7.4393097135258062 +0.10265042873875296j), 9)
     self.assertAlmostEqual(finger(vk[2]), (-2.5706492707654505 -1.4482274480570361j ), 9)
     self.assertAlmostEqual(finger(vk[3]), (-0.78973046762474153+0.01154399375447295j), 9)
Esempio n. 16
0
 def test_k_kpts(self):
     numpy.random.seed(1)
     nao = cell.nao_nr()
     dm = numpy.random.random((4,nao,nao))
     dm = dm + dm.transpose(0,2,1)
     mydf = df.DF(cell)
     mydf.kpts = numpy.random.random((4,3))
     mydf.gs = numpy.asarray((5,)*3)
     mydf.exxdiv = None
     mydf.auxbasis = 'weigend'
     vk = df_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]), (-2.8332405542539822 -1.0578703659011341j ), 9)
     self.assertAlmostEqual(finger(vk[1]), (-7.4404337144963018 +0.10233793208112751j), 9)
     self.assertAlmostEqual(finger(vk[2]), (-2.5718873173309404 -1.4487392786249131j ), 9)
     self.assertAlmostEqual(finger(vk[3]), (-0.79223061014449159+0.01169464922520067j), 9)
Esempio n. 17
0
 def test_k_kpts_high_cost(self):
     numpy.random.seed(1)
     nao = cell.nao_nr()
     dm = numpy.random.random((4,nao,nao))
     dm = dm + dm.transpose(0,2,1)
     mydf = rsdf.RSDF(cell).set(auxbasis='weigend')
     mydf.linear_dep_threshold = 1e-7
     mydf.kpts = numpy.random.random((4,3))
     mydf.exxdiv = None
     mydf.omega = 0.3
     mydf.exp_to_discard = 0.3
     mydf.auxbasis = 'weigend'
     vk = df_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(lib.fp(vk[0]), (-2.8332378458006682 + -1.0578692394119324j), 7)
     self.assertAlmostEqual(lib.fp(vk[1]), (-7.4404313581193380 + 0.1023364493364826j), 7)
     self.assertAlmostEqual(lib.fp(vk[2]), (-2.5718854219888430 + -1.4487422365382123j), 7)
     self.assertAlmostEqual(lib.fp(vk[3]), (-0.7922307287610381 + 0.0116940681352038j), 7)
Esempio n. 18
0
 def test_k_kpts_high_cost(self):
     numpy.random.seed(1)
     nao = cell0.nao_nr()
     dm = numpy.random.random((4,nao,nao))
     dm = dm + dm.transpose(0,2,1)
     mydf = df.DF(cell0).set(auxbasis='weigend')
     mydf.linear_dep_threshold = 1e-7
     mydf.kpts = numpy.random.random((4,3))
     mydf.exxdiv = None
     mydf.eta = 0.3
     mydf.exp_to_discard = mydf.eta
     mydf.auxbasis = 'weigend'
     vk = df_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(lib.fp(vk[0]), (4.831027586092549-0.12376435978940196j) , 9)
     self.assertAlmostEqual(lib.fp(vk[1]), (4.783208264204395-0.00585421470169705j) , 9)
     self.assertAlmostEqual(lib.fp(vk[2]), (4.823839360632854+0.002511545727704362j), 9)
     self.assertAlmostEqual(lib.fp(vk[3]), (4.833891390413435+0.0208696082684768j)  , 9)
Esempio n. 19
0
 def test_k_kpts(self):
     numpy.random.seed(1)
     nao = cell.nao_nr()
     dm = numpy.random.random((4,nao,nao))
     dm = dm + dm.transpose(0,2,1)
     mydf = df.DF(cell).set(auxbasis='weigend')
     mydf.kpts = numpy.random.random((4,3))
     mydf.mesh = numpy.asarray((11,)*3)
     mydf.exxdiv = None
     mydf.mesh = cell.mesh
     mydf.eta = 0.3
     mydf.auxbasis = 'weigend'
     vk = df_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]), (-2.8332400193836929 -1.0578696472684668j  ), 9)
     self.assertAlmostEqual(finger(vk[1]), (-7.440432864374058  +0.10233777556396761j ), 9)
     self.assertAlmostEqual(finger(vk[2]), (-2.5718862399533897 -1.4487403259747005j  ), 9)
     self.assertAlmostEqual(finger(vk[3]), (-0.79223093737594863+0.011694427945090839j), 9)
Esempio n. 20
0
    def test_k_kpts_1(self):
        cell = pgto.Cell()
        cell.atom = 'He 1. .5 .5; He .1 1.3 2.1'
        cell.basis = {'He': [(0, (2.5, 1)), (0, (1., 1))]}
        cell.a = numpy.eye(3) * 2.5
        cell.gs = [5] * 3
        cell.build()
        kpts = cell.get_abs_kpts([[-.25, -.25, -.25], [-.25, -.25, .25],
                                  [-.25, .25, -.25], [-.25, .25, .25],
                                  [.25, -.25, -.25], [.25, -.25, .25],
                                  [.25, .25, -.25], [.25, .25, .25]])

        numpy.random.seed(1)
        nao = cell.nao_nr()
        dm = numpy.random.random((8, nao, nao))
        mydf = df.DF(cell)
        mydf.kpts = kpts
        mydf.auxbasis = 'weigend'
        mydf.exxdiv = None
        vk = df_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
        self.assertAlmostEqual(finger(vk[0]),
                               (0.54015197313324537 - 0.0079752072085274676j),
                               9)
        self.assertAlmostEqual(finger(vk[1]),
                               (0.3582520398839657 + 0.0036801628264896014j),
                               9)
        self.assertAlmostEqual(finger(vk[2]),
                               (0.46108289884408604 - 0.0066080922040621061j),
                               9)
        self.assertAlmostEqual(finger(vk[3]),
                               (0.63466063181822774 + 0.0075857948337662746j),
                               9)
        self.assertAlmostEqual(finger(vk[4]),
                               (0.53482612780118588 - 0.0077463092279198443j),
                               9)
        self.assertAlmostEqual(finger(vk[5]),
                               (0.49433633153410605 + 0.0061326611410119211j),
                               9)
        self.assertAlmostEqual(finger(vk[6]),
                               (0.45244565342177845 - 0.0069645425083198157j),
                               9)
        self.assertAlmostEqual(finger(vk[7]),
                               (0.41675926649079686 + 0.0051848485986134649j),
                               9)
Esempio n. 21
0
 def test_k_kpts(self):
     numpy.random.seed(1)
     nao = cell.nao_nr()
     dm = numpy.random.random((4,nao,nao))
     dm = dm + dm.transpose(0,2,1)
     mydf = df.DF(cell).set(auxbasis='weigend')
     mydf.linear_dep_threshold = 1e-7
     mydf.kpts = numpy.random.random((4,3))
     mydf.mesh = numpy.asarray((11,)*3)
     mydf.exxdiv = None
     mydf.mesh = cell.mesh
     mydf.eta = 0.3
     mydf.exp_to_discard = mydf.eta
     mydf.auxbasis = 'weigend'
     vk = df_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]), (-2.8332400193836929 -1.0578696472684668j  ), 9)
     self.assertAlmostEqual(finger(vk[1]), (-7.440432864374058  +0.10233777556396761j ), 9)
     self.assertAlmostEqual(finger(vk[2]), (-2.5718862399533897 -1.4487403259747005j  ), 9)
     self.assertAlmostEqual(finger(vk[3]), (-0.79223093737594863+0.011694427945090839j), 9)
Esempio n. 22
0
 def test_k_kpts(self):
     numpy.random.seed(1)
     nao = cell.nao_nr()
     dm = numpy.random.random((4, nao, nao))
     dm = dm + dm.transpose(0, 2, 1)
     mydf = df.DF(cell)
     mydf.kpts = numpy.random.random((4, 3))
     mydf.gs = numpy.asarray((5, ) * 3)
     mydf.exxdiv = None
     mydf.auxbasis = 'weigend'
     vk = df_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]),
                            (-2.8332383229536533 - 1.0578698917131759j), 9)
     self.assertAlmostEqual(finger(vk[1]),
                            (-7.4404344284098975 + 0.10233829896587976j), 9)
     self.assertAlmostEqual(finger(vk[2]),
                            (-2.5718877141164285 - 1.4487388139184783j), 9)
     self.assertAlmostEqual(finger(vk[3]),
                            (-0.79223064808014754 + 0.01169455042040998j),
                            9)
Esempio n. 23
0
 def test_k_kpts(self):
     numpy.random.seed(1)
     nao = cell.nao_nr()
     dm = numpy.random.random((4, nao, nao))
     dm = dm + dm.transpose(0, 2, 1)
     mydf = df.DF(cell)
     mydf.kpts = numpy.random.random((4, 3))
     mydf.gs = numpy.asarray((5, ) * 3)
     mydf.exxdiv = None
     mydf.auxbasis = 'weigend'
     vk = df_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]),
                            (-2.8338631448322422 - 1.0571235846726912j), 9)
     self.assertAlmostEqual(finger(vk[1]),
                            (-7.4393097135258062 + 0.10265042873875296j), 9)
     self.assertAlmostEqual(finger(vk[2]),
                            (-2.5706492707654505 - 1.4482274480570361j), 9)
     self.assertAlmostEqual(finger(vk[3]),
                            (-0.78973046762474153 + 0.01154399375447295j),
                            9)
Esempio n. 24
0
File: df.py Progetto: chrinide/pyscf
    def get_jk(self, dm, hermi=1, kpts=None, kpts_band=None,
               with_j=True, with_k=True, exxdiv=None):
        if kpts is None:
            if numpy.all(self.kpts == 0):
                # Gamma-point calculation by default
                kpts = numpy.zeros(3)
            else:
                kpts = self.kpts
        kpts = numpy.asarray(kpts)

        if kpts.shape == (3,):
            return df_jk.get_jk(self, dm, hermi, kpts, kpts_band, with_j,
                                with_k, exxdiv)

        vj = vk = None
        if with_k:
            vk = df_jk.get_k_kpts(self, dm, hermi, kpts, kpts_band, exxdiv)
        if with_j:
            vj = df_jk.get_j_kpts(self, dm, hermi, kpts, kpts_band)
        return vj, vk
Esempio n. 25
0
 def test_k_kpts_2(self):
     cell = pgto.Cell()
     cell.atom = 'He 1. .5 .5; He .1 1.3 2.1'
     cell.basis = {'He': [(0, (2.5, 1)), (0, (1., 1))]}
     cell.a = numpy.eye(3) * 2.5
     cell.gs = [5] * 3
     cell.build()
     kpts = cell.get_abs_kpts([[-.25, -.25, -.25], [-.25, -.25, .25],
                               [-.25, .25, -.25], [-.25, .25, .25],
                               [.25, -.25, -.25], [.25, -.25, .25],
                               [.25, .25, -.25], [.25, .25, .25]])
     mydf = df.DF(cell)
     mydf.kpts = kpts
     mydf.auxbasis = 'weigend'
     mydf.exxdiv = None
     nao = cell.nao_nr()
     numpy.random.seed(1)
     dm = numpy.random.random((8, nao, nao))
     dm = dm + dm.transpose(0, 2, 1)
     vk = df_jk.get_k_kpts(mydf, dm, 1, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]),
                            (1.0898939666590253 - 0.014906612874026948j), 9)
     self.assertAlmostEqual(finger(vk[1]),
                            (0.71766985010790085 + 0.008841808731355736j),
                            9)
     self.assertAlmostEqual(finger(vk[2]),
                            (0.89500717500394655 - 0.011255970881451824j),
                            9)
     self.assertAlmostEqual(finger(vk[3]),
                            (1.2561632091272155 + 0.016131846517374523j), 9)
     self.assertAlmostEqual(finger(vk[4]),
                            (1.0452056696649636 - 0.012591023244846416j), 9)
     self.assertAlmostEqual(finger(vk[5]),
                            (0.98906700489431287 + 0.012847978938583308j),
                            9)
     self.assertAlmostEqual(finger(vk[6]),
                            (0.91811462227257712 - 0.012200120679750136j),
                            9)
     self.assertAlmostEqual(finger(vk[7]),
                            (0.84819570235790342 + 0.010245262542632964j),
                            9)
Esempio n. 26
0
 def test_k_kpts(self):
     numpy.random.seed(1)
     nao = cell.nao_nr()
     dm = numpy.random.random((4, nao, nao))
     dm = dm + dm.transpose(0, 2, 1)
     mydf = df.DF(cell).set(auxbasis='weigend')
     mydf.kpts = numpy.random.random((4, 3))
     mydf.gs = numpy.asarray((5, ) * 3)
     mydf.exxdiv = None
     mydf.gs = cell.gs
     mydf.eta = 0.3
     mydf.auxbasis = 'weigend'
     vk = df_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]),
                            (-2.8332405542541035 - 1.0578703659011017j), 9)
     self.assertAlmostEqual(finger(vk[1]),
                            (-7.4404337144965327 + 0.10233793208110664j), 9)
     self.assertAlmostEqual(finger(vk[2]),
                            (-2.5718873173308587 - 1.4487392786249167j), 9)
     self.assertAlmostEqual(finger(vk[3]),
                            (-0.79223061014463669 + 0.011694649225196911j),
                            9)
Esempio n. 27
0
 def test_k_kpts_high_cost(self):
     numpy.random.seed(1)
     nao = cell.nao_nr()
     dm = numpy.random.random((4, nao, nao))
     dm = dm + dm.transpose(0, 2, 1)
     mydf = df.DF(cell).set(auxbasis='weigend')
     mydf.linear_dep_threshold = 1e-7
     mydf.kpts = numpy.random.random((4, 3))
     mydf.mesh = [n, n, n]
     mydf.exxdiv = None
     mydf.eta = 0.3
     mydf.exp_to_discard = mydf.eta
     mydf.auxbasis = 'weigend'
     vk = df_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(lib.fp(vk[0]),
                            (-2.8332400193836929 - 1.0578696472684668j), 9)
     self.assertAlmostEqual(lib.fp(vk[1]),
                            (-7.440432864374058 + 0.10233777556396761j), 9)
     self.assertAlmostEqual(lib.fp(vk[2]),
                            (-2.5718862399533897 - 1.4487403259747005j), 9)
     self.assertAlmostEqual(lib.fp(vk[3]),
                            (-0.79223093737594863 + 0.011694427945090839j),
                            9)
Esempio n. 28
0
    def test_k_kpts_1(self):
        cell = pgto.Cell()
        cell.atom = 'He 1. .5 .5; He .1 1.3 2.1'
        cell.basis = {'He': [(0, (2.5, 1)), (0, (1., 1))]}
        cell.a = numpy.eye(3) * 2.5
        cell.mesh = [11] * 3
        cell.build()
        kpts = cell.get_abs_kpts([[-.25,-.25,-.25],
                                  [-.25,-.25, .25],
                                  [-.25, .25,-.25],
                                  [-.25, .25, .25],
                                  [ .25,-.25,-.25],
                                  [ .25,-.25, .25],
                                  [ .25, .25,-.25],
                                  [ .25, .25, .25]])

        numpy.random.seed(1)
        nao = cell.nao_nr()
        dm = numpy.random.random((8,nao,nao))
        mydf = df.DF(cell).set(auxbasis='weigend')
        mydf.linear_dep_threshold = 1e-7
        mydf.kpts = kpts
        mydf.auxbasis = {'He': [(0, (4.096, 1)), (0, (2.56, 1)), (0, (1.6, 1)), (0, (1., 1))]}
        mydf.exxdiv = None
        mydf.mesh = cell.mesh
        mydf.eta = 0.3
        mydf.exp_to_discard = mydf.eta
        vk = df_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
        self.assertAlmostEqual(finger(vk[0]), (0.54220010040518218-0.00787204295681934j  ), 9)
        self.assertAlmostEqual(finger(vk[1]), (0.35987105007103914+0.0036047438452865574j), 9)
        self.assertAlmostEqual(finger(vk[2]), (0.46287057223452965-0.0065045318150024475j), 9)
        self.assertAlmostEqual(finger(vk[3]), (0.63677390788341914+0.0075132081533213447j), 9)
        self.assertAlmostEqual(finger(vk[4]), (0.53680188658523353-0.0076414750780774933j), 9)
        self.assertAlmostEqual(finger(vk[5]), (0.49613855046499666+0.0060603767383680838j), 9)
        self.assertAlmostEqual(finger(vk[6]), (0.45430752211150049-0.0068611602260866128j), 9)
        self.assertAlmostEqual(finger(vk[7]), (0.41856931218763038+0.0051073315205987522j), 9)
Esempio n. 29
0
def get_k_kpts(mydf, dm_kpts, hermi=1, kpts=numpy.zeros((1,3)), kpts_band=None,
               exxdiv=None):
    vk_kpts = aft_jk.get_k_kpts(mydf, dm_kpts, hermi, kpts, kpts_band, exxdiv)
    vk_kpts += df_jk.get_k_kpts(mydf, dm_kpts, hermi, kpts, kpts_band, None)
    return vk_kpts