Пример #1
0
 def test_kernel(self):
     myci = select_ci.SelectCI()
     e1, c1 = select_ci.kernel(h1, eri, norb, nelec)
     e2, c2 = direct_spin1.kernel(h1, eri, norb, nelec)
     self.assertAlmostEqual(e1, e2, 9)
     self.assertAlmostEqual(abs(numpy.dot(c1.ravel(), c2.ravel())), 1, 9)
     dm1_1 = myci.make_rdm1(c1, norb, nelec)
     dm1_2 = direct_spin1.make_rdm1(c2, norb, nelec)
     self.assertAlmostEqual(abs(dm1_1 - dm1_2).sum(), 0, 4)
     dm2_1 = myci.make_rdm2(c1, norb, nelec)
     dm2_2 = direct_spin1.make_rdm12(c2, norb, nelec)[1]
     self.assertAlmostEqual(abs(dm2_1 - dm2_2).sum(), 0, 2)
Пример #2
0
 def test_contract_2e_1(self):
     myci = selected_ci.SCI()
     nelec = (4,3)
     strsa = cistring.make_strings(range(norb), nelec[0])
     strsb = cistring.make_strings(range(norb), nelec[1])
     ci0 = selected_ci._as_SCIvector(numpy.random.random((len(strsa),len(strsb))), (strsa,strsb))
     h2 = ao2mo.restore(1, eri, norb)
     c1 = myci.contract_2e(h2, ci0, norb, nelec)
     c2 = direct_spin1.contract_2e(h2, ci0, norb, nelec)
     self.assertAlmostEqual(float(abs(c1-c2).sum()), 0, 9)
     dm1_1 = myci.make_rdm1(c1, norb, nelec)
     dm1_2 = direct_spin1.make_rdm1(c2, norb, nelec)
     self.assertAlmostEqual(abs(dm1_1 - dm1_2).sum(), 0, 9)
     dm2_1 = myci.make_rdm12(c1, norb, nelec)[1]
     dm2_2 = direct_spin1.make_rdm12(c2, norb, nelec)[1]
     self.assertAlmostEqual(abs(dm2_1 - dm2_2).sum(), 0, 9)
Пример #3
0
def make_rdm1(fcivec, norb, nelec, link_index=None):
    return direct_spin1.make_rdm1(fcivec, norb, nelec, link_index)
Пример #4
0
        ["H", (0.0, -1.0, -1.0)],
        ["H", (1.0, -0.5, -1.0)],
        ["H", (0.0, -0.0, -1.0)],
        ["H", (1.0, -0.5, 0.0)],
        ["H", (0.0, 1.0, 1.0)],
        ["H", (1.0, 2.0, 3.0)],
        ["H", (1.0, 2.0, 4.0)],
    ]
    mol.basis = "sto-3g"
    mol.build()

    m = scf.RHF(mol)
    m.kernel()
    norb = m.mo_coeff.shape[1]
    nelec = mol.nelectron
    h1e = reduce(numpy.dot, (m.mo_coeff.T, m.get_hcore(), m.mo_coeff))
    eri = ao2mo.kernel(m._eri, m.mo_coeff, compact=False)
    eri = eri.reshape(norb, norb, norb, norb)

    e1, c1 = kernel(h1e, eri, norb, nelec)
    e2, c2 = direct_spin1.kernel(h1e, eri, norb, nelec)
    print(e1, e1 - -11.894559902235565, "diff to FCI", e1 - e2)

    print(c1[0].shape, c2.shape)
    dm1_1 = make_rdm1(c1, norb, nelec)
    dm1_2 = direct_spin1.make_rdm1(c2, norb, nelec)
    print(abs(dm1_1 - dm1_2).sum())
    dm2_1 = make_rdm2(c1, norb, nelec)
    dm2_2 = direct_spin1.make_rdm12(c2, norb, nelec)[1]
    print(abs(dm2_1 - dm2_2).sum())