Dear Sajjad,

The documentation of kwant is very rich and explains all these requirements
with multiple examples. Please have a thorough look at those examples.

The requested code is below.
I hope this helps,
Adel


import kwant
from numpy import *

lat=kwant.lattice.square()
sys=kwant.Builder()
def pot(site, V):
    return V
sys[(lat(x,y) for x in range(5) for y in range(5))]=pot
sys[lat.neighbors()]=-1
sym_lead = kwant.TranslationalSymmetry((-1, 0))
lead = kwant.Builder(sym_lead)
lead[(lat(0,y)  for y in range(5))]=0
lead[lat.neighbors()]=-1
sys.attach_lead(lead)
kwant.plot(sys)
sysf=sys.finalized()

Sites=list(sysf.sites)
Sites_pos=[site.pos for site in Sites]  #getting the positions for example
H=sysf.hamiltonian_submatrix(params=dict(V=5))

On Mon, Dec 2, 2019 at 9:41 AM Saj.ZiaBorujeni <
[email protected]> wrote:

> Dear Adel,
>
> Thank you for your response. I am trying to use your Instructions for
> finding all site in the scattering region and also finding eigenvalu but I
> can not. That is very kind of you if you send me a short example of these
> problem. Would you please?
>
> Best regard
>
> Sajad
> *From: *"Abbout Adel" <[email protected]>
> *To: *"Saj.ZiaBorujeni" <[email protected]>
> *Cc: *"kwant-discuss" <[email protected]>
> *Sent: *Saturday, Azar 2, 1398 7:21:58 PM
> *Subject: *Re: [Kwant] Access to eigenvalue, eigenvector and number of
> points in each unit cell
>
>
>
>
>
> Dear Sajad,
>
>
>
> Getting the number of sites in the central system is easy in kwant.
>
> sysf= syst.finalized()
>
> Sites= list(sysf.sites)   #list of all the sites in the scattering region
>
> number_of_sites=len(Sites).
>
>
>
> Getting the Hamiltonian of the central system is also straightforward:
>
> H=sysf.hamiltonian_submatrix()
>
>
>
> I want just to stress that the eigenvalues of this Hamiltonian have
> nothing to do with the band structure. In fact, to get the band structure,
> you need the hamiltonian H0 of the unit cell in the lead and the hopping
> matrix V between two unit cells. With the help of the Bloch theorem, the
> band can be obtained by diagonalizing:
>
>   H0+V*exp(+ik)+V^\dagger *exp(-ik)  for all your k points.
>
>
>
> ps: (H and H0 may be different depending on how you define your system!)
>
> I hope this helps.
>
> Adel
>
>
>
> On Sat, Nov 23, 2019 at 1:09 AM Saj.ZiaBorujeni <
> [email protected]> wrote:
>
> Dear Joseph Weston,
>
> yes you are right.
>
> "I am trying to create a system with translational symmetry, and that each
> Kwant *site* corresponds to a single atom."
>
> We know according to the nanoribbon, we have a scattering region that is
> attached to the leads.  I want to find the number of kwant site (which I
> mentioned as atom) in the scattering region (which I mentioned as unit
> cell).
>
> Please look at the following example for the graphene nanoribbon:
>
> import kwant
> from math import sqrt
> import matplotlib.pyplot as plt
> import tinyarray
> import numpy as np
> import math
> import cmath
>
> import matplotlib
> d=1.42;
> a1=d*math.sqrt(3)
> t=-3.033;
>
> latt = kwant.lattice.general([(a1,0),(a1*0.5,a1*math.sqrt(3)/2)],
>                              [(a1/2,-d/2),(a1/2,d/2)])
> a,b = latt.sublattices
> syst= kwant.Builder()
>
>
> #...................................................................................
> def rectangle(pos):
>     x, y = pos
>     z=x**2+y**2
>     return -2.9*a1<x<2.9*a1 and -7.5*d<y<7.5*d
>
> syst[latt.shape(rectangle, (1,1))]=0
>
>
> syst[[kwant.builder.HoppingKind((0,0),a,b)]] =t
> syst[[kwant.builder.HoppingKind((0,1),a,b)]] =t
> syst[[kwant.builder.HoppingKind((-1,1),a,b)]] =t
>
> ax=kwant.plot(syst);
>
> sym = kwant.TranslationalSymmetry(latt.vec((-5,0)))
> sym.add_site_family(latt.sublattices[0], other_vectors=[(-1, 2)])
> sym.add_site_family(latt.sublattices[1], other_vectors=[(-1, 2)])
>
> lead = kwant.Builder(sym)
>
> def lead_shape(pos):
>     x, y = pos
>     return   -7.5*d<y<7.5*d
>
> lead[latt.shape(lead_shape, (1,1))] = 0
>
> lead[[kwant.builder.HoppingKind((0,0),a,b)]] =t
> lead[[kwant.builder.HoppingKind((0,1),a,b)]] =t
> lead[[kwant.builder.HoppingKind((-1,1),a,b)]] =t
>
> syst.attach_lead(lead,add_cells=0)
> syst.attach_lead(lead.reversed(),add_cells=0)
> ax=kwant.plot(syst);
>
> def plot_bands(syst):
>     fsys = syst.finalized()
>
>     plt.figure()
>     kwant.plotter.bands(fsys.leads[0], args=(dict(gamma=1., ep=0.),))
>     plt.xlabel("K")
>     plt.ylabel("band structure (eV)")
>     plt.ylim((-4.0,4.0))
>     plt.show()
> plot_bands(syst)
>
> Here we have a main region such that the whole system can be made by
> repeating this region. I want to know the number of site in the main region.
>
> "It is not 100% clear to me what you want when you say "the eigenvectors
> and eigenvalue" of your Hamiltonian; if your system has translational
> symmetry then presumably you want the eigen-decomposition *at a given
> quasi-momentum*, but you do not explicitly state this, so I am not sure."
>
> When we plot the band structure, we have a Hamiltonian (the dimension is
> N*N) in terms of K point. So, we have N eigenvalues for each K point. How
> we can find these eigenvalues for each K point. How is it shown in Kwant?
> Would you please help me.
>
> Best,
>
> Sajad
>
>
>
> *From: *"Joseph Weston" <[email protected]>
>
> *To: *"Saj.ZiaBorujeni" <[email protected]>,
> [email protected]
> *Sent: *Thursday, Aban 30, 1398 3:59:57 PM
> *Subject: *Re: [Kwant] Access to eigenvalue, eigenvector and number of
> points in each unit cell
>
>
>
>
>
> Hi Sajad,
>
>
>
> Dear all,
>
> I need to access to the number of atoms of my unit cell, the eigenvalue
> and eigenvectors for each eigenvalue  of my Hamiltonian.
>
> Is there any one to help me and let me know if it is possible in kwan to
> access them.
>
>
>
> Could you post a short code example showing what you are doing? You refer
> to "atoms" and "unit cell", so I presume that you are trying to create a
> system with translational symmetry, and that each Kwant *site* corresponds
> to a single atom.
>
>
>
> It is not 100% clear to me what you want when you say "the eigenvectors
> and eigenvalue" of your Hamiltonian; if your system has translational
> symmetry then presumably you want the eigen-decomposition *at a given
> quasi-momentum*, but you do not explicitly state this, so I am not sure.
>
>
>
> Posting a complete code example is useful because it is more precise than
> describing your problem with words.
>
>
>
> Happy Kwanting,
>
>
>
> Joe
>
>
>
>
>
> --
>
> Abbout Adel
>


-- 
Abbout Adel

Reply via email to