コード例 #1
0
ファイル: test_mdf_jk.py プロジェクト: eronca/pyscf
    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 = mdf.MDF(cell)
        mydf.kpts = kpts
        mydf.auxbasis = 'weigend'
        mydf.exxdiv = None
        vk = mdf_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
        self.assertAlmostEqual(finger(vk[0]), (0.5418385019142542 -0.0078724013505413332j), 9)
        self.assertAlmostEqual(finger(vk[1]), (0.35952124697656695+0.0036057189081886336j), 9)
        self.assertAlmostEqual(finger(vk[2]), (0.4625120878413842 -0.0065045494016886737j), 9)
        self.assertAlmostEqual(finger(vk[3]), (0.63641999973765473+0.0075120497797564077j), 9)
        self.assertAlmostEqual(finger(vk[4]), (0.53644934892347451-0.0076425730500473956j), 9)
        self.assertAlmostEqual(finger(vk[5]), (0.49579571224501451+0.006059214200031502j ), 9)
        self.assertAlmostEqual(finger(vk[6]), (0.4539578168628049 -0.0068618292524707204j), 9)
        self.assertAlmostEqual(finger(vk[7]), (0.41822536109677522+0.0051098609317817099j), 9)
コード例 #2
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 mdf_jk.get_jk(self, dm, hermi, kpts, kpts_band, with_j,
                                 with_k, exxdiv)

        vj = vk = None
        if with_k:
            vk = mdf_jk.get_k_kpts(self, dm, hermi, kpts, kpts_band, exxdiv)
        if with_j:
            vj = mdf_jk.get_j_kpts(self, dm, hermi, kpts, kpts_band)
        return vj, vk
コード例 #3
0
ファイル: test_mdf_jk.py プロジェクト: eronca/pyscf
 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 = mdf.MDF(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 = mdf_jk.get_k_kpts(mydf, dm, 1, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]), (1.0933071616067864 -0.01474271237640193j ), 9)
     self.assertAlmostEqual(finger(vk[1]), (0.72036827661735581+0.008685775722653022j), 9)
     self.assertAlmostEqual(finger(vk[2]), (0.8979620015620533 -0.011091372770818691j), 9)
     self.assertAlmostEqual(finger(vk[3]), (1.2597854134048272 +0.015977292598694546j), 9)
     self.assertAlmostEqual(finger(vk[4]), (1.0485047112408323 -0.012426816811955727j), 9)
     self.assertAlmostEqual(finger(vk[5]), (0.99202495287727066+0.012695003848138148j), 9)
     self.assertAlmostEqual(finger(vk[6]), (0.92114488719642162-0.012036800944772899j), 9)
     self.assertAlmostEqual(finger(vk[7]), (0.85115980145319536+0.010089537647891509j), 9)
コード例 #4
0
ファイル: mdf_jk.py プロジェクト: zhcui/mpi4pyscf
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 = mdf_jk.get_k_kpts(mydf, dm_kpts, hermi, kpts, kpts_band, exxdiv)
    vk = mpi.reduce(vk)
    return vk
コード例 #5
0
ファイル: test_mdf_jk.py プロジェクト: gmwang18/pyscf
 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 = mdf.MDF(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 = mdf_jk.get_k_kpts(mydf, dm, 1, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]), (1.093802464678856  -0.014742352431919676j), 9)
     self.assertAlmostEqual(finger(vk[1]), (0.72086169197091587+0.008685418217133528j), 9)
     self.assertAlmostEqual(finger(vk[2]), (0.89846572708244654-0.011091007223188223j), 9)
     self.assertAlmostEqual(finger(vk[3]), (1.2603019232380572 +0.015976908426091924j), 9)
     self.assertAlmostEqual(finger(vk[4]), (1.0490203655653567 -0.012426437226316521j), 9)
     self.assertAlmostEqual(finger(vk[5]), (0.99252573352507678+0.012694645461974137j), 9)
     self.assertAlmostEqual(finger(vk[6]), (0.92165226277159285-0.012036432073368958j), 9)
     self.assertAlmostEqual(finger(vk[7]), (0.85167169839559342+0.010089165714668009j), 9)
