def test_ham_s2_ovlp (self): h1, h2 = ham_2q (las, las.mo_coeff, veff_c=None, h2eff_sub=None)[1:] lbls = ('ham','s2','ovlp') mats_o0 = op_o0.ham (las, h1, h2, las.ci, idx_all, orbsym=orbsym, wfnsym=wfnsym) fps_o0 = [lib.fp (mat) for mat in mats_o0] mats_o1 = op_o1.ham (las, h1, h2, las.ci, idx_all, orbsym=orbsym, wfnsym=wfnsym) for lbl, mat, fp in zip (lbls, mats_o1, fps_o0): with self.subTest(matrix=lbl): self.assertAlmostEqual (lib.fp (mat), fp, 9)
def test_rdms (self): h0, h1, h2 = ham_2q (las, las.mo_coeff) d1_r = rdm1s.sum (1) d2_r = rdm2s.sum ((1, 4)) nelec = float (sum (las.nelecas)) for ix, (d1, d2) in enumerate (zip (d1_r, d2_r)): with self.subTest (root=ix): self.assertAlmostEqual (np.trace (d1), nelec, 9) self.assertAlmostEqual (np.einsum ('ppqq->',d2), nelec*(nelec-1), 9) e_roots_test = h0 + np.tensordot (d1_r, h1, axes=2) + np.tensordot (d2_r, h2, axes=4) / 2 for e1, e0 in zip (e_roots_test, e_roots): self.assertAlmostEqual (e1, e0, 8)