I guess it can look a bit confusing
First, to get the names etc formally right (because then things are probably clearer), the
method is called
energies(), and belongs to the
object density_of_states which is returned by the
function calculateDensityOfStates. This function takes a
keyword (or parameter) called
energies.
So, why so many energies? Well, first we need to tell the function at which energies the DOS is to be computed. This is the
keyword to the function. Then, once we have the DOS object, we may (later, for some reason) want to know the energies again; we may have "forgotten" them; imagine if the object is stored in a file, later restored, etc. That's what the query function (method) is for.
A clearer way would be to first define a
variable containing the energies, and then use this for the keyword:
my_energies = [0.*eV]
density_of_states = calculateDensityOfStates(
self_const_cal = scf,
energies = my_energies
)
dos = density_of_states.densityOfStates()
So, finally, how to compute the DOS in a particular range? The function
calculateDensityOfStates actually doesn't take a range, it takes a
list of energies at which to evaluate the DOS. However, in Python it's quite easy to make a list from a range, esp. if you use the Numpy package. If, as in your examples, you prefer to specify the point spacing (0.01) between a min and a max (-10 and 2 eV), it's best to use
arange():
import numpy
my_energies = numpy.arange(-10,2.001,0.01)*eV
The
arange() function has some quirky behavior regarding the end-point (max), so you never know if it will be included or not if you just say (-10,2,0.01), it depends on the bit-representation of floats. So, for safety, always set the max a small amount above the max (smaller than the point spacing).
As an alternative, for completeness, there is also a very convenient function called
linspace(). It takes a min and a max too, but then a number of points to use in between:
import numpy
my_energies = numpy.linspace(-10,2,100)*eV
In this case it's quite safe to write (-10,2), the endpoints are always included.