コード例 #6
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 mdf_jk.get_jk(self, dm, hermi, kpts, kpts_band, with_j,
                                 with_k, exxdiv)

        vj = vk = None
        if with_k:
            vk = mdf_jk.get_k_kpts(self, dm, hermi, kpts, kpts_band, exxdiv)
        if with_j:
            vj = mdf_jk.get_j_kpts(self, dm, hermi, kpts, kpts_band)
        return vj, vk
コード例 #7
0
ファイル: test_mdf_jk.py プロジェクト: gmwang18/pyscf
    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 = mdf.MDF(cell)
        mydf.kpts = kpts
        mydf.auxbasis = 'weigend'
        mydf.exxdiv = None
        vk = mdf_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
        self.assertAlmostEqual(finger(vk[0]), (0.54208523897216732-0.0078722056426767627j), 9)
        self.assertAlmostEqual(finger(vk[1]), (0.35976712320322424+0.0036055471233112256j), 9)
        self.assertAlmostEqual(finger(vk[2]), (0.46276289905549617-0.0065043496646110801j), 9)
        self.assertAlmostEqual(finger(vk[3]), (0.63667714700745526+0.0075118648848031978j), 9)
        self.assertAlmostEqual(finger(vk[4]), (0.53670615076993111-0.0076423628684680065j), 9)
        self.assertAlmostEqual(finger(vk[5]), (0.49604529705337863+0.0060590377882828398j), 9)
        self.assertAlmostEqual(finger(vk[6]), (0.45421039104866701-0.0068616242937238692j), 9)
        self.assertAlmostEqual(finger(vk[7]), (0.41848041777106704+0.0051096776806240215j), 9)
コード例 #8
0
ファイル: test_mdf_jk.py プロジェクト: zwgsyntax/pyscf
    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 = mdf.MDF(cell).set(auxbasis='weigend')
        mydf.linear_dep_threshold = 1e-7
        mydf.kpts = kpts
        mydf.auxbasis = 'weigend'
        mydf.exxdiv = None
        mydf.mesh = numpy.asarray((11,)*3)
        mydf.eta = 0.3
        vk = mdf_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
        self.assertAlmostEqual(finger(vk[0]), (0.54208542933016668-0.007872205456027636j ), 9)
        self.assertAlmostEqual(finger(vk[1]), (0.35976730327192219+0.0036055469686362227j), 9)
        self.assertAlmostEqual(finger(vk[2]), (0.46276307618592272-0.006504349523994527j ), 9)
        self.assertAlmostEqual(finger(vk[3]), (0.63667731843923825+0.0075118647005158034j), 9)
        self.assertAlmostEqual(finger(vk[4]), (0.53670632359622572-0.00764236264065816j  ), 9)
        self.assertAlmostEqual(finger(vk[5]), (0.4960454361832054 +0.0060590376596187257j), 9)
        self.assertAlmostEqual(finger(vk[6]), (0.45421052168235576-0.006861624162215218j ), 9)
        self.assertAlmostEqual(finger(vk[7]), (0.41848054629487041+0.0051096775483082746j), 9)
コード例 #9
0
ファイル: test_mdf_jk.py プロジェクト: zwgsyntax/pyscf
 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 = mdf.MDF(cell).set(auxbasis='weigend')
     mydf.linear_dep_threshold = 1e-7
     mydf.kpts = kpts
     mydf.auxbasis = 'weigend'
     mydf.exxdiv = None
     mydf.mesh = numpy.asarray((11,)*3)
     mydf.eta = 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 = mdf_jk.get_k_kpts(mydf, dm, 1, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]), (1.0938028454012594 -0.014742352047969521j), 9)
     self.assertAlmostEqual(finger(vk[1]), (0.72086205228975953+0.008685417852198867j), 9)
     self.assertAlmostEqual(finger(vk[2]), (0.89846608130483796-0.011091006902191843j), 9)
     self.assertAlmostEqual(finger(vk[3]), (1.260302267937254  +0.015976908047169756j), 9)
     self.assertAlmostEqual(finger(vk[4]), (1.0490207113210688 -0.012426436820904021j), 9)
     self.assertAlmostEqual(finger(vk[5]), (0.99252601243537697+0.012694645170334074j), 9)
     self.assertAlmostEqual(finger(vk[6]), (0.92165252496655681-0.012036431811316108j), 9)
     self.assertAlmostEqual(finger(vk[7]), (0.85167195537981   +0.010089165459944484j), 9)
