def test_rdm1(self): 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 = '631g' mol.build() mf = scf.RHF(mol).run(conv_tol=1e-14) myci = ci.CISD(mf) myci.frozen = 1 myci.kernel() nmo = myci.nmo nocc = myci.nocc d1 = cisd._gamma1_intermediates(myci, myci.ci, nmo, nocc) myci.max_memory = 0 d2 = cisd._gamma2_intermediates(myci, myci.ci, nmo, nocc, True) dm2 = cisd.ccsd_rdm._make_rdm2(myci, d1, d2, with_dm1=True, with_frozen=True) dm1 = numpy.einsum('ijkk->ij', dm2)/(mol.nelectron-1) h1 = reduce(numpy.dot, (mf.mo_coeff.T, mf.get_hcore(), mf.mo_coeff)) eri = ao2mo.restore(1, ao2mo.kernel(mf._eri, mf.mo_coeff), nmo+1) e1 = numpy.einsum('ij,ji', h1, dm1) e1+= numpy.einsum('ijkl,ijkl', eri, dm2) * .5 e1+= mol.energy_nuc() self.assertAlmostEqual(e1, myci.e_tot, 7)
def grad_elec(cigrad, civec=None, eris=None, atmlst=None, verbose=logger.INFO): myci = cigrad.base if civec is None: civec = myci.ci assert(not isinstance(civec, (list, tuple))) nocc = myci.nocc nmo = myci.nmo d1 = cisd._gamma1_intermediates(myci, civec, nmo, nocc) fd2intermediate = lib.H5TmpFile() d2 = cisd._gamma2_outcore(myci, civec, nmo, nocc, fd2intermediate, True) t1 = t2 = l1 = l2 = civec return ccsd_grad.grad_elec(cigrad, t1, t2, l1, l2, eris, atmlst, d1, d2, verbose)