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 Thomas, dear kwant community,
the purpose of this mail is to discuss the technical details to calculate time-dependent heat and energies currents using tkwant (extension of kwant which allows to create a time-dependent Hamiltonian and compute the time-dependent observables like densities and currents) and if/how our additional modules to do so can be integrated into tkwant. As far as I know, tkwant is not yet officially released but publicly available.
Upon request of Christoph Groth, we will share our discussion with the kwant community and invite anyone to participate. As far as I know, the kwant mailing list was not (only) meant to be a Q&A platform for the community to ask questions to the developers but also for the whole community to discuss topics. Moreover, with the recent retiring of the developer mailing list, it was recommended to use the general mailing list also for development discussions. Still, this mail is mainly addressed to Thomas, which is why I apologize in advance for code details which are not explained and thus not understandable for everyone.
That being said, let's come to the physics.
I. Heat and energy currents in time-dependent systems
( https://github.com/PhiReck/heatCurrent )
We want to calculate time-dependent heat currents into a lead. The heat current is defined as I_h = I_E - μ I_N, with I_E being the energy current, μ is the chemical potential in the given lead and I_N is the particle current. Since μ is assumed to be known and I_N(t) can be calculated directly by (t)kwant with the help of the kwant.operator.Current class, the only missing part is the energy current.
In a static setup, the energy current is obtained easily by an additional factor of the energy in the integrand of the Landauer-Büttiker formula (e.g. for two leads: I_E =e/h \int dE E T(E) [f_L(E)-f_R(E)] ). However for time-dependent systems, the energy is not conserved anymore which makes things more complicated.
I do not want to explain how tkwant works here, since this would take too long. The basic idea is that the lesser Green's function can be expressed in terms of the time-dependent scattering states. The integration over the energy in a Landauer-Büttiker-type formula is done by an instance of the kwant.manybody.Solve class. The provided operator, e.g. kwant.operator.Current or kwant.operator.Density, tells this solver which observable is to be calculated.
So far, the kwant.operators available are:
- Density: 'bra_i M_i ket_i'
- Current: 'bra_i H_ij ket_j - c.c. '
- Source: 'bra_i M_i H_ii ket_i - c.c.
where "i" and "j" are sites, H is the Hamiltonian, M denotes an arbitrary onsite Operator (which is a matrix with dimensions given by the number of orbitals) and bra and ket are wave functions. For instance, for spin densities and spin currents, M would be the appropriate Pauli matrix (at least if spin is the only additional degree of freedom).
For the purpose of time-dependent heat and energy currents we need additionally:
- Energy Current: 'bra_i H_ij H_jk ket_k - c.c.'
- Explicit time dependence of hopping: 'bra_i M_i dH_ij/dt ket_j + c.c.'
These are of a similar shape as the operators above but different enough such that the old operators cannot be used. We already implemented them ( https://github.com/PhiReck/heatCurrent ) and tested them successfully in comparison to the analytical Keldysh-Green's function approach in the resonant level model. As far as we see, the calculation of the time-dependent wave function takes distinctly more time than the computation of the energy current (factor of >10) such that the calculation time is not really affected by the energy current.
(Note that we did not only implement the operators above, but also utility functions that makes it as easy for the user to calculate particle currents in tkwant as the heat current into/from a lead.)
II. A general operator module
( https://github.com/PhiReck/generalOperator )
Moreover, since the operators above all look rather similar, we generalized the operator module and discussed it already on the development mailing list. With this general operator, one is able to calculate any term of the following arbitrary form:
- generalOperator: 'bra_a O1_ab O2_bc ... O25_yz ket_z +/-/0 c.c. '
Here, 'a' to 'z' denote again sites where 'z' is used as an arbitrary level of deepness (i.e., 'z' could be equal to 'b', if only one hopping is desired, or 'd' if three hoppings are wished). Moreover, On_xy are user-defined operators (if x==y, it is also an onsite operator). '+/-/0' is meant to imply that the complex conjugate can either be added subtracted or not taken into account at all, depending on what the user wants to do.
In practice, we would first initialize each operator as
O1 = generalOperator.Operator(syst, O1-FUNCTION, where=where_O1)
O2 = generalOperator.Operator(syst, O2-FUNCTION, where=where_O2)
...
with On-FUNCTION being the function that defines the operator, e.g. syst.hamiltonian or any other function that takes 1-2 sites and returns a matrix with dimensions given by the additional degrees of freedom (spin, orbitals, ...) at the sites at hand. Moreover, each operator has to know where it is to be considered/computed, specified normally as a list of hoppings (where_On).
The product is achieved by
prodOp = generalOperator.Op_Product(O1, O2, ..., complex_conj, const_fac)
'complex+conj' takes care of the +/-/0 option above and 'const_fac' is a constant factor which is multiplied to the result (in case of the current, it would be the imaginary unit 1j).
To tell tkwant to calculate the matrix product with the wave functions as shown above, it is used the same way as for the kwant.operators:
result = prodOp(bra,ket)
which returns a list of results for all possible site connections.
Speaking of the site connections (or as I call it: the path finding), note that now, the different where_On have to be matched: since we want to have something like "O1_ab O2_bc", we have to make sure that only hoppings in where_O1 are connected to hoppings in where_O2 which have the same site 'b' at the according position. This path finding is done automatically in the initialization of the class generalOperator.Op_Product.
The path finding is the only new conceptual thing, but the user does not have to worry about it which is why I don't want to go into details here now. (There is a documentation in the git repository if someone is interested.)
How to create a new operator from the generalOperator at the example of the Energy Current :
This is a copy of the source code, where I omitted the check_hermiticity option and the sum option for better readability.
class offEnergyCurrent:
def __init__(self, syst, where1, where2):
self.hamil1 = Operator(syst, syst.hamiltonian, where1)
self.hamil2 = Operator(syst, syst.hamiltonian, where2)
self.offEn = Op_Product(self.hamil1, self.hamil2, complex_conj=-1, const_fac=1j)
def __call__(self, bra, ket=None, args=(), *, params=None):
return self.offEn(bra, ket, args, params=params)
Long story short: With the help of the generalOperator, it is very easy to create new operators (just define the individual operators and take the product via generalOperator.Op_Product). Before, for each operator inheriting from the kwant.operator._Localoperator, an individual "_operate" method was needed, although they are very similar in all 5 cases from above. At the moment, I am not sure if anyone ever needs to create new operators. So far, for kwant, it seems that the 3 kwant.operators have been enough (and would have been enough for our purpose of thermoelectric properties). With t-kwant however, I have the feeling that certain operators will be more complicated as compared to their time-independent counterparts as we have seen in the case of the energy current. Therefore, this general operator might be of use in the future.
However, the larger universality of the general Operator comes at a price: Calculations are slower, which is mostly due to the fact that recursive functions are called for each single site combination. For the three examples of the kwant.operators, we see that the __call__ of the same operators initialized with the general operator takes roughly 3-5 times longer. This means that the general operator is not (yet?) suited to replace the 'specialized' ones, but at least it will help potential users to easily define and use new operators: they won't have to write and test an operate method in the 'old' kwant.operator._LocalOperator way.
So this is the current state of progress. We hope to merge both the 'specialized' heat/energy current as well as the general operator with tkwant soon.
@ Thomas: Do you see any problems or do you have any concerns about merging it with tkwant? Maybe I should have added that all the features of the kwant operators should be able to use, e.g. bind or functions for where. For instance, all the kwant examples from the tutorial also work fine with the general operator.
Best regards,
Phillipp Reck

Dear all,
I am trying to obtain the coefficients of
the transmission matrix (fine, so far.....)
and to related them to the modes of the leads.
In particular, I would like to know the momenta of these
modes (supposing periodic conditions along the directions orthogonal
to the leads).
Is it possible ?
Thank you very much for the help.
L.

Dear Kwant users and developers,
Is there a way to calculate the integral(< u_nk | d_k(u_nk)>dk) across the
1D BZ of a system periodic in one direction. Here u_nk is the periodic part
of the Bloch wave function corresponding to band n. I am trying to compute
this for a simple system of graphene nanoribbon.
I am trying compute the gauge independent value of the above integral using
a "1D Wilsoon loop" where the integral is approximately equal to the
product of <u_nk|u_n(k+1) > for all k across the BZ. I defined the unit
cell of the nanoribbon as a lead and tried to get the u_nk as the
propagating modes using leads.modes() method (I have pasted the code below)
but the resolution in k is too large - only 4 momenta across the BZ.
How can we get u_n(k) with a good resolution of k, say for 100 points in
the BZ ? Is this something which can be easily done in Kwant ?
Code:
def make_1D_zigzag(N=7,t=1):
syst = kwant.Builder(kwant.TranslationalSymmetry(Zigzag.prim_vecs[0]))
syst[Zigzag.shape((lambda pos: pos[1] >0 and pos[1] <
get_width(N)),(0,0))] = 2*t
syst[Zigzag.neighbors()] = -t
return syst
lead = make_1D_zigzag(N=N,t=2);
lead = lead.finalized()
prop_modes=lead.modes()[0]
u_nk = prop_modes.wave_functions
Thanks a lot for your help!
Srilok Srinivasan
Graduate Student
Mechanical Engineering
Iowa State University, Ames, IA

Dear Colleagues,
I want to investigate the dephasing effect in the coherent junction, so I want to couple a phenomenological term $i\frac{\Gamma}{2}$ to the Hamiltonian $H(\phi)$. I want plot the figure that describe the conductance via the phase $\phi$ at different dephasing strength $\Gamma$.
I try it, but the total Hamiltonian becomes non-hermitian. The program got broken.
How to realize this by Kwant? Can you give more ways or some examples.
--
Jinlong Zhang
jlzhang(a)163.com

Hello everyone, i would appreciate any suggestion you could give me to
solve this
I'm trying to attach a couple of leads to my structure, I have the code for
both, but I want to know how to make that both leads begin with the same
atom,
In the code below you can see that the left lead starts in a gray atom,
while the lead in the right side starts in the couple of atoms blue and
yellow, if I increase the size of the structure it only creates another
primitive cell and the case is the same
Is there a way to make that the right lead starts in a gray atom as the
left lead, like only creating half primitive cell?
Thanks in advance
Here is the code
import kwant
from matplotlib import pyplot
%matplotlib tk
PrimVec = [(3.176, 0, 0), (1.588, 2.7504, 0), (0, 0, 17.49)]
base = [(0, 0, 0), (1.588, 0.9168, 0.8745), (0, 0, 1.749)]
lat = kwant.lattice.general(prim_vecs = PrimVec, basis = base)
d, e, f= lat.sublattices
def make_cuboid(t=1.0, a=15, b=10, c=5):
def cuboid_shape(pos):
x, y, z = pos
return 0 <= x < a and 0 <= y < b and 0 <= z < c
syst = kwant.Builder()
syst[lat.shape(cuboid_shape, (0, 0, 0))] = 4 * t
hoppings = (((1, 0, 0), d, e), ((0, 0, 0), d, e),((0, 1, 0), d, e),
((0, 0, 0), f, e), ((1, 0, 0), f, e), ((0, 1, 0), f, e))
syst[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] = -6
lead = kwant.Builder(kwant.TranslationalSymmetry((-3.176, 0, 0)))
def lead_shape(pos):
return 0 <= pos[1] < b and 0 <= pos[2] < c
lead[lat.shape(lead_shape, (0, 0, 0))] = 4 * t
lead[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] = -6
syst.attach_lead(lead)
syst.attach_lead(lead.reversed())
return syst
def main():
syst = make_cuboid(a=30, b=14, c=4)
def family_colors(site):
if site.family == d:
return 'yellow'
elif site.family == e:
return 'gray'
else:
return 'blue'
kwant.plot(syst, site_size=0.25, site_lw=0.025, hop_lw=0.05,
site_color=family_colors)
syst = syst.finalized()
if __name__ == '__main__':
main()

Hello everyone, I would appreciate any suggestion you could give me to
solve this:
Im currently working on a 2D finite monolayer of certain material that is
coupled to a pair of leads in both left and right sides, the thing is: how
can I get rid of the dangling bonds that appears in the edges of the
nanoribbon?, I cant use the function "eradicate dangling" because the
dissapearing atoms will just generate new dangling bonds.
(By the way: I tried to use this function just to see what happens but
nothing changed in the structure, is that normal?)
So, Is there a way to automatically fill the dangling bonds with Hydrogen
atoms? Or do I have to do it manually?
Thanks in advance.

Dear Kwant users,
I write for advices concening apparent
problems that I encountered programming with Kwant.
I would like to calculate quantities related to transport (e.g. conductivity,
Fano factor,.....) in 2D and 3D lattice systems hosting Dirac / Weyl points.
I have tried to implement a couple of examples of semimetals with Kwant,
where the lattices (scattering regions) are taken square or cubic,
and the leads attached on entire faces of the lattices.
I assumed both open and periodic (in the directions orthogonal to the leads)
boundaries conditions for the lattices and for the leads.
Generally, I have found strange things, like
sudden falls to zero of the conductivities within the energies of the
scattering areas, or suspicious conductivity asymmetries
around the energies of the cones, even if the lattice spectra are symmetric.
I am reasonably sure that the Hamiltonians are written correctly in Kwant,
at least because I checked separately the spectra of the scattering zones
and of the leads, comparing them with the analytics.
Discussing at a conference,
I got aware vaguely about possible problems
that may arise when one wants to
discretize in real space an Hamiltonian originally written in
the space of momenta (also continuous).
This is exaclty what I have done always;
notice that I performed the discretization by hand, without
exploiting the routine in Kwant.
Do you know about similar issues with semimetals ?
Do you have some advices ?
Thank you very much to everybody and best regards,
L. L.

Dear subscribers of kwant-devel and of kwant-discuss,
Due to the very limited usage of the kwant-devel mailing list (most
development discussions happen in the issues and merge requests of our
gitlab instance [1]), we have decided to retire it.
Still, a mailing list is a useful forum also for development, especially
when more general topics are being discussed. That's why, starting from
now, we recommend [2] the use the kwant-discuss list also for
development discussions. This will have the welcome side-effect of
giving development discussions a wider audience. Note that
kwant-discuss was never meant to be a pure Q&A list.
A number of subscribers to kwant-devel are not members of kwant-discuss.
Would you please consider subscribing? The average volume is rather
low: a couple of messages per week. In order to subscribe, simply send
an arbitrary message to kwant-discuss-join(a)kwant-project.org (the
subject and body are ignored).
(Those who are subscribed to both lists have received this message twice.
My apologies for that.)
As far as kwant-devel is concerned, you have nothing to do. Posting is
technically still allowed for the time being. We will eventually
disable it, but the list and its archives will continue to linger.
Cheers,
Christoph
[1] https://gitlab.kwant-project.org/
[2] https://kwant-project.org/community