Attachment 'STM.py'

Download

   1 #!/usr/bin/env python
   2 # =======================================
   3 #    STM of Al(fcc)100(N x M unit cell)
   4 # =======================================
   5 from Dacapo import Dacapo
   6 from ASE import Atom,ListOfAtoms
   7 from Numeric import sqrt,array
   8 from ASE.Visualization.VMD import VMD
   9 import os
  10 
  11 a0     = 4.05         # cubic fcc lattice constant
  12 N      = 2            # repetition along x
  13 M      = 2            # repetition along y
  14 layers = 2            # slab layers
  15 electronsperatom = 3 
  16 vaclay = 5            # interlayer dist = a0/2
  17 
  18 
  19 # ---------------------------------------------------
  20 # ------- Setup the structure/calculation -----------
  21 # ---------------------------------------------------
  22 
  23 atoms   = ListOfAtoms([])
  24 for n in range(layers):
  25     for i in range(N):
  26         for j in range(M):
  27             scaledpos = [(i+(n%2)/2.)/sqrt(2.),(j+(n%2)/2.)/sqrt(2.),-n/2.]
  28             atoms.append(Atom('Al', a0*array(scaledpos)))
  29                                        
  30                                        
  31 unitcell = [[N/sqrt(2.), 0.0,        0.0],
  32             [0.0,        M/sqrt(2.), 0.0],
  33             [0.0,        0.0,        (vaclay+layers)/2.]]
  34 
  35 atoms.SetUnitCell(a0*array(unitcell),fix=True)
  36 
  37 # VMD(atoms)
  38 
  39 # check if we have already calculated the nc file
  40 if not os.path.isfile('Al100.nc'):
  41 
  42     calc = Dacapo(planewavecutoff = 150, 
  43               nbands = 10 + len(atoms)*electronsperatom/2, 
  44               kpts=(4,4,1),
  45               xc = 'LDA',
  46               usesymm=True,
  47               out = 'Al100.nc',txtout = 'Al100.txt') 
  48 
  49     atoms.SetCalculator(calc) 
  50 
  51 else: 
  52     atoms = Dacapo.ReadAtoms('Al100.nc')
  53 
  54 energy = atoms.GetPotentialEnergy()
  55 
  56 # =======================================
  57 #    STM of Al(fcc)100(N x M unit cell)
  58 # =======================================
  59 # --------------------------------------------------
  60 # ------------ STM image generation part -----------
  61 # --------------------------------------------------
  62 
  63 from Dacapo.ElectronicStates import ElectronicStates
  64 from Dacapo import Dacapo
  65 from ASE.Utilities.STMTool import STMTool
  66 from ASE.Utilities.STMLineScan import STMLineScan
  67 
  68 atoms = Dacapo.ReadAtoms('Al100.nc')
  69 from ASE.Visualization.VMD import VMD
  70 # VMD(atoms)
  71 
  72 loe = ElectronicStates(filename='Al100.nc')
  73 stm = STMTool(loe,contourvalue=1.0e-4, channel="s",
  74              normalaxis=2, smoothfactor=0.1)    # available channels: s,px,py,p
  75 
  76 
  77 
  78 from pylab import *
  79 import matplotlib
  80 
  81 # select a linescan
  82 linescan = STMLineScan(stm,fftnumber=12,axis=1)
  83 
  84 # contour surface plot 
  85 extent = stm.GetExtentOfContourSurface()
  86 im2 = imshow(stm.GetContourSurface().Array,
  87              interpolation='bicubic',
  88              origin='lower',cmap=cm.jet, 
  89              extent = extent) 
  90 colorbar()
  91 
  92 # add position of line scan to contour plot
  93 linex,liney  = linescan.GetLine()
  94 plot(linex,liney,linewidth=2,color='black')
  95 axis(extent)
  96 
  97 savefig('contourplot')
  98 
  99 # line scan plot
 100 figure()
 101 
 102 values = linescan.GetArray()
 103 plot(values)
 104 xlabel('Distance along surface')
 105 ylabel('Height above surface')
 106 title('Linescan at FFT number 12 along the y-axis') 
 107 grid(True)
 108 
 109 savefig('linescan')

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.