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 all,
I want to attach a lead on a vertical surface. I have a problem with the
periods for kwant.TranslationalSymmetry. When I choose (b = 2, c = 1) in
the code below, I get the system plot. But the choice of (b = 1, c = 1)
doesn't work. I want the period to be (b = 1, c = 1). Can someone help me
understand why it doesn't work?
++++++++++++++++++++++++++++++++++++++++
import kwant
import matplotlib.pyplot as plt
def make_system(a, W, L):
def shape(pos):
(x, y) = pos
return (-L <= x <= 0 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
# (b = 2, c = 1) works, (b = 1, c = 1) does not work
b = 1
c = 1
lead = kwant.Builder(kwant.TranslationalSymmetry((b*a, c*a))) #,
time_reversal=1)
def lead_shape(pos):
(x, y) = pos
return - L/2 <= y <= L/2
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,
Barış

Dear Kwant users,
I just have a question for the unit of the Kwant output current,
I think there are 2 ways to calculate the current value:
1. By integrating the conductance data:
for specific, for the conductance generated the code below:
====================================================
for ie in range(-50,50):
energy = ie * 0.01
smatrix = kwant.smatrix(syst, energy)
energies.append(energy)
data.append(smatrix.transmission(1,0))
====================================================
according to the manul, the energy of smatrix.transmission(1,0) is e^2/h,
and since I buildup the system with the Hamiltonian with the unit of
"hartree"
I think the energy that I give to kwant.smatrix(syst,energy) is also
hartree.
I think if I want to get the current,
according to eq.10 of the Kwant paper,
I should change the "conductance-energy" data to "conductance-voltage" data
and then directly integrate it.
2. By using kwant.operator.Current with the script below:
====================================================
wf = kwant.wave_function(syst,energy=-0.25)
J =
kwant.operator.Current(syst,where=[(syst.sites[0],syst.sites[1]),(syst.sites[1],syst.sites[2])],sum=True)
current = sum(J(p) for p in wf(0))
====================================================
I'm trying to calculate the total current at a certain "bias energy" (-0.25
hartree, since I build the system with Hamiltonian in unit of hartree)
but I'm not quite clear with the unit of the output current.
Besides, is the current calculated by the second method should be equal to
the first method?
Thanks in advance for your help.
Hang Zang

