Example #1
0
    def test_ccsd_grad(self):
        mycc = cc.ccsd.CCSD(mf)
        mycc.max_memory = 1
        mycc.conv_tol = 1e-10
        eris = mycc.ao2mo()
        ecc, t1, t2 = mycc.kernel(eris=eris)
        l1, l2 = mycc.solve_lambda(eris=eris)
        g1 = ccsd_grad.Gradients(mycc).kernel(t1, t2, l1, l2)
        self.assertAlmostEqual(lib.finger(g1), -0.036999389889460096, 6)

        mol = gto.M(verbose=5,
                    output='/dev/null',
                    atom='H 0 0 0; H 0 0 1.706',
                    basis='631g',
                    unit='Bohr')
        mf0 = scf.RHF(mol).run(conv_tol=1e-14)
        mycc0 = cc.ccsd.CCSD(mf0).run(conv_tol=1e-10)
        mol.set_geom_('H 0 0 0; H 0 0 1.704', unit='Bohr')
        mf1 = scf.RHF(mol).run(conv_tol=1e-14)
        mycc1 = cc.ccsd.CCSD(mf1).run(conv_tol=1e-10)
        mol.set_geom_('H 0 0 0; H 0 0 1.705', unit='Bohr')
        mycc2 = cc.ccsd.CCSD(scf.RHF(mol))
        g_scanner = mycc2.nuc_grad_method().as_scanner().as_scanner()
        g1 = g_scanner(mol)[1]
        self.assertTrue(g_scanner.converged)
        self.assertAlmostEqual(g1[0, 2], (mycc1.e_tot - mycc0.e_tot) * 500, 6)
Example #2
0
def grad_elec(cc_grad, t1=None, t2=None, l1=None, l2=None, eris=None, atmlst=None,
              verbose=lib.logger.INFO):
    mycc = cc_grad.base
    if t1 is None: t1 = mycc.t1
    if t2 is None: t2 = mycc.t2
    if l1 is None: l1 = mycc.l1
    if l2 is None: l2 = mycc.l2
    if eris is None: eris = mycc.ao2mo()
    d1 = ccsd_t_rdm._gamma1_intermediates(mycc, t1, t2, l1, l2, eris,
                                          for_grad=True)
    fd2intermediate = lib.H5TmpFile()
    d2 = ccsd_t_rdm._gamma2_outcore(mycc, t1, t2, l1, l2, eris,
                                    fd2intermediate, True)
    cc_grad = ccsd_grad.Gradients(mycc)
    de = ccsd_grad.grad_elec(cc_grad, t1, t2, l1, l2, eris, atmlst,
                             d1, d2, verbose)
    return de