Attachment 'electrostatic.py'

Download

   1 """ workfunction and dipole correction for a Al slab 
   2 """
   3 
   4 import os
   5 import Numeric as num
   6 from ASE.Visualization.gnuplot import gnuplot
   7 from ASE.Visualization.VTK import VTKPlotArray
   8 from Dacapo import Dacapo
   9 from ASE import Atom, ListOfAtoms
  10 from ASE.Utilities.List import List
  11 import os.path,sys
  12 from ASE.IO.Cube import WriteCube
  13 
  14 sys.path.remove('/home/camp/lhansen/CamposASE')
  15 sys.path.remove('/usr/lib/python2.2/site-packages/CamposASE')
  16 
  17 # from Visualization import *
  18 
  19 # check if we have already calculated the nc file
  20 if not os.path.isfile('Al111-O.nc'):
  21 
  22     # setup the Al slab
  23     alslab =  ListOfAtoms([ Atom('Al',(0, 0, 0)),
  24                         Atom('Al',(0, 0.5, 0)),
  25                         Atom('Al',(0.5, 0, 0)),
  26                         Atom('Al',(0.5, 0.5, 0)),
  27                         Atom('Al',(0.3333333, 0.166666667, 0.2338/1.25)),
  28                         Atom('Al',(0.3333333, 0.666666667, 0.2338/1.25)),
  29                         Atom('Al',(0.8333333, 0.166666667, 0.2338/1.25)),
  30                         Atom('Al',(0.8333333, 0.666666667, 0.2338/1.25 ))])
  31 
  32     alslab.append(Atom('O',(0.0,0.0, -0.12),tag=1))
  33 
  34     unitcell = [[5.72756492761103, 0, 0],
  35                 [-2.86378246380552, 4.96021672913593, 0],
  36                 [0,0,12.5]]
  37 
  38     alslab.SetUnitCell(unitcell)
  39 
  40     calc = Dacapo(planewavecutoff = 340,
  41                   densitycutoff = 500,
  42                   dipole = True,
  43                   nbands = 30, 
  44                   out = 'Al111-O.nc', 
  45                   txtout = 'Al111-O.txt') 
  46 
  47 
  48     alslab.SetCalculator(calc)
  49 
  50 else: 
  51     alslab = Dacapo.ReadAtoms('Al111-O.nc') 
  52     calc = alslab.GetCalculator()
  53 
  54 
  55 electro = calc.GetElectrostaticPotential()
  56 
  57 nx,ny,nz = num.shape(electro) 
  58 
  59 # get the x-axis 
  60 unitcell = alslab.GetUnitCell()
  61 xaxis = [float(z)/float(nz)*unitcell[2,2] for z in range(nz)]
  62 
  63 # xy average of potential
  64 xyaverage = [num.sum(num.sum(electro[:,:,z]))/(nx*ny) for z in range(nz)]
  65 potential = List(zip(xaxis,xyaverage))
  66 potential.legend = 'Electrostatic potential'
  67 potential.ylabel = 'Electrostatic potential (eV)'
  68 potential.xlabel = 'Distance along z-axis (Angstrom)'
  69 
  70 # add fermilevel to the plot
  71 fermilevel = calc.GetFermilevel()
  72 fermilevel = List(zip(xaxis,[fermilevel for z in range(nz)]))
  73 fermilevel.legend = 'Fermi level'
  74 
  75 # make the plots
  76 plot = gnuplot(potential) 
  77 fermiplot = gnuplot(fermilevel,parent=plot) 
  78 plot.Update()
  79 
  80 electro = calc.GetDensityArray()
  81 
  82 # vtkplot = VTKPlotArray(electro,unitcell)
  83 WriteCube(alslab,electro[:,:,:],'test.cube')

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] (2005-11-10 12:53:31, 1.7 KB) [[attachment:Al_equation_of_state.py]]
  • [get | view] (2006-02-07 13:26:56, 5.2 KB) [[attachment:Al_murn.png]]
  • [get | view] (2005-11-10 12:52:32, 0.6 KB) [[attachment:CO_in_a_box.py]]
  • [get | view] (2005-11-10 12:52:58, 0.6 KB) [[attachment:CO_relaxed_in_a_box.py]]
  • [get | view] (2006-02-09 10:15:54, 0.5 KB) [[attachment:CO_vibrations.py]]
  • [get | view] (2006-02-07 13:34:52, 41.6 KB) [[attachment:HCo.jpg]]
  • [get | view] (2006-02-09 09:11:07, 1.7 KB) [[attachment:H_Co_ontop.py]]
  • [get | view] (2006-02-09 10:23:21, 3.0 KB) [[attachment:STM.py]]
  • [get | view] (2006-02-09 10:25:18, 3.4 KB) [[attachment:Wannier-Fe-bcc.py]]
  • [get | view] (2006-02-09 10:24:12, 1.9 KB) [[attachment:Wannier-Pt4.py]]
  • [get | view] (2006-02-09 10:24:44, 2.3 KB) [[attachment:Wannier-Ptwire.py]]
  • [get | view] (2006-02-09 10:23:48, 2.0 KB) [[attachment:Wannier-ethylene.py]]
  • [get | view] (2006-02-09 12:14:10, 1.5 KB) [[attachment:bee.py]]
  • [get | view] (2006-02-09 12:15:01, 1.5 KB) [[attachment:bee2.py]]
  • [get | view] (2006-02-07 13:39:49, 8.6 KB) [[attachment:dipole.gif]]
  • [get | view] (2006-02-09 10:16:22, 2.5 KB) [[attachment:electrostatic.py]]
  • [get | view] (2006-02-09 09:19:06, 1.8 KB) [[attachment:filter.py]]
  • [get | view] (2006-02-07 13:38:35, 51.2 KB) [[attachment:final.jpg]]
  • [get | view] (2006-02-07 13:36:15, 474.9 KB) [[attachment:h2o-hessian.png]]
  • [get | view] (2006-02-07 13:37:47, 10.7 KB) [[attachment:harris.gif]]
  • [get | view] (2006-02-09 10:06:30, 2.6 KB) [[attachment:harris.py]]
  • [get | view] (2006-02-07 13:38:12, 49.2 KB) [[attachment:initial.jpg]]
  • [get | view] (2006-02-09 10:14:38, 3.4 KB) [[attachment:neb.py]]
  • [get | view] (2006-02-07 13:39:08, 130.0 KB) [[attachment:nebpath.gif]]
  • [get | view] (2006-02-07 13:36:37, 82.3 KB) [[attachment:plottrajectory.gif]]
  • [get | view] (2006-02-09 10:05:51, 1.8 KB) [[attachment:plotwavefunction.py]]
  • [get | view] (2006-02-09 10:15:10, 1.9 KB) [[attachment:restart-neb.py]]
  • [get | view] (2006-02-09 10:38:41, 1.6 KB) [[attachment:setupham.py]]
  • [get | view] (2006-02-07 13:40:51, 84.3 KB) [[attachment:stm.jpg]]
  • [get | view] (2006-02-09 10:38:07, 3.3 KB) [[attachment:transport_1dmodel.py]]
  • [get | view] (2006-02-07 13:37:23, 69.9 KB) [[attachment:vtk.gif]]
  • [get | view] (2006-07-07 07:01:50, 108.7 KB) [[attachment:workfunction.pdf]]
 All files | Selected Files: delete move to page copy to page

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