Dear Sir,
I am a PhD student of Hong Kong University of Science and Technology. I
want to use KWANT to caculate Hall resistance of a Hall bar structure.We
can get the conductance between 6 electrodes, but how to get hall
resistance? Can you give me some help? Thank you very much.
Best Regards,
Zhang Bing
Hello everyone,
Is there currently way to visualize the current through a 2D cut for a
3D system that does not involve messing with the kwant code?
I have a 3D system and would like to see the differences in the
current when I switch some specific hoppings on and off.
Regards,

Dr. Eleni Chatzikyriakou
Computational Physics lab
Aristotle University of Thessaloniki
elchatz(a)auth.gr  tel:+30 2310 998109
Hello everyone,
I have defined two semiinfinite contacts in my system as follows:

def lead_shape(p):
x, y, z = p
return 10 < x < 10 and 6 < y < 6 and 0 < z < 30
sym_lead = kwant.TranslationalSymmetry(lattice.vec((6, 0, 0)))
lead = kwant.Builder(sym_lead)
lead[lattice.shape(lead_shape, (0, 0, 15))] = 0

Is there an easy way to calculate any reflections from the lead back
into the conductor?
I mean, ideally, I would like all electrons entering the contacts to
stay there.
Regards
Eleni

Dr. Eleni Chatzikyriakou
Computational Physics lab
Aristotle University of Thessaloniki
elchatz(a)auth.gr  tel:+30 2310 998109
Hello again,
I am having trouble defining the nomber of orbitals in the current
operator for an infinite system.

model = tbmodels.Model.from_wannier_files(
hr_file='seedname_hr.dat',
wsvec_file='seedname_wsvec.dat',
xyz_file='seedname_centres.xyz',
win_file='seedname.win'
)
def shape(p):
x, y, z = p
return 6*model.uc[0][0] < x < 6*model.uc[0][0] and
1*model.uc[1][1] < y < 1*model.uc[1][1] and 0 < z < 30
def lead_shape(p):
x, y, z = p
return 3*model.uc[0][0] < x < 1*model.uc[0][0] and
1*model.uc[1][1] < y < 1*model.uc[1][1] and 0 < z < 30
lattice = model.to_kwant_lattice()
for x in lattice.sublattices:
x.norbs=1
kwant_model = kwant.Builder()
kwant_model[lattice.shape(shape, (0, 0, 15))] = 0
model.add_hoppings_kwant(kwant_model)
sym_lead = kwant.TranslationalSymmetry(lattice.vec((4, 0, 0)))
lead = kwant.Builder(sym_lead)
lead[lattice.shape(lead_shape, (0, 0, 15))] = 0
model.add_hoppings_kwant(lead)
kwant_model.attach_lead(lead)
kwant_model.attach_lead(lead.reversed())
kwant_sys = kwant_model.finalized()
psi = kwant.wave_function(kwant_sys)(0)[0]
J = kwant.operator.Current(kwant_sys)
current = sum(J(p) for p in psi)
ValueError Traceback (most recent call last)
<ipythoninput374d2b8ea6f8e4> in <module>()
1 psi = kwant.wave_function(kwant_sys)(0)[0]
> 2 J = kwant.operator.Current(kwant_sys)
3 current = sum(J(p) for p in psi)
4
kwant\operator.pyx in kwant.operator.Current.__init__()
kwant\operator.pyx in kwant.operator._LocalOperator.__init__()
ValueError: Number of orbitals not defined.
Declare the number of orbitals using the `norbs` keyword argument when
constructing the site families (lattices).
for x in lattice.sublattices:
print(x.norbs)
1
1
1
1
1
1
1
1
1....

This worked for a closed system.
Regards,

Dr. Eleni Chatzikyriakou
Computational Physics lab
Aristotle University of Thessaloniki
elchatz(a)auth.gr  tel:+30 2310 998109
Dear Joe
I am a freshman about Kwant and I want to use Kwant exactly.I will
try to define the lattice differently as you adviced.Aha,thank you for your
response and it's really happy to communicate with you.
Thank you again.
Bill

