コード例 #1
0
ファイル: test_eom_uccsd.py プロジェクト: zwang123/pyscf
 def test_vector_to_amplitudes_eom_spin_keep(self):
     eomsf = eom_uccsd.EOMEESpinKeep(ucc0)
     size = eomsf.vector_size()
     v = numpy.random.random(size)
     r1, r2 = eomsf.vector_to_amplitudes(v)
     v1 = eomsf.amplitudes_to_vector(r1, r2)
     self.assertAlmostEqual(abs(v-v1).max(), 0, 12)
コード例 #2
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)
コード例 #3
0
ファイル: test_eom_uccsd.py プロジェクト: zwang123/pyscf
    def test_ucc_eomee_init_guess(self):
        uee = eom_uccsd.EOMEESpinKeep(ucc1)
        diag = uee.get_diag()[0]
        guess = uee.get_init_guess(nroots=1, koopmans=False, diag=diag)
        self.assertAlmostEqual(lib.finger(guess[0]), -0.99525784369029358, 9)

        guess = uee.get_init_guess(nroots=1, koopmans=True, diag=diag)
        self.assertAlmostEqual(lib.finger(guess[0]), -0.84387013299273794, 9)

        guess = uee.get_init_guess(nroots=4, koopmans=False, diag=diag)
        self.assertAlmostEqual(lib.finger(guess), -0.98261980006133565, 9)

        guess = uee.get_init_guess(nroots=4, koopmans=True, diag=diag)
        self.assertAlmostEqual(lib.finger(guess), -0.38124032366955651, 9)
コード例 #4
0
 def eomee_ccsd(self, nroots=1, koopmans=False, guess=None, eris=None):
     from pyscf.cc import eom_uccsd
     return eom_uccsd.EOMEESpinKeep(self).kernel(nroots, koopmans, guess,
                                                 eris)