コード例 #10
0
ファイル: test_mdf_jk.py プロジェクト: berquist/pyscf
    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.h = numpy.eye(3) * 2.5
        cell.gs = [5] * 3
        cell.build()
        kpts = cell.make_kpts((2,2,2))

        numpy.random.seed(1)
        nao = cell.nao_nr()
        dm = numpy.random.random((8,nao,nao))
        mydf = mdf.MDF(cell)
        mydf.kpts = kpts
        mydf.auxbasis = 'weigend'
        mydf.exxdiv = None
        vk = mdf_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
        self.assertAlmostEqual(finger(vk[0]), (0.54167993564799133-0.0078722013632614562j), 9)
        self.assertAlmostEqual(finger(vk[1]), (0.3593714867663208 +0.0036054974436528706j), 9)
        self.assertAlmostEqual(finger(vk[2]), (0.46234927585203783-0.0065043520189423856j), 9)
        self.assertAlmostEqual(finger(vk[3]), (0.63626519337979948+0.0075118282426430818j), 9)
        self.assertAlmostEqual(finger(vk[4]), (0.53630228285345427-0.0076423773076679524j), 9)
        self.assertAlmostEqual(finger(vk[5]), (0.4956577130753681 +0.0060590034846796439j), 9)
        self.assertAlmostEqual(finger(vk[6]), (0.45380714659933519-0.0068616367194157396j), 9)
        self.assertAlmostEqual(finger(vk[7]), (0.41808297427780505+0.0051096506509061114j), 9)

        numpy.random.seed(1)
        dm = numpy.random.random((8,nao,nao))
        dm = dm + dm.transpose(0,2,1)
        vk = mdf_jk.get_k_kpts(mydf, dm, 1, mydf.kpts)
        self.assertAlmostEqual(finger(vk[0]), (1.0929902110020242 -0.014742288503285355j ), 9)
        self.assertAlmostEqual(finger(vk[1]), (0.72006803096300986+0.0086853082996361259j), 9)
        self.assertAlmostEqual(finger(vk[2]), (0.89763598759314234-0.011090943227218j    ), 9)
        self.assertAlmostEqual(finger(vk[3]), (1.2594746237554506 +0.015976836949610319j ), 9)
        self.assertAlmostEqual(finger(vk[4]), (1.0482108645807622 -0.012426406003793576j ), 9)
        self.assertAlmostEqual(finger(vk[5]), (0.99174830962018801+0.012694552375379626j ), 9)
        self.assertAlmostEqual(finger(vk[6]), (0.9208432538335829 -0.01203638564702492j  ), 9)
        self.assertAlmostEqual(finger(vk[7]), (0.8508739289672812 +0.010089099047683993j ), 9)
コード例 #11
0
ファイル: mdf.py プロジェクト: verena-neufeld/pyscf
    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 MDF 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 MDF integrator. If a very strict MDF 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 < df.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 mdf_jk.get_jk(self, dm, hermi, kpts, kpts_band, with_j,
                                 with_k, exxdiv)

        vj = vk = None
        if with_k:
            vk = mdf_jk.get_k_kpts(self, dm, hermi, kpts, kpts_band, exxdiv)
        if with_j:
            vj = mdf_jk.get_j_kpts(self, dm, hermi, kpts, kpts_band)
        return vj, vk
