def test_ising_and_MPS_product_state(self): h = MPO_ham_ising(6, bx=2.0, j=0.1) dmrg = DMRG1(h, bond_dims=8) assert dmrg.solve(verbosity=1) eff_e, mps_gs = dmrg.energy, dmrg.state mps_gs_dense = mps_gs.to_dense() assert_allclose(mps_gs_dense.H @ mps_gs_dense, 1.0) # check against dense h_dense = h.to_dense() actual_e, gs = eigh(h_dense, k=1) assert_allclose(actual_e, eff_e) assert_allclose(abs(expec(mps_gs_dense, gs)), 1.0) exp_gs = MPS_product_state([plus()] * 6) assert_allclose(abs(exp_gs.H @ mps_gs), 1.0, rtol=1e-3)
def test_plus(self): p = plus(qtype='dop') assert_allclose(tr(p @ pauli('x')), 1.0)
def test_permute_ket(self): a = qu.up() & qu.plus() & qu.yplus() b = qu.permute(a, [2, 2, 2], [2, 0, 1]) assert_allclose(b, qu.yplus() & qu.up() & qu.plus())
def test_permute_ket(self): a = up() & plus() & yplus() b = permute(a, [2, 2, 2], [2, 0, 1]) assert_allclose(b, yplus() & up() & plus())