Re: [Kwant] Problem with bands in the lead
Hi Pawel,
It seems that Joe was too fast for me.
In addition to what Joe wrote - the need to rescale the momenta properly -
you also rescaled the energy twice so the energy scale was also wrong.
The following script adapted from yours gives correct results.
Regards,
Xavier
from matplotlib import pyplot
import kwant
import numpy
import math
def make_lead(W=30,dx=1.0,m=0.0667):
lat=kwant.lattice.square(dx)
#uzupelnianie
t=1.0/m/dx/dx
sym = kwant.TranslationalSymmetry((-dx, 0))
lead=kwant.Builder(sym)
lead[(lat(0,y) for y in range(-W+1,W))]=4*t
lead[lat.neighbors()]=-t
return lead
def calculation(mydx,W):
m=0.0667
lead=make_lead(W=100,dx=mydx).finalized()
band=kwant.physics.Bands(lead)
momenta = numpy.linspace(-numpy.pi, numpy.pi, 101)
energies = [band(k) for k in momenta]
f=open("band_W"+str(W)+"_dx"+str(mydx)+".dat",'w')
for i in range(len(momenta)):
f.write("%f " % (momenta[i]/mydx))
for j in range(len(energies[0])):
f.write("%f " % (energies[i][j]))
f.write("\n")
f.close()
calculation(0.1,100)
calculation(0.2,50)
Re: [Kwant] Problem with bands in the lead
Pawel Wojcik fis.agh.edu.pl> writes: > > Hello, > I have just started working with KWANT but at the beginning I have a problem with the calculation of the > energy band in lead. Blow I paste my code in which a define the lead and try to calculate the energy vs wave > vector. The definition of the lead comes from the example on the website > documentation. I assume a lattice with the size dx and then t=h/m/dx/dx. > > The energy from the function kwant.bands is expresed in units of [t] and in this point a have a problem > because if I define the lead with W=100 points and dx=0.1 nm and calculate the E vs k bands, it differs from > the E vs k bands calculated for W=50 points and dx=0.2 nm (of course scale the energy multiplying it by t), > although the width of the lead W_eff=W*dx is the same for both cases. Hi, The reason that you see different band structures is that you have not re-scaled the "momenta" correctly when calling the `bands` object returned by `kwant.physics.Bands`. Concretely, when you call `bands(k)`, the "k" value you give is in units reciprocal to the distance units which you have chosen (which manifests in the onsite and hopping parameters). This means that for the "dx = 0.2" case, the momentum units are twice as small as for the "dx = 0.1" case. If you want to plot the two band structures on the same curve then you need to rescale the momentum units:: lead100 = make_lead(W=100,dx=0.1*f_nm2au).finalized() lead50 = make_lead(W=50,dx=0.2*f_nm2au).finalized() band100 = kwant.physics.Bands(lead100) band50 = kwant.physics.Bands(lead50) # define this to be in units corresponding to "dx = 0.1" momenta = numpy.linspace(-numpy.pi, numpy.pi, 101) energies100 = [band100(k) for k in momenta] energies50 = [band50(2 * k) for k in momenta] # rescale momenta pyplot.plot(momenta, energies100, 'k', momenta, energies50) You should now see that for small "k" the two sets of curves match up. Regards, Joe
[Kwant] Problem with bands in the lead
Hello,
I have just started working with KWANT but at the beginning I have a problem
with the calculation of the energy band in lead. Blow I paste my code in which
a define the lead and try to calculate the energy vs wave
vector. The definition of the lead comes from the example on the website
documentation. I assume a lattice with the size dx and then t=h/m/dx/dx.
The energy from the function kwant.bands is expresed in units of [t] and in
this point a have a problem
because if I define the lead with W=100 points and dx=0.1 nm and calculate the
E vs k bands, it differs from
the E vs k bands calculated for W=50 points and dx=0.2 nm (of course scale the
energy multiplying it by t), although the width of the lead W_eff=W*dx is the
same for both cases.
I would be grateful for any suggestions ?
Code of my program
from matplotlib import pyplot
import kwant
import numpy
import math
f_nm2au=18.897261
f_eV2au=0.03674932587
f_Ha=27.2114
def make_lead(W=30,dx=1.0,m=0.0667):
lat=kwant.lattice.square(dx)
#uzupelnianie
t=1.0/m/dx/dx
sym = kwant.TranslationalSymmetry((-dx, 0))
lead=kwant.Builder(sym)
lead[(lat(0,y) for y in range(-W+1,W))]=4*t
lead[lat.neighbors()]=-t
return lead
## calculations for W=100 and dx=0.1 #
lead=make_lead(W=100,dx=0.1*f_nm2au).finalized()
band=kwant.physics.Bands(lead)
momenta = numpy.linspace(-numpy.pi, numpy.pi, 101)
energies = [band(k) for k in momenta]
dx=0.1*f_nm2au
m=0.0667
wsp=f_Ha/(m*dx*dx)
#print len(energies[1])
f=open('mode_W100_dx01.dat','w')
for i in range(len(momenta)):
f.write("%f " % (momenta[i]))
for j in range(len(energies[0])):
f.write("%f " % (energies[i][j]*wsp))
f.write("\n")
f.close()
## calculations for W=50 and dx=0.2 #
lead=make_lead(W=50,dx=0.2*f_nm2au).finalized()
band=kwant.physics.Bands(lead)
momenta = numpy.linspace(-numpy.pi, numpy.pi, 101)
energies = [band(k) for k in momenta]
dx=0.2*f_nm2au
m=0.0667
wsp=f_Ha/(m*dx*dx)
#print len(energies[1])
f=open('mode_W50_dx02.dat','w')
for i in range(len(momenta)):
f.write("%f " % (momenta[i]))
for j in range(len(energies[0])):
f.write("%f " % (energies[i][j]*wsp))
f.write("\n")
f.close()
Best Regards
Pawel Wojcik
