Esempio n. 1
0
    def _test_cu_metallic_nonequal_occ(self,
                                       kmf,
                                       cell,
                                       ecc1_bench=-0.9646107739333411):
        assert cell.mesh == [7, 7, 7]
        max_cycle = 5  # Too expensive to do more

        # The following calculation at full convergence gives -0.711071910294612
        # for a cell.mesh = [25, 25, 25].
        mycc = pbcc.kccsd_rhf.RCCSD(kmf, frozen=None)
        mycc.diis_start_cycle = 1
        mycc.iterative_damping = 0.05
        mycc.max_cycle = max_cycle
        eris = mycc.ao2mo()
        eris.mo_energy = [f.diagonal() for f in eris.fock]
        ecc1, t1, t2 = mycc.kernel(eris=eris)

        self.assertAlmostEqual(ecc1, ecc1_bench, 5)

        # IP
        nroots = 3
        # Default
        eip_d, _ = mycc.ipccsd(nroots=nroots)
        # Koopmans
        eip_k, _ = mycc.ipccsd(nroots=nroots, koopmans=True)
        # Manual (Koopmans)
        size = eom_kccsd_rhf.EOMIP(mycc).vector_size()
        guess = np.zeros((nroots, size))
        for i in range(mycc.nkpts):
            nocc = mycc.get_nocc(True)[i]
            rr = np.arange(nroots)
            guess[rr, nocc - rr - 1] = 1
        eip_m, _ = mycc.ipccsd(nroots=3, guess=guess)

        np.testing.assert_allclose(eip_k, eip_m)  # FIXME
        np.testing.assert_allclose(eip_d[:, 0], eip_k[:, 0], atol=1e-4)

        # EA
        # Default
        eea_d, _ = mycc.eaccsd(nroots=nroots)
        # Koopmans
        eea_k, _ = mycc.eaccsd(nroots=nroots, koopmans=True)
        # Manual (Koopmans)
        size = eom_kccsd_rhf.EOMEA(mycc).vector_size()
        guess = np.zeros((nroots, size))
        for i in range(mycc.nkpts):
            rr = np.arange(nroots)
            guess[rr, rr] = 1
        eea_m, _ = mycc.eaccsd(nroots=3, guess=guess)

        np.testing.assert_allclose(eea_k, eea_m)
        np.testing.assert_allclose(eea_d[1, :], eea_k[1, :], atol=1e-4)
Esempio n. 2
0
def _run_ip_matvec(cc, r1, r2, kshift):
    eom = eom_kccsd_rhf.EOMIP(cc)
    vector = eom.amplitudes_to_vector(r1, r2, kshift)
    vector = eom.matvec(vector, kshift)
    Hr1, Hr2 = eom.vector_to_amplitudes(vector, kshift)
    return Hr1, Hr2