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,*
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()
    
    
    
    

Reply via email to