I'd like to add to Christoph's answer

Thanks for feedback, but I am still confused. Let me make an example: there are two leads 0 and 1, the lead 0 is filled more than lead 1; from the leads 0 there is an outgoing mode exp(i k x), which is normalized by flux in the leads; the wave function inside of the scattering region is psi = t exp (i k x) + r exp (-i k x) What does the program give if the wave function is called with lead number 0? psi? (and when the leads have couple of modes, then psi[i] are sorted is some comfortable for the program way) or r exp (-i k x)?

Calling the wavefunction with lead number 0 would give you `psi`, the

*full scattering state*, in your example.

As to the ordering, the kwant documentation says (http://bit.ly/1EziBYZ):

The modes appear in the same order as incoming modes inHopefully this clarifies things.kwant.physics.modes

In your previous email you asked about calculating the electronic density in a transport

setup and gave an example. From what I can see your example is correct in the case

that there are no true bound states in the system. Any bound states will contribute

to the density and are not calculated by kwant.wave_function

(but they should not contribute to the DC transport).

In the second example you ask about the equivalence between calculating

a current in the leads using scattering matrices and current in the central part

of the system by using the scattering wavefunctions. You are, of course, correct

in your statement that the two should give the same result (at least in your

example of a bar attached to 2 leads). From an initial glance at your code, it seems

that there are at least 2 problems with your wavefunction calculation:

1) You add together the wavefunctions corresponding to different modes, and then

calculate the current given by this coherent superposition. What you should actually

do is calculate the current due to *each* of the wavefunctions and then add these

currents.

2) When you calculate the current you only do so between sites (1, 1) and (2, 1),

despite the fact that your system is 6 sites wide. To get the total current flowing

through the bar you should, of course, calculate the current between sites

(1, i) -> (2, i) for i in (0, 6] and add them all together.

Best,

Joe