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)
def test_sites_mpo_mps_product(self, cyclic): k = MPS_rand_state(13, 7, cyclic=cyclic) X = MPO_rand_herm(3, 5, sites=[3, 6, 7], nsites=13, cyclic=cyclic) b = k.H k.align_(X, b) assert (k & X & b) ^ ...