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

Hi,
To explain what I mean. I have a system where I have separated spin-up and spin-down into two lattices (like electron and hole in the example at the kwant site) so that it is would be easier to extract spin-resolved information (G_up/up, Gup/down etc.). In addition, these two lattices consists of two sublattices (A and B). The code is like this
lat_up = kwant.lattice.general([(1,0),(s,c)],[(0,0),(0,1/sqrt(3))], name='up')
A_up, B_up = lat_up.sublattices
lat_down = kwant.lattice.general([(1,0),(s,c)],[(0,0),(0,1/sqrt(3))], name='down')
A_down, B_down = lat_down.sublattices
What I want to do now, is to add a hopping term between say A_up (i,j) and B_down (i.j). So a hopping term between the two different lattices and sublattices. How can I implement this? Or is there a better way to achieve what I want?
Best
Camilla Espedal

Hi all,
Many thanks to all the developers of kwant not only for the strong potential development of the code but
very specially also for the help to solve coding and related physics problems. Presently, I am wondering
how to calculate current in a device, say a QWR, connected to source and drain through two infinite
leads! Applying the Landauer relation, I require no. of channels M upto the level of Fermi and
Transmission probabilities per channel. To me, this appears very involved programming; because (i) first
to find the Fermi first and next to find the no. of channels below that (ii) secondly, for any channel
the all energies upto the Fermi I have to calculate and (iii) finally to sum up. Then we may get the
total transmission probability.
I am not sure that is it right to think of a constant probability in a particular channel? I think it is
"no".
However, I noticed a tutoring correspondence from Joe and Akhmerov in a correspondence with an user
working with calculating the current like me. I could not understand the solution because current carried
by scattering state is written by a code which I am afraid how to write that code in high level python
text? Please, bear with me on this trifling matter. Should we wait for the version kwant2?
All the best wishes and awaiting your wise advise.
K.K.Ghosh

Thanks, I now changed the order, but I still get the same error message. So now the code reads
kwant.plotter.map(sys, V)
sys = sys.finalized()
but now it seems to be in a different place the error message is now 'int' object has no attribute 'site', and the V-function is still
def V(sys):
Hd = onsite(site)
return (Hd[0,0] - Hd[1,1]).real
Best,
Camilla

Hello,
I am making a system with 2 sublattices, so they belong to different families (a and b), and I wish to define a sublattice-dependent onsite energy. I tried using the following code for the onsite function.
def onsite(site):
onsite_a = 2
onsite_b = 2
return onsite_a if site.family == a else onsite_b
but it does not work. I get error message: 'int' object has no attribute 'family'. How can I solve this, or what am I doing wrong?
Best,
Camilla