コード例 #12
0
ファイル: test_mdf_jk.py プロジェクト: berquist/pyscf
 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 = mdf.MDF(cell)
     mydf.kpts = numpy.random.random((4,3))
     mydf.gs = numpy.asarray((5,)*3)
     mydf.exxdiv = None
     mydf.auxbasis = 'weigend'
     vk = mdf_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]), (-2.8420747650454392 -1.0532080235680654j  ), 9)
     self.assertAlmostEqual(finger(vk[1]), (-7.4479964653027597 +0.10327182213618791j ), 9)
     self.assertAlmostEqual(finger(vk[2]), (-2.5790215490804433 -1.4459077150581894j  ), 9)
     self.assertAlmostEqual(finger(vk[3]), (-0.79608989192947033+0.012002060547759118j), 9)
コード例 #13
0
ファイル: test_mdf_jk.py プロジェクト: gmwang18/pyscf
 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 = mdf.MDF(cell)
     mydf.kpts = numpy.random.random((4,3))
     mydf.gs = numpy.asarray((5,)*3)
     mydf.exxdiv = None
     mydf.auxbasis = 'weigend'
     vk = mdf_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]), (-2.8420620339045097-1.0520093453547801j ), 9)
     self.assertAlmostEqual(finger(vk[1]), (-7.4484103327425473+0.10323286175020963j), 9)
     self.assertAlmostEqual(finger(vk[2]), (-2.5801926784250275-1.4470101398726132j ), 9)
     self.assertAlmostEqual(finger(vk[3]), (-0.7966058224805721+0.01197494331158260j), 9)
コード例 #14
0
ファイル: test_mdf_jk.py プロジェクト: eronca/pyscf
 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 = mdf.MDF(cell)
     mydf.kpts = numpy.random.random((4,3))
     mydf.gs = numpy.asarray((5,)*3)
     mydf.exxdiv = None
     mydf.auxbasis = 'weigend'
     vk = mdf_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]), (-2.841991690391537  -1.0531936354491773j  ), 9)
     self.assertAlmostEqual(finger(vk[1]), (-7.4479409613933898 +0.10325698693704466j ), 9)
     self.assertAlmostEqual(finger(vk[2]), (-2.5789885244178263 -1.4459525565105991j  ), 9)
     self.assertAlmostEqual(finger(vk[3]), (-0.79603867462917455+0.011991290978492469j), 9)
コード例 #15
0
 def test_k_kpts(self):
     numpy.random.seed(1)
     nao = cell0.nao_nr()
     dm = numpy.random.random((4,nao,nao))
     dm = dm + dm.transpose(0,2,1)
     mydf = mdf.MDF(cell0).set(auxbasis='weigend')
     mydf.linear_dep_threshold = 1e-7
     mydf.kpts = numpy.random.random((4,3))
     mydf.mesh = numpy.asarray((11,)*3)
     mydf.eta = 0.3
     mydf.exxdiv = None
     mydf.auxbasis = 'weigend'
     vk = mdf_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(lib.fp(vk[0]), (4.831240836863933-0.12373190618477338j) , 9)
     self.assertAlmostEqual(lib.fp(vk[1]), (4.783417745841964-0.005852945569928365j), 9)
     self.assertAlmostEqual(lib.fp(vk[2]), (4.82403824304899+0.002483686050043201j) , 9)
     self.assertAlmostEqual(lib.fp(vk[3]), (4.8340892190932525+0.020822434708267664j), 9)
コード例 #16
0
ファイル: test_mdf_jk.py プロジェクト: zwgsyntax/pyscf
 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 = mdf.MDF(cell).set(auxbasis='weigend')
     mydf.linear_dep_threshold = 1e-7
     mydf.kpts = numpy.random.random((4,3))
     mydf.mesh = numpy.asarray((11,)*3)
     mydf.eta = 0.3
     mydf.exxdiv = None
     mydf.auxbasis = 'weigend'
     vk = mdf_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]), (-2.8420706204318527 -1.0520028601696778j  ), 9)
     self.assertAlmostEqual(finger(vk[1]), (-7.4484096949300751 +0.10323425122156138j ), 9)
     self.assertAlmostEqual(finger(vk[2]), (-2.580181288621187  -1.4470150314314312j  ), 9)
     self.assertAlmostEqual(finger(vk[3]), (-0.79660123464892396+0.011973030805184665j), 9)