Dear Zang,
1) Your question concerning the calculation of the current for all the
hoppings:
That is exactly what you get when you do not specify the argument ''
where" when you define the current. ie:
J = kwant.operator.Current(syst) returns the current for all the
hoppings.
Do you know that you can get all the hoppings in the system by doing
list(sys.hoppings()) with sys the non finalized system?
2)
Yes you can calculate the current in the presence of a bias, but for that
you need to do an integration over the contributions at all the energies
with a weight of Fermi Dirac for each lead.
but I don't see a bias in your example.
I hope this helps,
Adel
On Sun, Jun 30, 2019 at 7:15 AM Zang, Hang <zanghang(a)email.gwu.edu> wrote
Dear Adel and all Kwant users,
Below is my script for calculating the current density based on the
previous discussions (the main part might be the lines after "syst =
syst.finalized()"),
I just want to know is it correct to get the current density (for all the
hoppings) and the corresponding h for a system at a certain bias?
Thank you very much for your help.
###################################################################################
import kwant
primitive_vectors = [ (2.3,0.0) , (0.0,2.3) ]
atomic_sites = [ (2.0,2.0), (1.0,1.0) , (0.0,0.0) ,
(-1.0,-1.0),(-2.0,-2.0), (1.0,0.0)]
lat = kwant.lattice.Polyatomic(primitive_vectors , atomic_sites , norbs = 1)
atoms = lat.sublattices
#=============================================================
syst = kwant.Builder()
syst[atoms[0](0,0)] = 1
syst[atoms[1](0,0)] = 1
syst[atoms[2](0,0)] = 1
syst[atoms[3](0,0)] = 1
syst[atoms[4](0,0)] = 1
syst[atoms[5](0,0)] = 1
syst[atoms[0](0,0),atoms[1](0,0)] = -1
syst[atoms[1](0,0),atoms[2](0,0)] = -1
syst[atoms[2](0,0),atoms[3](0,0)] = -1
syst[atoms[3](0,0),atoms[4](0,0)] = -1
syst[atoms[2](0,0),atoms[5](0,0)] = -1
syst[atoms[1](0,0),atoms[5](0,0)] = -1
#============================================================
sym_up_lead = kwant.TranslationalSymmetry((0.0,2.3))
up_lead = kwant.Builder(sym_up_lead)
up_lead[atoms[0](0,1)] = 1
up_lead[atoms[0](0,1),atoms[0](0,2)] = -2
syst.attach_lead(up_lead)
#============================================================
sym_bottom_lead = kwant.TranslationalSymmetry((0.0,-2.3))
bottom_lead = kwant.Builder(sym_bottom_lead)
bottom_lead[atoms[4](0,-1)] = 1
bottom_lead[atoms[4](0,-1),atoms[4](0,-2)] = -2
syst.attach_lead(bottom_lead)
#============================================================
syst = syst.finalized()
#===========================================================
tmp1 = kwant.plotter.sys_leads_sites(syst,num_lead_cells=0)
tmp2 = kwant.plotter.sys_leads_pos(syst,site_lead_nr=tmp1[0])
tmp3 = kwant.plotter.sys_leads_hoppings(syst,num_lead_cells=0)
tmp4 = kwant.plotter.sys_leads_hopping_pos(syst,hop_lead_nr=tmp3[0])
hopping_number = len(tmp3[0])
print(hopping_number)
wf = kwant.wave_function(syst, energy=-1)
J =
kwant.operator.Current(syst,where=[(syst.sites[tmp3[0][i][0][0]],syst.sites[tmp3[0][i][0][1]])
for i in range(hopping_number)])
total_J=sum(J(p) for p in wf(0))
print(total_J)
for i in range(hopping_number):
print(tmp4[0][i],tmp4[1][i],total_J[i])
###################################################################################
Hang Zang
>
> On Sun, Jun 23, 2019 at 8:22 AM Abbout Adel <abbout.adel(a)gmail.com> wrote:
>
>> Dear Zang,
>>
>> If you do not specify the region where you want to calculate the current,
>> kwant will do that for all the hoppings in your system. In your case, I
>> guess that your system has 6 links (and thus 12 hoppings if we count the
>> two directions).
>>
>> Please check the documentation concerning the argument "where":
>>
>> *where* : sequence of pairs of *int* or Site
>> <https://kwant-project.org/doc/1/reference/generated/kwant.builder.Site.html…>,
>> or callable, optional
>>
>> Where to evaluate the operator. If syst is not a finalized Builder, then
>> this should be a sequence of pairs of integers. If a function is provided,
>> it should take a pair of integers or a pair of Site
>> <https://kwant-project.org/doc/1/reference/generated/kwant.builder.Site.html…>
>> (if syst is a finalized builder) and return True or False. If not
>> provided, the operator will be calculated over all hoppings in the system.
>>
>>
>>
>>
>> If you want to calculate the current just for a given hopping you can do
>> that as follows
>> site1=lat(0,1)
>> site1=lat(0,2)
>> J(syst, where=[(site1,site2)])
>> If you want the current at a given set of hoppings, you just use
>> where=[(site1,site2),(site3,site4),(site5,site6)....................]
>>
>>
>>
>> 2) The current that you get with kwant is actually the contribution of
>> the wave function psi (or the mode p) at a given energy to the total
>> current.
>> Depending on what you want to get, you may need to sum over all the modes
>> if you want to get the total current at the *Fermi surface* and
>> Integrate over the whole band with Fermi Dirac distribution, if you want to
>> get the total current of the *Fermi sea.*
>>
>> I hope this helps,
>> Adel
>>
>>
>> .
>>
>>
>>
>> On Fri, Jun 21, 2019 at 7:32 AM Zang, Hang <zanghang(a)email.gwu.edu>
>> wrote:
>>
>>> Dear All,
>>>
>>> I'm trying to calculate the site-to-site current with kwant,
>>> for a specific system, the output of
>>> "kwant.plotter.sys_leads_hopping_pos" is like below:
>>> (array([[-1., -1.],
>>> [-1., -1.],
>>> [ 0., 0.],
>>> [ 0., 0.],
>>> [ 1., 0.],
>>> [ 1., 1.]]), array([[ 0., 0.],
>>> [-2., -2.],
>>> [ 1., 1.],
>>> [ 1., 0.],
>>> [ 1., 1.],
>>> [ 2., 2.]]))
>>>
>>> For the current calculation of the same system, I use the command below:
>>> ------------------------------------------------------------------
>>> wf = kwant.wave_function(syst, energy=-1)
>>> psi = wf(0)[0]
>>> J_0 = kwant.operator.Current(syst)
>>> current = J_0(psi)
>>> ------------------------------------------------------------------
>>> and the out put of "current" is like below:
>>> [ 0.33230769 -0.33230769 0.33230769 0.22153846 -0.33230769 0.11076923
>>> -0.11076923 0.11076923 0.33230769 -0.22153846 -0.11076923 -0.33230769]
>>>
>>> I'm not clear about the exact correspondance between the element of
>>> current (12 element) and the element of hopping (2 array),
>>> could you plese give me some explanations about this?
>>>
>>> Also, I'm not sure that if I want to calculate the current at a certain
>>> energy (like "-1" above),
>>> do I have to calculate the current at all the wavefunction (like for all
>>> p of wf(0)[p])
>>> or I have to calculate the current only at the wavefunction with
>>> "negivate velocity"?
>>>
>>> Thanks in advance for your help.
>>> Hang Zang
>>>
>>
>>
>> --
>> Abbout Adel
>>
>
--
Abbout Adel

