Beispiel #1
0
 def test_simple(self):
     p = neel_state(1)
     assert_allclose(p, up())
     p = neel_state(2)
     assert_allclose(p, up() & down())
     p = neel_state(3)
     assert_allclose(p, up() & down() & up())
Beispiel #2
0
 def test_approx_spectral_function_with_v0(self, fn_matrix_rtol, bsz):
     fn, matrix, rtol = fn_matrix_rtol
     a = matrix(2**7)
     actual_x = sum(fn(eigvals(a)))
     # check un-normalized state work properly
     v0 = (neel_state(7) + neel_state(7, down_first=True))
     v0 = v0.A.reshape(-1)
     pos = fn == np.sqrt
     approx_x = approx_spectral_function(a, fn, K=20, v0=v0, pos=pos,
                                         bsz=bsz)
     assert_allclose(actual_x, approx_x, rtol=rtol)
Beispiel #3
0
    def test_NNI_and_single_site_terms_heis(self):
        n = 10
        psi0 = qtn.MPS_neel_state(n)
        H_nni = qtn.NNI_ham_heis(n, j=(0.7, 0.8, 0.9), bz=0.337)
        tebd = qtn.TEBD(psi0, H_nni)
        tebd.update_to(1.0, tol=1e-5)
        assert abs(psi0.H @ tebd.pt) < 1.0
        assert tebd.pt.entropy(5) > 0.0

        psi0_dns = qu.neel_state(n)
        H_dns = qu.ham_heis(10, j=(0.7, 0.8, 0.9), b=0.337, cyclic=False)
        evo = qu.Evolution(psi0_dns, H_dns)
        evo.update_to(1.0)

        assert qu.expec(tebd.pt.to_dense(), evo.pt) == pytest.approx(1.0)
Beispiel #4
0
    def test_NNI_and_single_site_terms(self):
        n = 10
        psi0 = qtn.MPS_neel_state(n)
        H_nni = qtn.NNI_ham_XY(n, bz=0.9)
        assert H_nni.special_sites == {(8, 9)}
        tebd = qtn.TEBD(psi0, H_nni)
        tebd.update_to(1.0, tol=1e-5)
        assert abs(psi0.H @ tebd.pt) < 1.0
        assert tebd.pt.entropy(5) > 0.0

        psi0_dns = qu.neel_state(n)
        H_dns = qu.ham_XY(10, jxy=1.0, bz=0.9, cyclic=False)
        evo = qu.Evolution(psi0_dns, H_dns)
        evo.update_to(1.0)

        assert qu.expec(tebd.pt.to_dense(), evo.pt) == pytest.approx(1.0)
Beispiel #5
0
 def test_mps_computation_state(self):
     p = MPS_neel_state(10)
     pd = qu.neel_state(10)
     assert_allclose(p.to_dense(), pd)
Beispiel #6
0
P = qu.zspin_projector(N, sz=0)

if dis_flag==1:
    H_full = qu.ham_mbl(N, W, J_tab, cyclic=False, dh_dist='qp', beta=0.721, seed=seed, sparse=True).real
else:
    H_full = qu.ham_mbl(N, W, J_tab, cyclic=False, seed=seed, sparse=True).real

H = P.T @ H_full @ P
basis = spin_basis_1d(N,Nup=N//2,pauli=False)
sublat_list = [[(-1.0)**i/N,i] for i in range(0,N)]
imbalance_list = [['z', sublat_list]]
no_checks={"check_herm":False,"check_pcon":False,"check_symm":False}

I = hamiltonian(imbalance_list, [], dtype=np.float64, basis=basis, **no_checks)

psi_0 = P.T @ qu.neel_state(N)
subsys = range(N//2) # define subsystem

base=hf.Base_states(N,N//2)
ind_n=np.zeros((len(base), 2))
for i in range(len(base)):
    somma=0
    for j in range(N//2):
        somma+=int(base[i][j])
    ind_n[i]=[somma,i]
StateList=[]
for i in range(N//2+1):
    StateList.append(np.where(ind_n[:,0]==i)[0])

compute = {
    'time': lambda t, p: t,