Example #1
0
    def test_uhf_external_hop(self):
        mol = gto.M(atom='O 0 0 0; O 0 0 1.2222', basis='631g*', spin=2)
        mf = scf.UHF(mol).run(conv_tol=1e-14)
        hop1ref, hop2ref = gen_hop_uhf_external(mf)
        hop1, hdiag1, hop2, hdiag2 = stability._gen_hop_uhf_external(mf)

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

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

        mol = gto.M(atom='O 0 0 0; O 0 0 1.2222',
                    basis='631g*',
                    symmetry=1,
                    spin=2)
        mf = scf.UHF(mol).run(conv_tol=1e-14)
        hop1ref, hop2ref = gen_hop_uhf_external(mf)
        hop1, hdiag1, hop2, hdiag2 = stability._gen_hop_uhf_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)
Example #2
0
    def test_uhf_external_hop(self):
        mol = gto.M(atom='O 0 0 0; O 0 0 1.2222', basis='631g*', spin=2)
        mf = scf.UHF(mol).newton().run(conv_tol=1e-14)
        hop1ref, hop2ref = gen_hop_uhf_external(mf)
        hop1, hdiag1, hop2, hdiag2 = stability._gen_hop_uhf_external(mf)

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

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

        mol = gto.M(atom='O 0 0 0; O 0 0 1.2222', basis='631g*', symmetry=1, spin=2)
        mf = scf.UHF(mol).newton().run(conv_tol=1e-14)
        hop1ref, hop2ref = gen_hop_uhf_external(mf)
        hop1, hdiag1, hop2, hdiag2 = stability._gen_hop_uhf_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)