Dear Sir,
Thank you for your reply. The problem I am facing is that if I assign the site values like (1,2,3,...) along the bottom line, the colormap of the site values are changing whenever I compile the code.
############################
import kwant
from pylab import *
import matplotlib.pyplot as plt
from random import *
import numpy as np
class Honeycomb(kwant.lattice.Polyatomic):
def __init__(self, name=''):
prim_vecs = [[0.5, sqrt(3)/2], [1, 0]] # bravais lattice vectors
# offset the lattice so that it is symmetric around x and y axes
basis_vecs = [[-0.5, -1/sqrt(12)], [-0.5, 1/sqrt(12)]]
super(Honeycomb, self).__init__(prim_vecs, basis_vecs, name)
self.a, self.b = self.sublattices
sys=kwant.Builder()
lat = Honeycomb()
a,b= lat.sublattices
def cross(W, L):
def shape(pos):
return ((-W <= pos[1] <= W and -L <= pos[0] <= L))
return shape
pv1, pv2 = lat.prim_vecs
xsym1 = kwant.TranslationalSymmetry((-pv2)) # lattice symmetry in -x direction
xsym1.add_site_family(lat.sublattices[0], other_vectors=[(-2, 1)])
xsym1.add_site_family(lat.sublattices[1], other_vectors=[(-2, 1)])
xsym2=kwant.TranslationalSymmetry((pv2))
xsym2.add_site_family(lat.sublattices[0], other_vectors=[(-2, 1)])
xsym2.add_site_family(lat.sublattices[1], other_vectors=[(-2, 1)])
def create_lead_h(W, symmetry, axis):
lead = kwant.Builder(symmetry)
lead[lat.wire(axis, W)] = 0.
lead[lat.neighbors(1)] = -1.
return lead
def make_system(W, L, no_of_line):
## scattering region ##
sys = kwant.Builder()
sys[lat.shape(cross(W,L), (0,0))] = 0
sys[lat.neighbors(1)] = -1.
line=[]
for site in sys.expand(lat.shape(cross(W,L), (0, 0))):
line.append(site.pos[1])
line=set(line)
line=list(line)
line=sort(line)
sys[site]=i
i=i+1
## leads ##
leads = [create_lead_h(W, xsym1,axis=(0,0))]
leads += [create_lead_h(W, xsym2,axis=(0,0))]
for lead in leads:
sys.attach_lead(lead)
#=============================================================================
return {'sys': sys }
def main():
sys_2 = make_system(W=3.5, L=5, no_of_line=1)
kwant.plotter.plot(sys_2['sys'],site_color=lambda site:sys_2['sys'][site],colorbar=True, cmap=None)
if __name__ == '__main__':
main()
#################################
I can resolve this issue by collecting the site positions from the array named my_list in the given code and then assign the site values accordingly. However, this procedure is a bit lengthy. If there is any other way to do that with less coding, that will be very helpful.
With Regards,
Sudin