def test_adding_mpo(self): h = MPO_ham_heis(6) hd = h.to_dense() assert_allclose(h @ h.H, (hd @ hd.H).tr()) h2 = h + h assert_allclose(h2 @ h2.H, (hd @ hd.H).tr() * 4) h2.right_compress() assert_allclose(h2 @ h2.H, (hd @ hd.H).tr() * 4) assert max(h2['I3'].shape) == 5
def test_mpo_site_ham_heis(self, cyclic, j, bz, n): hh_mpo = MPO_ham_heis(n, tags=['foo'], cyclic=cyclic, j=j, bz=bz) assert hh_mpo[0].tags == {'I0', 'foo'} assert hh_mpo[1].tags == {'I1', 'foo'} assert hh_mpo[-1].tags == {'I{}'.format(n - 1), 'foo'} assert hh_mpo.shape == (2, ) * 2 * n hh_ex = qu.ham_heis(n, cyclic=cyclic, j=j, b=bz) assert_allclose(qu.eigvalsh(hh_ex), qu.eigvalsh(hh_mpo.to_dense()), atol=1e-13)