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

Hello everyone,
I am trying to reproduce the QHE bar device calculations
http://nbviewer.jupyter.org/github/topocm/topocm_content/blob/master/w3_pum…
However, I am having difficulty with the onsite and hopping values as
I am using TBModels
https://github.com/Z2PackDev/TBmodels
and therefore the values are not the same for all sites.
The problem is that after the scalar values have been passed on to the
Builder, these will then be overriden when using functions for the
position-dependent Hamiltonian.
I tried making a deep copy of the model, which would then serve as a
data structure where to draw the scalar values from when calling the
Onsite and Hopping functions. The problem with this is
a) I am getting a KeyError which I am still not sure why it happens
b) It does not feel very memory-efficient.
I am wondering if there is another way that this could be done on the
Kwant side that I have not been able to think of.
Regards
--
Dr. Eleni Chatzikyriakou
Computational Physics lab
Aristotle University of Thessaloniki
elchatz(a)auth.gr - tel:+30 2310 998109

Dear sir,
Please help me with the following error in the program
from __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
import kwant
from matplotlib import pyplot
import numpy as np
from holoviews.core.options import Cycle
from types import SimpleNamespace
def nanowire_chain():
lat = kwant.lattice.chain()
sys = kwant.Builder(kwant.TranslationalSymmetry(*lat.prim_vecs))
def onsite(onsite, p):
return (2 * p.t - p.mu) * pauli.szs0 + p.B *
(np.cos(p.phi)*pauli.s0sz+
np.sin(p.phi)*np.sin(p.theta)*pauli.s0sy+np.sin(p.phi)*np.sin(p.theta)*pauli.s0sx)+
p.delta * pauli.sxs0
sys[lat(0)] = onsite
def hop(site1, site2, p):
return -p.t * pauli.szs0 - .5j * p.alpha * pauli.szsx
sys[kwant.HoppingKind((1,), lat)] = hop
return sys
def spinful_kitaev_chain():
lat = kwant.lattice.chain()
sys = kwant.Builder(kwant.TranslationalSymmetry(*lat.prim_vecs))
def onsite(site, p):
return (2 * p.t - p.mu) * pauli.szs0 + p.B * pauli.szsz
sys[lat(0)] = onsite
def hop(site1, site2, p):
return -p.t * pauli.szs0 - 1j * p.delta * pauli.sys0
sys[kwant.HoppingKind((1,), lat)] = hop
return sys
def find_gap(sys, p, resolution=1e-4):
"""Find gap in a system by doing a binary search in energy."""
# This tells us if there are modes at a certain energy.
if len(sys.modes(energy=0, args=[p])[0].momenta):
return 0
gap = step = min(abs(kwant.physics.Bands(sys, args=[p])(k=0))) / 2
while step > resolution:
step /= 2
if len(sys.modes(gap, args=[p])[0].momenta):
gap -= step
else:
gap += step
return gap
def spinorbit_band_gap(sys, mu, t, delta, Bs):
sys = sys.finalized()
alphas = [0.0, 0.1, 0.2, 0.3]
p = SimpleNamespace(mu=mu, t=t, delta=delta,theta=theta,phi=phi)
def gap(sys, p, alpha, B):
p.alpha = alpha
p.B = B
return find_gap(sys, p)
gaps = [gap(sys, p, alpha, B) for alpha in alphas for B in Bs]
gaps = np.reshape(gaps, (len(alphas), -1))
dims = {'kdims': [r'$B$'], 'vdims': ['Band gap']}
B_crit = holoviews.VLine(np.sqrt(p.delta**2 + p.mu**2))
plot = [holoviews.Curve((Bs, gaps[i]), label=r'$\alpha={}$'.format(
alphas[i]), **dims) * B_crit for i, alpha in enumerate(alphas)]
title = r'$\Delta={delta}$, $\mu={mu}$'.format(delta=np.round(p.delta,
2), mu=np.round(p.mu, 2))
style = {'xticks': [0, 0.1, 0.2, 0.3], 'yticks': [0, 0.05, 0.1],
'fig_size': 150}
plot = holoviews.Overlay(plot)
return plot(plot=style)
def title(p):
try:
title = r"$\alpha={alpha}$, $\mu={mu}$, $B={B}$, $\Delta={delta}$"
title = title.format(alpha=np.round(p.alpha, 2),
mu=np.round(p.mu, 2),
B=np.round(p.B, 2),
delta=np.round(p.delta, 2))
except AttributeError:
title = r"$\mu={mu}$, $B={B}$, $\Delta={delta}$"
title = title.format(mu=np.round(p.mu, 2),
B=np.round(p.B, 2),
delta=np.round(p.delta, 2))
return title
style = {'k_x': np.linspace(-1, 1, 101),
'xdim': r'$k$',
'ydim': r'$E/t$',
'xticks': [-1, 0, 1],
'yticks': [-1, 0, 1],
'xlims': [-1, 1],
'ylims': [-1.5, 1.5],
'title': title}
sys = nanowire_chain()
p = SimpleNamespace(t=1, mu=0.1, delta=0.1, B=0.3,theta=np.pi/2,phi=np.pi/2)
alphas = np.linspace(0, 0.4, 10)
holoviews.HoloMap({alpha: spectrum(sys, p.update(alpha=alpha), **style) for
alpha in alphas}, kdims=[r'$\alpha$'])
c:\python36\lib\site-packages\kwant\linalg\lll.py:103: FutureWarning:
`rcond` parameter will change to the default of machine precision
times ``max(M, N)`` where M and N are the input matrix dimensions.
To use the future default and silence this warning we advise to pass
`rcond=None`, to keep using the old, explicitly pass `rcond=-1`.
coefs = np.linalg.lstsq(vecs_orig.T, vecs.T)[0]
c:\python36\lib\site-packages\kwant\linalg\lll.py:144: FutureWarning:
`rcond` parameter will change to the default of machine precision
times ``max(M, N)`` where M and N are the input matrix dimensions.
To use the future default and silence this warning we advise to pass
`rcond=None`, to keep using the old, explicitly pass `rcond=-1`.
center_coords = np.array(np.round(np.linalg.lstsq(basis.T, vec)[0]), int)
---------------------------------------------------------------------------NameError
Traceback (most recent call
last)<ipython-input-3-9ff9219a759e> in <module>() 2 p =
SimpleNamespace(t=1, mu=0.1, delta=0.1,
B=0.3,theta=np.pi/2,phi=np.pi/2) 3 alphas = np.linspace(0, 0.4,
10)----> 4 holoviews.HoloMap({alpha: spectrum(sys,
p.update(alpha=alpha), **style) for alpha in alphas},
kdims=[r'$\alpha$'])
NameError: name 'holoviews' is not defined

