Hi Ousmane,
I'm trying different geometries of junctions. I've added Code 1 and 2 below. Code 1 produces 2 separate leads attached to horizontal and vertical surfaces. Using Code 2 (just TranslationalSymmetry and lead_shape() is different than Code 1), I tried to produce a single lead which is attached horizontally and vertically but it failed. How should I play with kwant.TranslationalSymmetry or lead_shape() to create such a lead?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Code 1
import kwant import matplotlib.pyplot as plt
def make_system(a, W, L):
def shape(pos): (x, y) = pos if x <= 0: return (-L <= x <= 0 and -L <= y <= 0) elif x >0: return (0 <= x <= L and -L <= y <= L)
def onsite(site, par): return 4 * par.t - par.mu
def hopx(site1, site2, par):
return -par.t
def hopy(site1, site2, par): return -par.t
lat = kwant.lattice.square(a, norbs=1) syst = kwant.Builder() syst[lat.shape(shape, (0, 0))] = onsite syst[kwant.builder.HoppingKind((1, 0), lat, lat)] = hopx syst[kwant.builder.HoppingKind((0, 1), lat, lat)] = hopy
# attach lead to horizontal normal surface
lead = kwant.Builder(kwant.TranslationalSymmetry((-a, a)))
def lead_shape(pos): (x, y) = pos return -L <= x <= -5
def lead_hopx(site1, site2, par): return -par.t
def lead_onsite(site, par): return 4 * par.t - par.mu
lead[lat.shape(lead_shape, (-7, 0))] = lead_onsite lead[kwant.builder.HoppingKind((1, 0), lat, lat)] = lead_hopx lead[kwant.builder.HoppingKind((0, 1), lat, lat)] = hopy syst.attach_lead(lead)
# attach lead to vertical normal surface
lead = kwant.Builder(kwant.TranslationalSymmetry((-2*a, a)))
def lead_shape(pos): (x, y) = pos return 5 <= y <= L
def lead_hopx(site1, site2, par): return -par.t
def lead_onsite(site, par): return 4 * par.t - par.mu
lead[lat.shape(lead_shape, (0, 7))] = lead_onsite lead[kwant.builder.HoppingKind((1, 0), lat, lat)] = lead_hopx lead[kwant.builder.HoppingKind((0, 1), lat, lat)] = hopy syst.attach_lead(lead)
syst = syst.finalized() return syst
a = 5
number_of_sites = 20
L=number_of_sites*a
number_of_sites2 = 50 L2=number_of_sites2*a
syst = make_system(a=a, W=L2, L=L)
kwant.plot(syst)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Code 2
import kwant import matplotlib.pyplot as plt
def make_system(a, W, L):
def shape(pos): (x, y) = pos
if x <= 0: return (-L <= x <= 0 and -L <= y <= 0) elif x >0: return (0 <= x <= L and -L <= y <= L)
def onsite(site, par): return 4 * par.t - par.mu
def hopx(site1, site2, par):
return -par.t
def hopy(site1, site2, par): return -par.t
lat = kwant.lattice.square(a, norbs=1) syst = kwant.Builder() syst[lat.shape(shape, (0, 0))] = onsite syst[kwant.builder.HoppingKind((1, 0), lat, lat)] = hopx syst[kwant.builder.HoppingKind((0, 1), lat, lat)] = hopy
# works but does not plot the lead attached to vertical surface lead = kwant.Builder(kwant.TranslationalSymmetry((-a, a))) #, time_reversal=1)
# doesn't work #lead = kwant.Builder(kwant.TranslationalSymmetry((-2*a, a))) #, time_reversal=1)
# doesn't work #lead = kwant.Builder(kwant.TranslationalSymmetry((-a, 2*a))) #, time_reversal=1)
def lead_shape(pos): (x, y) = pos return -L <= x <= 0 or 5 <= y <= L """ if x < 0: return -L <= x <= 0 #or 5 <= y <= L else: return 0 <= y <= L """
def lead_hopx(site1, site2, par): return -par.t
def lead_onsite(site, par): return 4 * par.t - par.mu
lead[lat.shape(lead_shape, (0, 0))] = lead_onsite lead[kwant.builder.HoppingKind((1, 0), lat, lat)] = lead_hopx lead[kwant.builder.HoppingKind((0, 1), lat, lat)] = hopy syst.attach_lead(lead)
syst = syst.finalized() return syst
a = 5
number_of_sites = 20
L=number_of_sites*a
number_of_sites2 = 50 L2=number_of_sites2*a
syst = make_system(a=a, W=L2, L=L)
kwant.plot(syst)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Thanks,
Dear Barış, your code #1 is good for attaching the lead as you want, just omit the vertical lead and change the lead_shape(). Please have a look to the code below. Regards, Ousmane
########################################## import kwant import matplotlib.pyplot as plt
def shape(pos): (x, y) = pos if x <= 0: return (-L <= x <= 0 and -L <= y <= 0) elif x >0: return (0 <= x <= L and -L <= y <= L)
def color_site(site):
if shape(site.pos): return 'b' else: return 'r'
def make_system(a, W, L):
def onsite(site, par): return 4 * par.t - par.mu
def hopx(site1, site2, par):
return -par.t
def hopy(site1, site2, par): return -par.t
lat = kwant.lattice.square(a, norbs=1) syst = kwant.Builder() syst[lat.shape(shape, (0, 0))] = onsite syst[kwant.builder.HoppingKind((1, 0), lat, lat)] = hopx syst[kwant.builder.HoppingKind((0, 1), lat, lat)] = hopy
# attach lead to horizontal normal surface
lead = kwant.Builder(kwant.TranslationalSymmetry((-a, a)))
def lead_shape(pos): (x, y) = pos return -L <= x <= L
def lead_hopx(site1, site2, par): return -par.t
def lead_onsite(site, par): return 4 * par.t - par.mu
lead[lat.shape(lead_shape, (-7, 0))] = lead_onsite lead[kwant.builder.HoppingKind((1, 0), lat, lat)] = lead_hopx lead[kwant.builder.HoppingKind((0, 1), lat, lat)] = hopy syst.attach_lead(lead)
""" # attach lead to vertical normal surface
lead = kwant.Builder(kwant.TranslationalSymmetry((-2*a, a)))
def lead_shape(pos): (x, y) = pos return 5 <= y <= L
def lead_hopx(site1, site2, par): return -par.t
def lead_onsite(site, par): return 4 * par.t - par.mu
lead[lat.shape(lead_shape, (0, 7))] = lead_onsite lead[kwant.builder.HoppingKind((1, 0), lat, lat)] = lead_hopx lead[kwant.builder.HoppingKind((0, 1), lat, lat)] = hopy #syst.attach_lead(lead)
#syst = syst.finalized() """ return syst
a = 5
number_of_sites = 20
L=number_of_sites*a
number_of_sites2 = 50 L2=number_of_sites2*a
syst = make_system(a=a, W=L2, L=L)
kwant.plot(syst,site_color=color_site) ##########################################
Le ven. 5 juil. 2019 à 19:20, Barış Özgüler ozguler@wisc.edu a écrit :
Hi Ousmane,
I'm trying different geometries of junctions. I've added Code 1 and 2 below. Code 1 produces 2 separate leads attached to horizontal and vertical surfaces. Using Code 2 (just TranslationalSymmetry and lead_shape() is different than Code 1), I tried to produce a single lead which is attached horizontally and vertically but it failed. How should I play with kwant.TranslationalSymmetry or lead_shape() to create such a lead?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Code 1
import kwant import matplotlib.pyplot as plt
def make_system(a, W, L):
def shape(pos): (x, y) = pos if x <= 0: return (-L <= x <= 0 and -L <= y <= 0) elif x >0: return (0 <= x <= L and -L <= y <= L) def onsite(site, par): return 4 * par.t - par.mu def hopx(site1, site2, par): return -par.t def hopy(site1, site2, par): return -par.t lat = kwant.lattice.square(a, norbs=1) syst = kwant.Builder() syst[lat.shape(shape, (0, 0))] = onsite syst[kwant.builder.HoppingKind((1, 0), lat, lat)] = hopx syst[kwant.builder.HoppingKind((0, 1), lat, lat)] = hopy # attach lead to horizontal normal surface lead = kwant.Builder(kwant.TranslationalSymmetry((-a, a))) def lead_shape(pos): (x, y) = pos return -L <= x <= -5 def lead_hopx(site1, site2, par): return -par.t def lead_onsite(site, par): return 4 * par.t - par.mu lead[lat.shape(lead_shape, (-7, 0))] = lead_onsite lead[kwant.builder.HoppingKind((1, 0), lat, lat)] = lead_hopx lead[kwant.builder.HoppingKind((0, 1), lat, lat)] = hopy syst.attach_lead(lead) # attach lead to vertical normal surface lead = kwant.Builder(kwant.TranslationalSymmetry((-2*a, a))) def lead_shape(pos): (x, y) = pos return 5 <= y <= L def lead_hopx(site1, site2, par): return -par.t def lead_onsite(site, par): return 4 * par.t - par.mu lead[lat.shape(lead_shape, (0, 7))] = lead_onsite lead[kwant.builder.HoppingKind((1, 0), lat, lat)] = lead_hopx lead[kwant.builder.HoppingKind((0, 1), lat, lat)] = hopy syst.attach_lead(lead) syst = syst.finalized() return syst
a = 5
number_of_sites = 20
L=number_of_sites*a
number_of_sites2 = 50 L2=number_of_sites2*a
syst = make_system(a=a, W=L2, L=L)
kwant.plot(syst)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Code 2
import kwant import matplotlib.pyplot as plt
def make_system(a, W, L):
def shape(pos): (x, y) = pos if x <= 0: return (-L <= x <= 0 and -L <= y <= 0) elif x >0: return (0 <= x <= L and -L <= y <= L) def onsite(site, par): return 4 * par.t - par.mu def hopx(site1, site2, par): return -par.t def hopy(site1, site2, par): return -par.t lat = kwant.lattice.square(a, norbs=1) syst = kwant.Builder() syst[lat.shape(shape, (0, 0))] = onsite syst[kwant.builder.HoppingKind((1, 0), lat, lat)] = hopx syst[kwant.builder.HoppingKind((0, 1), lat, lat)] = hopy # works but does not plot the lead attached to vertical surface lead = kwant.Builder(kwant.TranslationalSymmetry((-a, a))) #,
time_reversal=1)
# doesn't work #lead = kwant.Builder(kwant.TranslationalSymmetry((-2*a, a))) #,
time_reversal=1)
# doesn't work #lead = kwant.Builder(kwant.TranslationalSymmetry((-a, 2*a))) #,
time_reversal=1)
def lead_shape(pos): (x, y) = pos return -L <= x <= 0 or 5 <= y <= L """ if x < 0: return -L <= x <= 0 #or 5 <= y <= L else: return 0 <= y <= L """ def lead_hopx(site1, site2, par): return -par.t def lead_onsite(site, par): return 4 * par.t - par.mu lead[lat.shape(lead_shape, (0, 0))] = lead_onsite lead[kwant.builder.HoppingKind((1, 0), lat, lat)] = lead_hopx lead[kwant.builder.HoppingKind((0, 1), lat, lat)] = hopy syst.attach_lead(lead) syst = syst.finalized() return syst
a = 5
number_of_sites = 20
L=number_of_sites*a
number_of_sites2 = 50 L2=number_of_sites2*a
syst = make_system(a=a, W=L2, L=L)
kwant.plot(syst)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Thanks,
-- A. Barış Özgüler
PhD Candidate in Physics
https://home.physics.wisc.edu/ozguler/
University of Wisconsin–Madison Madison, Wisconsin 53706, USA