You can try the script in http://quantumwise.com/forum/index.php?topic=1013.0 instead, although I generally warn against treating the calculation of the band gap as a black box - you have to inspect the band structure and make sure you ask for the right thing. Ideally you should use the DOS with a dense enough k-point sampling, and then get the gap from there. If on the other hand you want the specific gap at a particular k-point, you can use a very simple approach:
import sys
b = nlread(sys.argv[1], BulkConfiguration)[0]
t = Bandstructure(b, route=['G','G'], points_per_segment=2)
vbmax_ix = numpy.where(t.evaluate()[0]<=0.*eV)[0][-1]
cbmin_ix = numpy.where(t.evaluate()[0]>=0.*eV)[0][0]
bandgap = t.evaluate()[0][cbmin_ix]-t.evaluate()[0][vbmax_ix]
print "Direct band gap at Gamma point", bandgap
Save as bandgap.py and use as "atkpython bandgap.py file.nc", assuming the first BulkConfiguration in the NC file is the relevant one (else modify the script as needed).
This is for the Gamma point, but if you want another k-point just change the route.
In general in Python you can find out a lot of information about objects by using "dir". For example,
in Python produces a list of all methods and properties on the object. Then, if you want more information on a method, you can type e.g.
help Bandstructure.evaluate
The best way to explore these things is by using ATK interactively, i.e. just start "atkpython" from the command line (without any script argument), then you can type Python commands manually, like those above, or any other ones that would normally appear in a script. It's a great way to develop a new script, to prototype something. This also allow you to do the "dir" thing above in a cool way: if you type something like
config = nlread("file.nc",BulkConfiguration)[0]
config.
Note where this stops - with a ".". Now, hit the TAB key - and you will see all possible things you can continue this statement with. And it will autocomplete them, if you start typing "e" and hit TAB, you see only two choices: "elements" and "externalPotential". Saves a lot of typing!
Now, the information contained in this is actually given in the Reference Manual (http://quantumwise.com/documents/manuals/latest/ReferenceManual) as well, there is no difference, except that with "dir" you also see "hidden" or "private" functionality, methods and properties that the object has, but which we haven't made public yet. These can be utilized for many things, just don't trust them to work 100% the same way in future versions on ATK. It can also be faster to look things up interactively than browse the html manual.
More specifically, about the band structure, if you use "evaluate", it returns a matrix of all the energies, with Npoints rows and Nbands columns, where Npoints is how many points are on the route (20 per segment, by default) and Nbands is the total number of bands.
So, after
b = nlread('silver.nc', BulkConfiguration)[0]
bs = Bandstructure(b, route=['G','X'])
E = bs.evaluate()
we could use E[0] to get all band energies at the Gamma point, and E[20] for those at the X point. If, instead, we want all energies for the 4th lowest band, as a function of k, we would use E[:,3] for the energies, and bs.kpoints() for the k-points.
Note that in this case there are 21 k-points; this is because there are 20 per segment + the final end-point.
I came back to this to try what you suggested ... i am not understanding it at all ... what i mean is, the values read dont seem to match the picture, or i can not reading it correctly ... attached is a zoomed out image of bands .. now there is some more complex thing i want to do, but let me explain the issue with a simple calculation:
objid = "bulkUndoped"
bandstructures = nlread('file_bands.nc', Bandstructure, object_id=objid+"bands")
E = bandstructures[0].evaluate()
numPts = len(E)
numBands = len(E[0])
Now, I set the variables above numPts and numBands as above, because when I ran len(E) I got 22, and len(E[0]) i got 184, which seems to mean that the first index is the point index, and the 2nd is the band index ... is this correct?
Now the question is then, if that is true, then why dont't the values from E[0][0] to E[21][0] match the first band? I dont understand it ...
What I want to do is index each value on the band in order, how can I do that please?