def get_jk(self, dm, hermi=1, with_j=True, with_k=True, direct_scf_tol=getattr(__config__, 'scf_hf_SCF_direct_scf_tol', 1e-13), omega=None): if omega is None: return df_jk.get_jk(self, dm, hermi, with_j, with_k, direct_scf_tol) # A temporary treatment for RSH-DF integrals key = '%.6f' % omega if key in self._rsh_df: rsh_df = self._rsh_df[key] else: rsh_df = self._rsh_df[key] = copy.copy(self).reset() logger.info(self, 'Create RSH-DF object %s for omega=%s', rsh_df, omega) with rsh_df.mol.with_range_coulomb(omega): return df_jk.get_jk(rsh_df, dm, hermi, with_j, with_k, direct_scf_tol)
def get_jk(self, dm, hermi=1, with_j=True, with_k=True, direct_scf_tol=getattr(__config__, 'scf_hf_SCF_direct_scf_tol', 1e-13)): return df_jk.get_jk(self, dm, hermi, with_j, with_k, direct_scf_tol)
def test_rhf_veff(self): nao = mol.nao_nr() numpy.random.seed(1) dm = numpy.random.random((2, nao, nao)) mf = scf.density_fit(scf.RHF(mol), auxbasis='weigend') vhf1 = mf.get_veff(mol, dm, hermi=0) naux = mf._cderi.shape[0] cderi = numpy.empty((naux, nao, nao)) for i in range(naux): cderi[i] = lib.unpack_tril(mf._cderi[i]) vj0 = [] vk0 = [] for dmi in dm: v1 = numpy.einsum('kij,ij->k', cderi, dmi) vj0.append(numpy.einsum('kij,k->ij', cderi, v1)) v1 = numpy.einsum('pij,jk->pki', cderi, dmi.T) vk0.append(numpy.einsum('pki,pkj->ij', cderi, v1)) vj1, vk1 = df_jk.get_jk(mf.with_df, dm, 0) self.assertTrue(numpy.allclose(vj0, vj1)) self.assertTrue(numpy.allclose(numpy.array(vk0), vk1)) vhf0 = vj1 - vk1 * .5 self.assertTrue(numpy.allclose(vhf0, vhf1))
def test_rhf_veff(self): nao = mol.nao_nr() numpy.random.seed(1) dm = numpy.random.random((2,nao,nao)) mf = scf.density_fit(scf.RHF(mol), auxbasis='weigend') vhf1 = mf.get_veff(mol, dm, hermi=0) naux = mf._cderi.shape[0] cderi = numpy.empty((naux,nao,nao)) for i in range(naux): cderi[i] = lib.unpack_tril(mf._cderi[i]) vj0 = [] vk0 = [] for dmi in dm: v1 = numpy.einsum('kij,ij->k', cderi, dmi) vj0.append(numpy.einsum('kij,k->ij', cderi, v1)) v1 = numpy.einsum('pij,jk->pki', cderi, dmi.T) vk0.append(numpy.einsum('pki,pkj->ij', cderi, v1)) vj1, vk1 = df_jk.get_jk(mf.with_df, dm, 0) self.assertTrue(numpy.allclose(vj0, vj1)) self.assertTrue(numpy.allclose(numpy.array(vk0), vk1)) vhf0 = vj1 - vk1 * .5 self.assertTrue(numpy.allclose(vhf0, vhf1))
def get_jk(self, dm, hermi=1, vhfopt=None, with_j=True, with_k=True): return df_jk.get_jk(self, dm, hermi, vhfopt, with_j, with_k)
def get_jk(self, dm, hermi=1, vhfopt=None, with_j=True, with_k=True): return df_jk.get_jk(self, dm, hermi, vhfopt, with_j, with_k)
def get_jk(self, dm, hermi=1, vhfopt=None, with_j=True, with_k=True): from pyscf.df import df_jk return df_jk.get_jk(self, dm, hermi, vhfopt, with_j, with_k)
def get_jk(self, dm, hermi=1, vhfopt=None, with_j=True, with_k=True): from pyscf.df import df_jk return df_jk.get_jk(self, dm, hermi, vhfopt, with_j, with_k)