コード例 #17
0
ファイル: test_mdf_jk.py プロジェクト: KMCzajkowski/pyscf
    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 = mdf.MDF(cell).set(auxbasis='weigend')
        mydf.kpts = kpts
        mydf.auxbasis = 'weigend'
        mydf.exxdiv = None
        mydf.gs = numpy.asarray((5, ) * 3)
        mydf.eta = 0.3
        vk = mdf_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
        self.assertAlmostEqual(finger(vk[0]),
                               (0.54208542933016868 - 0.007872205456027688j),
                               9)
        self.assertAlmostEqual(finger(vk[1]),
                               (0.35976730327192064 + 0.0036055469686364274j),
                               9)
        self.assertAlmostEqual(finger(vk[2]),
                               (0.46276307618592205 - 0.0065043495239945522j),
                               9)
        self.assertAlmostEqual(finger(vk[3]),
                               (0.63667731843923825 + 0.0075118647005158069j),
                               9)
        self.assertAlmostEqual(finger(vk[4]),
                               (0.53670632359622705 - 0.0076423626406581808j),
                               9)
        self.assertAlmostEqual(finger(vk[5]),
                               (0.49604543618320496 + 0.0060590376596186381j),
                               9)
        self.assertAlmostEqual(finger(vk[6]),
                               (0.45421052168235398 - 0.006861624162215172j),
                               9)
        self.assertAlmostEqual(finger(vk[7]),
                               (0.41848054629486886 + 0.00510967754830822j), 9)
コード例 #18
0
ファイル: mdf.py プロジェクト: ushnishray/pyscf
    def get_jk(self, dm, hermi=1, kpts=None, kpt_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 mdf_jk.get_jk(self, dm, hermi, kpts, kpt_band, with_j, with_k, exxdiv)

        vj = vk = None
        if with_k:
            vk = mdf_jk.get_k_kpts(self, dm, hermi, kpts, kpt_band, exxdiv)
        if with_j:
            vj = mdf_jk.get_j_kpts(self, dm, hermi, kpts, kpt_band)
        return vj, vk
コード例 #19
0
ファイル: test_mdf_jk.py プロジェクト: mattwelborn/pyscf
    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 = mdf.MDF(cell)
        mydf.kpts = kpts
        mydf.auxbasis = 'weigend'
        mydf.exxdiv = None
        vk = mdf_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
        self.assertAlmostEqual(finger(vk[0]),
                               (0.5418385019142542 - 0.0078724013505413332j),
                               9)
        self.assertAlmostEqual(finger(vk[1]),
                               (0.35952124697656695 + 0.0036057189081886336j),
                               9)
        self.assertAlmostEqual(finger(vk[2]),
                               (0.4625120878413842 - 0.0065045494016886737j),
                               9)
        self.assertAlmostEqual(finger(vk[3]),
                               (0.63641999973765473 + 0.0075120497797564077j),
                               9)
        self.assertAlmostEqual(finger(vk[4]),
                               (0.53644934892347451 - 0.0076425730500473956j),
                               9)
        self.assertAlmostEqual(finger(vk[5]),
                               (0.49579571224501451 + 0.006059214200031502j),
                               9)
        self.assertAlmostEqual(finger(vk[6]),
                               (0.4539578168628049 - 0.0068618292524707204j),
                               9)
        self.assertAlmostEqual(finger(vk[7]),
                               (0.41822536109677522 + 0.0051098609317817099j),
                               9)
コード例 #20
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 = mdf.MDF(cell)
     mydf.kpts = numpy.random.random((4, 3))
     mydf.gs = numpy.asarray((5, ) * 3)
     mydf.exxdiv = None
     mydf.auxbasis = 'weigend'
     vk = mdf_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]),
                            (-2.8420690776723521 - 1.0520032225125369j), 9)
     self.assertAlmostEqual(finger(vk[1]),
                            (-7.4484073115980589 + 0.10323612296497409j), 9)
     self.assertAlmostEqual(finger(vk[2]),
                            (-2.5801797461396694 - 1.4470142156554828j), 9)
     self.assertAlmostEqual(finger(vk[3]),
                            (-0.7965970307739134 + 0.01197284205215638j), 9)
