QuantumATK Forum

QuantumATK => General Questions and Answers => Topic started by: zdhlover on June 10, 2009, 15:18

Title: How can we get the band index of the bulk?
Post by: zdhlover on June 10, 2009, 15:18
Hi, ;D
we can get the quantum number of the molecular through computing it's Molecular energy spectrum,but when we put the bulk into the Nanolanguage Scripter,there has no energy spectrum in the Analysis. So how we can get the band index (quantum number of energy band)?And how we can know the band index corresponding which band in the band structure figure?

Thanks a lot!
Title: Re: How can we get the band index of the bulk?
Post by: Anders Blom on June 10, 2009, 16:58
There is no energy spectrum in the analysis for a bulk, because what you do for bulk is compute the band structure. But I think you figured that out already? :)

So, why do you need the index? I assume it is because you want to compute the Bloch function for a particular eigenstate, for which you need the quantum numbers "band index" and k-point. The k-point is obvious, but how to get the band index?

If you look at the band structure plot in VNL (in the Result Browser), there is a band index shown in the "Tool Tip" which appears if you let the mouse rest over a particular point on the curves. Sadly, this index is wrong!

Therefore, unfortunately it's not extremely easy to find the index (as it should be)...

Here's what you could do.


Code
from ATK.KohnSham import *

# Restore the self-consistent calculation
# --- Change filename to match your case! ---
scf = restoreSelfConsistentCalculation("c:/vnl/bulk.nc")

# Calculate the band structure in just one single point
# --- Change the k-point value to the one relevant for you! ---
k = (0,0,0)
bands = calculateEnergyBands(scf,[k])

print "Index\tEnergy (eV)"
print "---------------------------"
for i in range(bands.numberOfBands()):
    print i,'\t',bands.band(i)[0].inUnitsOf(eV)


The output will look like
Quote
Index   Energy (eV)
---------------------------
0       -7.88580879754
1       -2.46911803845
2       -2.46911803746
3       -2.46911803684
4       -0.93553745241
5       -0.935537451013
6       24.7557039501
7       24.7557039577
8       24.7557039583
9       26.3855165124
10      41.5600392667
11      41.560039267
12      41.5600392725
13      53.5208120456
14      53.5208120462

Notes:


Hope you figure it out!

