Attachment 'dos.py'

Download

   1 #!/usr/bin/env python
   2 """Program to plot the density of states for a Dacapo calculation
   3 
   4 Make a gnuplot:
   5 
   6 > dos.py filename.nc
   7 
   8 Dump the data to a file:
   9 
  10 > dos.py filename.nc dos.dat
  11 """
  12 
  13 import sys
  14 from Dacapo import Dacapo
  15 from ASE.Utilities.DOS import DOS
  16 import Gnuplot as gp
  17 
  18 # Get the filename of the Dacapo output file:
  19 filename = sys.argv[1]
  20 
  21 # Read in the atom and restart the calculator:
  22 atoms = Dacapo.ReadAtoms(filename)
  23 
  24 # Create a DOS object and extract data:
  25 dos = DOS(atoms, width=0.2)
  26 e = dos.GetEnergies()
  27 dos0 = dos.GetDOS(0)
  28 if dos.nspins == 2:
  29     # Spin polarized calculation:
  30     dos1 = dos.GetDOS(1)
  31 
  32 if len(sys.argv) > 2:
  33     # Dump the numbers to a file:
  34     out = file(sys.argv[2], 'w')
  35     if dos.nspins == 1:
  36         for x, y in zip(e, dos0):
  37             print >> out, x, y
  38     else:
  39         for x, y1, y2 in zip(e, dos0, dos1):
  40             print >> out, x, y1, y2
  41 else:
  42     # Make a gnuplot of the data:
  43     plot = gp.Gnuplot(persist=True)
  44     if dos.nspins == 1:
  45         plot.plot(gp.Data(e, dos0, with='lines'))
  46     else:
  47         plot.plot(gp.Data(e, dos0, with='lines'),
  48                   gp.Data(e, dos1, with='lines'))

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2007-01-26 13:09:42, 0.8 KB) [[attachment:Fe-ferro.py]]
  • [get | view] (2006-02-02 12:16:15, 0.8 KB) [[attachment:H2O_vib.py]]
  • [get | view] (2007-02-20 13:13:49, 0.6 KB) [[attachment:LDOS.py]]
  • [get | view] (2007-03-14 13:57:46, 1.3 KB) [[attachment:VTKplotwavefunction.py]]
  • [get | view] (2006-02-02 14:33:52, 1.1 KB) [[attachment:dos.py]]
  • [get | view] (2007-02-20 15:04:44, 1.4 KB) [[attachment:localmagmoment.py]]
  • [get | view] (2007-03-14 13:54:20, 0.7 KB) [[attachment:plotwavefunction.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.