def test_specials(self, var_one, var_two): K1 = qu.rand_herm(2**1) n = 10 HB = qtn.SpinHam(S=1 / 2) if var_two == 'some': HB += 1, K1, K1 HB[4, 5] += 1, K1, K1 HB[7, 8] += 1, K1, K1 elif var_two == 'only': for i in range(n - 1): HB[i, i + 1] += 1, K1, K1 else: HB += 1, K1, K1 if var_one == 'some': HB += 1, K1 HB[2] += 1, K1 HB[3] += 1, K1 elif var_one == 'only': for i in range(n - 1): HB[i] += 1, K1 elif var_one == 'only-some': HB[1] += 1, K1 elif var_one == 'def-only': HB += 1, K1 HB.build_mpo(n) HB.build_nni(n)
def test_specials(self, var_one, var_two): K1 = qu.rand_herm(2**1) n = 10 HB = qtn.SpinHam(S=1 / 2) if var_two == 'some': HB += 1, K1, K1 HB[4, 5] += 1, K1, K1 HB[7, 8] += 1, K1, K1 elif var_two == 'only': for i in range(n - 1): HB[i, i + 1] += 1, K1, K1 else: HB += 1, K1, K1 if var_one == 'some': HB += 1, K1 HB[2] += 1, K1 HB[3] += 1, K1 elif var_one == 'only': for i in range(n - 1): HB[i] += 1, K1 elif var_one == 'only-some': HB[1] += 1, K1 elif var_one == 'def-only': HB += 1, K1 HB.build_nni(n) H_mpo = HB.build_mpo(n) H_sps = HB.build_sparse(n) assert_allclose(H_mpo.to_dense(), H_sps.A)
def test_no_default_term(self): N = 10 builder = qtn.SpinHam(1 / 2) for i in range(N - 1): builder[i, i + 1] += 1.0, 'Z', 'Z' H = builder.build_mpo(N) dmrg = qtn.DMRG2(H) dmrg.solve(verbosity=1) assert dmrg.energy == pytest.approx(-2.25)