I will also take the opportunity to make some advertising for the new tutorial on band structure calculations (http://quantumwise.com/publications/tutorials) (and DOS); actually this little script might make for a useful appendix to that tutorial...
 
Title: Re: How can we get the band index of the bulk?
Post by: Anders Blom on June 10, 2009, 17:10
Here's how you would do it for a spin-polarized system:

Code
from ATK.KohnSham import *

# Restore the self-consistent calculation
# --- Change filename to match your case! ---
scf = restoreSelfConsistentCalculation("c:/vnl/fe.nc")

# Calculate the band structure in just one single point
# --- Change the k-point value to the one relevant for you! ---
k = (0,0,0)

bands_up = calculateEnergyBands(scf,[k],Spin.Up)
bands_dn = calculateEnergyBands(scf,[k],Spin.Down)
print "Index\t\tEnergy (eV)"
print "\tSpin.Up\t\tSpin.Down"
print "------------------------------------"
for i in range(bands_up.numberOfBands()):
    print i,'\t',bands_up.band(i)[0].inUnitsOf(eV),
    print '\t',bands_dn.band(i)[0].inUnitsOf(eV)

Output looks like:

Quote
Index           Energy (eV)
        Spin.Up         Spin.Down
------------------------------------
0       -8.57804275842  -8.00798815437
1       -2.31747667937  -0.580211098406
2       -2.31747667888  -0.580211097992
3       -2.31747638121  -0.580210882288
4       -1.0434911475   1.33719151525
5       -1.04349114563  1.33719151738
6       29.3066311312   30.3959460736
7       29.3066311709   30.3959461524
8       29.3066311719   30.3959461533
Title: Re: How can we get the band index of the bulk?
Post by: zdhlover on June 11, 2009, 04:59
First ,thanks for your detailed reply, and you are so wise that I am really want to compute the Bloch function for a particular eigenstate .Because I saw the Tutorial_GoldMonowire.pdf  , and I see the beautiful  Bloch function figure of band structure in that pdf .But I also have some questions to ask:
1,My python knowledge is poor, I don't know what's mean of (i)[0] of bands_dn.band(i)[0] in your post ? And waht is the difference between (i)[0] and
  [band][ i ]  ? i.e.  the difference one parenthesis one square brackets and two square brackets?
 by the way:the [band][ i ] is a segment in the manu of ATk -2008-manual CHAPTER 3. BULK MATERIALS (67page)
    ([band][ i ] have no blank in the last square brackets is not correct display)
2,when I see the export log files ,in the energy band ,It have one line "Energy Band: number" , what's meaning of this number between that band index?
 and i also see four column under that line (the first three is k points ,and the last is energy), are they belong to one list? or from (i)[0] that you write
 I guess they belong to two different list(one is the kpoint list and the energy is another)?  any way  I want to know how to use member of a list and
 how can we know the constitutes of a list?
Title: Re: How can we get the band index of the bulk?
Post by: Anders Blom on June 11, 2009, 09:46
1,My python knowledge is poor, I don't know what's mean of (i)[0] of bands_dn.band(i)[0] in your post ? And waht is the difference between (i)[0] and
  [band][ i ]  ? i.e.  the difference one parenthesis one square brackets and two square brackets?
 by the way:the [band][ i ] is a segment in the manu of ATk -2008-manual CHAPTER 3. BULK MATERIALS (67page)
    ([band][ i ] have no blank in the last square brackets is not correct display)

band() is a function (a method, if you wish) of the object returned by the function calculateEnergyBands(). It takes one parameter, an integer, corresponding to the band index (the loop variable "i" in our case). The band() function in turn returns a list which has the same length as the k-point list. In our case there is just one k-point, so the energy we are looking for is the first element, [ 0 ].

Blanks are often irrelevant in Python. [ j ] and [j] is the same; I use [ 0 ] above because without spaces the Forum thinks I'm trying to make a list :)
Title: Re: How can we get the band index of the bulk?
Post by: Anders Blom on June 11, 2009, 10:29
2,when I see the export log files ,in the energy band ,It have one line "Energy Band: number" , what's meaning of this number between that band index?
 and i also see four column under that line (the first three is k points ,and the last is energy), are they belong to one list? or from (i)[0] that you write
 I guess they belong to two different list(one is the kpoint list and the energy is another)?  any way  I want to know how to use member of a list and
 how can we know the constitutes of a list?

The index shown in the log appears to be shifted by 1. So, what is called "Energy Band: 1" would be index=0.

The columns are indeed kA, kB, kC, and the energy, in eV, and would belong to the list energy_bands.band(0). To extract elements (not members :) ) from this list, use square brackets. Thus, to print the energy of the 22nd k-point of the 13th band, I would add this line at the end of the VNL-generated script for the band structure calculation:

Code
print energy_bands.band(12)[21]

Note the shift by 1! If I wanted the 1st k-point of the 1st band, I would use

Code
print energy_bands.band(0)[0]
Title: Re: How can we get the band index of the bulk?
Post by: kaypu on October 18, 2012, 08:57
Dear professor Anders
   how to write the script in the new version? i've already calculated the Bandstructure.
Title: Re: How can we get the band index of the bulk?
Post by: Anders Blom on October 18, 2012, 09:44
We can probably improve on the script today, to fit more precisely what you need. So, please specify the exact data you are looking for, and it's probably 1-2 lines of code only.
Title: Re: How can we get the band index of the bulk?
Post by: kaypu on October 18, 2012, 11:18
I want to compute the Bloch state at gamma(0,0,0),so i must know the quantum number of energy band(band index), but there are so many bands in my system(the unit cell is too big).  At first, i modify the script above(write in atk 2008), but my python knowledge is poor. can you give me the script of the new version to calculate the band index like this pic.
Title: Re: How can we get the band index of the bulk?
Post by: Anders Blom on October 18, 2012, 23:29
Ok, easy enough. I assume your converged calculation is in "file.nc", which contains only one BulkConfiguration.