コード例 #21
0
ファイル: test_mdf_jk.py プロジェクト: KMCzajkowski/pyscf
 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 = mdf.MDF(cell).set(auxbasis='weigend')
     mydf.kpts = kpts
     mydf.auxbasis = 'weigend'
     mydf.exxdiv = None
     mydf.gs = numpy.asarray((5, ) * 3)
     mydf.eta = 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 = mdf_jk.get_k_kpts(mydf, dm, 1, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]),
                            (1.0938028454012594 - 0.014742352047969667j), 9)
     self.assertAlmostEqual(finger(vk[1]),
                            (0.72086205228976086 + 0.008685417852198991j),
                            9)
     self.assertAlmostEqual(finger(vk[2]),
                            (0.89846608130483663 - 0.011091006902191652j),
                            9)
     self.assertAlmostEqual(finger(vk[3]),
                            (1.2603022679372518 + 0.015976908047169988j), 9)
     self.assertAlmostEqual(finger(vk[4]),
                            (1.0490207113210683 - 0.0124264368209042j), 9)
     self.assertAlmostEqual(finger(vk[5]),
                            (0.99252601243537519 + 0.012694645170333901j),
                            9)
     self.assertAlmostEqual(finger(vk[6]),
                            (0.92165252496655681 - 0.012036431811316016j),
                            9)
     self.assertAlmostEqual(finger(vk[7]),
                            (0.85167195537980778 + 0.010089165459944104j),
                            9)
コード例 #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 = mdf.MDF(cell)
     mydf.kpts = numpy.random.random((4, 3))
     mydf.gs = numpy.asarray((5, ) * 3)
     mydf.exxdiv = None
     mydf.auxbasis = 'weigend'
     vk = mdf_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]),
                            (-2.8420747650454392 - 1.0532080235680654j), 9)
     self.assertAlmostEqual(finger(vk[1]),
                            (-7.4479964653027597 + 0.10327182213618791j), 9)
     self.assertAlmostEqual(finger(vk[2]),
                            (-2.5790215490804433 - 1.4459077150581894j), 9)
     self.assertAlmostEqual(finger(vk[3]),
                            (-0.79608989192947033 + 0.012002060547759118j),
                            9)
コード例 #23
0
ファイル: test_mdf_jk.py プロジェクト: mattwelborn/pyscf
 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 = mdf.MDF(cell)
     mydf.kpts = numpy.random.random((4, 3))
     mydf.gs = numpy.asarray((5, ) * 3)
     mydf.exxdiv = None
     mydf.auxbasis = 'weigend'
     vk = mdf_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]),
                            (-2.841991690391537 - 1.0531936354491773j), 9)
     self.assertAlmostEqual(finger(vk[1]),
                            (-7.4479409613933898 + 0.10325698693704466j), 9)
     self.assertAlmostEqual(finger(vk[2]),
                            (-2.5789885244178263 - 1.4459525565105991j), 9)
     self.assertAlmostEqual(finger(vk[3]),
                            (-0.79603867462917455 + 0.011991290978492469j),
                            9)
コード例 #24
0
ファイル: test_mdf_jk.py プロジェクト: KMCzajkowski/pyscf
 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 = mdf.MDF(cell).set(auxbasis='weigend')
     mydf.kpts = numpy.random.random((4, 3))
     mydf.gs = numpy.asarray((5, ) * 3)
     mydf.eta = 0.3
     mydf.exxdiv = None
     mydf.auxbasis = 'weigend'
     vk = mdf_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]),
                            (-2.8420690776723045 - 1.0520032225121236j), 9)
     self.assertAlmostEqual(finger(vk[1]),
                            (-7.4484073115981797 + 0.10323612296501217j), 9)
     self.assertAlmostEqual(finger(vk[2]),
                            (-2.5801797461394251 - 1.4470142156560293j), 9)
     self.assertAlmostEqual(finger(vk[3]),
                            (-0.7965970307738880 + 0.01197284205213897j), 9)
