def test_solve_bigger(self): n = 14 chi = 16 ham = MPO_ham_mbl(n, dh=8, seed=42) p0 = MPS_computational_state('00110111000101') dmrgx = DMRGX(ham, p0, chi) assert dmrgx.solve(tol=1e-5, sweep_sequence='R') assert dmrgx.state[0].dtype == float
def test_explicit_sweeps(self): # import pdb; pdb.set_trace() n = 8 chi = 16 ham = MPO_ham_mbl(n, dh=5, run=42) p0 = MPS_neel_state(n).expand_bond_dimension(chi) b0 = p0.H align_TN_1D(p0, ham, b0, inplace=True) en0 = np.asscalar(p0 & ham & b0 ^ ...) dmrgx = DMRGX(ham, p0, chi) dmrgx.sweep_right() en1 = dmrgx.sweep_left(canonize=False) assert en0 != en1 dmrgx.sweep_right(canonize=False) en = dmrgx.sweep_right(canonize=True) # check normalized assert_allclose(dmrgx._k.H @ dmrgx._k, 1.0) k = dmrgx._k.to_dense() h = ham.to_dense() el, ev = eigsys(h) # check variance very low assert np.abs((k.H @ h @ h @ k) - (k.H @ h @ k)**2) < 1e-12 # check exactly one eigenvalue matched well assert np.sum(np.abs(el - en) < 1e-12) == 1 # check exactly one eigenvector is matched with high fidelity ovlps = (ev.H @ k).A**2 big_ovlps = ovlps[ovlps > 1e-12] assert_allclose(big_ovlps, [1]) # check fully assert is_eigenvector(k, h)
def test_explicit_sweeps(self): n = 8 chi = 16 ham = MPO_ham_mbl(n, dh=4, seed=42) p0 = MPS_rand_state(n, 2).expand_bond_dimension(chi) b0 = p0.H p0.align_(ham, b0) en0 = (p0 & ham & b0) ^ ... dmrgx = DMRGX(ham, p0, chi) dmrgx.sweep_right() en1 = dmrgx.sweep_left(canonize=False) assert en0 != en1 dmrgx.sweep_right(canonize=False) en = dmrgx.sweep_right(canonize=True) # check normalized assert_allclose(dmrgx._k.H @ dmrgx._k, 1.0) k = dmrgx._k.to_dense() h = ham.to_dense() el, ev = eigh(h) # check variance very low assert np.abs((k.H @ h @ h @ k) - (k.H @ h @ k)**2) < 1e-12 # check exactly one eigenvalue matched well assert np.sum(np.abs(el - en) < 1e-12) == 1 # check exactly one eigenvector is matched with high fidelity ovlps = (ev.H @ k).A**2 big_ovlps = ovlps[ovlps > 1e-12] assert_allclose(big_ovlps, [1]) # check fully assert is_eigenvector(k, h, tol=1e-10)