Example #1
0
    def test_Lsym(self):
        no = 3
        nv = 4
        L1, L2 = test_utils.make_random_L(no, nv)

        test = L2 + L2.transpose((0, 1, 3, 2))
        s1 = numpy.linalg.norm(test) < self.thresh
        test = L2 + L2.transpose((1, 0, 2, 3))
        s2 = numpy.linalg.norm(test) < self.thresh
        test = L2 - L2.transpose((1, 0, 3, 2))
        s3 = numpy.linalg.norm(test) < self.thresh
        err = "Bad symmetry in T2"
        self.assertTrue(s1 and s2 and s3, err)
Example #2
0
    def test_ccd(self):
        no = self.no
        nv = self.nv
        T1old, T2old = test_utils.make_random_T(no, nv)
        L1old, L2old = test_utils.make_random_L(no, nv)
        F, I = test_utils.make_random_integrals(no, nv)
        T1old = numpy.zeros((nv, no))
        L1old = numpy.zeros((no, nv))

        L2 = cc_equations.ccd_lambda_simple(F, I, L2old, T2old)
        L1t, L2t \
            = cc_equations.ccsd_lambda_simple(F, I, L1old, L2old, T1old, T2old)
        D = numpy.linalg.norm(L2 - L2t)
        s = D < self.thresh
        err = "Error in CCD L2"
        self.assertTrue(s, err)
Example #3
0
    def test_2rdm_opt(self):
        no = 4
        nv = 8
        thresh = 1e-12
        T1, T2 = test_utils.make_random_T(no, nv)
        L1, L2 = test_utils.make_random_L(no, nv)

        pcdab_ref = cc_equations.ccsd_2rdm_cdab(T1, T2, L1, L2)
        pcdab_out = cc_equations.ccsd_2rdm_cdab_opt(T1, T2, L1, L2)
        diff = numpy.linalg.norm(pcdab_ref - pcdab_out)
        diff /= numpy.sqrt(pcdab_ref.size)
        self.assertTrue(diff < thresh, "Error in p_cdab: {}".format(diff))

        pbcai_ref = cc_equations.ccsd_2rdm_bcai(T1, T2, L1, L2)
        pbcai_out = cc_equations.ccsd_2rdm_bcai_opt(T1, T2, L1, L2)
        diff = numpy.linalg.norm(pbcai_ref - pbcai_out)
        diff /= numpy.sqrt(pbcai_ref.size)
        self.assertTrue(diff < thresh, "Error in p_bcai: {}".format(diff))

        pbjai_ref = cc_equations.ccsd_2rdm_bjai(T1, T2, L1, L2)
        pbjai_out = cc_equations.ccsd_2rdm_bjai_opt(T1, T2, L1, L2)
        diff = numpy.linalg.norm(pbjai_ref - pbjai_out)
        diff /= numpy.sqrt(pbjai_ref.size)
        self.assertTrue(diff < thresh, "Error in p_bjai: {}".format(diff))

        pabij_ref = cc_equations.ccsd_2rdm_abij(T1, T2, L1, L2)
        pabij_out = cc_equations.ccsd_2rdm_abij_opt(T1, T2, L1, L2)
        diff = numpy.linalg.norm(pabij_ref - pabij_out)
        diff /= numpy.sqrt(pabij_ref.size)
        self.assertTrue(diff < thresh, "Error in p_abij: {}".format(diff))

        pkaij_ref = cc_equations.ccsd_2rdm_kaij(T1, T2, L1, L2)
        pkaij_out = cc_equations.ccsd_2rdm_kaij_opt(T1, T2, L1, L2)
        diff = numpy.linalg.norm(pkaij_ref - pkaij_out)
        diff /= numpy.sqrt(pkaij_ref.size)
        self.assertTrue(diff < thresh, "Error in p_kaij: {}".format(diff))

        pklij_ref = cc_equations.ccsd_2rdm_klij(T1, T2, L1, L2)
        pklij_out = cc_equations.ccsd_2rdm_klij_opt(T1, T2, L1, L2)
        diff = numpy.linalg.norm(pklij_ref - pklij_out)
        diff /= numpy.sqrt(pklij_ref.size)
        self.assertTrue(diff < thresh, "Error in p_klij: {}".format(diff))
Example #4
0
    def test_ccsd_stanton(self):
        no = self.no
        nv = self.nv
        T1old, T2old = test_utils.make_random_T(no, nv)
        L1old, L2old = test_utils.make_random_L(no, nv)
        F, I = test_utils.make_random_integrals(no, nv)

        L1sim, L2sim = cc_equations.ccsd_lambda_simple(F, I, L1old, L2old,
                                                       T1old, T2old)
        L1opt, L2opt = cc_equations.ccsd_lambda_stanton(
            F, I, L1old, L2old, T1old, T2old)

        D1 = numpy.linalg.norm(L1sim - L1opt)
        D2 = numpy.linalg.norm(L2sim - L2opt)
        s1 = D1 < self.thresh
        s2 = D2 < self.thresh
        e1 = "Error in optimized L1"
        e2 = "Error in optimized L2"
        self.assertTrue(s1, e1)
        self.assertTrue(s2, e2)
Example #5
0
    def test_1rdm_opt(self):
        no = 4
        nv = 8
        thresh = 1e-12
        T1, T2 = test_utils.make_random_T(no, nv)
        L1, L2 = test_utils.make_random_L(no, nv)

        pba_ref = cc_equations.ccsd_1rdm_ba(T1, T2, L1, L2)
        pba_out = cc_equations.ccsd_1rdm_ba_opt(T1, T2, L1, L2)
        diff = numpy.linalg.norm(pba_ref - pba_out)/numpy.sqrt(pba_ref.size)
        self.assertTrue(diff < thresh, "Error in p_ba: {}".format(diff))

        pji_ref = cc_equations.ccsd_1rdm_ji(T1, T2, L1, L2)
        pji_out = cc_equations.ccsd_1rdm_ji_opt(T1, T2, L1, L2)
        diff = numpy.linalg.norm(pji_ref - pji_out)/numpy.sqrt(pji_ref.size)
        self.assertTrue(diff < thresh, "Error in p_ji: {}".format(diff))

        pai_ref = cc_equations.ccsd_1rdm_ai(T1, T2, L1, L2)
        pai_out = cc_equations.ccsd_1rdm_ai_opt(T1, T2, L1, L2)
        diff = numpy.linalg.norm(pai_ref - pai_out)/numpy.sqrt(pai_ref.size)
        self.assertTrue(diff < thresh, "Error in p_ai: {}".format(diff))