Author Topic: Function for calculating Projected Density of States  (Read 84750 times)

0 Members and 1 Guest are viewing this topic.

Offline Nordland

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 812
  • Reputation: 18
    • View Profile
Function for calculating Projected Density of States
« on: January 14, 2009, 15:34 »
Hey everyone!

I did some snooping around - and I managed to create a function that enables the us to calculate the projected density of states using the newest version of ATK.
It requires some very advanced stuff, so I have combined into a small function that looks like all the other nanolanguage functions.
I have attached the file with the function and an example of the usage of it.
It can only calculate the projected density of states onto atoms, not orbitals, but I guess this is a good start :)
You can use just like the builtin calculateDensityOfStates, but it is called calculatedProjectedDensityOfStates and accepts the keyword
projection_atoms being a list of the indices of the atoms of the central region to project onto.
For example projection_atoms =[3,4,5,6]. I have tested that it gives the same density of states as ATK does, if you desire to project onto all the atoms,
so it should be correct.

Please free to use and please comment on it you can use it or have suggestions for modifications.

P.S Added a small script of example of usage.

Offline Roc

  • QuantumATK Guru
  • ****
  • Posts: 104
  • Reputation: 0
    • View Profile
Re: Function for calculating Projected Density of States
« Reply #1 on: January 15, 2009, 02:13 »
Thanks, Nordland.

Great job! We expect your more pretty works! ;)

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5573
  • Country: dk
  • Reputation: 95
    • View Profile
    • QuantumATK at Synopsys
Re: Function for calculating Projected Density of States
« Reply #2 on: February 10, 2009, 13:22 »
One minor point to note: If you project onto "all" atoms, you do not get exactly the same result as from the built-in function calculateDensityOfStates().

The reason is that in ATK, the definition of "all" atoms in the DOS calculation includes the electrode region as well, while in Nordland's superb PDOS script you are limited to projecting on atoms in the central region.

Offline M.Albert

  • Regular QuantumATK user
  • **
  • Posts: 13
  • Reputation: 0
    • View Profile
Re: Function for calculating Projected Density of States
« Reply #3 on: March 3, 2009, 14:11 »
  thanks,Norland. But it seems that your function for calculating PDOS is useless in VNL 2008.02.
  And your pdos is really ldos(local density of states).
  Pdos is partial density of states which plots for certain angular momenta on selected atoms,such as s,p,d,f.

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5573
  • Country: dk
  • Reputation: 95
    • View Profile
    • QuantumATK at Synopsys
Re: Function for calculating Projected Density of States
« Reply #4 on: March 3, 2009, 14:54 »
There are two definitions of "PDOS", which makes it confusing:
  • Projected Density of States
  • Partial Density of States
In ATK, we use the label LDOS (local DOS) for the real-space projection of the DOS...
 
Projecting on individual angular momenta cannot easily be done by just writing a NanoLanguage script like the one in this post, but it is something that may become available in future releases.

Since the script uses undocumented features of the NetCDF file format and internal ATK commands, there is no guarantee that the script works for a particular version. It is probably designed to work with the latest release (2008.10).
« Last Edit: March 3, 2009, 14:59 by Anders Blom »

Offline Nordland

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 812
  • Reputation: 18
    • View Profile
Re: Function for calculating Projected Density of States
« Reply #5 on: March 3, 2009, 15:44 »
  thanks,Norland. But it seems that your function for calculating PDOS is useless in VNL 2008.02.
  And your pdos is really ldos(local density of states).
  Pdos is partial density of states which plots for certain angular momenta on selected atoms,such as s,p,d,f.

Hey Albert.

I don't have access to VNL 2008.02, but you are properly right since I have never tested it in VNL 2008.02.

I would like to generalize the script into projection into certain orbitals, but I have not found a way to do it yet - and I don't have a clue on how to do it :|

Offline M.Albert

  • Regular QuantumATK user
  • **
  • Posts: 13
  • Reputation: 0
    • View Profile
Re: Function for calculating Projected Density of States
« Reply #6 on: March 5, 2009, 04:34 »
  Hi,Nordland!
  I just have installed ATK 2008.10 .Your function for calculating PDOS is very good !
  But I think you should delete "from projected_density_of_states import *
" in your lih2li example. Because there is no such module in ATK .
  Excellent job ,thank you!

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5573
  • Country: dk
  • Reputation: 95
    • View Profile
    • QuantumATK at Synopsys
Re: Function for calculating Projected Density of States
« Reply #7 on: March 5, 2009, 07:50 »
If you remove that line the script doesn't work. It is needed to give access to the function calculateProjectedDensityOfStates(), provided by the file projected_density_of_states.py. "import" statements are not only related to the built-in functionality in ATK, but also allows you to extend the functionality with customized modules/script, like this example shows.

Offline Nordland

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 812
  • Reputation: 18
    • View Profile
Re: Function for calculating Projected Density of States
« Reply #8 on: March 5, 2009, 11:27 »
As Dr. Anders Blom says, you need to download the functionality in form of the file projected_density_of_states.py,
and place it in the same directory as the file you are going to use it with.

So in this case the example.py and projected_density_of_states.py must be placed in the same directory.

