Plot Band-Structure of SSH Model with Linearly Varying Chemical Potential Using Kwant.continuum

Hi Kwant Users ! I was trying to plot the band structure of the SSH model using kwant.continuum. I could do it when the hopping terms are constant. Now let say the hoppings are linearly varying along x direction (t*x) or say I want to add a chemical potential like (\mu*x). In that case, how should I introduce this potential in the code ? I have attached my code below. It will be a great help if anyone kindly tells me where I need to modify the code and how to insert this (\mu*x term) in the code. The code is attached herewith. _______________________________________ import kwant import kwant.continuum import scipy.sparse.linalg import scipy.linalg import numpy as np # For plotting import matplotlib as mpl from matplotlib import pyplot as plt def ssh(): hamiltonian = "m*sigma_x + alpha * k_x * sigma_y" def plot(ax, a=1): params = dict(m=.5, alpha=.5) h_k = kwant.continuum.lambdify(hamiltonian, locals=params) k_cont = np.linspace(-1, 1, 201) e_cont = [scipy.linalg.eigvalsh(h_k(k_x=ki)) for ki in k_cont] template = kwant.continuum.discretize(hamiltonian, grid=a) syst = kwant.wraparound.wraparound(template).finalized() def h_k(k_x): p = dict(k_x=k_x, **params) return syst.hamiltonian_submatrix(params=p) ax.plot(k_cont, e_cont, 'r-') ax.plot([], [], 'r-', label='continuum') ax.set_xlim(-1, 1) ax.set_ylim(-2, 2) ax.set_title('a={}'.format(a)) ax.set_xlabel('Momentum k_x') ax.set_ylabel('energy E') ax.grid() ax.legend() _, (ax1, ax2) = plt.subplots(1, 2, sharey=True, figsize=(12, 4)) plot(ax1, a=1) plot(ax2, a=.25) plt.show() def main(): ssh() if __name__ == '__main__': main() _______________________________________________________ *_Thanks in advance,*

Dear Subhadeep, I think it is better to do it without continuous hamiltonians. Defining a function for the hopping will be enough. If you still want to do it with the discretization of a continuous hamiltonian, you can proceed this way: Define a hamiltonian: "k_x*A(x)* k_x". #check docomentation This will induce a hopping equal to A(x+1/2) but at the same time, you will have an onsite potential A(x+1/2)+A(x-1/2). What you have to do in this case is to cancel this latter with a potential V(x)= -A(x+1/2)-A(x-1/2) So the hamiltonian becomes "k_x*A(x)* k_x+V(x)". The function A(x)=x-1/2 (in order to have t=x). The following program summarizes all this. I hope this helps, Adel #################################################################### import kwant import kwant.continuum import scipy.sparse.linalg import scipy.linalg import numpy as np # For plotting import matplotlib as mpl from matplotlib import pyplot as plt L=30 def Line(site): x=site.pos[0] return abs(x)<L def Hopping(x): return x-0.5 hamiltonian= "k_x*A(x)*k_x-A(x+0.5)-A(x-0.5)" template=kwant.continuum.discretize(hamiltonian) print(template) syst=kwant.Builder() syst.fill(template,Line,(0,)) syst=syst.finalized() ham=syst.hamiltonian_submatrix(params=dict(A=Hopping),sparse=True) vals,evecs=scipy.sparse.linalg.eigsh(ham,k=36,which='SM') plt.plot(vals,'-o') On Thu, Jun 9, 2022 at 4:43 PM Subhadeep Chakraborty < sc20rs001@iiserkol.ac.in> wrote:
Hi Kwant Users !
I was trying to plot the band structure of the SSH model using kwant.continuum. I could do it when the hopping terms are constant. Now let say the hoppings are linearly varying along x direction (t*x) or say I want to add a chemical potential like (\mu*x). In that case, how should I introduce this potential in the code ?
I have attached my code below. It will be a great help if anyone kindly tells me where I need to modify the code and how to insert this (\mu*x term) in the code.
The code is attached herewith. _______________________________________ import kwant import kwant.continuum import scipy.sparse.linalg import scipy.linalg import numpy as np
# For plotting import matplotlib as mpl from matplotlib import pyplot as plt
def ssh(): hamiltonian = "m*sigma_x + alpha * k_x * sigma_y"
def plot(ax, a=1):
params = dict(m=.5, alpha=.5)
h_k = kwant.continuum.lambdify(hamiltonian, locals=params) k_cont = np.linspace(-1, 1, 201) e_cont = [scipy.linalg.eigvalsh(h_k(k_x=ki)) for ki in k_cont]
template = kwant.continuum.discretize(hamiltonian, grid=a) syst = kwant.wraparound.wraparound(template).finalized()
def h_k(k_x): p = dict(k_x=k_x, **params) return syst.hamiltonian_submatrix(params=p)
ax.plot(k_cont, e_cont, 'r-')
ax.plot([], [], 'r-', label='continuum')
ax.set_xlim(-1, 1) ax.set_ylim(-2, 2) ax.set_title('a={}'.format(a))
ax.set_xlabel('Momentum k_x') ax.set_ylabel('energy E') ax.grid() ax.legend()
_, (ax1, ax2) = plt.subplots(1, 2, sharey=True, figsize=(12, 4))
plot(ax1, a=1) plot(ax2, a=.25) plt.show()
def main(): ssh()
if __name__ == '__main__': main() _______________________________________________________
*_Thanks in advance,*
-- Abbout Adel

