mol.build() mf0 = mf = scf.UHF(mol).run(conv_tol=1) mf = scf.addons.convert_to_ghf(mf) from pyscf.cc import uccsd_t_slow from pyscf.cc import uccsd_t_lambda from pyscf.cc import uccsd_t_rdm mycc0 = cc.UCCSD(mf0) eris0 = mycc0.ao2mo() mycc0.kernel(eris=eris0) t1 = mycc0.t1 t2 = mycc0.t2 imds = uccsd_t_lambda.make_intermediates(mycc0, t1, t2, eris0) l1, l2 = uccsd_t_lambda.update_lambda(mycc0, t1, t2, t1, t2, eris0, imds) dm1ref = uccsd_t_rdm.make_rdm1(mycc0, t1, t2, l1, l2, eris0) dm2ref = uccsd_t_rdm.make_rdm2(mycc0, t1, t2, l1, l2, eris0) mycc = cc.GCCSD(mf) eris = mycc.ao2mo() t1 = mycc.spatial2spin(t1, mycc.mo_coeff.orbspin) t2 = mycc.spatial2spin(t2, mycc.mo_coeff.orbspin) l1 = mycc.spatial2spin(l1, mycc.mo_coeff.orbspin) l2 = mycc.spatial2spin(l2, mycc.mo_coeff.orbspin) gdm1 = make_rdm1(mycc, t1, t2, l1, l2, eris) gdm2 = make_rdm2(mycc, t1, t2, l1, l2, eris) idxa = numpy.where(mycc.mo_coeff.orbspin == 0)[0] idxb = numpy.where(mycc.mo_coeff.orbspin == 1)[0] print(abs(dm1ref[0] - gdm1[idxa[:,None],idxa]).max()) print(abs(dm1ref[1] - gdm1[idxb[:,None],idxb]).max()) print(abs(dm2ref[0] - gdm2[idxa[:,None,None,None],idxa[:,None,None],idxa[:,None],idxa]).max())
mol.build() mf0 = mf = scf.UHF(mol).run(conv_tol=1) mf = scf.addons.convert_to_ghf(mf) from pyscf.cc import uccsd_t_slow from pyscf.cc import uccsd_t_lambda from pyscf.cc import uccsd_t_rdm mycc0 = cc.UCCSD(mf0) eris0 = mycc0.ao2mo() mycc0.kernel(eris=eris0) t1 = mycc0.t1 t2 = mycc0.t2 imds = uccsd_t_lambda.make_intermediates(mycc0, t1, t2, eris0) l1, l2 = uccsd_t_lambda.update_lambda(mycc0, t1, t2, t1, t2, eris0, imds) dm1ref = uccsd_t_rdm.make_rdm1(mycc0, t1, t2, l1, l2, eris0) dm2ref = uccsd_t_rdm.make_rdm2(mycc0, t1, t2, l1, l2, eris0) mycc = cc.GCCSD(mf) eris = mycc.ao2mo() t1 = mycc.spatial2spin(t1, mycc.mo_coeff.orbspin) t2 = mycc.spatial2spin(t2, mycc.mo_coeff.orbspin) l1 = mycc.spatial2spin(l1, mycc.mo_coeff.orbspin) l2 = mycc.spatial2spin(l2, mycc.mo_coeff.orbspin) gdm1 = make_rdm1(mycc, t1, t2, l1, l2, eris) gdm2 = make_rdm2(mycc, t1, t2, l1, l2, eris) idxa = numpy.where(mycc.mo_coeff.orbspin == 0)[0] idxb = numpy.where(mycc.mo_coeff.orbspin == 1)[0] print(abs(dm1ref[0] - gdm1[idxa[:, None], idxa]).max()) print(abs(dm1ref[1] - gdm1[idxb[:, None], idxb]).max()) print(
mcc = cc.UCCSD(a) mcc.frozen = frozen mcc.diis_space = 10 mcc.conv_tol = 1e-6 mcc.conv_tol_normt = 1e-6 mcc.max_cycle = 150 ecc = mcc.kernel()[0] eris = mcc.ao2mo() e3 = uccsd_t.kernel(mcc, eris, mcc.t1, mcc.t2) lib.logger.info(mcc, "* CCSD(T) energy : %12.6f" % (ehf + ecc + e3)) l1, l2 = uccsd_t_lambda.kernel(mcc, eris, mcc.t1, mcc.t2)[1:] rdm1a, rdm1b = uccsd_t_rdm.make_rdm1(mcc, mcc.t1, mcc.t2, l1, l2, eris=eris) rdm2aa, rdm2ab, rdm2bb = uccsd_t_rdm.make_rdm2(mcc, mcc.t1, mcc.t2, l1, l2, eris=eris) mo_a = a.mo_coeff[0] mo_b = a.mo_coeff[1] nmoa = mo_a.shape[1] nmob = mo_b.shape[1] eriaa = ao2mo.kernel(a._eri, mo_a, compact=False).reshape([nmoa] * 4) eribb = ao2mo.kernel(a._eri, mo_b, compact=False).reshape([nmob] * 4) eriab = ao2mo.kernel(a._eri, (mo_a, mo_a, mo_b, mo_b), compact=False) eriab = eriab.reshape([nmoa, nmoa, nmob, nmob]) hcore = a.get_hcore() h1a = reduce(numpy.dot, (mo_a.T.conj(), hcore, mo_a)) h1b = reduce(numpy.dot, (mo_b.T.conj(), hcore, mo_b)) e1 = einsum('ij,ji', h1a, rdm1a)