Offline M.Albert

  • Regular QuantumATK user
  • **
  • Posts: 13
  • Reputation: 0
    • View Profile
Re: Function for calculating Projected Density of States
« Reply #9 on: March 5, 2009, 13:57 »
I put example.py and projected_density_of_states.py in the same directory,and draged example.py to "Job Manager" ,then
an error appeared.

Running: C:\Program Files\QuantumWise\Virtual NanoLab 2008.10.0\atk\bin\atk.exe c:/users/yanmi/appdata/local/temp/tmppkiqut.nl
Traceback (most recent call last):
  File "c:/users/yanmi/appdata/local/temp/tmppkiqut.nl", line 2, in ?
    from projected_density_of_states import *
ImportError: No module named projected_density_of_states
Terminated Abnormally
 
I have tried sveral times ,the same. I don't know why. I wish you can help me.THANK YOU!



Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5573
  • Country: dk
  • Reputation: 95
    • View Profile
    • QuantumATK at Synopsys
Re: Function for calculating Projected Density of States
« Reply #10 on: March 5, 2009, 14:21 »
Nordland's reply says that you should place the file "in the same directory as the file you are going to use it with". However, when you drop your script on the Job Manager, your main script is in c:/users/yanmi/appdata/local/temp/ (as the error message says). You have a couple of way to resolve this.
  • You could copy the file projected_density_of_states.py to the "temp" directory. Not a clean solution, but it works, at least it's a quick fix.
  • Instead of using the Job Manager, export the script to the same directory where projected_density_of_states.py is located, and run ATK manually from there. This requires that you have either installed ATK separately or set up your PATH you include the atk/bin directory under the VNL installation. This can be useful under any circumstance!
  • The most pythonic way would be to include this line at the top of the script, before the import statement:
Code
import sys
sys.path.append("c:/users/yanmi/")
I assumed that projected_density_of_states.py is located in c:/users/yanmi/; adjust to reflect the correct location.

Offline M.Albert

  • Regular QuantumATK user
  • **
  • Posts: 13
  • Reputation: 0
    • View Profile
Re: Anders Blom
« Reply #11 on: March 6, 2009, 04:04 »
Hey ,Anders Blom ,you are right. All your three ways worked!  :D
  I really appreciate your help!

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5573
  • Country: dk
  • Reputation: 95
    • View Profile
    • QuantumATK at Synopsys
Re: Function for calculating Projected Density of States
« Reply #12 on: March 13, 2009, 21:48 »
Also see http://quantumwise.com/forum/index.php?topic=64.msg684#msg684 for a fourth - and perhaps even better - way to handle the import issue, without adding any code to the scripts (method B on that page).

Offline alan

  • Regular QuantumATK user
  • **
  • Posts: 23
  • Reputation: 0
    • View Profile
Re: Function for calculating Projected Density of States
« Reply #13 on: October 19, 2009, 03:45 »
Hi,
  I want to calculate the spin dependent Projected Density of States.how can i modify the script of the Density Of States:
f = open('pdos.dat','w') 
import numpy
projecte_density_of_states = calculateProjectedDensityOfStates(
    self_consistent_calculation = scf,
    projection_atoms =[11,18],
    energies = numpy.arange(-1.0, 1.0+0.1, 0.01)*electronVolt,
    brillouin_zone_integration_parameters = brillouinZoneIntegrationParameters((1, 1)),
    green_function_infinitesimal = 1.0e-5*electronVolt
)

energies = projecte_density_of_states.energies()
pdos = projecte_density_of_states.projectedensityofstates()
if len(pdos.shape)==2:
    # spin-polarized
    print '                    Projected Density of states'
    print 'Energy (eV)     Spin-up       Spin-down'
    print '------------------------------------------'
    for i in range(len(energies)):
        print "%g\t%g\t%g\n" % ( energies.inUnitsOf(eV),
            pdos[0,i].inUnitsOf(eV**(-1)),pdos[1,i].inUnitsOf(eV**(-1)) )
        s = '%g\t%g\t%g\n' % ( energies.inUnitsOf(eV),
            pdos[0,i].inUnitsOf(eV**(-1)),pdos[1,i] .inUnitsOf(eV**(-1)))
        f.write(s)
else:
    print 'Energy (eV)    Projected Density of states'
    print '-----------------------------------'
    for i in range(len(energies)):
        print "%g\t%g\n" % ( energies.inUnitsOf(eV**(-1)),pdos )
        s = '%g\t%g\n' % ( energies.inUnitsOf(eV**(-1)),pdos )
        f.write(s)
f.close()
i have replaced the Density Of States with Projected Density of States.but it does not worked.i want to know how can i deal with the red part i indicated in the script above.

Offline Nordland

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 812
  • Reputation: 18
    • View Profile
Re: Function for calculating Projected Density of States
« Reply #14 on: October 19, 2009, 11:57 »
The red line should simply be:
pdos = projecte_density_of_states.densityOfStates()

I know that the lines says density of states, but it is the projected density of states that gets return.
I know it is a little misleading, but the script is a tweak of the original implementation.

Changing this line, and everything should work fine.