Example #1
0
def test_Z2Charge_raises():
    np.random.seed(10)
    charges = np.array([-1, 0, 1, 2])
    with pytest.raises(ValueError):
        Z2Charge(charges)
    with pytest.raises(ValueError, match="Z2 charges can only"):
        Z2Charge.random(10, -1, 1)
    with pytest.raises(ValueError, match="Z2 charges can only"):
        Z2Charge.random(10, 0, 2)
Example #2
0
m1 = np.arange((1 - n_sites) / 2, (n_sites + 1) / 2, 1)
q1 = 2 * np.pi * m1 / n_sites
wq1 = np.sqrt(1 + 2 * mag * np.cos(q1) + mag**2)

m2 = np.arange(-n_sites / 2, n_sites / 2, 1)
q2 = 2 * np.pi * m2 / n_sites
wq2 = np.sqrt(1 + 2 * mag * np.cos(q2) + mag**2)

en_even0 = -sum(wq1)
if mag > 1:
    en_odd0 = -sum(wq2) + 2 * wq2[0]
else:
    en_odd0 = -sum(wq2)

# define Ising hamiltonian
q_chib = Z2Charge([0, 1])
ind_chib0 = Index(charges=q_chib, flow=True)
ind_chib1 = Index(charges=q_chib, flow=False)

sX = np.array([[0, 1], [1, 0]])
sZ = np.array([[1, 0], [0, -1]])
ham_s = (-np.kron(sX, sX) + 0.5 * mag * np.kron(np.eye(2), sZ) +
         0.5 * mag * np.kron(np.eye(2), sZ))
ham_init = (np.kron(ham_s, np.eye(2**(n_sites - 2)))).reshape(
    2 * np.ones(2 * n_sites, dtype=int))

ham_Z0 = BT.fromdense([ind_chib1] * n_sites + [ind_chib0] * n_sites, ham_init)

cyc_perm = np.array([*list(range(1, n_sites)), 0])
ham_temp = ham_Z0
ham_final = ham_Z0
Example #3
0
def test_Z2Charge_raises():
    np.random.seed(10)
    charges = np.array([-1, 0, 1, 2])
    with pytest.raises(ValueError):
        Z2Charge(charges)