Code: python
configuration = nlread("file.nc", BulkConfiguration)[0]
energies_at_G = Bandstructure(configuration, kpoints=[[0,0,0],[0,0,0]])
print "Index\tEnergy / eV"
print "-"*30
for ix,energy in enumerate(energies_at_G.evaluate().inUnitsOf(eV)[0]):
    print ix, "\t", energy
Title: Re: How can we get the band index of the bulk?
Post by: kaypu on October 19, 2012, 02:42
Thank you very much professor Anders

i run the code, but something wrong with it, it says:
**************************************************************
File "c:\docume~1\utada\locals~1\temp\0888823095207956.py", line 8
    print ix + "\t + energy
                          ^
SyntaxError: EOL while scanning string literal
**************************************************************

what's wrong with it?
Title: Re: How can we get the band index of the bulk?
Post by: Anders Blom on October 19, 2012, 09:41
Sorry, small mistake. Fixed above.
Title: Re: How can we get the band index of the bulk?
Post by: kaypu on October 19, 2012, 12:07
still mistake:
*****************************************************
Traceback (most recent call last):
  File "c:\docume~1\utada\locals~1\temp\0733476747132319.py", line 4, in <module>
    energies_at_G = Bandstructure(configuration, kpoints=[[0,0,0],[0,0,0]]) 
TypeError: __init__() got an unexpected keyword argument 'kpoints'
*********************************************************

what's wrong with it?
Title: Re: How can we get the band index of the bulk?
Post by: Anders Blom on October 19, 2012, 12:21
Wrong version of ATK. You need 12.8, I didn't realize that. But you can fix it like this:

Code: python
configuration = nlread("file.nc", BulkConfiguration)[0]  
energies_at_G = Bandstructure(configuration, route=['G','G'], points_per_segment=2) 
print "Index\tEnergy / eV" 
print "-"*30 
for ix,energy in enumerate(energies_at_G.evaluate().inUnitsOf(eV)[0]): 
    print ix, "\t", energy
Title: Re: How can we get the band index of the bulk?
Post by: kaypu on October 19, 2012, 13:06
thank you very much professor Anders
Title: Re: How can we get the band index of the bulk?
Post by: GJK on July 19, 2014, 12:56
Dear Dr.Anders,

Thanks for your elaborative discussion.I find here that you have given the scripts for calculating the band index of a system containing odd number of electrons in both spin dependent and spin independent states.

So how to locate the conduction band and valence band quantum number in this case of odd number of electrons in order to evaluate the Bloch States-where we are supposed to give the quantum numbers of conduction band and valence band respectively.

Title: Re: How can we get the band index of the bulk?
Post by: Anders Blom on July 20, 2014, 06:08
Please be a bit more specific. You don't really "calculate" the band index, you specify it when e.g. computing a Bloch state, or you want to determine a particular energy in a list. So what you are looking for is a way to determine a particular index, with some property, for instance the one (for a given k-point) with the lowest positive energy (i.e. the lowest conduction band index at this k).

In order to avoid confusion if you are not used to Python programming, I would strongly recommend using the Bandstructure Analyzer in VNL and just put the mouse over the state of interest, to determine its band index.
Title: Re: How can we get the band index of the bulk?
Post by: GJK on July 20, 2014, 13:27
Its so nice of you Dr.Anders.

Actually from the Graphene Bloch states tutorial I find that we can find the band index and thus determine the conduction and valence band.
But in a system (not the unit cell) when doing work on adsorption on graphene we get so many electrons,since we can't use the unit cell for such special cases.
If the number of electrons is even (say 200 in the system) the band index will be 100 for conduction and 99 for valence(assuming number starts from 1).
But if we have a system of odd number of electrons what will be index the conduction band and valence band???

As per your advice I have tried with the Band structure Custom analyser for GNR for locating the valence band,conduction band and energy  gap value.But the analyser is not giving and curve for the band gap and valence band maxima and conduction band minima.It's giving a dot alone.I have verified that my system is having band gap from the band structure after introducing spin polarisation.But one of the direct band gap is correct(spin up) and the spin down is showing wrong message,with no curve only dots in the figure.

Your assistance and help will be appreciated Dr.Anders.