コード例 #1
0
# -----------------

# define hamiltonian and do 2-to-1 blocking
chi_b = 4
sX = np.array([[0, 1], [1, 0]])
sY = np.array([[0, -1j], [1j, 0]])
sZ = np.array([[1, 0], [0, -1]])
ham_s = np.real(np.kron(sX, sX) + np.kron(sY, sY))
# ham_s = (-np.kron(sX, sX) + 0.5 * np.kron(np.eye(2), sZ) +
#          0.5 * np.kron(np.eye(2), sZ))
ham_temp = (0.5 * np.kron(np.eye(8), np.kron(ham_s, np.eye(2))) +
            np.kron(np.eye(4), np.kron(ham_s, np.eye(4))) +
            0.5 * np.kron(np.eye(2), np.kron(ham_s, np.eye(8))))
bias_shift = max(LA.eigvalsh(ham_temp)) - min(LA.eigvalsh(ham_temp))
# ham_temp = ham_temp - min(LA.eigvalsh(ham_temp))*np.eye(64,64)
ham_init = BT.fromdense([ind_chib1] * 3 + [ind_chib0] * 3,
                        ham_temp.reshape([chi_b] * 6))

if initialize_on:
    # initialize tensors
    u = [0] * n_levels
    w = [0] * n_levels
    utemp = np.eye(chi_b**2, chi_b**2).reshape(chi_b, chi_b, chi_b, chi_b)
    u[0] = BT.fromdense([ind_chib1] * 2 + [ind_chib0] * 2, utemp)
    w[0] = orthog_sym(BT.randn([ind_chib1] * 2 + [ind_chi0], dtype='float64'),
                      pivot=2)
    for k in range(n_levels - 1):
        utemp = (np.eye(chi**2, chi_p**2)).reshape(chi, chi, chi_p, chi_p)
        u[k + 1] = BT.fromdense([ind_chi1] * 2 + [ind_chip0] * 2, utemp)
        w[k + 1] = orthog_sym(BT.randn([ind_chip1] * 2 + [ind_chi0],
                                       dtype='float64'),
                              pivot=2)
コード例 #2
0
ファイル: examples_eigh.py プロジェクト: gevenbly/test_codes
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
for n in range(n_sites - 1):
    ham_temp = ham_temp.transpose([*cyc_perm, *(cyc_perm + n_sites)])
    ham_final = ham_final + ham_temp

# diagonalize Ising hamiltonian for GS in even and odd symmetry sector
E, V = eigh(ham_final, link_charges=Z2Charge([0, 1]), which='SA')
en_even1 = E.todense()[0].item()
en_odd1 = E.todense()[1].item()

# compare with analytic energies
assert np.allclose(en_even0, en_even1)
コード例 #3
0
ファイル: sym_MERA.py プロジェクト: gevenbly/test_codes
# -----------------

# define hamiltonian and do 2-to-1 blocking
# en_exact = (-2 / np.sin(np.pi / (2 * n_sites))) / n_sites
en_exact = (-4 / np.sin(np.pi / n_sites)) / n_sites  # PBC (XX model)
sX = np.array([[0, 1], [1, 0]])
sZ = np.array([[1, 0], [0, -1]])
sY = np.array([[0, -1j], [1j, 0]])
ham_s = np.real(np.kron(sX, sX) + np.kron(sY, sY))
# ham_s = (-np.kron(sX, sX) + 0.5 * np.kron(np.eye(2), sZ) +
#          0.5 * np.kron(np.eye(2), sZ))
ham_init = (0.5 * np.kron(np.eye(8), np.kron(ham_s, np.eye(2))) +
            np.kron(np.eye(4), np.kron(ham_s, np.eye(4))) +
            0.5 * np.kron(np.eye(2), np.kron(ham_s, np.eye(8))))
bias = max(LA.eigvalsh(ham_init))
ham_z0 = BT.fromdense([ind_chib1] * 3 + [ind_chib0] * 3,
                      ham_init.reshape([chib] * 6))

# initialize tensors
u = [0] * n_levels
w = [0] * n_levels
ham = [0] * (n_levels + 1)
rho = [0] * (n_levels + 1)

# --- Martin: is there a way of directly defining blocksparse `eye` matrices?
eye_mat = np.eye(chib**2, chib**2).reshape(chib, chib, chib, chib)
u[0] = BT.fromdense([ind_chib1, ind_chib1, ind_chib0, ind_chib0], eye_mat)
# -----------------