Hi All,
I have a general question about kwant package.
In the kwant paper (https://downloads.kwant-project.org/doc/kwant-paper.pdf),
I presume the conductance matrix given in Eq. (10) is for zero temperature
calculation. I also presume that the conductance matrix G should be
dependent on energy E, i.e., G(E).
I am wondering if the output from the transmission matrix t(E) (used to
calculate G(E)) of kwant is calculated at E = 0, i.e., what we have is
actually t(E=0) and G(E=0). Although this looks like that the Fermi level
is fixed at E = 0, the actual Fermi level (e.g., relative to charge neutral
point) can be changed via the onsite potential.
Please correct me if I have the wrong understanding. Thanks!
--
Jiuning Hu

Hi everyone,
I am trying to use Kwant to calculate the band structure of a carbon
nanotube.
For example, I build a zigzag nanoribbon with translation symmetry (1,0).
Then I add the hopping between the a and b sites at the ends of the
ribbon by hand. This usually gives the correct nanotube spectrum in a
tight-binding scheme. However, I got incorrect one using Kwant. I cannot
figure out what is the missing part in the code. Could anyone help me out
here?
The following is the code, and in the attachments there are the graph of
the system and also the incorrect spectrum given by Kwant.
>From the system plot, the a, b sites at the ends of the ribbon are indeed
connected.
The incorrect spectrum looks similar to the correct one, but for all the
armchair nanotubes they should be metals not insulators.
Many thanks in advance!
Best regards,
Feng Liu
import kwant
import numpy as np
from types import SimpleNamespace
w=4
W=np.sqrt(3)*0.5*w+1/sqrt(3) #width of zigzag nanoribbon
p = SimpleNamespace(t=1.0, mu = 0.0, B=0.0)
def ribbon_shape(pos):
return -W/2<= pos[1] < W/2
def onsite(site,p):
(x,y)=site.pos
return 0.0
def hopping(site1,site2,p):
x1, y1 = site1.pos
x2, y2 = site2.pos
return p.t
lat = kwant.lattice.honeycomb()
a,b=lat.sublattices
sym_sys = kwant.TranslationalSymmetry((1, 0))
sys = kwant.Builder(sym_sys)
sys[lat.shape(ribbon_shape, (0, 0))] = onsite
sys[lat.neighbors()] = hopping
sys[a(0, w/2), b(0, -w/2-1)] = p.t #connect the ends
kwant.plot(sys)
sys=sys.finalized()
kwant.plotter.bands(sys,args=[p],momenta=600)

Hello everyone,
I am trying to implement Kitaev model in Kwant via the Hamiltonian:
H = -\mu \sum_{n=1}^{N} c_{n}^{\dagger}c_{n} - t \sum_{n=1}^{N-1}(c_{n+1}^{\dagger}c_n + h.c.) + \Delta \sum_{n=1}^{N-1}(c_{n}c_{n+1} + h.c.)
The first two terms are simple, but I am stucked in the superconducting p-wave pairing term. I've tried to implement it by doing
sys[((lat_e(x+1, 0), lat_h(x, 0)) for x in range(0,L-1))] = Delta
which seems somehow correct once I got the zero modes at the edges for the Kitaev limit \mu=0 and t=\Delta. But once I vary \mu I lost one of the edge states, and also it does not close the gap, which makes me belive that I am dealing with a trivial phase.
Does anyone ever done it? Can you see something wrong with my approach?
Cheers,
Antônio.
The complete code is the following:
====================================================
from cmath import exp
import numpy as np
import kwant
# For eigenvalue computation
import scipy.sparse.linalg as sla
# For plotting
from matplotlib import pyplot
def make_system(a=1.0, W=1, L=50, mu=1.5, Delta=1.0, t=1.0):
# Start with an empty tight-binding system and two square lattices,
# corresponding to electron and hole degree of freedom
lat_e = kwant.lattice.square(a=1.0, name='e')
lat_h = kwant.lattice.square(a=1.0, name='h')
sys = kwant.Builder()
#### Define the scattering region. ####
sys[(lat_e(x, y) for x in range(L) for y in range(W))] = - mu
sys[(lat_h(x, y) for x in range(L) for y in range(W))] = mu
# hoppings for both electrons and holes
sys[lat_e.neighbors()] = -t
sys[lat_h.neighbors()] = t
# Superconducting order parameter enters as hopping between
# electrons and holes
sys[((lat_e(x+1, y), lat_h(x, y)) for x in range(0,L-1) for y in range(W))] = Delta
#### Define the leads. ####
# Symmetry for the left leads.
sym_left = kwant.TranslationalSymmetry((-a, 0))
# left electron lead
lead0 = kwant.Builder(sym_left)
lead0[(lat_e(0, j) for j in range(W))] = - mu
lead0[lat_e.neighbors()] = t
lead0[lat_h.neighbors()] = -t
# left hole lead
lead1 = kwant.Builder(sym_left)
lead1[(lat_h(0, j) for j in range(W))] = mu
lead1[lat_e.neighbors()] = t
lead1[lat_h.neighbors()] = -t
# Then the lead to the right
# this one is superconducting and thus is comprised of electrons
# AND holes
sym_right = kwant.TranslationalSymmetry((a, 0))
lead2 = kwant.Builder(sym_right)
lead2 += lead0
lead2 += lead1
lead2[((lat_e(1, j), lat_h(0, j)) for j in range(W))] = Delta
#### Attach the leads and return the system. ####
sys.attach_lead(lead2)
sys.attach_lead(lead2.reversed())
return sys
def plot_wave_function(sys, L=100):
# Calculate the wave functions in the system.
ham_mat = sys.hamiltonian_submatrix(sparse=True)
evecs = sla.eigsh(ham_mat, k=50, which='SM')[1]
# Plot the probability density of the 1st eigenmode.
kwant.plotter.map(sys, np.abs(evecs[:, 0])**2, colorbar=False, a=1.0, oversampling=2)
def main():
sys = make_system()
# Check that the system looks as intended.
kwant.plot(sys)
# Finalize the system.
sys = sys.finalized()
plot_wave_function(sys)
if __name__ == '__main__':
main()
=================================================================

Dear All,
I have tried with a kwant code to see the transmission through barrier imposed by a qwr between the
source and drain. The wire is constructed and its bands are formed successfully; but the plot of
transmission through the constant barrier is not obtained. In the long run, I would like to use the
standardised varying barrier potential and see the transport.
Please help me overcome this difficulty so that I may proceed further.
Kind regards.
K.K.Ghosh
PS. code is attached herewith.

Hello everyone,
I am trying to implement Kitaev model in Kwant via the Hamiltonian:
H = -\mu \sum_{n=1}^{N} c_{n}^{\dagger}c_{n} - t \sum_{n=1}^{N-1}(c_{n+1}^{\dagger}c_n + h.c.) + \Delta \sum_{n=1}^{N-1}(c_{n}c_{n+1} + h.c.)
The first two terms are simple, but I am stucked in the superconducting p-wave pairing term. I've tried to implement it by doing
sys[((lat_e(x+1, 0), lat_h(x, 0)) for x in range(0,L-1))] = Delta
which seems somehow correct once I got the zero modes at the edges for the Kitaev limit \mu=0 and t=\Delta. But once I vary \mu I lost one of the edge states, and also it does not close the gap, which makes me belive that I am dealing with a trivial phase.
Does anyone ever done it? Can you see something wrong with my approach?
Cheers,
Antônio.
The complete code is the following:
====================================================
from cmath import exp
import numpy as np
import kwant
# For eigenvalue computation
import scipy.sparse.linalg as sla
# For plotting
from matplotlib import pyplot
def make_system(a=1.0, W=1, L=50, mu=1.5, Delta=1.0, t=1.0):
# Start with an empty tight-binding system and two square lattices,
# corresponding to electron and hole degree of freedom
lat_e = kwant.lattice.square(a=1.0, name='e')
lat_h = kwant.lattice.square(a=1.0, name='h')
sys = kwant.Builder()
#### Define the scattering region. ####
sys[(lat_e(x, y) for x in range(L) for y in range(W))] = - mu
sys[(lat_h(x, y) for x in range(L) for y in range(W))] = mu
# hoppings for both electrons and holes
sys[lat_e.neighbors()] = -t
sys[lat_h.neighbors()] = t
# Superconducting order parameter enters as hopping between
# electrons and holes
sys[((lat_e(x+1, y), lat_h(x, y)) for x in range(0,L-1) for y in range(W))] = Delta
#### Define the leads. ####
# Symmetry for the left leads.
sym_left = kwant.TranslationalSymmetry((-a, 0))
# left electron lead
lead0 = kwant.Builder(sym_left)
lead0[(lat_e(0, j) for j in range(W))] = - mu
lead0[lat_e.neighbors()] = t
lead0[lat_h.neighbors()] = -t
# left hole lead
lead1 = kwant.Builder(sym_left)
lead1[(lat_h(0, j) for j in range(W))] = mu
lead1[lat_e.neighbors()] = t
lead1[lat_h.neighbors()] = -t
# Then the lead to the right
# this one is superconducting and thus is comprised of electrons
# AND holes
sym_right = kwant.TranslationalSymmetry((a, 0))
lead2 = kwant.Builder(sym_right)
lead2 += lead0
lead2 += lead1
lead2[((lat_e(1, j), lat_h(0, j)) for j in range(W))] = Delta
#### Attach the leads and return the system. ####
sys.attach_lead(lead2)
sys.attach_lead(lead2.reversed())
return sys
def plot_wave_function(sys, L=100):
# Calculate the wave functions in the system.
ham_mat = sys.hamiltonian_submatrix(sparse=True)
evecs = sla.eigsh(ham_mat, k=50, which='SM')[1]
# Plot the probability density of the 1st eigenmode.
kwant.plotter.map(sys, np.abs(evecs[:, 0])**2, colorbar=False, a=1.0, oversampling=2)
def main():
sys = make_system()
# Check that the system looks as intended.
kwant.plot(sys)
# Finalize the system.
sys = sys.finalized()
plot_wave_function(sys)
if __name__ == '__main__':
main()
=================================================================