Discussion:
[Kwant] Kwant for bulk system
Weiyuan Tong
2016-02-03 18:00:12 UTC
Permalink
Dear all,
I want to calculate the conductance and the band structure of a bulk
graphene system.(infinite in y direction) I have checked the source code
for the calculation of band structure.
https://github.com/kwantproject/kwant/blob/7c55b0cb2d0dec163e5483dea8ffdbc88c208397/kwant/physics/dispersion.py
It seems that we can get the sys.cell_hamiltonian and hopping between the
sys.cell_hamiltonian in kwant. In y direction, we can also have
sys.cell_hamiltonian and hopping, then it can be extended to infinite in y
direction: V^\dagger e^{iky} + H + Ve^{-iky}. I am not familiar with kwant
coding. Can anyone help me to write some code lines to do these
calculations? Or you can also change the Tutorial 2.2.3 as an example.
Thanks in advance!
Best wishes
Weiyuan Tong
Christoph Groth
2016-02-07 22:56:29 UTC
Permalink
This post might be inappropriate. Click to display it.
Christoph Groth
2016-02-07 23:11:57 UTC
Permalink
For people who do not use git, the code can be found directly at
https://gitlab.kwant-project.org/cwg/wraparound/raw/master/wraparound.py

(To get there from the main page
https://gitlab.kwant-project.org/cwg/wraparound, use the "files"
link on the left side.)
Weiyuan Tong
2016-02-10 17:24:37 UTC
Permalink
Dear Christoph
Thanks for your code. Can I run it on kwant 1.0 ? When I run your code on
File "E:\360data\importantdata\desktop\Bulk system.py", line 191, in
<module>
test()
File "E:\360data\importantdata\desktop\Bulk system.py", line 181, in test
np.testing.assert_almost_equal(energies_a, energies_b)
File "E:\Kwant
Install\Python27\lib\site-packages\numpy\testing\utils.py", line
452, in assert_almost_equal
return assert_array_almost_equal(actual, desired, decimal, err_msg)
File "E:\Kwant
Install\Python27\lib\site-packages\numpy\testing\utils.py", line
812, in assert_array_almost_equal
header=('Arrays are not almost equal to %d decimals' % decimal))
File "E:\Kwant
Install\Python27\lib\site-packages\numpy\testing\utils.py", line
645, in assert_array_compare
raise AssertionError(msg)
Arrays are not almost equal to 7 decimals
(mismatch 90.3225806452%)
x: array([[-1. , 1. ],
[-1.19292464, 1.19292464],
[-1.3736081 , 1.3736081 ],...
y: array([[-1. , 1. ],
[-0.79754736, 0.79754736],
[-0.58925337, 0.58925337],...
Do you know why this happens?
Best wishes,
Weiyuan Tong
I want to calculate the conductance and the band structure of a bulk
Post by Weiyuan Tong
graphene system.
Finalized systems in current Kwant can only handle a single direction of
translational symmetry. We are working on removing this restriction, but
this unfortunately requires modifying some deep internals of Kwant.
There is, however, a workaround: I just finished a little code that makes
it possible (and quite easy) to work with bulk systems in current Kwant.
The code takes a Kwant builder with an arbitrary number of translational
symmetries and returns an equivalent builder with 1 or 0 symmetries that
can be finalized. The symmetries that are removed are replaced by momentum
parameters that are added to the system.
https://gitlab.kwant-project.org/cwg/wraparound. It should be completely
general, i.e. it should work with _any_ builder that uses _any_ values. It
should be also reasonably efficient. The code seems to work well, but I
did only some basic testing so far.
With this hack one can now do transport through systems with periodic BCs,
transport across infinite planes, and calculate multi-dimensional band
structures. The provided example (function "demo") plots the band
structure of bulk graphene. To try it out, simply execute "python
wraparound.py".
As always, I’m happy to hear comments and suggestions.
Cheers,
Christoph
Christoph Groth
2016-02-10 22:02:04 UTC
Permalink
Post by Weiyuan Tong
Thanks for your code. Can I run it on kwant 1.0 ? When I run
your code on
The code will work with Kwant 1.0 as well. The test fails because
the convention for the sign of momentum of kwant.physics.Bands
changed in Kwant 1.1 [1]. "wraparound" uses the new convention
and hence the test did not consider that.

I just fixed the test in "wraparound": it should no longer fail.
But bear in mind that wraparound keeps using the new convention.
If you find this too confusing, just replace all 1j by -1j in
wraparound.py...

But the best would be if you would upgrade to 1.1. It should be
easy. May I ask what is holding you back?

Let me know if there are any other problems,
Christoph

[1]
http://kwant-project.org/doc/1.1/pre/whatsnew/1.1#harmonize-bands-with-modes
chong wang
2016-05-12 12:18:13 UTC
Permalink
Hi, Christoph:

I am trying to calculate transport across infinite planes. Can you show
me an example?

Best!

Chong Wang
Ph. D. Candidate
Institute for Advanced Study, Tsinghua University, Beijing 100084
Christoph Groth
2016-05-17 09:31:41 UTC
Permalink
Post by chong wang
I am trying to calculate transport across infinite planes. Can
you show
me an example?
It should be quite easy with the wraparound module: let's say that
you want to compute transmission in the z direction while x and y
are the transversal directions.

You create a builder with three translational symmetries and use
wraparound to turn the two transversal symmetries into k_x and k_y
parameters (see the source code of wraparound for how to use it).
The builder returned by wraparound can be finalized and used with
Kwant as usual, for example to calculate transmission. Whenever
using for calculations it you have to provide values for the two
additional parameters (k_x and k_y) in addition to any other
parameters that you might have used in your value functions.

If you set both of k_x and k_y to 0 that's equivalent to having
periodic boundary conditions along the transversal directions. If
you want to compute transmission across the plane, you will have
to integrate over the Fermi surface.

I haven't ever done this myself, but I believe that you simply
have to calculate this:

T_total = ∫ dk_x ∫ dk_y T(E_f, k_x, k_y),

where T() is the transmission as given by Kwant.

To do the integral, you could use something like
scipy.integrate.dblquad. It could take a while to evaluate,
especially since there's no easy way to parallelize adaptive
integration. (But I'm working on this!)

Cheers,
Christoph
Xin Dai
2016-06-08 13:42:16 UTC
Permalink
Hi Christoph,

Could you please give an example for calculating conductance
using wraparound module?
I've tried this with the following script to calculate the transmission in
z-direction of a 3D cubic lattice,
with infinite x-y plane:

#creating the scattering region with symmetries in all directions
t = 1
L, W = 4, 4
lat = kwant.lattice.general(np.identity(3))
sym = kwant.TranslationalSymmetry(*lat.prim_vecs)
sys = kwant.Builder(sym)
sys[lat.shape(lambda p: True, (0, 0, 0))] = -2*t
sys[lat.neighbors(1)] = -t

#using wraparound module
sys = wraparound(sys)

#build and attach the lead in z-direction
lead = kwant.Builder(kwant.TranslationalSymmetry((0, 0, -1)))
lead[(lat(i,j,0) for i in range(L) for j in range(W))] = -2*t
lead[lat.neighbors(1)] = -t
sys.attach_lead(lead)
sys.attach_lead(lead.reversed())
sys = sys.finalized()

#is it the right way to specify k_x=k_y=0?
smatrix = kwant.smatrix(sys, 0, [0,0])
print(smatrix.transmission(1, 0))

but it returns the error message:
"ValueError: Builder does not interrupt the lead, this lead cannot be
attached."

If I instead call wraparound after attaching the lead, i.e.,
...
sys.attach_lead(lead.reversed())
sys = wraparound(sys).finalized()

It returns
"ValueError: No output is requested." which might suggest no lead attached
at all.

So what is the right way of implementing such calculations?
Thank you!

Best,

Xin Dai
Post by chong wang
I am trying to calculate transport across infinite planes. Can you show
Post by chong wang
me an example?
It should be quite easy with the wraparound module: let's say that you
want to compute transmission in the z direction while x and y are the
transversal directions.
You create a builder with three translational symmetries and use
wraparound to turn the two transversal symmetries into k_x and k_y
parameters (see the source code of wraparound for how to use it). The
builder returned by wraparound can be finalized and used with Kwant as
usual, for example to calculate transmission. Whenever using for
calculations it you have to provide values for the two additional
parameters (k_x and k_y) in addition to any other parameters that you might
have used in your value functions.
If you set both of k_x and k_y to 0 that's equivalent to having periodic
boundary conditions along the transversal directions. If you want to
compute transmission across the plane, you will have to integrate over the
Fermi surface.
I haven't ever done this myself, but I believe that you simply have to
T_total = ∫ dk_x ∫ dk_y T(E_f, k_x, k_y),
where T() is the transmission as given by Kwant.
To do the integral, you could use something like scipy.integrate.dblquad.
It could take a while to evaluate, especially since there's no easy way to
parallelize adaptive integration. (But I'm working on this!)
Cheers,
Christoph
weiyuanphysics
2016-02-12 16:08:56 UTC
Permalink
Dear Christoph,
Sorry for the late reply. Gmail and Google is blocked by the Chinese government, so it is really inconvenient for the communication. I use another mailbox to discuss with you about my proposed topic. Now, I can run your code for bulk system on my computer according to your guide. I had tried to install kwant 1.1 after its release, but it showed some error message like "lack of lapack". Do I need to install lapack before I install all the kwant codes? It seems i do not need to do this for kwant 1.0.
Best wishes,
Weiyuan Tong
Christoph Groth
2016-02-12 17:18:41 UTC
Permalink
Post by weiyuanphysics
I had tried to install kwant 1.1 after its release, but it
showed some error message like "lack of lapack". Do I need to
install lapack before I install all the kwant codes? It seems i
do not need to do this for kwant 1.0.
Are you perhaps referring to the Microsoft Windows packages that
are prepared by C. Gohlke? Installation using these packages
indeed got a little bit more complicated, but this is because
Gohlke switched to a different package format. It should be still
quite straightforward.

For all the other operating systems, installation of Kwant 1.1
and 1.2 should work in the same way as for Kwant 1.0.

Everything is described at http://kwant-project.org/install. Do
let us know if you encounter difficulties.

Christoph
Loading...