Kwant for bulk system
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/7c55b0cb2d0dec163e5483dea8ffdbc88... 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
Weiyuan Tong wrote:
I want to calculate the conductance and the band structure of a bulk 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. The code is available here: https://gitlab.kwantproject.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 multidimensional 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
For people who do not use git, the code can be found directly at https://gitlab.kwantproject.org/cwg/wraparound/raw/master/wraparound.py (To get there from the main page https://gitlab.kwantproject.org/cwg/wraparound, use the "files" link on the left side.)
Dear Christoph， Thanks for your code. Can I run it on kwant 1.0 ? When I run your code on my computer I get some error message: Traceback (most recent call last):
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\sitepackages\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\sitepackages\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\sitepackages\numpy\testing\utils.py", line
645, in assert_array_compare raise AssertionError(msg) AssertionError: 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
On Monday, February 8, 2016, Christoph Groth <christoph.groth@cea.fr> wrote:
Weiyuan Tong wrote:
I want to calculate the conductance and the band structure of a bulk
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.
The code is available here: https://gitlab.kwantproject.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 multidimensional 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
Weiyuan Tong wrote:
Thanks for your code. Can I run it on kwant 1.0 ? When I run your code on my computer I get some error message:
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://kwantproject.org/doc/1.1/pre/whatsnew/1.1#harmonizebandswithmodes
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
chong wang wrote:
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
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 zdirection of a 3D cubic lattice, with infinite xy 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 zdirection 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 20160517 17:31 GMT+08:00 Christoph Groth <christoph.groth@cea.fr>:
chong wang wrote:
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
participants (4)

chong wang

Christoph Groth

Weiyuan Tong

Xin Dai