Dear Adel, Thank you very much for your help! But I still have a question: In the tutorial http://kwant-project.org/doc/1.0/tutorial/tutorial6, 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. Best, Johnny On 18 April 2016 at 23:55, Abbout Adel <abbout.adel@gmail.com> 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:
http://kwant-project.org/doc/1.0/reference/generated/kwant.solvers.default.w...
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): x,y=pos return x**2+y**2<=l lat = kwant.lattice.square(a) sys = kwant.Builder() sys[lat.shape(Tshape, (0, 1))] = 0 sys[lat.neighbors()]=-1
sym = kwant.TranslationalSymmetry((-2, 1)) lead = kwant.Builder(sym) lead[lat.wire((0, 3), 5)] = 0 lead[lat.neighbors()] = -1 sys.attach_lead(lead) sys.attach_lead(lead.reversed())
return sys
def main():
sys = make_sys() kwant.plot(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 wf_35=wfs_of_lead_0[34]
#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 site_index=Positions.index((-5,7))
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 <http://docs.python.org/library/__main__.html>. if __name__ == '__main__': main()
I hope it will help. Best regards, Adel
On Mon, Apr 18, 2016 at 4:32 PM, Johnny Wu <darknesswtc@gmail.com> 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!
Best, Johnny
On 18 April 2016 at 03:44, Abbout Adel <abbout.adel@gmail.com> wrote:
Dear Johnny,
you need just to finalize your system before doing calculation. so : sys=sys.finalized() m=len(sys.sites)
and it will work . Best regards, Adel
On Sun, Apr 17, 2016 at 7:23 PM, Johnny Wu <darknesswtc@gmail.com> 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.
Best, Johnny
On 14 April 2016 at 18:44, Abbout Adel <abbout.adel@gmail.com> wrote:
Dear Johnny,
if you want to get the index of a site in you system, you can do it as follow:
sys=make_system() sys=sys.finalized()
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 :
function(sys.sites[index_i])
I hope that this helps
Best regards, Adel www.abboutadelhomepage.com
-- Abbout Adel
-- Abbout Adel