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 users,
Good day.
My query is about hoppings.
In fact, sometimes we have to change the onsite parameters when for
instance a magnetic field is applied.
What is the difference between hop[0].tag and hop[1].tag
My second question
the onsite fuction for example: def onsite(site, V):return V
why it depends on site where the shape functions for example
def circle(pos): rsq = pos[0] ** 2 + pos[1] ** 2
depends on pos
Best
A BELAYADI

Dear Sir,
I have a problem to install Kwant when download the Pre-built packages ( Anaconda package ). That is to say I can't download the package. My operating systems is Microsoft Windows. Can you help me.
Best regards,
Chunxu Bai

I am trying to plot the wavefunction for a 2D NISIN Hamiltonian however I am unable to get a result, this is my code:
import kwant
import tinyarray as ta
import numpy as np
import matplotlib.pyplot as plt
from tqdm import tqdm
import winsound
import os
from datetime import datetime
import scipy.sparse.linalg as sla
sig_0 = np.identity(4)
s_0 = np.identity(2)
s_z = np.array([[1., 0.], [0., -1.]])
s_x = np.array([[0., 1.], [1., 0.]])
s_y = np.array([[0., -1j], [1j, 0.]])
tau_z = ta.array(np.kron(s_z, s_0))
tau_x = ta.array(np.kron(s_x, s_0))
tau_y = ta.array(np.kron(s_y, s_0))
sig_z = ta.array(np.kron(s_0, s_z))
tau_zsig_x = ta.array(np.kron(s_z, s_x))
tau_zsig_y = ta.array(np.kron(s_z, s_y))
# Lorentzian definition
def lorentzianxy(x, y, ind,y0):
gam = 3
L = params["L"]
#if 0<ind<L:
return gam ** 2 /( gam ** 2 + (x - ind) ** 2 + (y - y0) ** 2)
# else :
# return 0
# Define potential
def potential(site, pot,ind,y0):
(x, y) = site.pos
return pot * lorentzianxy(x,y,ind,y0)
# Make system
def makeNISIN2D(params):
# List all the params
W=params["W"]
L=params["L"]
pot = params["pot"]
ind = params["ind"]
mu=params["mu"]
B=params["B"]
Delta=params["Delta"]
alpha=params["alpha"]
t=params["t"]
barrier = params["barrier"]
Smu = params["Smu"]
def lorentzianxy(x, y, ind,y0):
gam = 3
L = params["L"]
#if 0<ind<L:
return gam ** 2 /( gam ** 2 + (x - ind) ** 2 + (y - y0) ** 2)
# else :
# return 0
# Define potential
def potential(site, pot,ind,y0):
(x, y) = site.pos
return pot * lorentzianxy(x,y,ind,y0)
# if y < lorentzian(x,ind)*4:
#
# return (tru_pot)
# else:
# return 0
#
def Straightpotential(site, pot,ind):
(x, y) = site.pos
if x == ind:
return pot
else:
return 0
def onsiteSc(site, pot,ind,y0):
#(x,y)=site.pos
#L=params["L"]
# if x>L/2:
return (4 * t - Smu) * tau_z + B * sig_z + Delta * tau_x - potential(site, pot,ind,y0)*tau_z
# else:
#return (4 * t ) * tau_z + B * sig_z + Delta * tau_x - potential(site, pot,ind,y0)*tau_z
def onsiteNormal(site, pot,ind,y0):
return (4 * t - mu) * tau_z #- potential(site, pot,ind,y0)*tau_z
def onsiteBarrier(site, pot,ind,y0):
return (4 * t - mu + barrier) * tau_z #- potential(site, pot,ind,y0)*tau_z
def hop_x(site, pot, ind,y0):
return -t * tau_z + 0.5j * alpha * tau_zsig_y
def hop_y(site, pot, ind,y0):
return -t * tau_z - .5j * alpha * tau_zsig_x
# On each site, electron and hole orbitals.
lat = kwant.lattice.square(norbs=4)
syst = kwant.Builder()
# S
syst[(lat(i, j) for i in range(1,L-1) for j in range(W))] = onsiteSc
barrierLen = 1;
# I's
syst[(lat(i, j) for i in range(barrierLen) for j in range(W))] = onsiteBarrier
syst[(lat(i, j) for i in range(L-barrierLen, L)for j in range(W))] = onsiteBarrier
syst[kwant.builder.HoppingKind((1, 0), lat, lat)]= hop_x
syst[kwant.builder.HoppingKind((0, 1), lat, lat)]= hop_y
# N's
lead = kwant.Builder(kwant.TranslationalSymmetry((-1,0)),
conservation_law=-tau_z#, particle_hole=tau_y
)
lead[(lat(0, j) for j in range(W))] = onsiteNormal
lead[kwant.builder.HoppingKind((1, 0), lat, lat)]= hop_x
lead[kwant.builder.HoppingKind((0, 1), lat, lat)]= hop_y
syst.attach_lead(lead)
syst.attach_lead(lead.reversed())
return syst
def sorted_eigs(ev):
evals, evecs = ev
evals, evecs = map(np.array, zip(*sorted(zip(evals, evecs.transpose()))))
return evals, evecs.transpose()
params = dict(mu=0.3, Delta=.1, alpha=.8, t=1.0, barrier = 2.0, pot = 0.0,W = 5, L = 30, ind = 0, B = 0.3, Smu=0.00,y0=0)
sys = makeNISIN2D(params)
sys = sys.finalized()
# Calculate the wave functions in the system.
ham_mat = sys.hamiltonian_submatrix(sparse=True, params = params)
evals, evecs = sorted_eigs(sla.eigsh(ham_mat.tocsc(), k=20, sigma=0))
# Plot the probability density of the 10th eigenmode.
kwant.plotter.map(sys, np.abs(evecs[:, 9])**2,
colorbar=False, oversampling=1)
And the error I get is this: "ValueError: The number of sites doesn't match the number of provided values."
When I print the values they indeed are more than what they should be. I've tried a couple of things but I'm quite at a loss of what to do. I want to plot the wavefunction so I can see the Majoranas at the edges of the superconductor so that I can see how they respond to a local perturbation in the potential. Any tips would be very helpful.
Kind regards,
Hanifa

