コード例 #1
0
ファイル: test_eom_uccsd.py プロジェクト: zwang123/pyscf
    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)
コード例 #2
0
ファイル: test_eom_uccsd.py プロジェクト: chrinide/pyscf
    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)
コード例 #3
0
 def test_ucc_eomee_ccsd_matvec(self):
     numpy.random.seed(10)
     r1 = numpy.random.random((no, nv)) - .9
     r2 = numpy.random.random((no, no, nv, nv)) - .9
     r1 = cc.addons.spin2spatial(r1, orbspin)
     r2 = cc.addons.spin2spatial(r2, orbspin)
     vec = eom_uccsd.amplitudes_to_vector_ee(r1, r2)
     vec1 = eom_uccsd.eomee_ccsd_matvec(eom_uccsd.EOMEE(ucc1), vec)
     self.assertAlmostEqual(lib.finger(vec1), 275.11801889278121, 9)