Author Topic: when I calculate density of states, the problem occurs  (Read 5595 times)

0 Members and 1 Guest are viewing this topic.

Offline wring

  • Regular QuantumATK user
  • **
  • Posts: 24
  • Reputation: 0
    • View Profile
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!

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: when I calculate density of states, the problem occurs
« Reply #1 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.)
« Last Edit: April 1, 2009, 11:02 by Anders Blom »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: when I calculate density of states, the problem occurs
« Reply #2 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.

Offline wring

  • Regular QuantumATK user
  • **
  • Posts: 24
  • Reputation: 0
    • View Profile
Re: when I calculate density of states, the problem occurs
« Reply #3 on: April 2, 2009, 02:32 »
Thank you a lot!
     I konw what mistake I make. I trust the manul.