Thanks for the suggestion. I could do the most part of it but got stuck at one point. I was trying to do it from lattice model (discrete), defining an onsite potential which is varying linearly along the lattice sites. But is still showing error. Could you please tell where I am making the mistake ? import kwant import numpy as np import math ## import matplotlib #matplotlib.use('Agg') ## # For plotting from matplotlib import pyplot as plt # For matrix support import tinyarray I2 = tinyarray.array([[1,0], [0,1]]) Sx = tinyarray.array([[0,1], [1,0]]) Sy = tinyarray.array([[0,-1j], [1j,0]]) Sz = tinyarray.array([[1,0], [0,-1]]) Sp = tinyarray.array([[0,2], [0,0]]) Sm = tinyarray.array([[0,0], [2,0]]) def create_system(length=10): t1 = 0.5 ; t2 = 1.0 ; def Onsite(site): (x, ) = site.pos potential = x return x # system building lat = kwant.lattice.square(a=1, norbs=2) syst = kwant.Builder() # central scattering region syst[(lat(x, 0) for x in range(length))] = t1*Sx syst[lat.neighbors()] = (t2*Sx - 1j*t2*Sy)/2 # add leads sym = kwant.TranslationalSymmetry((-1, 0)) lead_left = kwant.Builder(sym) lead_left[lat(0, 0)] = t1*Sx + Onsite*I2 lead_left[lat.neighbors()] = (t2*Sx - 1j*t2*Sy)/2 syst.attach_lead(lead_left) syst.attach_lead(lead_left.reversed()) return syst def main(): # parameters # create system syst = create_system(length=10).finalized() # plot the system and dispersion kwant.plot(syst) kwant.plotter.bands(syst.leads[0], show=False) plt.plot([-np.pi, np.pi], [chemical_potential, chemical_potential], 'k--') plt.show() lead = syst.leads[0] bands = kwant.physics.Bands(lead) momenta = np.linspace(-2*np.pi, 2*np.pi, 401) energies = [bands(k) for k in momenta] plt.plot(momenta, energies,linestyle='--') plt.xlim(-2*np.pi, 2*np.pi) #pyplot.ylim(-5, 5) plt.xlabel("$k$") plt.ylabel("Energy") #pyplot.axhline(y=0.0, color='k', linestyle='-') plt.tight_layout() plt.grid() plt.show() plt.close() if __name__ == '__main__': main()
participants (3)
-
Abbout Adel
-
sc20rs001@iiserkol.ac.in
-
Subhadeep Chakraborty