Esempio n. 1
0
 def test_spin_half_double_space(self, sz):
     prj = qu.zspin_projector(5, sz)
     h = qu.ham_heis(5)
     h0 = prj.T @ h @ prj
     v0s = qu.eigvecsh(h0)
     for v0 in v0s.T:
         vf = prj @ v0.T
         prjv = vf @ vf.H
         # Check reconstructed full eigenvectors commute with full ham
         assert_allclose(prjv @ h, h @ prjv, atol=1e-13)
     if sz == 0:
         # Groundstate must be in most symmetric subspace
         gs = qu.groundstate(h)
         gs0 = prj @ v0s[:, 0]
         assert_allclose(qu.expec(gs, gs0), 1.0)
         assert_allclose(qu.expec(h, gs0), qu.expec(h, gs))
Esempio n. 2
0
 def test_works(self, sz):
     prj = zspin_projector(4, sz)
     h = ham_heis(4)
     h0 = prj @ h @ prj.H
     v0s = eigvecs(h0)
     for v0 in v0s.T:
         vf = prj.H @ v0.T
         prjv = vf @ vf.H
         # Check reconstructed full eigenvectors commute with full ham
         assert_allclose(prjv @ h, h @ prjv, atol=1e-13)
     if sz == 0:
         # Groundstate must be in most symmetric subspace
         gs = groundstate(h)
         gs0 = prj .H @ v0s[:, 0]
         assert_allclose(expec(gs, gs0), 1.0)
         assert_allclose(expec(h, gs0), expec(h, gs))
Esempio n. 3
0
 def test_works(self, sz):
     prj = qu.zspin_projector(4, sz)
     h = qu.ham_heis(4)
     h0 = prj.T @ h @ prj
     v0s = qu.eigvecsh(h0)
     for i in range(v0s.shape[1]):
         v0 = v0s[:, [i]]
         vf = prj @ v0
         prjv = vf @ vf.H
         # Check reconstructed full eigenvectors commute with full ham
         assert_allclose(prjv @ h, h @ prjv, atol=1e-13)
     if sz == 0:
         # Groundstate must be in most symmetric subspace
         gs = qu.groundstate(h)
         gs0 = prj @ v0s[:, [0]]
         assert_allclose(qu.expec(gs, gs0), 1.0)
         assert_allclose(qu.expec(h, gs0), qu.expec(h, gs))
Esempio n. 4
0
 def test_raises(self):
     with pytest.raises(ValueError):
         qu.zspin_projector(5, 0)
     with pytest.raises(ValueError):
         qu.zspin_projector(4, 1 / 2)
Esempio n. 5
0
N = params.L
W_i = params.W_i
W = params.D
J = 1.0
dis_flag = params.Dis_gen
seed = int(1000000 * np.random.random())
int_flag = params.Int_flag
t_tab = np.logspace(-1, 1.5, 200)

if int_flag == 0:
    J_tab = (J, J, 0)
else:
    J_tab = (J, J, J)

P = qu.zspin_projector(N, sz=0)

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

H_pre = P.T @ H_0 @ P