コード例 #25
0
ファイル: test_mdf_jk.py プロジェクト: mattwelborn/pyscf
 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 = mdf.MDF(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 = mdf_jk.get_k_kpts(mydf, dm, 1, mydf.kpts)
     self.assertAlmostEqual(finger(vk[0]),
                            (1.0933071616067864 - 0.01474271237640193j), 9)
     self.assertAlmostEqual(finger(vk[1]),
                            (0.72036827661735581 + 0.008685775722653022j),
                            9)
     self.assertAlmostEqual(finger(vk[2]),
                            (0.8979620015620533 - 0.011091372770818691j), 9)
     self.assertAlmostEqual(finger(vk[3]),
                            (1.2597854134048272 + 0.015977292598694546j), 9)
     self.assertAlmostEqual(finger(vk[4]),
                            (1.0485047112408323 - 0.012426816811955727j), 9)
     self.assertAlmostEqual(finger(vk[5]),
                            (0.99202495287727066 + 0.012695003848138148j),
                            9)
     self.assertAlmostEqual(finger(vk[6]),
                            (0.92114488719642162 - 0.012036800944772899j),
                            9)
     self.assertAlmostEqual(finger(vk[7]),
                            (0.85115980145319536 + 0.010089537647891509j),
                            9)
コード例 #26
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.h = numpy.eye(3) * 2.5
        cell.gs = [5] * 3
        cell.build()
        kpts = cell.make_kpts((2, 2, 2))

        numpy.random.seed(1)
        nao = cell.nao_nr()
        dm = numpy.random.random((8, nao, nao))
        mydf = mdf.MDF(cell)
        mydf.kpts = kpts
        mydf.auxbasis = 'weigend'
        mydf.exxdiv = None
        vk = mdf_jk.get_k_kpts(mydf, dm, 0, mydf.kpts)
        self.assertAlmostEqual(finger(vk[0]),
                               (0.54167993564799133 - 0.0078722013632614562j),
                               9)
        self.assertAlmostEqual(finger(vk[1]),
                               (0.3593714867663208 + 0.0036054974436528706j),
                               9)
        self.assertAlmostEqual(finger(vk[2]),
                               (0.46234927585203783 - 0.0065043520189423856j),
                               9)
        self.assertAlmostEqual(finger(vk[3]),
                               (0.63626519337979948 + 0.0075118282426430818j),
                               9)
        self.assertAlmostEqual(finger(vk[4]),
                               (0.53630228285345427 - 0.0076423773076679524j),
                               9)
        self.assertAlmostEqual(finger(vk[5]),
                               (0.4956577130753681 + 0.0060590034846796439j),
                               9)
        self.assertAlmostEqual(finger(vk[6]),
                               (0.45380714659933519 - 0.0068616367194157396j),
                               9)
        self.assertAlmostEqual(finger(vk[7]),
                               (0.41808297427780505 + 0.0051096506509061114j),
                               9)

        numpy.random.seed(1)
        dm = numpy.random.random((8, nao, nao))
        dm = dm + dm.transpose(0, 2, 1)
        vk = mdf_jk.get_k_kpts(mydf, dm, 1, mydf.kpts)
        self.assertAlmostEqual(finger(vk[0]),
                               (1.0929902110020242 - 0.014742288503285355j), 9)
        self.assertAlmostEqual(finger(vk[1]),
                               (0.72006803096300986 + 0.0086853082996361259j),
                               9)
        self.assertAlmostEqual(finger(vk[2]),
                               (0.89763598759314234 - 0.011090943227218j), 9)
        self.assertAlmostEqual(finger(vk[3]),
                               (1.2594746237554506 + 0.015976836949610319j), 9)
        self.assertAlmostEqual(finger(vk[4]),
                               (1.0482108645807622 - 0.012426406003793576j), 9)
        self.assertAlmostEqual(finger(vk[5]),
                               (0.99174830962018801 + 0.012694552375379626j),
                               9)
        self.assertAlmostEqual(finger(vk[6]),
                               (0.9208432538335829 - 0.01203638564702492j), 9)
        self.assertAlmostEqual(finger(vk[7]),
                               (0.8508739289672812 + 0.010089099047683993j), 9)