Dear Kwant developers,
I have a finalized closed system ''sys_f'' for which I computed the local charge densities "ch_densities", which is basically a vector of length=len(sys_f.sites).
For complexity reason, I'd like to feed a slice of sys_f to the interpolate_density() as:
>> kwant.plotter.interpolate_density(syst=sys_p, density=ch_densities_p)
where sys_p is a slice of sys_f and ch_densities_p is the corresponding density vector.Could you please let me know how to do it?
Best regards,Hadi

Dear developers,
I constructed Lat_A and Lat_B for a system.
A1,A2=Lat_A.sublattices
B1,B2=Lat_B.sublattices
I want to set hoppings between Lat_A and Lat_B, and the hoppings are
dependent on the site position.Every atom of Lat_A is coupled to all the
atoms in Lat_B.
Now I have tried it like this :
def coupling(site1,site2):
xp1,yp1=site1.pos
xp2,yp2=siye2.pos
return t*sqrt((xp1-xp2)**2+(yp1-yp2)**2)/d
for i in range(100):
for j in range(100):
sys[kwant.builder.HoppingKind(( i, j), A1, B1)] = coupling
sys[kwant.builder.HoppingKind(( i, j), A1, B2)] = coupling
sys[kwant.builder.HoppingKind(( i, j), A2, B1)] = coupling
sys[kwant.builder.HoppingKind(( i, j), A2, B2)] = coupling
It can not work because it take too long to do the calculations. I am
considering a bilayer system but rotations are considered, for example a
twisted bilayer graphene. Could you please help me to solve this problem?
Regards,
Hosein Khani

Dear KWANT developers,
I want to generate a 3D annulus cylinder with hopping in all the three
directions(periodic in x-direction) like the following figure. Please
suggest me the way to generate such type of geometry. If possible then
provide an example code for that for better understanding.
[image: image.png]
I will be very thankful to you.
Naveen
--
With Best Regards
NAVEEN YADAV
Ph.D Research Scholar
Deptt. Of Physics & Astrophysics
University Of Delhi.

Dear Kwant developers,
I write concerning the group velocites
of the modes in the leads.
In particular, I wonder how Kwant calculates them.
I see two possibilities (leads along x):
1) knowing the dispersion along x, from the usual definition v(kx) =
\partial E(kx) / \partial kx;
2) working equivalently in the real space basis, and in particular on
a unitary cell
of a lead, one can calculate vx also as:
vx = <\psi |i [H, \hat{x}] | \psi>,
being \psi the wavefunction of the mode and
H the Hamiltonian respectively, both defined on the unitary cell of
the lead, and \hat{x}
the position operator.
The second approach can be useful also to estimate the expectation
value of the velocities in the direction orthogonal to the leads (say
when close boundary conditions are assumed).
Does Kwant utilizes directly one of these two strategies ?
Thank you very much and best regards
L. L.

Dear Kwant Developers
My name is Dominic Ko and I am a master student.
I am using Kwant to stimulate 2D nanowire (square lattice) with two barriers (quite similar to NS junction described in Section 2.6 in the tutorial but topological superconductor is sandwiched between two barriers) and I am measuring the conductance across it using "smatrix.transmission(1, 0)". Somehow in a topological phase, I cannot get zero bias peak to maintain is something wrong with my code? (Checked with spectrum)
Thanks and I am looking forward to hearing from you.
Yours faithfully,
Dominic

Hi Ousmane et al,
I actually want the block of unit cells to be perpendicular to the
scattering region as in the Wanted_System.png, attached. Note that it is a
representative plot, I didn't produce it via Kwant but I want to attach the
red lead to the black region in that direction, not like in
Unwanted_System.png, which is also attached and produced via the code:
##########################################
import kwant
import numpy as np
import matplotlib.pyplot as plt
from types import SimpleNamespace
def make_system(a, W, L):
def shape(pos):
(x, y) = pos
return (0 <= y <= W/2 and -x/2 <= y <= (-x + L)/2) # or (-W <= y
<= 0 and 0 <= x <= L)
def onsite(site, par):
return 4 * par.t - par.mu
def hopx(par):
return -par.t
def hopy(par):
return -par.t
# lead
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
lead = kwant.Builder(kwant.TranslationalSymmetry((-a, -2*a)))
def lead_shape(pos):
(x, y) = pos
return -W <= x <= 0
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, (-2*a, -a))] = 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
syst = make_system(a=5, W=100, L=100)
kwant.plot(syst)
##########################################
I couldn't make the lead rotated in the perpendicular direction to the
surface. Is there a way to do it?
Thanks,
Barış