Dear Suman,
for plotting the system you just need to consider the function you defined
for making it, not the empty Builder object use kwant.plot(make_cuboid())
instead of kwant.plot(syst).
For attaching leads you need to define the corresponding shape as you did
for the system and specify the translationally invariant direction (see
kwant documentation for more details).
Regards,
Ousmane
Le sam. 29 juin 2019 à 17:25, <kwant-discuss-request(a)kwant-project.org> a
écrit :
> Send Kwant-discuss mailing list submissions to
> kwant-discuss(a)kwant-project.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://mailman-mail5.webfaction.com/listinfo/kwant-discuss
> or, via email, send a message with subject or body 'help' to
> kwant-discuss-request(a)kwant-project.org
>
> You can reach the person managing the list at
> kwant-discuss-owner(a)kwant-project.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Kwant-discuss digest..."
>
>
> Today's Topics:
>
> 1. Fwd: Supercell building in Kwant (Suman Chowdhury)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 29 Jun 2019 12:16:16 +0530
> From: Suman Chowdhury <sumanchowdhury88(a)gmail.com>
> To: kwant-discuss(a)kwant-project.org
> Subject: [Kwant] Fwd: Supercell building in Kwant
> Message-ID:
> <CABFgFhF2xqCzaC7O7qbXn0nVe=BcPTtb4ZJ_Scr=
> r+g9zQ6yEQ(a)mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Dear Kwant user,
> I am trying to buil an extended system (supercell) by only defining its
> lattice vectors and its unit cell coordinate. After doing that whenever I
> am trying to plot the system, I am getting the following error :
>
> Traceback (most recent call last):
> File "practice.py", line 49, in <module>
> kwant.plot(syst)
> File "/usr/lib/python3/dist-packages/kwant/plotter.py", line 834, in plot
> sites_pos = sys_leads_pos(syst, sites)
> File "/usr/lib/python3/dist-packages/kwant/plotter.py", line 475, in
> sys_leads_pos
> num_lead_cells = site_lead_nr[-1][2] + 1
> IndexError: list index out of range
> ______________________________________________________________
>
> Nothing has been mentioned in the Kwant manual. I am also pasting the
> python code which I am trying to run :
>
> import kwant
> import matplotlib.pyplot
> from math import sqrt
>
> syst = kwant.Builder()
>
> # Defining the lattice
> sin_45 = 1 / sqrt(2)
> cos_45 = 1 / sqrt(2)
>
> lv=1
>
> lat=kwant.lattice.general([(0,1),(1,0)],[(cos_45/2,sin_45/2),(cos_45/2+1,sin_45/2),(cos_45/2+1,-sin_45/2),(cos_45/2,-sin_45/2)])
>
> a, b, c, d = lat.sublattices
>
> t = 1.0
> W=10
> L=10
>
> syst = kwant.Builder()
>
> def make_cuboid(W=10, L=10):
> def cuboid_shape(pos):
> x, y = pos
> return 0 <= x < W and 0 <= y < L
> syst = kwant.Builder()
> syst[lat.shape(cuboid_shape, (0, 0))] = None
> syst[lat.a.neighbors()] = -0.5
> syst[lat.b.neighbors()] = 0.5
> syst[lat.c.neighbors()] = -0.5
> syst[lat.d.neighbors()] = 0.5
> return syst
>
> kwant.plot(syst)
>
>
> I am requesting you to help me in this regard. Also please let me know how
> should I attach leads according to my choice in the above system.
> --
> *Dr. Suman Chowdhury*
>
>
>
> *Assistant Professor Dept. of Physics, Bangabasi College Kolkata- 700009,
> West Bengal, India.*
> * Ph no-+91-9830512232*
>

