Author Topic: How can we get the band index of the bulk?  (Read 6657 times)

0 Members and 1 Guest are viewing this topic.

Offline zdhlover

  • Global Moderator
  • ATK Guru
  • *****
  • Posts: 106
  • Reputation: 2
    • View Profile
How can we get the band index of the bulk?
« 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!
« Last Edit: June 10, 2009, 15:22 by zdhlover »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme ATK Wizard
  • *****
  • Posts: 5074
  • Country: dk
  • Reputation: 85
    • View Profile
    • QuantumATK at Synopsys
Re: How can we get the band index of the bulk?
« Reply #1 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.
  • Assume we have converged a calculation for a bulk material, computed the band structure, and looked at it, and determined that at a particular k-point (let's say [0,0,0] for simplicity), it would be interesting to see the Bloch function for the band with an energy which is about -0.93 eV.
  • We have stored the calculation in a checkpoint file, "c:/vnl/bulk.nc" (assuming Windows, modify for Linux or if your file is elsewhere; note forward-slashes "/", backslash "\" means something else in Python strings!).
  • Now, we write a small script that shows us the band indices at this k-point:
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)
  • Either run this in ATK, from the command line, or drop it on the "Job Manager" in VNL. In the latter case you need to take care to use the full path to the NetCDF file; if you run from the command line you can just write the file name, if the file is in the same directory as you execute ATK in.
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:
  • If you have a spin-polarized calculation, some modifications are needed!
  • The bands are usually degenerate! Take care to get the right index, if there are two with the same energy (most likely you will want both, simply).
Hope you figure it out! I will also take the opportunity to make some advertising for the new tutorial on band structure calculations (and DOS); actually this little script might make for a useful appendix to that tutorial...  
« Last Edit: June 10, 2009, 17:05 by Anders Blom »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme ATK Wizard
  • *****
  • Posts: 5074
  • Country: dk
  • Reputation: 85
    • View Profile
    • QuantumATK at Synopsys
Re: How can we get the band index of the bulk?
« Reply #2 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

Offline zdhlover

  • Global Moderator
  • ATK Guru
  • *****
  • Posts: 106
  • Reputation: 2
    • View Profile
Re: How can we get the band index of the bulk?
« Reply #3 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?
« Last Edit: June 11, 2009, 05:16 by zdhlover »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme ATK Wizard
  • *****
  • Posts: 5074
  • Country: dk
  • Reputation: 85
    • View Profile
    • QuantumATK at Synopsys
Re: How can we get the band index of the bulk?
« Reply #4 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 :)
« Last Edit: June 11, 2009, 10:23 by Anders Blom »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme ATK Wizard
  • *****
  • Posts: 5074
  • Country: dk
  • Reputation: 85
    • View Profile
    • QuantumATK at Synopsys
Re: How can we get the band index of the bulk?
« Reply #5 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]

Offline kaypu

  • ATK Guru
  • ****
  • Posts: 135
  • Country: 00
  • Reputation: 1
    • View Profile
Re: How can we get the band index of the bulk?
« Reply #6 on: October 18, 2012, 08:57 »
Dear professor Anders
   how to write the script in the new version? i've already calculated the Bandstructure.

Offline Anders Blom

  • QuantumATK Staff
  • Supreme ATK Wizard
  • *****
  • Posts: 5074
  • Country: dk
  • Reputation: 85
    • View Profile
    • QuantumATK at Synopsys
Re: How can we get the band index of the bulk?
« Reply #7 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.

Offline kaypu

  • ATK Guru
  • ****
  • Posts: 135
  • Country: 00
  • Reputation: 1
    • View Profile
Re: How can we get the band index of the bulk?
« Reply #8 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.

Offline Anders Blom

  • QuantumATK Staff
  • Supreme ATK Wizard
  • *****
  • Posts: 5074
  • Country: dk
  • Reputation: 85
    • View Profile
    • QuantumATK at Synopsys
Re: How can we get the band index of the bulk?
« Reply #9 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
« Last Edit: October 19, 2012, 09:41 by Anders Blom »

Offline kaypu

  • ATK Guru
  • ****
  • Posts: 135
  • Country: 00
  • Reputation: 1
    • View Profile
Re: How can we get the band index of the bulk?
« Reply #10 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?
« Last Edit: October 19, 2012, 03:02 by kaypu »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme ATK Wizard
  • *****
  • Posts: 5074
  • Country: dk
  • Reputation: 85
    • View Profile
    • QuantumATK at Synopsys
Re: How can we get the band index of the bulk?
« Reply #11 on: October 19, 2012, 09:41 »
Sorry, small mistake. Fixed above.

Offline kaypu

  • ATK Guru
  • ****
  • Posts: 135
  • Country: 00
  • Reputation: 1
    • View Profile
Re: How can we get the band index of the bulk?
« Reply #12 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?

Offline Anders Blom

  • QuantumATK Staff
  • Supreme ATK Wizard
  • *****
  • Posts: 5074
  • Country: dk
  • Reputation: 85
    • View Profile
    • QuantumATK at Synopsys
Re: How can we get the band index of the bulk?
« Reply #13 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 

Offline kaypu

  • ATK Guru
  • ****
  • Posts: 135
  • Country: 00
  • Reputation: 1
    • View Profile
Re: How can we get the band index of the bulk?
« Reply #14 on: October 19, 2012, 13:06 »
thank you very much professor Anders