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

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.
Best regards,
the kwant team

Dear all,
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
conductance.
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?
Thank you.
Best,
Johnny
Code:
# 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
#execfile('C:/Users/wtc/Google Drive/Linnian/plot_graphene.py')
from __future__ import division # so that 1/2 == 0.5, and not 0
from math import pi, sqrt, tanh
import random
import kwant
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
def circle(pos):
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
def potential(site):
(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]] =
hopping2
# 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)))
def lead0_shape(pos):
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]] =
hopping2
# The second lead, going to the top right
sym1 = kwant.TranslationalSymmetry(graphene.vec((0, 1)))
def lead1_shape(pos):
v = pos[1] * sin_30 - pos[0] * 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]] =
hopping2
return sys, [lead0, lead1]
def compute_evs(sys):
# Compute some eigenvalues of the closed system
sparse_mat = sys.hamiltonian_submatrix(sparse=True)
evs = sla.eigs(sparse_mat, 2)[0]
print evs.real
def plot_conductance(sys, energy):
# Compute transmission as a function of energy
data = []
for phi in Bs:
smatrix = kwant.smatrix(sys, energy,args =[phi,""])
data.append(smatrix.transmission(0, 1))
pyplot.figure()
pyplot.plot(Bs, 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 density(sys, energy, args, lead_nr):
wf = kwant.wave_function(sys, energy, args)
return (abs(wf(lead_nr))**2).sum(axis=0)
def main():
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:
def family_colors(site):
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.
compute_evs(sys.finalized())
# Attach the leads to the system.
for lead in leads:
sys.attach_lead(lead)
# Then, plot the system with leads.
kwant.plot(sys, site_color=family_colors, site_lw=0.1,
lead_site_lw=0, colorbar=False)
# 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_bandstructure(sys.leads[0], momenta)
# plot wf
d = density(sys, energy, [1/40.0, ""], 0)
kwant.plotter.map(sys, d)
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
lead 0
pyplot.plot(reciprocal_phis, conductances)
pyplot.show()
# 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
imported).
# See <http://docs.python.org/library/__main__.html>.
if __name__ == '__main__':
main()

Dear all
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
direction.
>ge=kwant.lattice.general([(1.0,0),(sin_30,cos_30)],
[(0,0),(0,1.0/sqrt(3))])
>lead=kwant.TranslationalSymmetry(ge.vec((-1,0)),ge.vec((0,1)))
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
bandstructure calculation
Thanks for advance.
Best regards,
Liming

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
InfiniteSystem."
I can't identify what's problem here. can anyone help?
Thanks for advance.
code:
================================
l_a=1.0
agnr=kwant.lattice.general([(3*l_a,0),(0,sqrt(3)*l_a)],
[(0,0),(0.5*l_a,sqrt(3)*l_a/2),(1.5*l_a,sqrt(3)*l_a/2),(2*l_a,0)])
a,b,c,d=agnr.sublattices
print agnr.vec((-1,0))
ld=kwant.TranslationalSymmetry(agnr.vec((-1,0)))
h=10
w=h
def shape1(pos):
x,y=pos
return (abs(y)<h and abs(x)<w)
left_lead=kwant.Builder(ld)
left_lead[agnr.shape(shape1,(0,0))]=0
left_lead[[kwant.builder.HoppingKind((0,0),a,b)]]=-2.74
left_lead[[kwant.builder.HoppingKind((0,0),b,c)]]=-2.74
left_lead[[kwant.builder.HoppingKind((0,0),c,d)]]=-2.74
left_lead[[kwant.builder.HoppingKind((-1,0),d,a)]]=-2.74
left_lead[[kwant.builder.HoppingKind((0,1),a,b)]]=-2.74
left_lead[[kwant.builder.HoppingKind((0,1),d,c)]]=-2.74
kwant.plot(left_lead);
left_lead.finalized();
bands=kwant.physics.Bands(left_lead);
mom=np.linspace(-np.pi,np.pi,101)
ee=[bands(k) for k in mom]
pyplot.plot(mom, ee);
pyplot.grid('on')
pyplot.ylim(-2.2,2.2)

Dear Anton,
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
https://mailman-mail5.webfaction.com/pipermail/kwant-discuss/2013-September…
)?
-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
the original ground state wavefunction.
Part of my code is as follows.
####### Case 1: hopping = -t * sigma_0 ########
iplot = 1
evecs = la.eigh(ham)[1]
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
(2*i)th wavefunction
wf = wf_up + wf_down
def site_size_sum(i):
return 1* wf[i] / wf.max()
def site_size_up(i):
return 1* wf_up[i] / wf.max()
def site_size_down(i):
return 1* wf_down[i] / wf.max()
kwant.plot(sys, site_size=site_size_up, site_color=(0, 0, 1,
0.3),hop_lw=0.1)
kwant.plot(sys, site_size=site_size_down, site_color=(0, 0, 1,
0.3),hop_lw=0.1)
kwant.plot(sys, site_size=site_size_sum, site_color=(0, 0, 1,
0.3),hop_lw=0.1)
####### Case 2: hopping = -t ##########
wf = abs(evecs[:, iplot])**2
def site_size(i):
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
2.
What should be correct way to do it? Any hint for the mistakes is
appreciated. Thanks.
Best,
Johnny
On 26 November 2015 at 19:01, Anton Akhmerov <anton.akhmerov(a)gmail.com>
wrote:
> 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).
>
> Best,
> Anton
>
> 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
> 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
> >
> https://mailman-mail5.webfaction.com/pipermail/kwant-discuss/2013-September…
> )?
> >
> > -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
> the
> > 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
> to
> >> > show
> >> > the distribution of the spin in the same plot? Should I include the
> spin
> >> > orbital coupling? Thanks.
> >> >
> >> > Best,
> >> > Johnny
> >
> >
>

Dear all,
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.
Cheers,
Sergey

Hello all,
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
'tutorial/quantum_wire.py' example.
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?
Thanks,
Oscar Erlandsson

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.
Best,
Johnny

Hello all,
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
assures hermiticity."
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?
Thanks,
Oscar Erlandsson