def ao2mo(self, mo_coeff=None): nmo = self.nmo nao = self.mo_coeff.shape[0] nmo_pair = nmo * (nmo+1) // 2 nao_pair = nao * (nao+1) // 2 mem_incore = (max(nao_pair**2, nmo**4) + nmo_pair**2) * 8/1e6 mem_now = lib.current_memory()[0] if (self._scf._eri is not None and (mem_incore+mem_now < self.max_memory) or self.mol.incore_anyway): return ccsd._make_eris_incore(self, mo_coeff) if getattr(self._scf, 'with_df', None): logger.warn(self, 'CISD detected DF being used in the HF object. ' 'MO integrals are computed based on the DF 3-index tensors.\n' 'It\'s recommended to use dfccsd.CCSD for the ' 'DF-CISD calculations') return ccsd._make_df_eris_outcore(self, mo_coeff) return ccsd._make_eris_outcore(self, mo_coeff)
if __name__ == '__main__': from pyscf import gto from pyscf import ao2mo mol = gto.Mole() mol.verbose = 0 mol.atom = [ ['O', (0., 0., 0.)], ['H', (0., -0.757, 0.587)], ['H', (0., 0.757, 0.587)], ] mol.basis = 'sto3g' mol.build() mf = scf.RHF(mol).run() myci = CISD(mf) eris = ccsd._make_eris_outcore(myci, mf.mo_coeff) ecisd, civec = myci.kernel(eris=eris) print(ecisd - -0.048878084082066106) nmo = myci.nmo nocc = myci.nocc rdm1 = myci.make_rdm1(civec) rdm2 = myci.make_rdm2(civec) h1e = reduce(numpy.dot, (mf.mo_coeff.T, mf.get_hcore(), mf.mo_coeff)) h2e = ao2mo.kernel(mf._eri, mf.mo_coeff) h2e = ao2mo.restore(1, h2e, nmo) e2 = (numpy.einsum('ij,ji', h1e, rdm1) + numpy.einsum('ijkl,ijkl', h2e, rdm2) * .5) print(ecisd + mf.e_tot - mol.energy_nuc() - e2) # = 0 print(