Dear Abel,

Sorry for being annoying. Suppose I obtained the index of a particular site, say it's 5. Then, for the eigenvector (call it wf) of the localized state, is it correct to obtain the contribution of that site by wf[5]? Thanks again.


On 19 April 2016 at 00:28, Abbout Adel <> wrote:
Dear Johnny,

Yes, of course you can still do that. I wanted just to tell you that for your question :

>>>Is the wavefunction corresponding to site i given by evecs[i] ?

the answer is NO. 
because evec[i] is a vector. So if you want the contribution to the wavefunction at a a given site you need to look at the elements of this vector and  the  order of the sites of your system needs to be found.  

Best regards,

On Mon, Apr 18, 2016 at 7:02 PM, Johnny Wu <> wrote:
Dear Adel,

Thank you very much for your help! But I still have a question: In the tutorial, it is demonstrated that the localized wavefunction can be plotted without attaching the leads. What I am trying to do is to extract the intensity of the wavefunction at a particular site. I suppose the intensity at each site plotted by 
 kwant.plot(sys, site_color=wf, site_symbol=family_shape,
               site_size=0.5, hop_lw=0, cmap='gist_heat_r')
can be obtained from wf without attaching the leads right? Thanks again for your time.


On 18 April 2016 at 23:55, Abbout Adel <> wrote:
Dear Johnny,

what you are doing is just diagonalizing a matrix and obtaining the eigenvectors. So, first, this  does not concern the whole system (sys with the leads ). second, the eigenvectors are not the wavefunction at a given site and theirfore evecs[i] will return the eigenvector corresponding the the eigenvalues number "i".

If you want the wavefunction, look at this in the documentation:

I have also written this code as an example for you:

import kwant
from matplotlib import pyplot

def make_sys(a=1,t=1,l=50):
    def Tshape(pos):
        return  x**2+y**2<=l
    lat = kwant.lattice.square(a)
    sys = kwant.Builder()
    sys[lat.shape(Tshape, (0, 1))] = 0

    sym = kwant.TranslationalSymmetry((-2, 1))
    lead = kwant.Builder(sym)
    lead[lat.wire((0, 3), 5)] = 0
    lead[lat.neighbors()] = -1

    return sys

def main():

    sys = make_sys()
    sys = sys.finalized()
    wf = kwant.solvers.default.wave_function(sys, energy=0)
    wfs_of_lead_0 = wf(0)[3]   #wave function due to lead 0 and mode 4 (counting starts from 0)
    # if you want this wave function at site 35 just do

    #if you want this function at the position x,y=(-5,7) just do
    Positions=[sys.sites[i].pos for i in range(len(sys.sites))]  #list of all the positions of the sites

    wf_5_7=wfs_of_lead_0[site_index]  #wave function at site (-5,7) due to mode 4 of lead 0

    print wf_5_7
    #plot_conductance(Mysys, energies=[-4.5+0.01/3 * i for i in xrange(3*900)])

# Call the main function if the script gets executed (as opposed to imported).
# See <>.
if __name__ == '__main__':

I hope it will help.
Best regards,

On Mon, Apr 18, 2016 at 4:32 PM, Johnny Wu <> wrote:
Dear all,

I obtained the wavefunction of the system by using
    ham = sys.hamiltonian_submatrix()
    evecs = la.eigh(ham)[1]

Is the wavefunction corresponding to site i given by evecs[i] ? Thanks!


On 18 April 2016 at 03:44, Abbout Adel <> wrote:
Dear Johnny,

you need just to finalize your system before doing calculation.
so :

and it will work .
Best regards,

On Sun, Apr 17, 2016 at 7:23 PM, Johnny Wu <> wrote:
Dear Dr. Adel

I could not compute len(sys.sites) since sys.sites is of the type "method". How should I change it? Thanks.


On 14 April 2016 at 18:44, Abbout Adel <> wrote:
Dear Johnny,

if you want to get the index of a site in you system, you can do it as follow:

    Positions=[sys.sites[i].pos for i in range(len(sys.sites))]      # list of all the positions of the sites

   Since you know the form of you system, you can obtain the positions of the sites at the edge.
   for example if the site at (3,5) is at the edge you can find its index straightforwardly:

     Index_i= Positions.index((3,5)) 

once you know the index of your site, you can do whatever you want. for example delete that site:

del sys[sys.sites[index_i]]

or you can pass it  to a function which has site as an argument :


I hope that this helps 

Best regards,

Abbout Adel

Abbout Adel

Abbout Adel