Пример #1
0
    def _test_ea_diag(self, kmf, kshift=0):
        cc = kccsd.KUCCSD(kmf)
        Ecc = cc.kernel()[0]

        eom = kccsd_uhf.EOMEA(cc)
        imds = eom.make_imds()
        t1a, t1b = imds.t1
        nkpts, nocc_a, nvir_a = t1a.shape
        nkpts, nocc_b, nvir_b = t1b.shape
        nocc = nocc_a + nocc_b
        nvir = nvir_a + nvir_b
        diag = kccsd_uhf.eaccsd_diag(eom, kshift, imds=imds)

        I = np.identity(diag.shape[0], dtype=complex)
        indices = np.arange(diag.shape[0])
        H = np.zeros((I.shape[0], len(indices)), dtype=complex)
        for j, idx in enumerate(indices):
            H[:, j] = kccsd_uhf.eaccsd_matvec(eom,
                                              I[:, idx],
                                              kshift,
                                              imds=imds)

        diag_ref = np.zeros(len(indices), dtype=complex)
        diag_out = np.zeros(len(indices), dtype=complex)
        for j, idx in enumerate(indices):
            diag_ref[j] = H[idx, j]
            diag_out[j] = diag[idx]
        diff = np.linalg.norm(diag_ref - diag_out)
        self.assertTrue(
            abs(diff) < KGCCSD_TEST_THRESHOLD,
            "Difference in EA diag: {}".format(diff))
Пример #2
0
    def _test_ip_diag(self,kmf,kshift=0):
        cc = kccsd.KUCCSD(kmf)
        Ecc = cc.kernel()[0]

        eom = kccsd_uhf.EOMIP(cc)
        imds = eom.make_imds()
        t1a,t1b = imds.t1
        nkpts, nocc_a, nvir_a = t1a.shape
        nkpts, nocc_b, nvir_b = t1b.shape
        nocc = nocc_a + nocc_b
        diag = kccsd_uhf.ipccsd_diag(eom,kshift,imds=imds)
        
        I = np.zeros((diag.shape[0],diag.shape[0]),dtype=complex)
        I[:nocc,:nocc] = np.identity(nocc,dtype=complex)
        indices = get_ip_identity(nocc_a,nocc_b,nvir_a,nvir_b,nkpts,I)
        H = np.zeros((I.shape[0],len(indices)),dtype=complex)
        for j,idx in enumerate(indices):
            H[:,j] = kccsd_uhf.ipccsd_matvec(eom,I[:,idx],kshift,imds=imds)

        diag_ref = np.zeros(len(indices),dtype=complex)
        diag_out = np.zeros(len(indices),dtype=complex)
        for j,idx in enumerate(indices):
            diag_ref[j] = H[idx,j]
            diag_out[j] = diag[idx]
        diff = np.linalg.norm(diag_ref - diag_out)
        self.assertTrue(abs(diff) < thresh,"Difference in IP diag: {}".format(diff))