示例#1
0
    def test_rhf_external_hop(self):
        mol = gto.M(atom='O 0 0 0; O 0 0 1.2222', basis='631g*')
        mf = scf.RHF(mol).run(conv_tol=1e-14)
        hop1ref, hop2ref = gen_hop_rhf_external(mf)
        hop1, hdiag1, hop2, hdiag2 = stability._gen_hop_rhf_external(mf)

        numpy.random.seed(1)
        x1 = numpy.random.random(hdiag1.size)
        self.assertAlmostEqual(abs(hop1(x1) - hop1ref(x1)).max(), 0, 8)

        numpy.random.seed(1)
        x1 = numpy.random.random(hdiag2.size)
        self.assertAlmostEqual(abs(hop2(x1) - hop2ref(x1)).max(), 0, 8)

        mol = gto.M(atom='N 0 0 0; N 0 0 1.2222', basis='631g*', symmetry=1)
        mf = scf.RHF(mol).run(conv_tol=1e-14)
        hop1ref, hop2ref = gen_hop_rhf_external(mf)
        hop1, hdiag1, hop2, hdiag2 = stability._gen_hop_rhf_external(mf)

        numpy.random.seed(1)
        x1 = numpy.random.random(hdiag1.size)
        x1[hdiag1 == 0] = 0
        xref = hop1ref(x1)
        xref[hdiag1 == 0] = 0
        self.assertAlmostEqual(abs(hop1(x1) - xref).max(), 0, 8)

        numpy.random.seed(1)
        x1 = numpy.random.random(hdiag2.size)
        x1[hdiag2 == 0] = 0
        xref = hop2ref(x1)
        xref[hdiag2 == 0] = 0
        self.assertAlmostEqual(abs(hop2(x1) - xref).max(), 0, 8)
示例#2
0
    def test_rhf_external_hop(self):
        mol = gto.M(atom='O 0 0 0; O 0 0 1.2222', basis='631g*')
        mf = scf.RHF(mol).run(conv_tol=1e-14)
        hop1ref, hop2ref = gen_hop_rhf_external(mf)
        hop1, hdiag1, hop2, hdiag2 = stability._gen_hop_rhf_external(mf)

        numpy.random.seed(1)
        x1 = numpy.random.random(hdiag1.size)
        self.assertAlmostEqual(abs(hop1(x1) - hop1ref(x1)).max(), 0, 8)

        numpy.random.seed(1)
        x1 = numpy.random.random(hdiag2.size)
        self.assertAlmostEqual(abs(hop2(x1) - hop2ref(x1)).max(), 0, 8)

        mol = gto.M(atom='N 0 0 0; N 0 0 1.2222', basis='631g*', symmetry=1)
        mf = scf.RHF(mol).run(conv_tol=1e-14)
        hop1ref, hop2ref = gen_hop_rhf_external(mf)
        hop1, hdiag1, hop2, hdiag2 = stability._gen_hop_rhf_external(mf)

        numpy.random.seed(1)
        x1 = numpy.random.random(hdiag1.size)
        x1[hdiag1==0] = 0
        xref = hop1ref(x1)
        xref[hdiag1==0] = 0
        self.assertAlmostEqual(abs(hop1(x1) - xref).max(), 0, 8)

        numpy.random.seed(1)
        x1 = numpy.random.random(hdiag2.size)
        x1[hdiag2==0] = 0
        xref = hop2ref(x1)
        xref[hdiag2==0] = 0
        self.assertAlmostEqual(abs(hop2(x1) - xref).max(), 0, 8)