In order to select the sites at the edge, you can use the function 'degree' as follows : sys.degree(site)<=3
Just becareful about the sites connected to the leads. I guess that you do not want to put them at the potential you chose for the edge.
Here, I added the condition 'abs(site.pos[0])!=19' to deselect them as an example.
I strongly suggest for you to plot your system with a different color for the sites you put at that potential to check if you really selected only those you wanted.
An example is provided below.
from cmath import exp
from math import pi
import kwant
from matplotlib import pyplot
def make_system(a=1, t=1.0, W=10, r1=10, r2=20,edge_potential=0):
lat = kwant.lattice.square(a)
sys = kwant.Builder()
#### Define the scattering region. ####
# Now, we aim for a more complex shape, namely a ring (or annulus)
def ring(pos):
(x, y) = pos
rsq = x ** 2 + y ** 2
return (r1 ** 2 < rsq < r2 ** 2)
# and add the corresponding lattice points using the `shape`-function
sys[lat.shape(ring, (0, r1 + 1))]=4*t
sys[lat.neighbors()] = -t
#change the values of the potential at the edge
for site in sys.expand(lat.shape(ring, (0, r1 + 1))):
if sys.degree(site)<=3 and abs(site.pos[0])!=19: #abs(site.pos[0])!=19 execludes the interfaces with the leads
sys[site]=edge_potential
sym_lead = kwant.TranslationalSymmetry((-a, 0))
lead = kwant.Builder(sym_lead)
def lead_shape(pos):
(x, y) = pos
return (-W / 2 < y < W / 2)
lead[lat.shape(lead_shape, (0, 0))] = 4 * t
lead[lat.neighbors()] = -t
#### Attach the leads and return the system. ####
sys.attach_lead(lead)
sys.attach_lead(lead.reversed())
return sys
edge_potential=10
sys = make_system(edge_potential=edge_potential)
def family_color(site):
#print(sys[site])
if sys[site]==edge_potential:
return 'green'
else: return 'black'
def site_size(site):
if sys[site]==edge_potential:
return 0.35
else:return 0.2
# Check that the system looks as intended.
kwant.plot(sys,site_color=family_color,site_size=site_size)