Dear Kwant user,
I am trying to buil an extended system (supercell) by only defining its
lattice vectors and its unit cell coordinate. After doing that whenever I
am trying to plot the system, I am getting the following error :
Traceback (most recent call last):
File "practice.py", line 49, in <module>
kwant.plot(syst)
File "/usr/lib/python3/dist-packages/kwant/plotter.py", line 834, in plot
sites_pos = sys_leads_pos(syst, sites)
File "/usr/lib/python3/dist-packages/kwant/plotter.py", line 475, in
sys_leads_pos
num_lead_cells = site_lead_nr[-1][2] + 1
IndexError: list index out of range
______________________________________________________________
Nothing has been mentioned in the Kwant manual. I am also pasting the
python code which I am trying to run :
import kwant
import matplotlib.pyplot
from math import sqrt
syst = kwant.Builder()
# Defining the lattice
sin_45 = 1 / sqrt(2)
cos_45 = 1 / sqrt(2)
lv=1
lat=kwant.lattice.general([(0,1),(1,0)],[(cos_45/2,sin_45/2),(cos_45/2+1,sin_45/2),(cos_45/2+1,-sin_45/2),(cos_45/2,-sin_45/2)])
a, b, c, d = lat.sublattices
t = 1.0
W=10
L=10
syst = kwant.Builder()
def make_cuboid(W=10, L=10):
def cuboid_shape(pos):
x, y = pos
return 0 <= x < W and 0 <= y < L
syst = kwant.Builder()
syst[lat.shape(cuboid_shape, (0, 0))] = None
syst[lat.a.neighbors()] = -0.5
syst[lat.b.neighbors()] = 0.5
syst[lat.c.neighbors()] = -0.5
syst[lat.d.neighbors()] = 0.5
return syst
kwant.plot(syst)
I am requesting you to help me in this regard. Also please let me know how
should I attach leads according to my choice in the above system.
--
*Dr. Suman Chowdhury*
*Assistant Professor Dept. of Physics, Bangabasi College Kolkata- 700009,
West Bengal, India.*
* Ph no-+91-9830512232*

Dear All,
I'm trying to calculate the site-to-site current with kwant,
for a specific system, the output of "kwant.plotter.sys_leads_hopping_pos"
is like below:
(array([[-1., -1.],
[-1., -1.],
[ 0., 0.],
[ 0., 0.],
[ 1., 0.],
[ 1., 1.]]), array([[ 0., 0.],
[-2., -2.],
[ 1., 1.],
[ 1., 0.],
[ 1., 1.],
[ 2., 2.]]))
For the current calculation of the same system, I use the command below:
------------------------------------------------------------------
wf = kwant.wave_function(syst, energy=-1)
psi = wf(0)[0]
J_0 = kwant.operator.Current(syst)
current = J_0(psi)
------------------------------------------------------------------
and the out put of "current" is like below:
[ 0.33230769 -0.33230769 0.33230769 0.22153846 -0.33230769 0.11076923
-0.11076923 0.11076923 0.33230769 -0.22153846 -0.11076923 -0.33230769]
I'm not clear about the exact correspondance between the element of current
(12 element) and the element of hopping (2 array),
could you plese give me some explanations about this?
Also, I'm not sure that if I want to calculate the current at a certain
energy (like "-1" above),
do I have to calculate the current at all the wavefunction (like for all p
of wf(0)[p])
or I have to calculate the current only at the wavefunction with "negivate
velocity"?
Thanks in advance for your help.
Hang Zang

.Dear all, Right now I am working with spin transport. Kwant documentations 2.3 of docu1.0.5 and 2.7 of docu1.3.2 are very much helpful and informative to my study. I have a few questions/ doubts to understand the Hamiltonians meaningfully. Hamiltonian for spin (docu2.7) :- H= -Σ‹ij›Σα│iα›‹jα│+ JΣiΣαβ mi. σαβ│iα›‹iβ│ (1) Hamiltonian for spin (docu2.3) :-
H= (-ħ2/2m)(∂x2+∂y2) – iα(∂xσy - ∂yσx ) + Ezσz + V(y) (2)(i) Is there a missing of hopping energy tα (t alpha) in eqn.(1) because the first term takes care of the hopping ? Further, are the kinetic and potential parts for charge transport not considered. I mean, term like the first term in eqn.(2) ? As both the charge and spin transport are there so should we not consider them simultaneously ? Also, does the J in eqn.(1) signify the magnetic field arising out of Rashba interaction which is clearly expressed in eqn,(2)?(ii) Am I right to understand that the second and third terms in eqn.(2) signify the Zeeman splitting and Rashba interaction? Please bear with me that I cannot derive these two terms from Zeeman splitting term and Rashba interacti
on term as found in text books on quantum mechanics. I would be thankful if the origin of these terms be made understood! or else, atleast the reference from where i may get idea.I am earnestly requesting the learned developers of Kwant and / my co-members in the family of Kwant to help solving my problems.All the best and Happy Kwanting.K.K.Ghosh i