# --- Martin: is there a way of directly defining blocksparse isometries?
w_temp = BT.randn([ind_chib1, ind_chib1, ind_chi0], dtype=np.float64)
ut, st, vt = BLA.svd(w_temp.reshape([chib**2, chi]), full_matrices=False)
コード例 #4
0
ファイル: tester.py プロジェクト: gevenbly/test_codes
ind_chi1 = Index(charges=q_chi, flow=False)
ind_1 = Index(charges=U1Charge([0]), flow=False)
# -----------------

# define hamiltonian and do 2-to-1 blocking
chi_b = 4
sX = np.array([[0, 1], [1, 0]])
sY = np.array([[0, -1j], [1j, 0]])
sZ = np.array([[1, 0], [0, -1]])
ham_s = np.real(np.kron(sX, sX) + np.kron(sY, sY))
# ham_s = (-np.kron(sX, sX) + 0.5 * np.kron(np.eye(2), sZ) +
#          0.5 * np.kron(np.eye(2), sZ))
ham_temp = (0.5 * np.kron(np.eye(8), np.kron(ham_s, np.eye(2))) +
            np.kron(np.eye(4), np.kron(ham_s, np.eye(4))) +
            0.5 * np.kron(np.eye(2), np.kron(ham_s, np.eye(8))))
ham_init = BT.fromdense([ind_chib1] * 3 + [ind_chib0] * 3,
                        ham_temp.reshape([chi_b] * 6))
bias_shift = max(LA.eigvalsh(ham_temp)) - min(LA.eigvalsh(ham_temp))
ham = [0] * (n_levels + 1)
ham[0] = ham_init.copy()

if initialize_on:
    # initialize tensors
    u = [0] * n_levels
    w = [0] * n_levels
    utemp = np.eye(chi_b**2, chi_b**2).reshape(chi_b, chi_b, chi_b, chi_b)
    u[0] = BT.fromdense([ind_chib1] * 2 + [ind_chib0] * 2, utemp)
    w[0] = BT.randn([ind_chib1] * 2 + [ind_chib0], dtype='float64')
    for k in range(n_levels - 1):
        utemp = (np.eye(chi**2, chi_p**2)).reshape(chi, chi, chi_p, chi_p)
        u[k + 1] = BT.fromdense([ind_chi1] * 2 + [ind_chip0] * 2, utemp)
        w[k + 1] = BT.randn([ind_chip1] * 2 + [ind_chi0], dtype='float64')
コード例 #5
0
ファイル: new_sym_script.py プロジェクト: gevenbly/test_codes
# define quantum numbers
q_chi_b = U1Charge([-2, 0, 0, 2])
ind_chib0 = Index(charges=q_chi_b, flow=True)
ind_chib1 = Index(charges=q_chi_b, flow=False)

# define hamiltonian and do 2-to-1 blocking
chi_b = 4
sX = np.array([[0, 1], [1, 0]])
sY = np.array([[0, -1j], [1j, 0]])
sZ = np.array([[1, 0], [0, -1]])
ham_s = np.real(np.kron(sX, sX) + np.kron(sY, sY))
ham_temp = (0.5 * np.kron(np.eye(8), np.kron(ham_s, np.eye(2))) +
            np.kron(np.eye(4), np.kron(ham_s, np.eye(4))) +
            0.5 * np.kron(np.eye(2), np.kron(ham_s, np.eye(8))))
bias_shift = max(LA.eigvalsh(ham_temp)) - min(LA.eigvalsh(ham_temp))
ham_init = BT.fromdense([ind_chib1] * 3 + [ind_chib0] * 3,
                        ham_temp.reshape([chi_b] * 6))

if initialize_on:
    # initialize tensors
    u = [0] * n_levels
    w = [0] * n_levels
    utemp = np.eye(chi_b**2, chi_b**2).reshape(chi_b, chi_b, chi_b, chi_b)
    u[0] = BT.fromdense([ind_chib1] * 2 + [ind_chib0] * 2, utemp)
    w[0] = orthog_sym(BT.randn([ind_chib1] * 2 + [ind_chib0], dtype='float64'),
                      pivot=2)
    for k in range(n_levels - 1):
        utemp = (np.eye(chi_b**2, chi_b**2)).reshape(chi_b, chi_b, chi_b,
                                                     chi_b)
        u[k + 1] = BT.fromdense([ind_chib1] * 2 + [ind_chib0] * 2, utemp)
        w[k + 1] = orthog_sym(BT.randn([ind_chib1] * 2 + [ind_chib0],
                                       dtype='float64'),