Dear Anna, I'm glad it works now.
but I am worry about the large noises in transverse conductivity beyond the energy gap In an infinite 2d plane, the xy conductivity should decay to zero outside the gap. We can approximate this behavior with a finite system with the KPM expansion. Here, the number of moments (that is, the energy resolution) will broaden the delta peaks of your finite system.
In the example above there are two distict sources of noise outside the gap: a) due to the energy resolution and b) due to random vectors. a) The `num_moments = 400` makes that we have enough energy resolution to resolve single states in your finite system, therefore you see the oscillation outside the gap, for example, using `LocalVectors`. In this case, you can lower the energy resolution, so that the system "appears" infinite at that broadenin. You can try with `num_moments=100`. A note on the `LocalVectors`: you just need to trace over one unit cell if the system has no disorder. So setting ``` if random_vecs: edge_width = min(L, W) / 4 ... else: # use local vectors edge_width = min(L, W) / 2 - 1 # only 1 unit cell ``` is enough to get standard infinite 2d plane result, approximated by the KPM expansion (it will use only 2 vectors, and will be very fast). b) even if you have a lower energy resolution (`num_moments=100`) and you use random vectors over some central area of your system, you might see noise outside the gap. This is due to the large off-diagonal elements in the Kubo-Bastin operator. There are a few tricks to get around it, but still, random vectors introduce noise by definition. To ease the noise from random vectors you can either use more random vectors, or use a larger system / central area (computation scales linearly with the number of vectors *and* with the number of system sites). However, if you don't have a reason to average over a central area (such as disorder in your system), I advice to use `LocalVectors`.
According to the KWANT documentation, I found a method to calculate the band structure: kwant.physics.Bands() but it works only for infinite system. Actually, a kwant system with leads attached can be used for both the bands and the kpm computation. The `kwant.kpm` module will only take the `FiniteSystem` part, and work just the same. To compute the bands you have to point which lead you want to compute:
kwant.physics.Bands(syst_infty.leads[0])
Note that `syst_infty` contains the finite system and the two leads, but it is an instance of `FiniteSystem`, while `syst_infty.leads[0]` is an instance of `InfiniteSystem`, which is what `kwant.physics.Bands` expects.