def realization(vs,H_XXZ,basis,real): """ This function computes the entropies for a single disorder realisation. --- arguments --- vs: vector of ramp speeds H_XXZ: time-dep. Heisenberg Hamiltonian with driven zz-interactions basis: spin_basis_1d object containing the spin basis n_real: number of disorder realisations; used only for timing """ ti = time() # get start time # global v # declare ramp speed v a global variable # seed() # the random number needs to be seeded for each parallel process # # draw random field uniformly from [-1.0,1.0] for each lattice site unscaled_fields=-1+2*ranf((basis.L,)) # define z-field operator site-coupling list h_z=[[unscaled_fields[i],i] for i in range(basis.L)] # static list disorder_field = [["z",h_z]] # compute disordered z-field Hamiltonian no_checks={"check_herm":False,"check_pcon":False,"check_symm":False} Hz=hamiltonian(disorder_field,[],basis=basis,dtype=np.float64,**no_checks) # compute the MBL and ETH Hamiltonians for the same disorder realisation H_MBL=H_XXZ+h_MBL*Hz H_ETH=H_XXZ+h_ETH*Hz # ### ramp in MBL phase ### v=1.0 # reset ramp speed to unity # calculate the energy at infinite temperature for initial MBL Hamiltonian eigsh_args={"k":2,"which":"BE","maxiter":1E4,"return_eigenvectors":False} Emin,Emax=H_MBL.eigsh(time=0.0,**eigsh_args) E_inf_temp=(Emax+Emin)/2.0 # calculate nearest eigenstate to energy at infinite temperature E,psi_0=H_MBL.eigsh(time=0.0,k=1,sigma=E_inf_temp,maxiter=1E4) psi_0=psi_0.reshape((-1,)) # calculate the eigensystem of the final MBL hamiltonian E_final,V_final=H_MBL.eigh(time=(0.5/vs[-1])) # evolve states and calculate entropies in MBL phase run_MBL=[_do_ramp(psi_0,H_MBL,basis,v,E_final,V_final) for v in vs] run_MBL=np.vstack(run_MBL).T # ### ramp in ETH phase ### v=1.0 # reset ramp speed to unity # calculate the energy at infinite temperature for initial ETH hamiltonian Emin,Emax=H_ETH.eigsh(time=0.0,**eigsh_args) E_inf_temp=(Emax+Emin)/2.0 # calculate nearest eigenstate to energy at infinite temperature E,psi_0=H_ETH.eigsh(time=0.0,k=1,sigma=E_inf_temp,maxiter=1E4) psi_0=psi_0.reshape((-1,)) # calculate the eigensystem of the final ETH hamiltonian E_final,V_final=H_ETH.eigh(time=(0.5/vs[-1])) # evolve states and calculate entropies in ETH phase run_ETH=[_do_ramp(psi_0,H_ETH,basis,v,E_final,V_final) for v in vs] run_ETH=np.vstack(run_ETH).T # stack vertically elements of list run_ETH # show time taken print "realization {0}/{1} took {2:.2f} sec".format(real+1,n_real,time()-ti) # return run_MBL,run_ETH
drive_args = [Omega] # compute basis in the 0-total momentum and +1-parity sector basis = spin_basis_1d(L=L, a=1, kblock=0, pblock=1) # define PBC site-coupling lists for operators x_field_pos = [[+g, i] for i in range(L)] x_field_neg = [[-g, i] for i in range(L)] z_field = [[h, i] for i in range(L)] J_nn = [[J, i, (i + 1) % L] for i in range(L)] # PBC # static and dynamic lists static = [["zz", J_nn], ["z", z_field], ["x", x_field_pos]] dynamic = [["zz", J_nn, drive, drive_args], ["z", z_field, drive, drive_args], ["x", x_field_neg, drive, drive_args]] # compute Hamiltonians H = 0.5 * hamiltonian(static, dynamic, dtype=np.float64, basis=basis) # ##### set up second-order van Vleck Floquet Hamiltonian ##### # zeroth-order term Heff_0 = 0.5 * hamiltonian(static, [], dtype=np.float64, basis=basis) # second-order term: site-coupling lists Heff2_term_1 = [[+J**2 * g, i, (i + 1) % L, (i + 2) % L] for i in range(L)] # PBC Heff2_term_2 = [[+J * g * h, i, (i + 1) % L] for i in range(L)] # PBC Heff2_term_3 = [[-J * g**2, i, (i + 1) % L] for i in range(L)] # PBC Heff2_term_4 = [[+J**2 * g + 0.5 * h**2 * g, i] for i in range(L)] Heff2_term_5 = [[0.5 * h * g**2, i] for i in range(L)] # define static list Heff_static = [["zxz", Heff2_term_1], ["xz", Heff2_term_2], ["zx", Heff2_term_2], ["yy", Heff2_term_3], ["zz", Heff2_term_2], ["x", Heff2_term_4],
A = 0.8 # spin-photon coupling strength (drive amplitude) Delta = 1.0 # difference between atom energy levels # ##### set up photon-atom Hamiltonian ##### # define operator site-coupling lists ph_energy = [[Omega]] # photon energy at_energy = [[Delta, 0]] # atom energy absorb = [[A / (2.0 * np.sqrt(Nph)), 0]] # absorption term emit = [[A / (2.0 * np.sqrt(Nph)), 0]] # emission term # define static and dynamics lists static = [["|n", ph_energy], ["x|-", absorb], ["x|+", emit], ["z|", at_energy]] dynamic = [] # compute atom-photon basis basis = photon_basis(spin_basis_1d, L=1, Nph=Nph_tot) # compute atom-photon Hamiltonian H H = hamiltonian(static, dynamic, dtype=np.float64, basis=basis) # ##### set up semi-classical Hamiltonian ##### # define operators dipole_op = [[A, 0]] # define periodic drive and its parameters def drive(t, Omega): return np.cos(Omega * t) drive_args = [Omega] # define semi-classical static and dynamic lists static_sc = [["z", at_energy]] dynamic_sc = [["x", dipole_op, drive, drive_args]]
##### set up Heisenberg Hamiltonian with linearly varying zz-interaction ##### # define linear ramp function v = 1.0 # declare ramp speed variable def ramp(t): return (0.5 + v*t) ramp_args=[] # compute basis in the 0-total magnetisation sector (requires L even) basis = spin_basis_1d(L,Nup=L/2,pauli=False) # define operators with OBC using site-coupling lists J_zz = [[Jzz_0,i,i+1] for i in range(L-1)] # OBC J_xy = [[Jxy/2.0,i,i+1] for i in range(L-1)] # OBC # static and dynamic lists static = [["+-",J_xy],["-+",J_xy]] dynamic =[["zz",J_zz,ramp,ramp_args]] # compute the time-dependent Heisenberg Hamiltonian H_XXZ = hamiltonian(static,dynamic,basis=basis,dtype=np.float64) # ##### calculate diagonal and entanglement entropies ##### def realization(vs,H_XXZ,basis,real): """ This function computes the entropies for a single disorder realisation. --- arguments --- vs: vector of ramp speeds H_XXZ: time-dep. Heisenberg Hamiltonian with driven zz-interactions basis: spin_basis_1d object containing the spin basis n_real: number of disorder realisations; used only for timing """ ti = time() # get start time # global v # declare ramp speed v a global variable #
def test_trace(): M = np.arange(9).reshape((3,3)).astype(np.complex128) H = hamiltonian([M],[]) H_trace = H.trace() trace = np.trace(M) np.testing.assert_equal(H_trace,trace)