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] (2006-02-03 13:40:31, 0.7 KB) [[attachment:Al-fcc.py]]
  • [get | view] (2006-02-03 13:41:10, 78.7 KB) [[attachment:Al_dos.jpg]]
  • [get | view] (2006-02-03 14:04:32, 27.8 KB) [[attachment:CO_dos.jpg]]
  • [get | view] (2006-02-03 13:28:17, 85.3 KB) [[attachment:CO_eigenstates.jpg]]
  • [get | view] (2006-02-03 13:24:30, 4.1 KB) [[attachment:CO_moscheme.gif]]
  • [get | view] (2006-02-03 13:27:59, 1.3 KB) [[attachment:CO_wavefunction.py]]
  • [get | view] (2006-02-03 13:33:40, 0.5 KB) [[attachment:Fe-anti.py]]
  • [get | view] (2006-02-03 13:33:18, 0.5 KB) [[attachment:Fe-ferro_compl.py]]
  • [get | view] (2006-02-03 13:33:58, 0.5 KB) [[attachment:Fe-non.py]]
  • [get | view] (2006-02-03 13:39:48, 28.7 KB) [[attachment:Fe_anti_viz.jpg]]
  • [get | view] (2006-02-03 13:28:48, 1.9 KB) [[attachment:Fe_atom_magn.gif]]
  • [get | view] (2006-02-03 13:34:47, 91.0 KB) [[attachment:Fe_dos_anti.jpg]]
  • [get | view] (2006-02-03 13:34:30, 100.7 KB) [[attachment:Fe_dos_ferro.jpg]]
  • [get | view] (2006-02-03 13:35:29, 85.6 KB) [[attachment:Fe_dos_non.jpg]]
  • [get | view] (2006-02-03 13:43:25, 0.9 KB) [[attachment:Si-diamond.py]]
  • [get | view] (2006-02-03 14:04:11, 67.5 KB) [[attachment:Si_dos.jpg]]
  • [get | view] (2006-02-03 13:38:47, 1.1 KB) [[attachment:dos.py]]
  • [get | view] (2006-02-03 13:39:11, 0.6 KB) [[attachment:viz_Fe_anti.py]]
 All files | Selected Files: delete move to page copy to page

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