= 10 #sites S
import numpy as np
import matplotlib.pyplot as plt
from scipy.linalg import expm as matrixexp
from scipy.linalg import logm as matrixlog
%config InlineBackend.figure_format = "svg"
= np.array([[1,0],[0,1]],dtype=complex)
s0 = np.array([[0,1],[1,0]],dtype=complex)
sx = np.array([[0,-1j],[1j,0]],dtype=complex)
sy = np.array([[1,0],[0,-1]],dtype=complex)
sz
= {"0" : s0,
pauli "x" : sx,
"y" : sy,
"z" : sz,
"+" : (sx+1j*sy)/2,
"-" : (sx-1j*sy)/2}
def spin(polarization,s,S):
if(s==0):
= pauli[polarization]
temp else:
= s0
temp for i in range(1,S,1):
if(i==s):
= np.kron(temp,pauli[polarization])
temp else:
= np.kron(temp,s0)
temp return temp
def vacuum(S):
= np.zeros(2**S,dtype=complex)
vac -1] = 1
vac[return vac
def random_state(S): #random state--not in a particular number sector!
= vacuum(S)
state = bin(2**S+np.random.randint(0,2**S))
b for i in range(1,S+1,1):
if(int(b[-i])==1):
= spin("+",i-1,S)@state
state return state
def H_XX(S): #open boundaries
= np.zeros((2**S,2**S),dtype=complex)
H for i in range(0,S-1,1):
+= spin("x",i,S)@spin("x",i+1,S) + spin("y",i,S)@spin("y",i+1,S)
H return H
= H_XX(S)
HXX
def H_Z(S): #open boundaries
= np.zeros((2**S,2**S),dtype=complex)
H for i in range(0,S-1,1):
+= spin("z",i,S)@spin("z",i+1,S)
H return H
= H_Z(S)
HZ
def Z_s(S):
#create a dictionary for the Sz operators
= {}
numbers for i in range(0,S,1):
str(i)] = spin("z",i,S)
numbers[return numbers
= Z_s(S)
Szs
def H_h(S,W):
#build the disorder Hamiltonian
= np.zeros((2**S,2**S),dtype=complex)
H for i in range(0,S,1):
= np.random.uniform(-W,W)
w += w*Szs[str(i)]
H return H
def half_basis(S):
= {}
basis_states for i in range(0,2**(S//2),1):
= vacuum(S//2)
state = bin(2**(S//2)+i)
b for j in range(1,S//2+1,1):
if(int(b[-j])==1):
= spin("+",j-1,S//2)@state
state str(i)] = state
basis_states[return basis_states
= half_basis(S)
basis_states
def half_trace(rho,S): #trace rho over the first s sites of a length S chain
= np.zeros((2**(S//2),2**(S//2)),dtype=complex) #not bothering to reduce dimensionality or take advantage of rho being real
rho_A for i in range(0,2**(S//2),1):
= np.kron(np.identity(2**(S//2),dtype=complex),basis_states[str(i)])
psi_j += psi_j@rho@np.conjugate(psi_j.T)
rho_A return rho_A
# %%time
= 1
J = [0,0.01,0.1,0.2]
Jps = 5
W
= 31
timesteps = 150
num_states = np.logspace(np.log10(5*10**-2),np.log10(2*10**3),timesteps)
times = np.zeros((4,timesteps),dtype=complex)
S_EE
# for j in range(0,4,1):
# for s in range(0,num_states,1):
# H = J*HXX + Jps[j]*HZ + H_h(S,W) #create a Hamiltonian with disorder
# psi0 = random_state(S) #create a random state
# for t in range(0,timesteps,1):
# psi = matrixexp(-1j*times[t]*H)@psi0 #time evolve starting from a random product state
# rho = np.outer(np.conjugate(psi),psi) #since this is a pure state
# rho_A = half_trace(rho,S)
# S_EE[j,t] += -np.trace(rho_A@matrixlog(rho_A))/num_states
#31,10 - 1 min with L=8
#31,40 - 1 hr with L=10
#np.save("SEE.npy",S_EE)
= np.load("SEE.npy") S_EE
1))*np.real(S_EE[0,:]),marker="o",c="#0800FF",label=r"$J'={}$".format(Jps[0]))
plt.plot(times,np.log10(np.exp(1))*np.real(S_EE[1,:]),marker="s",c="#008000",label=r"$J'={}$".format(Jps[1]))
plt.plot(times,np.log10(np.exp(1))*np.real(S_EE[2,:]),marker="d",c="#FE0000",label=r"$J'={}$".format(Jps[2]))
plt.plot(times,np.log10(np.exp(1))*np.real(S_EE[3,:]),marker="^",c="#01BFBF",label=r"$J'={}$".format(Jps[3]))
plt.plot(times,np.log10(np.exp(
plt.semilogx()r"Time ($t$)")
plt.xlabel(
plt.legend()"entropy-obc-10.pdf")
plt.savefig( plt.show()