20180426 17:26 GMT+08:00 Joseph Weston <joseph.weston08(a)gmail.com>:
> Hi Bill,
>
> Dear Joe
> "add_site_family" did work in graphene zigzag nanoribbon.When I use
> "add_site_family",the central scattering region would not enlarge after
> connected with leads in zigzag nanoribbon.But when I use it in graphene
> armchair nanoribbon,the central scattering region will enlarge. If you have
> spare time,you can run my code,and you can see the picture that the central
> scattering is enlarge a little in up and downd leads,left and right lead is
> right.
> Thank you
> Bill Yang
>
>
>
> Ah, I understand now. In your original email you talked about a "triangle
> of sites", which I did not see in the images you posted, so I was unsure
> what you were talking about.
>
> I don't think you be able to get rid of the "extra added bit" with a
> judicious choice of 'other_vectors'; I think you'll have to define the
> lattice differently in order to do what you want.
>
> On the other hand, is this extra added region such a problem? There will
> be no physical consequences, as the extra added piece has the same
> Hamiltonian as the leads...
>
> Happy Kwanting,
>
> Joe
>
Dear Joe
"add_site_family" did work in graphene zigzag nanoribbon.When I use
"add_site_family",the central scattering region would not enlarge after
connected with leads in zigzag nanoribbon.But when I use it in graphene
armchair nanoribbon,the central scattering region will enlarge. If you have
spare time,you can run my code,and you can see the picture that the central
scattering is enlarge a little in up and downd leads,left and right lead is
right.
Thank you
Bill Yang
This is my code
from math import pi, sqrt, tanh
import kwant
# For computing eigenvalues
import scipy.sparse.linalg as sla
# For plotting
from matplotlib import pyplot
#Paramter
LeftLength=0.5 #width of scattering region
RightLength=5
UpWidth=0
DownWidth=2*4+1#length of scattering region
UnitCell=int((DownWidth1)/2)+1 #unit cell
# Define the graphene lattice
sin_30, cos_30 = (1 / 2, sqrt(3) / 2)
graphene = kwant.lattice.general([(1, 0), (sin_30, cos_30)],
[(0, 0), (0, 1 / sqrt(3))])
a,b=graphene.sublattices
#graphene2 = graphene = kwant.lattice.general([(sqrt(3)/2, 1/2), (0, 1)],
#[(0, 0), (1 / (2*sqrt(3)),1/2)])
def make_system(LeftLength,RightLength,UpWidth,DownWidth):
#### Define the scattering region. ####
# circular scattering region
def circle(pos):
x, y = pos
return (LeftLength <= x <= RightLength and
((sqrt(3)/2*DownWidth+1/2/sqrt(3))<=y<=sqrt(3)/2*UpWidth))
syst = kwant.Builder()
# w: width and pot: potential maximum of the pn junction
def potential(pos):
#def potential(pos):
(x, y) = pos
return 0
syst[graphene.shape(circle, (0, 0))] = potential
# specify the hoppings of the graphene lattice in the
# format expected by builder.HoppingKind
hoppings = (((0, 0), a, b), ((0, 1), a, b), ((1, 1), a, b))
syst[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] = 1
# Lead left and right
sym0 = kwant.TranslationalSymmetry(graphene.vec((1, 0)))
sym0.add_site_family(graphene.sublattices[0], other_vectors=[(1, 2)])
sym0.add_site_family(graphene.sublattices[1], other_vectors=[(1, 2)])
def lead0_shape(pos):
x, y = pos
return ((sqrt(3)/2*DownWidth+1/2/sqrt(3))<=y<=sqrt(3)/2*UpWidth)
lead0= kwant.Builder(sym0)
lead0[graphene.shape(lead0_shape, (0, 0))] = 0
lead0[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] = 1
#Lead up and down
sym1 = kwant.TranslationalSymmetry(graphene.vec((1, 2)))
#sym1.add_site_family(graphene.sublattices[0], other_vectors=[(1,1)])
#sym1.add_site_family(graphene.sublattices[1], other_vectors=[(1,1)])
def lead1_shape(pos):
x, y = pos
return (1<x<6)
lead1= kwant.Builder(sym1)
lead1[graphene.shape(lead1_shape, (0, 0))] = 0
lead1[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] = 1
return syst, [lead0,lead0.reversed(),lead1,lead1.reversed()]
def compute_evs(syst):
# Compute some eigenvalues of the closed system
sparse_mat = syst.hamiltonian_submatrix(sparse=True)
evs = sla.eigs(sparse_mat, 2)[0]
print(evs.real)
def plot_conductance(syst, energies):
# Compute transmission as a function of energy
data = []
for energy in energies:
smatrix = kwant.smatrix(syst, energy)
data.append(smatrix.transmission(0, 1))
pyplot.figure()
pyplot.plot(energies, data)
pyplot.xlabel("energy [t]")
pyplot.ylabel("conductance [e^2/h]")
pyplot.show()
def plot_bandstructure(flead, momenta):
bands = kwant.physics.Bands(flead)
energies = [bands(k) for k in momenta]
pyplot.figure()
pyplot.plot(momenta, energies)
pyplot.xlabel("momentum [(lattice constant)^1]")
pyplot.ylabel("energy [t]")
pyplot.show()
def main():
pot = 0
syst, leads = make_system(LeftLength,RightLength,UpWidth,DownWidth)
# To highlight the two sublattices of graphene, we plot one with
# a filled, and the other one with an open circle:
def family_colors(site):
return 0 if site.family == a else 1
# Plot the closed system without leads.
#kwant.plot(syst, site_color=family_colors, site_lw=0.1, colorbar=False)
# Attach the leads to the system.
for lead in leads:
syst.attach_lead(lead)
# Then, plot the system with leads.
kwant.plot(syst, site_color=family_colors, site_lw=0.1,
lead_site_lw=0, colorbar=False)
# Finalize the system.
syst = syst.finalized()
# Plot conductance.
'''energies = []
for ie in range(1,400):
energy = ie * 0.01
energies.append(energy)
plot_conductance(syst, energies)'''
# Call the main function if the script gets executed (as opposed to imported).
# See <http://docs.python.org/library/__main__.html>.
if __name__ == '__main__':
main()
Dear all
I am having a problem defining a system which matches leads I want.
'''I start by defining a rectangular graphene lattice of size 0<=x<L in the x
direction and 0<=x<W in the y direction. (By "rectangular" I mean in the
real space coordinates, not the crystallographic coordinates.)
I want to attach a lead to the lefthad end of this rectangle, going to
minus infinity. Therefore, I define a lead with translational symmetry
(1,0) and the appropriate hopping. I attach the lead and plot the system.
When I plot the system, I find that the lead has been attached along the
(0,1) crystallographic direction (so, that is along the (1/2, sqrt(3)/3)
real space vector). A triangle of extra sites have been added for x<0 (real
space) so that the total shape of the scattering region is now not
rectangular.'''
This is David's question.Link is
https://mailmanmail5.webfaction.com/pipermail/kwantdiscuss/2014October/0….
and Anton had givern the answer:"We should use add_site_family"
I use "add_site_family",but it didn't work.
*In summary,I don't know how to use "add_site_family" exactly in
kwant.Then I can't create armchair nonaribbon and four leads*
*or six leads hall bar (The up and down leads are wrong.Left and right
leads are right according to my code.The central scattering*
* region is rectangle）.Can you explain "add_site_family" in detail or *
*give me a six leads hall bar code to compare with my code .I have spent a
lot of time but I can't solve it.*
This is my code
from math import pi, sqrt, tanh
import kwant
# For computing eigenvalues
import scipy.sparse.linalg as sla
# For plotting
from matplotlib import pyplot
#Paramter
LeftLength=0.5 #width of scattering region
RightLength=5
UpWidth=0
DownWidth=2*4+1#length of scattering region
UnitCell=int((DownWidth1)/2)+1 #unit cell
# Define the graphene lattice
sin_30, cos_30 = (1 / 2, sqrt(3) / 2)
graphene = kwant.lattice.general([(1, 0), (sin_30, cos_30)],
[(0, 0), (0, 1 / sqrt(3))])
a,b=graphene.sublattices
#graphene2 = graphene = kwant.lattice.general([(sqrt(3)/2, 1/2), (0, 1)],
#[(0, 0), (1 / (2*sqrt(3)),1/2)])
def make_system(LeftLength,RightLength,UpWidth,DownWidth):
#### Define the scattering region. ####
# circular scattering region
def circle(pos):
x, y = pos
return (LeftLength <= x <= RightLength and
((sqrt(3)/2*DownWidth+1/2/sqrt(3))<=y<=sqrt(3)/2*UpWidth))
syst = kwant.Builder()
# w: width and pot: potential maximum of the pn junction
def potential(pos):
#def potential(pos):
(x, y) = pos
return 0
syst[graphene.shape(circle, (0, 0))] = potential
# specify the hoppings of the graphene lattice in the
# format expected by builder.HoppingKind
hoppings = (((0, 0), a, b), ((0, 1), a, b), ((1, 1), a, b))
syst[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] = 1
# Lead left and right
sym0 = kwant.TranslationalSymmetry(graphene.vec((1, 0)))
sym0.add_site_family(graphene.sublattices[0], other_vectors=[(1, 2)])
sym0.add_site_family(graphene.sublattices[1], other_vectors=[(1, 2)])
def lead0_shape(pos):
x, y = pos
return ((sqrt(3)/2*DownWidth+1/2/sqrt(3))<=y<=sqrt(3)/2*UpWidth)
lead0= kwant.Builder(sym0)
lead0[graphene.shape(lead0_shape, (0, 0))] = 0
lead0[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] = 1
#Lead up and down
sym1 = kwant.TranslationalSymmetry(graphene.vec((1, 2)))
#sym1.add_site_family(graphene.sublattices[0], other_vectors=[(1,1)])
#sym1.add_site_family(graphene.sublattices[1], other_vectors=[(1,1)])
def lead1_shape(pos):
x, y = pos
return (1<x<6)
lead1= kwant.Builder(sym1)
lead1[graphene.shape(lead1_shape, (0, 0))] = 0
lead1[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] = 1
return syst, [lead0,lead0.reversed(),lead1,lead1.reversed()]
def compute_evs(syst):
# Compute some eigenvalues of the closed system
sparse_mat = syst.hamiltonian_submatrix(sparse=True)
evs = sla.eigs(sparse_mat, 2)[0]
print(evs.real)
def plot_conductance(syst, energies):
# Compute transmission as a function of energy
data = []
for energy in energies:
smatrix = kwant.smatrix(syst, energy)
data.append(smatrix.transmission(0, 1))
pyplot.figure()
pyplot.plot(energies, data)
pyplot.xlabel("energy [t]")
pyplot.ylabel("conductance [e^2/h]")
pyplot.show()
def plot_bandstructure(flead, momenta):
bands = kwant.physics.Bands(flead)
energies = [bands(k) for k in momenta]
pyplot.figure()
pyplot.plot(momenta, energies)
pyplot.xlabel("momentum [(lattice constant)^1]")
pyplot.ylabel("energy [t]")
pyplot.show()
def main():
pot = 0
syst, leads = make_system(LeftLength,RightLength,UpWidth,DownWidth)
# To highlight the two sublattices of graphene, we plot one with
# a filled, and the other one with an open circle:
def family_colors(site):
return 0 if site.family == a else 1
# Plot the closed system without leads.
#kwant.plot(syst, site_color=family_colors, site_lw=0.1, colorbar=False)
# Attach the leads to the system.
for lead in leads:
syst.attach_lead(lead)
# Then, plot the system with leads.
kwant.plot(syst, site_color=family_colors, site_lw=0.1,
lead_site_lw=0, colorbar=False)
# Finalize the system.
syst = syst.finalized()
# Plot conductance.
'''energies = []
for ie in range(1,400):
energy = ie * 0.01
energies.append(energy)
plot_conductance(syst, energies)'''
# Call the main function if the script gets executed (as opposed to imported).
# See <http://docs.python.org/library/__main__.html>.
if __name__ == '__main__':
main()
Thanks in advance.
Bill Yang
Hello,
I want to create a graphenelike system with periodic BC at transverse
direction. I'm following
the discussion at
https://www.mailarchive.com/kwantdiscuss@kwantproject.org/msg00036.html.
For nearestneighbor hopping, it works. There is hopping between the upper
and lower side.
But when I add NNN hopping using:
A,B=graphene.sublattices
sys[A.neighbors()]=hopp_qsvh
sys[B.neighbors()]=hopp_qsvh
The NNN hopping doesn't exist between the upper and lower side.
Is there any way to solve it?
Thank you,
Yuhao
Attached is the code:
import numpy as np
import kwant
X,Y = 4, 4
s0=np.identity(2)
sz=np.array([[1,0],[0,1]])
graphene = kwant.lattice.honeycomb(1,'b')
A,B=graphene.sublattices
def rectangle(pos):
x, y = pos
return X/2 < x < X/2
def onsite_qsvh(site):
x,y=site.pos
if y<0:
onsite_a = .4*s0
onsite_b = .4*s0
return onsite_a if site.family == A else onsite_b
else:
return np.zeros([2,2])
def hopp_qsvh(site1,site2):
x1,y1=site1.pos
x2,y2=site2.pos
hop_a = .4*1j*sz
hop_b = .4*1j*sz
if (y1+0.1)*(y2+0.1)>0 and y1+0.1>0:
return hop_a if site1.family == A else hop_b
else:
return np.zeros([2,2])
sym = kwant.TranslationalSymmetry(graphene.vec((Y/2,Y)))
anc = kwant.Builder(sym)
anc[graphene.shape(rectangle,(0, 0))] = None
anc[graphene.neighbors()] = None
sys = kwant.Builder()
sys[anc.sites()] = onsite_qsvh
sys[((a, sym.to_fd(b)) for a, b in anc.hoppings())] = s0
sys[A.neighbors()]=hopp_qsvh
sys[B.neighbors()]=hopp_qsvh
sys = sys.finalized()
kwant.plot(sys,fig_size=(20, 10))
Hello everybody!
We recently added a new section to the Kwant website [1] that contains
links to pieces of code that "extend" Kwant in some cool way. If you've
used Kwant in a way that you feel may be useful to the wider community
make sure to get in touch so that we can add it to the website. The best
way to do that is to make a post to the Kwant development mailing list
[2] with a link to your code and a few sentences describing what it
enables you to do.
Happy Kwanting,
Joe
[1]: https://kwantproject.org/extensions
[2]: mailto:kwantdevel@kwantproject.org
Sorry I only just saw this email; please remember to "reply All" so that
the email gets sent to the mailing list too!
> Thanks. But except the PBC imposed on transverse direction, I need
> attach the lead on longitude direction. So I want the transverse size
> of sample to be finite.
>
Ah I see. In this case your could consider using 'kwant.wraparound' [1].
In your case you would want to set the 'keep' paramter to '0' to keep
the 0th translational symmetry in the wrapped around system. Using
wraparound in this way will produce a Builder with a single
(longitudinal) translational symmetry that you may use as a lead. The
produced Builder will have an (additional) parameter 'k_y'; the
transverse momentum. Don't be confused by the name; it will also work
when the "wrapped" symmetry vector was not in the "y" direction!
There were already several people on the mailing list who used
wraparound, so you could also search the archives. If it's still not
clear after this post back to this thread.
Happy Kwanting,
Joe
[1]:
https://kwantproject.org/doc/1/reference/generated/kwant.wraparound.wrapar…