Dear KWANT Depelopers,
Following the Kwant documentation, it is easy to plot probability density
for 2D systems. But on following the same procedure for the 3D systems it
shows an *ValueError: Only 2D systems can be plotted this way.* Please
suggest me if there is a way to plot probability density for 3D system
having only an orbital degree of freedom per site.
Thanks in advance.
Naveen
Naveen
Department of Physics & Astrophysics
University of Delhi
New Delhi-110007

Dear everyone,
I would like to solve the 3D Schrödinger equation with a 1D potential step.
With the material in the mailing list as well as from the tutorial the 2D case works fine.
Extending to 3D gives the same when just taking one lattice site in the z direction (H>1).
Increasing the hight of the slab (H>1) changes the minimal energy for which transmission is possible thus my code is wrong.
Did I define and attach the leads correctly with the wraparound in 3D? The short code is below.
Thank you for any hint!
Best,
B
import numpy as np
import matplotlib.pyplot as plt
import scipy as sp
from numpy import *
import kwant
import sys
#calculate the conductance for a sheet (Dim=2) or a Slab (Dim=3) that is translational invariant in y direction
a = 1.0 #lattice constant
V0 = 0.2 #potential step size
L = 2 #Length x-direction the length is a bit useless in this code
W = 6 #Width y-direction
H = 6 #Hight z-direction
t = 1 #hopping parameter
Dim=3 #dimension of the system
# for H=1, Dim=2
# for H>1, Dim=3
#params for integration and plotting
Nky=100 #points in ky space
NE=25 #points in energy
lat = kwant.lattice.cubic(a)
# Define the scattering region
# Infinite potential plane/Slab in y direction
sys = kwant.Builder(kwant.TranslationalSymmetry(lat.vec((0, W, 0))))
for i in range(L):
for j in range(W):
for k in range(H):
# On-site Hamiltonian
sys[lat(i, j, k)] = 2*Dim * t + heaviside(i,0)*V0 #potential step located at the center between the leads
sys[lat.neighbors(1)] = -t
sys = kwant.wraparound.wraparound(sys)
#Left lead
leadL = kwant.Builder(kwant.TranslationalSymmetry((-a, 0, 0), lat.vec((0, W, 0)))) #trans inv in transport dir and ky
leadL[(lat(0,j,k) for j in range(W) for k in range(H))] = 2*Dim*t #onsite terms in the left lead
leadL[lat.neighbors(1)] = -t
#Right lead
leadR = kwant.Builder(kwant.TranslationalSymmetry(( a, 0, 0), lat.vec((0, W, 0))))
leadR[(lat(0,j,k) for j in range(W) for k in range(H))] = 2*Dim*t+V0 #onsite terms in the right lead
leadR[lat.neighbors(1)] = -t
leadL = kwant.wraparound.wraparound(leadL, keep=0) #keeping the translational invariance in x direction
leadR = kwant.wraparound.wraparound(leadR, keep=0)
sys.attach_lead(leadL)
sys.attach_lead(leadR)
kwant.plot(sys)
sys = sys.finalized()
# Calculation of the total transmission for a given Energy
ky_array = np.linspace(-pi,pi,Nky)
dky=ky_array[1]-ky_array[0]
energies = np.linspace(0.0, 1.0,NE)
Ttot=[]
for energy in energies:
Tky_array=zeros(Nky)
for i in arange(len(ky_array)):
ky=ky_array[i]
smatrix = kwant.smatrix(sys, energy, [ky])
Tky_array[i]=smatrix.transmission(1, 0)
Ttot.append((2*pi)/(W)*(sum(Tky_array)-0.5*Tky_array[0]-0.5*Tky_array[Nky-1])*dky) #cheap trapezodial rule to integrate over ky
# Plot transmission
plt.plot(energies, Ttot)
plt.show()