QuantumATK Forum

QuantumATK => General Questions and Answers => Topic started by: wring on April 1, 2009, 04:39

Title: when I calculate density of states, the problem occurs
Post by: wring on April 1, 2009, 04:39
When I calculate density of states, I met the problem,
traceback (most recent call last):
  File "dos.py", line 18, in ?
    print energies.inUnitsOf(eV),'\t',dos[0,i],'\t',dos[1,i]
TypeError: float argument required
   I use the file, such as ,
from ATK.TwoProbe import *
density_of_states = calculateDensityOfStates(
    self_consistent_calculation = scf_calc,
    energies = numpy.arange(-5,5,0.1)*electronVolt
    )
energies = density_of_states.energies()
dos = density_of_states.densityOfStates()
if len(dos.shape)==2:
    # spin-polarized
    print '                   Density of states'
    print 'Energy (eV)     Spin-up       Spin-down'
    print '------------------------------------------'
    for i in range(len(energies)):
        print "%g\t%g\t%g" % ( energies.inUnitsOf(eV),dos[0,i],dos[1,i] )
else:
    print 'Energy (eV)     Density of states'
    print '-----------------------------------'
    for i in range(len(energies)):
        print "%g\t%g" % ( energies.inUnitsOf(eV),dos )
     Do you tell me what mistakes I make when I calcualte the DOS? Thanks very much for your reolies!
Title: Re: when I calculate density of states, the problem occurs
Post by: Anders Blom on April 1, 2009, 10:58
energies is an array of energies, so you need to subscript it in order to extract an energy from which you can get and print the value using the method inUnitsOf().

Thus, change the line

Code
print energies.inUnitsOf(eV),'\t',dos[0,i],'\t',dos[1,i]

to

Code
print energies[i].inUnitsOf(eV),'\t',dos[0,i],'\t',dos[1,i]

and you should be set to go! (Actually there are 2 places to change, for spin/non-spin.)
Title: Re: when I calculate density of states, the problem occurs
Post by: Anders Blom on April 1, 2009, 11:02
I think you may be using an older edition of ATK, or at least an example from the manual of an older version. There was a mistake in the manual on exactly this. See the new updated manual at http://quantumwise.com/documents/manuals/ATK-2008.10/ref.calculatedensityofstates.html for the correct code example, which also takes care of the unit of the DOS properly.
Title: Re: when I calculate density of states, the problem occurs
Post by: wring on April 2, 2009, 02:32
Thank you a lot!
     I konw what mistake I make. I trust the manul.