def test_jk(self): mf = df_jk.density_fit(mf0, auxbasis='weigend', gs=(5,)*3) dm = mf.get_init_guess() vj, vk = mf.get_jk(cell, dm) ej1 = numpy.einsum('ij,ji->', vj, dm) ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ej1, 46.698942503368144, 8) self.assertAlmostEqual(ek1, 31.723584951501 , 8) numpy.random.seed(12) nao = cell.nao_nr() dm = numpy.random.random((nao,nao)) dm = dm + dm.T vj1, vk1 = mf.get_jk(cell, dm, hermi=0) ej1 = numpy.einsum('ij,ji->', vj1, dm) ek1 = numpy.einsum('ij,ji->', vk1, dm) self.assertAlmostEqual(ej1, 242.04814846354407, 8) self.assertAlmostEqual(ek1, 280.16142282936778, 8) numpy.random.seed(1) kpt = numpy.random.random(3) mydf = df.DF(cell, [kpt]) vj, vk = mydf.get_jk(dm, 1, kpt) ej1 = numpy.einsum('ij,ji->', vj, dm) ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ej1, 231.44815444295386+0j, 8) self.assertAlmostEqual(ek1, 682.70050207852307+0j, 8)
def test_jk_single_kpt(self): mf = df_jk.density_fit(mf0, auxbasis='weigend', gs=(5, ) * 3) mf.with_df.gs = cell.gs mf.with_df.eta = 0.3 dm = mf.get_init_guess() vj, vk = mf.get_jk(cell, dm) ej1 = numpy.einsum('ij,ji->', vj, dm) ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ej1, 46.69888588120217, 8) self.assertAlmostEqual(ek1, 31.72349032270801, 8) numpy.random.seed(12) nao = cell.nao_nr() dm = numpy.random.random((nao, nao)) dm = dm + dm.T vj1, vk1 = mf.get_jk(cell, dm, hermi=0) ej1 = numpy.einsum('ij,ji->', vj1, dm) ek1 = numpy.einsum('ij,ji->', vk1, dm) self.assertAlmostEqual(ej1, 242.04678235140264, 8) self.assertAlmostEqual(ek1, 280.15934926575903, 8) numpy.random.seed(1) kpt = numpy.random.random(3) mydf = df.DF(cell, [kpt]).set(auxbasis='weigend') mydf.gs = cell.gs mydf.eta = 0.3 vj, vk = mydf.get_jk(dm, 1, kpt, exxdiv=None) ej1 = numpy.einsum('ij,ji->', vj, dm) ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ej1, 241.15121903857556 + 0j, 8) self.assertAlmostEqual(ek1, 279.64649194057051 + 0j, 8) vj, vk = mydf.get_jk(dm, 1, kpt, with_j=False, exxdiv='ewald') ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ek1, 691.64624456329909 + 0j, 6)
def test_jk(self): mf = df_jk.density_fit(mf0, auxbasis='weigend', gs=(5, ) * 3) dm = mf.get_init_guess() vj, vk = mf.get_jk(cell, dm) ej1 = numpy.einsum('ij,ji->', vj, dm) ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ej1, 46.698942503368144, 8) self.assertAlmostEqual(ek1, 31.723584951501, 8) numpy.random.seed(12) nao = cell.nao_nr() dm = numpy.random.random((nao, nao)) dm = dm + dm.T vj1, vk1 = mf.get_jk(cell, dm, hermi=0) ej1 = numpy.einsum('ij,ji->', vj1, dm) ek1 = numpy.einsum('ij,ji->', vk1, dm) self.assertAlmostEqual(ej1, 242.04814846354407, 8) self.assertAlmostEqual(ek1, 280.16142282936778, 8) numpy.random.seed(1) kpt = numpy.random.random(3) mydf = df.DF(cell, [kpt]) vj, vk = mydf.get_jk(dm, 1, kpt) ej1 = numpy.einsum('ij,ji->', vj, dm) ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ej1, 231.44815444295386 + 0j, 8) self.assertAlmostEqual(ek1, 682.70050207852307 + 0j, 8)
def test_jk_single_kpt(self): mf = df_jk.density_fit(mf0, auxbasis='weigend', gs=(5, ) * 3) mf.with_df.gs = cell.gs mf.with_df.eta = 0.3 dm = mf.get_init_guess() vj, vk = mf.get_jk(cell, dm) ej1 = numpy.einsum('ij,ji->', vj, dm) ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ej1, 46.69888588854387, 8) self.assertAlmostEqual(ek1, 31.72349032270801, 8) numpy.random.seed(12) nao = cell.nao_nr() dm = numpy.random.random((nao, nao)) dm = dm + dm.T vj1, vk1 = mf.get_jk(cell, dm, hermi=0) ej1 = numpy.einsum('ij,ji->', vj1, dm) ek1 = numpy.einsum('ij,ji->', vk1, dm) self.assertAlmostEqual(ej1, 242.04675958582985, 8) self.assertAlmostEqual(ek1, 280.15934765887238, 8) numpy.random.seed(1) kpt = numpy.random.random(3) mydf = df.DF(cell, [kpt]).set(auxbasis='weigend') mydf.gs = cell.gs mydf.eta = 0.3 vj, vk = mydf.get_jk(dm, 1, kpt, exxdiv=None) ej1 = numpy.einsum('ij,ji->', vj, dm) ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ej1, 241.1511965365826 + 0j, 8) self.assertAlmostEqual(ek1, 279.64649180140344 + 0j, 8) vj, vk = mydf.get_jk(dm, 1, kpt, with_j=False, exxdiv='ewald') ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ek1, 691.64624442413174 + 0j, 6)
def test_jk(self): mf = df_jk.density_fit(mf0, auxbasis='weigend', gs=(5, ) * 3) dm = mf.get_init_guess() vj, vk = mf.get_jk(cell, dm) ej1 = numpy.einsum('ij,ji->', vj, dm) ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ej1, 46.698885887058495, 8) self.assertAlmostEqual(ek1, 31.723490322441389, 8) numpy.random.seed(12) nao = cell.nao_nr() dm = numpy.random.random((nao, nao)) dm = dm + dm.T vj1, vk1 = mf.get_jk(cell, dm, hermi=0) ej1 = numpy.einsum('ij,ji->', vj1, dm) ek1 = numpy.einsum('ij,ji->', vk1, dm) self.assertAlmostEqual(ej1, 242.04675570748412, 8) self.assertAlmostEqual(ek1, 280.15933405636196, 8) numpy.random.seed(1) kpt = numpy.random.random(3) mydf = df.DF(cell, [kpt]) vj, vk = mydf.get_jk(dm, 1, kpt, exxdiv=None) ej1 = numpy.einsum('ij,ji->', vj, dm) ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ej1, 241.15119240999368 + 0j, 8) self.assertAlmostEqual(ek1, 279.64647733018984 + 0j, 8) vj, vk = mydf.get_jk(dm, 1, kpt, with_j=False, exxdiv='ewald') ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ek1, 691.98171156880562 + 0j, 8)
def test_jk(self): mf = df_jk.density_fit(mf0, auxbasis='weigend', gs=(5,)*3) dm = mf.get_init_guess() vj, vk = mf.get_jk(cell, dm) ej1 = numpy.einsum('ij,ji->', vj, dm) ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ej1, 46.698885887058495, 8) self.assertAlmostEqual(ek1, 31.723490322441389, 8) numpy.random.seed(12) nao = cell.nao_nr() dm = numpy.random.random((nao,nao)) dm = dm + dm.T vj1, vk1 = mf.get_jk(cell, dm, hermi=0) ej1 = numpy.einsum('ij,ji->', vj1, dm) ek1 = numpy.einsum('ij,ji->', vk1, dm) self.assertAlmostEqual(ej1, 242.04675958581976, 8) self.assertAlmostEqual(ek1, 280.15934765885805, 8) numpy.random.seed(1) kpt = numpy.random.random(3) mydf = df.DF(cell, [kpt]) vj, vk = mydf.get_jk(dm, 1, kpt, exxdiv=None) ej1 = numpy.einsum('ij,ji->', vj, dm) ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ej1, 241.15119653657837+0j, 8) self.assertAlmostEqual(ek1, 279.64649180139776+0j, 8) vj, vk = mydf.get_jk(dm, 1, kpt, with_j=False, exxdiv='ewald') ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ek1, 691.6462444241248+0j, 6)
def test_jk_single_kpt_high_cost(self): mf0 = pscf.RHF(cell) mf0.exxdiv = None mf = df_jk.density_fit(mf0, auxbasis='weigend', mesh=(11,)*3) mf.with_df.mesh = cell.mesh mf.with_df.eta = 0.3 mf.with_df.exp_to_discard = 0.3 dm = mf.get_init_guess() vj, vk = mf.get_jk(cell, dm) ej1 = numpy.einsum('ij,ji->', vj, dm) ek1 = numpy.einsum('ij,ji->', vk, dm) j_ref = 48.283789539266174 # rsjk result k_ref = 32.30441176447805 # rsjk result self.assertAlmostEqual(ej1, j_ref, 4) self.assertAlmostEqual(ek1, k_ref, 2) self.assertAlmostEqual(ej1, 48.283745538383684, 8) self.assertAlmostEqual(ek1, 32.30260871417842 , 8) numpy.random.seed(12) nao = cell.nao_nr() dm = numpy.random.random((nao,nao)) dm = dm + dm.T vj1, vk1 = mf.get_jk(cell, dm, hermi=0) ej1 = numpy.einsum('ij,ji->', vj1, dm) ek1 = numpy.einsum('ij,ji->', vk1, dm) self.assertAlmostEqual(ej1, 242.04678235140264, 8) self.assertAlmostEqual(ek1, 280.15934926575903, 8) numpy.random.seed(1) kpt = numpy.random.random(3) mydf = df.DF(cell, [kpt]).set(auxbasis='weigend') mydf.linear_dep_threshold = 1e-7 mydf.mesh = cell.mesh mydf.eta = 0.3 mydf.exp_to_discard = mydf.eta vj, vk = mydf.get_jk(dm, 1, kpt, exxdiv=None) ej1 = numpy.einsum('ij,ji->', vj, dm) ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ej1, 241.15121903857556+0j, 8) self.assertAlmostEqual(ek1, 279.64649194057051+0j, 8) vj, vk = mydf.get_jk(dm, 1, kpt, with_j=False, exxdiv='ewald') ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ek1, 691.64624456329909+0j, 6)
def test_jk_single_kpt(self): mf = df_jk.density_fit(mf0, auxbasis='weigend', mesh=(11,)*3) mf.with_df.mesh = cell.mesh mf.with_df.eta = 0.3 mf.with_df.exp_to_discard = 0.3 dm = mf.get_init_guess() vj, vk = mf.get_jk(cell, dm) ej1 = numpy.einsum('ij,ji->', vj, dm) ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ej1, 46.69888588120217, 8) self.assertAlmostEqual(ek1, 31.72349032270801, 8) numpy.random.seed(12) nao = cell.nao_nr() dm = numpy.random.random((nao,nao)) dm = dm + dm.T vj1, vk1 = mf.get_jk(cell, dm, hermi=0) ej1 = numpy.einsum('ij,ji->', vj1, dm) ek1 = numpy.einsum('ij,ji->', vk1, dm) self.assertAlmostEqual(ej1, 242.04678235140264, 8) self.assertAlmostEqual(ek1, 280.15934926575903, 8) numpy.random.seed(1) kpt = numpy.random.random(3) mydf = df.DF(cell, [kpt]).set(auxbasis='weigend') mydf.linear_dep_threshold = 1e-7 mydf.mesh = cell.mesh mydf.eta = 0.3 mydf.exp_to_discard = mydf.eta vj, vk = mydf.get_jk(dm, 1, kpt, exxdiv=None) ej1 = numpy.einsum('ij,ji->', vj, dm) ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ej1, 241.15121903857556+0j, 8) self.assertAlmostEqual(ek1, 279.64649194057051+0j, 8) vj, vk = mydf.get_jk(dm, 1, kpt, with_j=False, exxdiv='ewald') ek1 = numpy.einsum('ij,ji->', vk, dm) self.assertAlmostEqual(ek1, 691.64624456329909+0j, 6)
def density_fit(self, auxbasis=None, with_df=None): from pyscf.pbc.df import df_jk return df_jk.density_fit(self, auxbasis, with_df=with_df)
def density_fit(self, auxbasis=None, with_df=None): from pyscf.df.addons import aug_etb_for_dfbasis from pyscf.pbc.df import df_jk if auxbasis is None: auxbasis = aug_etb_for_dfbasis(self.cell, beta=1.8, start_at=0) return df_jk.density_fit(self, auxbasis, with_df)