<jupyter_start><jupyter_text>Here we're going to look at the following 1D quantum Hamiltonian defined on a chain of size $L$:$$H = \sum_{n=1}^{L-1} \sigma^x_n\sigma^x_{n+1} + \sigma^y_n\sigma^y_{n+1} + \sigma^z_n\sigma^z_{n+1} + \sum_{n=1}^{L} h_n \sigma^z_n$$where each $h_n$ is drawn from a uniform distribution $[-h,h]$.The phase diagram of this model is well-studied using exact diagonalization and has a phase transition from the thermal into the full MBL phase at $h_c ≈ 3.5$.See https://arxiv.org/pdf/1707.05362.pdf<jupyter_code>import numpy as np
from scipy.sparse import csr_matrix, kron, eye
import scipy.sparse.linalg as las
import scipy.linalg as la
import matplotlib.pyplot as plt
from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras import regularizers, optimizers
I = csr_matrix(np.array([[1, 0], 
                         [0, 1]]))
X = csr_matrix(np.array([[0, 1], 
                         [1, 0]]))
Y = csr_matrix(np.array([[0, -1j], 
                         [1j, 0]]))
Z = csr_matrix(np.array([[1, 0], 
                         [0, -1]]))
# setting up main parameters of the model

# number of spins in the chain
L  = 15
# a grid of distribution's lengths
h = np.linspace(0,4,21)
# number of configurations to be sampled for every longitudinal field distribution length in the grid
N  = 10000
# this function returns a sigma_z operator on spin number i on a chain of size L, we'll need it for the Hamiltonian
def sigma_z(i,L):
    if i==1: 
        return kron(Z,eye(2**(L-1)))
    if i==L:
        return kron(eye(2**(L-1)),Z)
    else:
        return kron(kron(eye(2**(i-1)),Z),eye(2**(L-i)))
# this function returns a quantum many-body Hamiltonian XX+YY+ZZ
def Ham_0(L=3):
    if L == 2:
        return kron(X,X) + kron(Y,Y) + kron(Z,Z)
    
    else:
        Lm1 = eye(2**(L-1))
        Lm2 = eye(2**(L-2))
        return kron(Ham_0(L-1),I) + kron(Lm2,kron(X,X)) + kron(Lm2,kron(Y,Y)) + kron(Lm2,kron(Z,Z))
# this function takes H_0 and adds \sum{h_i * Z_i}
def Ham(L,h):
    fields = np.random.uniform(-h,h,L)
    return Ham_0(L) + sum(fields[i-1]*sigma_z(i,L) for i in np.arange(1,L+1))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1484375, 'fraction_numerical': 0.03308823529411765, 'mean_word_length': 3.2436647173489277, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '170385', 'license': 'Apache-2.0', 'n_tokens_mistral': 880, 'n_tokens_neox': 828, 'n_words': 237, 'path': 'Misc/.ipynb_checkpoints/Random_Heisenberg-checkpoint.ipynb', 'repo_name': 'meandmytram/ML_Ising_XY', 'size': '2176'}