Example #1
0
    def test_ucc_eomee_ccsd_matvec(self):
        numpy.random.seed(10)
        r1 = [numpy.random.random((nocca,nvira))-.9,
              numpy.random.random((noccb,nvirb))-.9]
        r2 = [numpy.random.random((nocca,nocca,nvira,nvira))-.9,
              numpy.random.random((nocca,noccb,nvira,nvirb))-.9,
              numpy.random.random((noccb,noccb,nvirb,nvirb))-.9]
        r2[0] = r2[0] - r2[0].transpose(1,0,2,3)
        r2[0] = r2[0] - r2[0].transpose(0,1,3,2)
        r2[2] = r2[2] - r2[2].transpose(1,0,2,3)
        r2[2] = r2[2] - r2[2].transpose(0,1,3,2)

        gcc1 = cc.addons.convert_to_gccsd(ucc1)
        gr1 = gcc1.spatial2spin(r1)
        gr2 = gcc1.spatial2spin(r2)
        gee1 = eom_gccsd.EOMEE(gcc1)
        gvec = eom_gccsd.amplitudes_to_vector_ee(gr1, gr2)
        vecref = eom_gccsd.eeccsd_matvec(gee1, gvec)

        vec = eom_uccsd.amplitudes_to_vector_ee(r1,r2)
        uee1 = eom_uccsd.EOMEESpinKeep(ucc1)
        vec1 = eom_uccsd.eomee_ccsd_matvec(uee1, vec)

        uv = eom_uccsd.amplitudes_to_vector_ee(r1, r2)
        gv = eom_gccsd.amplitudes_to_vector_ee(gr1, gr2)
        r1, r2 = uee1.vector_to_amplitudes(uee1.matvec(uv))
        gr1, gr2 = gee1.vector_to_amplitudes(gee1.matvec(gv))

        r1, r2 = uee1.vector_to_amplitudes(vec1)
        gr1, gr2 = gee1.vector_to_amplitudes(vecref)
        self.assertAlmostEqual(float(abs(gr1-gcc1.spatial2spin(r1)).max()), 0, 9)
        self.assertAlmostEqual(float(abs(gr2-gcc1.spatial2spin(r2)).max()), 0, 9)
        self.assertAlmostEqual(lib.finger(vec1), 49.499911123484523, 9)
Example #2
0
    def test_ucc_eomee_ccsd_matvec(self):
        numpy.random.seed(10)
        r1 = [numpy.random.random((nocca,nvira))-.9,
              numpy.random.random((noccb,nvirb))-.9]
        r2 = [numpy.random.random((nocca,nocca,nvira,nvira))-.9,
              numpy.random.random((nocca,noccb,nvira,nvirb))-.9,
              numpy.random.random((noccb,noccb,nvirb,nvirb))-.9]
        r2[0] = r2[0] - r2[0].transpose(1,0,2,3)
        r2[0] = r2[0] - r2[0].transpose(0,1,3,2)
        r2[2] = r2[2] - r2[2].transpose(1,0,2,3)
        r2[2] = r2[2] - r2[2].transpose(0,1,3,2)

        gcc1 = cc.addons.convert_to_gccsd(ucc1)
        gr1 = gcc1.spatial2spin(r1)
        gr2 = gcc1.spatial2spin(r2)
        gee1 = eom_gccsd.EOMEE(gcc1)
        gvec = eom_gccsd.amplitudes_to_vector_ee(gr1, gr2)
        vecref = eom_gccsd.eeccsd_matvec(gee1, gvec)

        vec = eom_uccsd.amplitudes_to_vector_ee(r1,r2)
        uee1 = eom_uccsd.EOMEESpinKeep(ucc1)
        vec1 = eom_uccsd.eomee_ccsd_matvec(uee1, vec)

        uv = eom_uccsd.amplitudes_to_vector_ee(r1, r2)
        gv = eom_gccsd.amplitudes_to_vector_ee(gr1, gr2)
        r1, r2 = uee1.vector_to_amplitudes(uee1.matvec(uv))
        gr1, gr2 = gee1.vector_to_amplitudes(gee1.matvec(gv))

        r1, r2 = uee1.vector_to_amplitudes(vec1)
        gr1, gr2 = gee1.vector_to_amplitudes(vecref)
        self.assertAlmostEqual(float(abs(gr1-gcc1.spatial2spin(r1)).max()), 0, 9)
        self.assertAlmostEqual(float(abs(gr2-gcc1.spatial2spin(r2)).max()), 0, 9)
        self.assertAlmostEqual(lib.finger(vec1), 49.499911123484523, 9)
Example #3
0
    def test_ucc_eomsf_ccsd_matvec(self):
        numpy.random.seed(10)
        myeom = eom_uccsd.EOMEESpinFlip(ucc1)
        vec = numpy.random.random(myeom.vector_size()) - .9
        vec1 = eom_uccsd.eomsf_ccsd_matvec(myeom, vec)
        self.assertAlmostEqual(lib.finger(vec1), -1655.5564756993756, 8)

        r1, r2 = myeom.vector_to_amplitudes(vec)
        gr1 = eom_uccsd.spatial2spin_eomsf(r1, orbspin)
        gr2 = eom_uccsd.spatial2spin_eomsf(r2, orbspin)
        gvec = eom_gccsd.amplitudes_to_vector_ee(gr1, gr2)

        gcc1 = cc.addons.convert_to_gccsd(ucc1)
        gee1 = eom_gccsd.EOMEE(gcc1)
        vecref = eom_gccsd.eeccsd_matvec(gee1, gvec)
        gr1, gr2 = gee1.vector_to_amplitudes(vecref)
        v1, v2 = myeom.vector_to_amplitudes(vec1)
        self.assertAlmostEqual(float(abs(gr1-eom_uccsd.spatial2spin_eomsf(v1, orbspin)).max()), 0, 9)
        self.assertAlmostEqual(float(abs(gr2-eom_uccsd.spatial2spin_eomsf(v2, orbspin)).max()), 0, 9)
Example #4
0
    def test_ucc_eomsf_ccsd_matvec(self):
        numpy.random.seed(10)
        myeom = eom_uccsd.EOMEESpinFlip(ucc1)
        vec = numpy.random.random(myeom.vector_size()) - .9
        vec1 = eom_uccsd.eomsf_ccsd_matvec(myeom, vec)
        self.assertAlmostEqual(lib.finger(vec1), -1655.5564756993756, 8)

        r1, r2 = myeom.vector_to_amplitudes(vec)
        gr1 = eom_uccsd.spatial2spin_eomsf(r1, orbspin)
        gr2 = eom_uccsd.spatial2spin_eomsf(r2, orbspin)
        gvec = eom_gccsd.amplitudes_to_vector_ee(gr1, gr2)

        gcc1 = cc.addons.convert_to_gccsd(ucc1)
        gee1 = eom_gccsd.EOMEE(gcc1)
        vecref = eom_gccsd.eeccsd_matvec(gee1, gvec)
        gr1, gr2 = gee1.vector_to_amplitudes(vecref)
        v1, v2 = myeom.vector_to_amplitudes(vec1)
        self.assertAlmostEqual(float(abs(gr1-eom_uccsd.spatial2spin_eomsf(v1, orbspin)).max()), 0, 9)
        self.assertAlmostEqual(float(abs(gr2-eom_uccsd.spatial2spin_eomsf(v2, orbspin)).max()), 0, 9)