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.
Dear kwant users,
we have posted new instructions for installing kwant on Windows on the
kwant website: http://www.kwant-project.org/install
The old instructions do not work any more, as the format of the python
packages on Christoph Gohlke's webpage have changed.
the kwant team
I am trying to use kwant to reproduce the QHE in graphene. I combine the
example in qhe.py and graphene.py provided in the official website(see the
code below).However, I got the following error when I plot out the
wavefunction at energy = 0:
RuntimeError: Numbers of left- and right-propagating modes differ, possibly
due to a numerical instability.
Moreover, if I don't choose energy = 0, say energy = 0.1, then the error
disappear. However, I cannot recover the plateaus in the plot of
Lastly, it is correct to change t -> t*sigma_0 in order to extract the
distribution of spin(i.e. choosing the odd /even elements in the
wavefunction by [1::2]/[0::2]) in this case?
# Tutorial 2.5. Beyond square lattices: graphene
# Physics background
# Transport through a graphene quantum dot with a pn-junction
# Kwant features highlighted
# - Application of all the aspects of tutorials 1-3 to a more complicated
# lattice, namely graphene
from __future__ import division # so that 1/2 == 0.5, and not 0
from math import pi, sqrt, tanh
import numpy as np
# For computing eigenvalues
import scipy.sparse.linalg as sla
# For plotting
from matplotlib import pyplot
# 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
Bs = np.linspace(4,50,200)
t = -1
def make_system(r=10, w=2.0, pot=0.1):
#### Define the scattering region. ####
# circular scattering region
x, y = pos
return x ** 2 + y ** 2 < r ** 2
#return y > (abs(x)*np.tan(np.pi/3) -size) and y < size
sys = kwant.Builder()
# w: width and pot: potential maximum of the p-n junction
(x, y) = site.pos
d = y * cos_30 + x * sin_30
return pot * tanh(d / w)
def hopping2(site1, site2, phi = 0,salt=0):
xt, yt = site1.pos
xs, ys = site2.pos
return -t * np.exp(-1j * phi * (xt-xs) *(yt+ys))
sys[graphene.shape(circle, (0, 0))] = 0
# 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))
sys[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] =
# Modify the scattering region
# del sys[a(0, 0)]
# del sys[a(5, 5)]
# del sys[a(5,5)]
# sys[a(-2, 1), b(2, 2)] = -1
#### Define the leads. ####
# left lead
sym0 = kwant.TranslationalSymmetry(graphene.vec((-1, 0)))
x, y = pos
return (-0.4 * r < y < 0.4 * r)
lead0 = kwant.Builder(sym0)
lead0[graphene.shape(lead0_shape, (0, 0))] = 0
lead0[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] =
# The second lead, going to the top right
sym1 = kwant.TranslationalSymmetry(graphene.vec((0, 1)))
v = pos * sin_30 - pos * cos_30
return (-0.4 * r < v < 0.4 * r)
lead1 = kwant.Builder(sym1)
lead1[graphene.shape(lead1_shape, (0, 0))] = 0
lead1[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] =
return sys, [lead0, lead1]
# Compute some eigenvalues of the closed system
sparse_mat = sys.hamiltonian_submatrix(sparse=True)
evs = sla.eigs(sparse_mat, 2)
def plot_conductance(sys, energy):
# Compute transmission as a function of energy
data = 
for phi in Bs:
smatrix = kwant.smatrix(sys, energy,args =[phi,""])
def plot_bandstructure(flead, momenta):
bands = kwant.physics.Bands(flead)
energies = [bands(k) for k in momenta]
pyplot.xlabel("momentum [(lattice constant)^-1]")
def density(sys, energy, args, lead_nr):
wf = kwant.wave_function(sys, energy, args)
pot = 0.1
energy = 0.0
sys, leads = make_system(pot=pot)
# To highlight the two sublattices of graphene, we plot one with
# a filled, and the other one with an open circle:
return 0 if site.family == a else 1
# Plot the closed system without leads.
kwant.plot(sys, site_color=family_colors, site_lw=0.1, colorbar=False)
# Compute some eigenvalues.
# Attach the leads to the system.
for lead in leads:
# Then, plot the system with leads.
kwant.plot(sys, site_color=family_colors, site_lw=0.1,
# Finalize the system.
sys = sys.finalized()
# Compute the band structure of lead 0.
momenta = [-4*pi + 0.02 * 4*pi * i for i in xrange(101)]
# plot wf
d = density(sys, energy, [1/40.0, ""], 0)
reciprocal_phis = np.linspace(4, 50, 200)
conductances = 
for phi in 1 / reciprocal_phis:
smatrix = kwant.smatrix(sys, energy, args=[phi, ""])
conductances.append(smatrix.transmission(0, 1)) # from lead 1 to
# Plot conductance.
# energies = [-2 * pot + 4. / 50. * pot * i for i in xrange(51)]
# plot_conductance(sys, 0)
# Call the main function if the script gets executed (as opposed to
# See <http://docs.python.org/library/__main__.html>.
if __name__ == '__main__':
Is there an easy way to produce band structure plot over certain high
symmetry point in brillouin zone?
In order to calculate the bandstructure of certain lattice, graphene for
example, One has to define a lead with periodicity in both a and b
But the kwant doesn't allows me to finalize the system.
Did I made a mistake or kwant currently doesn't support the brillouin zone
Thanks for advance.
I was trying to calculate the arm-chair graphene nano ribbon band structure.
I used translational symmetry to define the lead to be infinite, but I
still got an error saying "TypeError: Expecting an instance of
I can't identify what's problem here. can anyone help?
Thanks for advance.
return (abs(y)<h and abs(x)<w)
ee=[bands(k) for k in mom]
Thanks for your reply. If I don't include the spin-orbital coupling term
and just want to see how are the spin up /down components of the
wavefunction distributed on the graphene surface, is it possible to do it by
1. change the n.n. hopping from -t to -t*sigma0
2. just plot out the even/odd index of the wavefunction (just like in
-Originally, I have 86 wavefunctions in total (since there are 86
-By using the above approach, I get 172 wavefunctions (now there are 172
-But when I sum the ground state wavefunction together, I cannot recover
the original ground state wavefunction.
Part of my code is as follows.
####### Case 1: hopping = -t * sigma_0 ########
iplot = 1
evecs = la.eigh(ham)
wf_up = abs(evecs[::2, 2*iplot])**2
wf_down = abs(evecs[1::2,2*iplot])**2
Note: Now the number of wavefunction obtained is doubled (say 2n in total).
But the 1st and the 2nd one seems to be the same, so I just pick the
wf = wf_up + wf_down
return 1* wf[i] / wf.max()
return 1* wf_up[i] / wf.max()
return 1* wf_down[i] / wf.max()
kwant.plot(sys, site_size=site_size_up, site_color=(0, 0, 1,
kwant.plot(sys, site_size=site_size_down, site_color=(0, 0, 1,
kwant.plot(sys, site_size=site_size_sum, site_color=(0, 0, 1,
####### Case 2: hopping = -t ##########
wf = abs(evecs[:, iplot])**2
return 1* wf[i] / wf.max()
kwant.plot(sys, site_size=site_size, site_color=(0, 0, 1, 0.3),hop_lw=0.1)
I noticed that the plot of site_size_sum in Case 1 is not the same as Case
What should be correct way to do it? Any hint for the mistakes is
On 26 November 2015 at 19:01, Anton Akhmerov <anton.akhmerov(a)gmail.com>
> Dear Johnny,
> Sorry for a delayed reply. Please send the email to the mailing list
> and not only to me personally (that way someone else may reply if I'm
> slow, and others can benefit from the discussion).
> On Tue, Nov 24, 2015 at 10:54 AM, T.C. Wu <tcwu(a)connect.ust.hk> wrote:
> > Dear Anton,
> > Thanks for your reply. If I don't include the spin-orbital coupling term
> > just want to see how are the spin up /down components of the wavefunction
> > distributed on the graphene surface, is it possible to do it by
> > 1. change the n.n. hopping from -t to -t*sigma0
> > 2. just plot out the even/odd index of the wavefunction (just like in
> > -Originally, I have 86 wavefunctions in total (since there are 86
> > eigenvalues).
> > -By using the above approach, I get 172 wavefunctions (now there are 172
> > eigenvalues, ).
> > -But when I sum the ground state wavefunction together, I cannot recover
> > original ground state wavefunction.
> > What should be correct way to do it? Any hint for the mistakes is
> > appreciated. Thanks.
> > Best,
> > Johnny
> > On 22 November 2015 at 20:18, Anton Akhmerov <anton.akhmerov(a)gmail.com>
> > wrote:
> >> Dear Johnny,
> >> Yes, you can superimpose more plots on top of each other, by providing
> >> axes returned by one plot as an argument to the next one. If you want
> >> to do something with spin you probably should include spin-orbit
> >> coupling, yes.
> >> Best,
> >> Anton
> >> On Sun, Nov 22, 2015 at 10:22 AM, T.C. Wu <tcwu(a)connect.ust.hk> wrote:
> >> > Dear Kwant developers and users,
> >> >
> >> > For the plot of the graphene wavefunction as illustrated in
> >> > http://kwant-project.org/doc/1.0/tutorial/tutorial6, is it possible
> >> > show
> >> > the distribution of the spin in the same plot? Should I include the
> >> > orbital coupling? Thanks.
> >> >
> >> > Best,
> >> > Johnny
Could you please explain me how I can put hopping parameters for a multilayered system with kwant.builder.HoppingKind(). The difficulty is that the intralayer hopping parameters are different for each layer and depend on the layer's position z. T he hopping integrals between neighbouring layers are the same. Thank you in advance.
I'm trying to better understand the requirement that 'Builder should
interrupt the lead(s)'. I am not fully sure whether my question is a
KWANT question or a physics question.
Let's say I want to model a 2D system with 'wide leads' like illustrated
in the attached figure, i.e. with leads wider than the scattering
region, and use a code like the one provided in the
If I use the code
for j in xrange(W+1):
left_lead[lat(0, j)] = 4 * t
and so on, where I have replaced 'W' with 'W+1' then attach_lead gives
the error "ValueError: Builder does not interrupt the lead, this lead
cannot be attached.". If I try another approach where I initially
increase the width of the scattering region, attach the leads with the
same width as the scattering region, and then use
for i in xrange(L):
del sys[lat(i, W-1)]
del sys[lat(i, 0)]
to "peel off" the scattering region edges, sys.finalized() gives me the
error "KeyError: Site(kwant.lattice.Monatomic([[1.0, 0.0], [0.0, 1.0]],
[0.0, 0.0], ''), array([0, 9]))".
I also want to note that I have read a previous thread called "3D
structure construction with leads" from 2014 where related issues are
discussed. In that thread, Anton Akhmerov writes that "if I follow the
lead hoppings from unit cells that are far from the system (say
-infinity), then eventually every possible path should end up at a
system site, and there should be no path to +infinity that avoids the
system" for the leads to be attached meaningfully. I believe my
situation satisfies this condition.
Is there a reason that it does not make sense to model a system the way
I am trying to? If not, how do I go about doing it in KWANT?
Dear Kwant developers and users,
For the plot of the graphene wavefunction as illustrated in
http://kwant-project.org/doc/1.0/tutorial/tutorial6, is it possible to show
the distribution of the spin in the same plot? Should I include the spin
orbital coupling? Thanks.
In Section 2.3 of the Kwant 1.0.3 documentation it says:
"(...) it is enough to specify one direction of the hopping (i.e. when
specifying (1, 0) it is not necessary to specify (-1, 0)), Builder
However, if I want the hopping in the e.g. -x direction to be different
from that in the +x direction, how do I implement this? Is it OK to write:
sys[kwant.builder.HoppingKind((0, 0, -1), lat, lat)] = value1
sys[kwant.builder.HoppingKind((0, 0, 1), lat, lat)] = value2
Will the above code produce the desired result?