Dear Kwant,
I am trying to plot the phase of the hopping term.
def hop_c(i,j):
return np.angle(sys.hamiltonian(i, j, params=params)[0,0])
kwant.plot(sys, hop_color=hop_c, hop_lw=0.25, site_size=0, cmap=('hsv',
'hsv'));
I would like the limits of the colorbar to be -pi to pi but kwant
automatically sets the limits to the min and max.
Is there a way to set the limits?
Thanks,
Eric
Eric Mascot College of Liberal Arts
Graduate Student and Sciences
Department of Physics
emasco2(a)uic.edu 845 W Taylor St
M: 248 433 6435 2158 SES
O: 312 413 2109 Chicago, IL 60607

Dear Kwant Developer,
I note there was a discussion in the community about next nearest neighbor hopping in the community (Leads with greater than NN hopping<https://www.mail-archive.com/search?l=kwant-discuss@kwant-project.org&q=sub…>).
However, I still have the following questions about next nearest neighbour hopping in the lead after reading the discussion.
1. Can we add next nearest neighbour hopping to a lead without expanding the unit cell, if there are only hoppings between nearest neighbouring unit cells even with next nearest neighbour hopping? Can the band structure be calculated properly using the Kwant library?
2. When the lead is attached to the system, will the next nearest neighbour hopping be included in the action automatically?
Thank you in advance for your help.
KS Chan
Disclaimer: This email (including any attachments) is for the use of the intended recipient only and may contain confidential information and/or copyright material. If you are not the intended recipient, please notify the sender immediately and delete this email and all copies from your system. Any unauthorized use, disclosure, reproduction, copying, distribution, or other form of unauthorized dissemination of the contents is expressly prohibited.

Hello All,
I am trying to attach a 3D lead to a 3D system that I have built, but am
facing troubles in the same. I am aware of another thread (
https://mailman-mail5.webfaction.com/pipermail/kwant-discuss/2014-May/00012…)
highlighting my question, but having gone through that thread I was still
unable to successfully attach a lead to my system.
Ideally, I want to attach gold leads to my system but I started by
attaching a simple cubic lattice (by breaking it into 2 different
lattices). Following is my code.
*h = 2.707 * np.cos(13.69*np.pi/180)*
*dx = 4.43*
*dy = 3.27*
*shift_x = 2.164 * np.cos(0.5*98.15*np.pi/180)*
*shift_y = 2.164 * np.sin(0.5*98.15*np.pi/180)*
*lat0 = kwant.lattice.general([(dx, 0, 0), (0, dy, 0)], [(0, 0, 0),
(shift_x, shift_y, 0)])*
*lat1 = kwant.lattice.general([(dx, 0, 0), (0, dy, 0)], [(0.5*dx, 0.5*dy,
h), (0.5*dx + shift_x, 0.5*dy + shift_y, h)])*
*a_const = 2*
*b_const = 2*
*c_const = 1*
*def make_cuboid(a = a_const*dx, b = b_const*dy, c = c_const*h):*
* def cuboid_shape(pos):*
* x, y, z = pos*
* return -a <= x <= a and -b <= y <= b and -c <= z <= c*
* sys = kwant.Builder()*
* sys[lat0.shape(cuboid_shape, (0, 0, 0))] = None*
* sys[lat0.neighbors(1)] = 1*
* sys[lat0.neighbors(2)] = 1*
* sys[lat1.shape(cuboid_shape, (0.5*dx, 0.5*dy, h))] = None*
* sys[lat1.neighbors(1)] = 1*
* sys[lat1.neighbors(2)] = 1*
* # Diagonally going up-right/down_left bonds*
* for j in range(-a_const, a_const):*
* for i in range(-b_const, b_const):*
* sys[lat0.sublattices[1](j,i), lat1.sublattices[0](j,i)] = 1*
* # Diagonally going up-left/down-right bonds*
* for m in range(a_const, -a_const, -1):*
* for n in range(-b_const, b_const):*
* sys[lat0.sublattices[0](m,n), lat1.sublattices[1](m-1,n-1)] =
1*
* # Define the leads*
* lat0_lead = kwant.lattice.square(dy)*
* sym_lead0 = kwant.TranslationalSymmetry((dy, 0))*
* lead0 = kwant.Builder(sym_lead0)*
* lead0[(lat0_lead(0, i) for i in range(-2,3))] = 0*
* lead0[lat0_lead.neighbors()] = 1*
* sys[(lat0_lead(3, i) for i in range(-2,3))] = 0*
* sys[lat0_lead.neighbors()] = 1*
* # Manually attach sites from the base (height=0) lattice to square
lattice*
* sys[((lat0_lead(3, i), lat0.sublattices[0](2, i)) for i in
range(-2,3))] = 1*
* def family_colors(site):*
* if site.family == lat0.sublattices[0]:*
* return 'b'*
* elif site.family == lat0.sublattices[1]:*
* return 'b'*
* elif site.family == lat1.sublattices[0]:*
* return 'g'*
* elif site.family == lat1.sublattices[1]:*
* return 'g'*
* kwant.plot(sys, site_size=0.2, hop_lw=0.1, site_color=family_colors)*
* return sys.finalized()*
*def main():*
* sys = make_cuboid()*
*if __name__ == '__main__':*
* main()*
>From my knowledge, this should attach a 2D square lattice lead (or to be
precise, just 1 layer of the 2D square lattice lead as shown in
https://kwant-project.org/doc/1.3/tutorial/faq) to one side of my 3D
system. I would be really glad if someone could help me out with this
problem.
Best Regards,
Shivang
--
*Shivang Agarwal*
Senior Undergraduate
Discipline of Electrical Engineering
IIT Gandhinagar
Contact: +91-9869321451

Dear Sir,
I have two questions.
(1) I want to study the intralayer intrinsic spin-orbit coupling in bilayer graphene. For the monolayer case, it is easy to put the nnn hopping by,
sys[graphene.neighbors(2)] = spin_orbit
But for the bilayer case, as there are two planes and the intralayer coupling which I want to calculate should be in those two planes, Can I use the above code to get the effect. If not, then how can I put the effect in bilayer system.
(2) When I am calculating the Hamiltonian submatrix between two sites to see the full matrix without spin-orbit ( only for tight-binding in bilayer where t=1 and interlayer coupling ,t_prep= 0.2) it is showing
[[7.+0.j 0.+0.j 0.+0.j 0.+0.j]
[0.+0.j 7.+0.j 0.+0.j 0.+0.j]
[0.+0.j 0.+0.j 7.+0.j 0.+0.j]
[0.+0.j 0.+0.j 0.+0.j 7.+0.j]]
where 7 is for onsite element (sys[graphene.shape(rect, (0, 0, 0))] = 7 * sigma_0).
Thanks in advance.
sincerely,
Priyanka Sinha

Dear Professors,
I want to put a transverse electric field on this example. So Imodify the onsite energy as follows,
def onsite(site, p):
x, y = site.pos
E = 0.15 # the magnitude of electrical field in y direction
return tau_z * (p.mu - 2 * p.t) + sigma_z * p.B + tau_x * p.Delta + E* y* s_0
s_0 = numpy.identity(2). However, the program crashed to
UserCodeError: Error occurred in user-supplied value function "onsite".
The same error also occur when I put a perpendicular magnetic field and modify the hopping energy as
def hopping(sitei, sitej, phi, salt):
xi, yi = sitei.pos
xj, yj = sitej.pos
return t0 * exp(-0.5j * phi * (xi - xj) * (yi + yj))
where t0 is the hopping matrix before put magnetic field.
Would you like help me in this issue?
Happy Kwant!
QC
HNIE
__________The full code _____________________
from matplotlib import pyplot
import kwant
from kwant.digest import gauss
import numpy
import tinyarray
import scipy.sparse.linalg
# Python >= 3.3 provides SimpleNamespace in the
# standard library so we can simply import it:
# >>> from types import SimpleNamespace
# (Kwant does not yet support Python 3.)
class SimpleNamespace(object):
"""A simple container for parameters."""
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
s_0 = numpy.identity(2)
s_z = numpy.array([[1, 0], [0, -1]])
s_x = numpy.array([[0, 1], [1, 0]])
s_y = numpy.array([[0, -1j], [1j, 0]])
tau_z = tinyarray.array(numpy.kron(s_z, s_0))
tau_x = tinyarray.array(numpy.kron(s_x, s_0))
sigma_z = tinyarray.array(numpy.kron(s_0, s_z))
tau_zsigma_x = tinyarray.array(numpy.kron(s_z, s_x))
def onsite(site, p):
x, y = site.pos
Electric = 0.15 # the magnitude of electrical field in y direction
return tau_z * (p.mu - 2 * p.t) + sigma_z * p.B + tau_x * p.Delta + Eeletric * y* s_0
def hopping(site0, site1, p):
return tau_z * p.t + 1j * tau_zsigma_x * p.alpha
def make_system(l=70):
sys = kwant.Builder()
lat = kwant.lattice.chain()
sys[(lat(x) for x in range(l))] = onsite
sys[lat.neighbors()] = hopping
return sys.finalized()
sys = make_system()
# Calculate and plot lowest eigenenergies in B-field.
B_values = numpy.linspace(0, 0.6, 80)
energies = []
params = SimpleNamespace(
t=1, mu=-0.1, alpha=0.05, Delta=0.2)
for params.B in B_values:
H = sys.hamiltonian_submatrix(
args=[params], sparse=True)
H = H.tocsc()
eigs = scipy.sparse.linalg.eigsh(H, k=20, sigma=0)
energies.append(numpy.sort(eigs[0]))
pyplot.plot(B_values, energies)
pyplot.show()

Dear Professors,
I want to put a transverse electric field on this example. So Imodify the onsite energy as follows,
def onsite(site, p):
x, y = site.pos
E = 0.15 # the magnitude of electrical field in y direction
return tau_z * (p.mu - 2 * p.t) + sigma_z * p.B + tau_x * p.Delta + E* y* s_0
s_0 = numpy.identity(2). However, the program crashed to
UserCodeError: Error occurred in user-supplied value function "onsite".
The same error also occur when I put a perpendicular magnetic field and modify the hopping energy as
def hopping(sitei, sitej, phi, salt):
xi, yi = sitei.pos
xj, yj = sitej.pos
return t0 * exp(-0.5j * phi * (xi - xj) * (yi + yj))
where t0 is the hopping matrix before put magnetic field.
Would you like help me in this issue?
Happy Kwant!
QC
HNIE
__________The full code _____________________
from matplotlib import pyplot
import kwant
from kwant.digest import gauss
import numpy
import tinyarray
import scipy.sparse.linalg
# Python >= 3.3 provides SimpleNamespace in the
# standard library so we can simply import it:
# >>> from types import SimpleNamespace
# (Kwant does not yet support Python 3.)
class SimpleNamespace(object):
"""A simple container for parameters."""
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
s_0 = numpy.identity(2)
s_z = numpy.array([[1, 0], [0, -1]])
s_x = numpy.array([[0, 1], [1, 0]])
s_y = numpy.array([[0, -1j], [1j, 0]])
tau_z = tinyarray.array(numpy.kron(s_z, s_0))
tau_x = tinyarray.array(numpy.kron(s_x, s_0))
sigma_z = tinyarray.array(numpy.kron(s_0, s_z))
tau_zsigma_x = tinyarray.array(numpy.kron(s_z, s_x))
def onsite(site, p):
x, y = site.pos
Electric = 0.15 # the magnitude of electrical field in y direction
return tau_z * (p.mu - 2 * p.t) + sigma_z * p.B + tau_x * p.Delta + Eeletric * y* s_0
def hopping(site0, site1, p):
return tau_z * p.t + 1j * tau_zsigma_x * p.alpha
def make_system(l=70):
sys = kwant.Builder()
lat = kwant.lattice.chain()
sys[(lat(x) for x in range(l))] = onsite
sys[lat.neighbors()] = hopping
return sys.finalized()
sys = make_system()
# Calculate and plot lowest eigenenergies in B-field.
B_values = numpy.linspace(0, 0.6, 80)
energies = []
params = SimpleNamespace(
t=1, mu=-0.1, alpha=0.05, Delta=0.2)
for params.B in B_values:
H = sys.hamiltonian_submatrix(
args=[params], sparse=True)
H = H.tocsc()
eigs = scipy.sparse.linalg.eigsh(H, k=20, sigma=0)
energies.append(numpy.sort(eigs[0]))
pyplot.plot(B_values, energies)
pyplot.show()