Beispiel #1
0
 def test_spatial2spin_eomsf(self):
     eomsf = eom_uccsd.EOMEESpinFlip(ucc0)
     size = eomsf.vector_size()
     v = numpy.random.random(size)
     r1, r2 = eomsf.vector_to_amplitudes(v)
     v1 = eom_uccsd.spin2spatial_eomsf(eom_uccsd.spatial2spin_eomsf(r1, orbspin), orbspin)
     v2 = eom_uccsd.spin2spatial_eomsf(eom_uccsd.spatial2spin_eomsf(r2, orbspin), orbspin)
     self.assertAlmostEqual(abs(r1[0]-v1[0]).max(), 0, 12)
     self.assertAlmostEqual(abs(r1[1]-v1[1]).max(), 0, 12)
     self.assertAlmostEqual(abs(r2[0]-v2[0]).max(), 0, 12)
     self.assertAlmostEqual(abs(r2[1]-v2[1]).max(), 0, 12)
     self.assertAlmostEqual(abs(r2[2]-v2[2]).max(), 0, 12)
     self.assertAlmostEqual(abs(r2[3]-v2[3]).max(), 0, 12)
Beispiel #2
0
 def test_spatial2spin_eomsf(self):
     eomsf = eom_uccsd.EOMEESpinFlip(ucc0)
     size = eomsf.vector_size()
     v = numpy.random.random(size)
     r1, r2 = eomsf.vector_to_amplitudes(v)
     v1 = eom_uccsd.spin2spatial_eomsf(eom_uccsd.spatial2spin_eomsf(r1, orbspin), orbspin)
     v2 = eom_uccsd.spin2spatial_eomsf(eom_uccsd.spatial2spin_eomsf(r2, orbspin), orbspin)
     self.assertAlmostEqual(abs(r1[0]-v1[0]).max(), 0, 12)
     self.assertAlmostEqual(abs(r1[1]-v1[1]).max(), 0, 12)
     self.assertAlmostEqual(abs(r2[0]-v2[0]).max(), 0, 12)
     self.assertAlmostEqual(abs(r2[1]-v2[1]).max(), 0, 12)
     self.assertAlmostEqual(abs(r2[2]-v2[2]).max(), 0, 12)
     self.assertAlmostEqual(abs(r2[3]-v2[3]).max(), 0, 12)
Beispiel #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)
Beispiel #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)