Attachment 'neb.py'

Download

   1 #!/usr/bin/env python
   2 
   3 from math import sqrt
   4 
   5 import Numeric as num
   6 
   7 from Dacapo import Dacapo
   8 from ASE.Filters.Subset import Subset
   9 from ASE.Filters.NudgedElasticBand import NudgedElasticBand
  10 from ASE.Dynamics.QuasiNewton import QuasiNewton
  11 from ASE.Trajectories.NetCDFTrajectory import NetCDFTrajectory
  12 from ASE import Atom,ListOfAtoms
  13 
  14 # setup the static Al slab 
  15 alslab =  ListOfAtoms([ Atom('Al',(0, 0, 0)),
  16                         Atom('Al',(0, 0.5, 0)),
  17                         Atom('Al',(0.5, 0, 0)),
  18                         Atom('Al',(0.5, 0.5, 0)),
  19                         Atom('Al',(0.3333333, 0.166666667, 0.125*2.)),
  20                         Atom('Al',(0.3333333, 0.666666667, 0.125*2.)),
  21                         Atom('Al',(0.8333333, 0.166666667, 0.125*2.)),
  22                         Atom('Al',(0.8333333, 0.666666667, 0.125*2.))])
  23 
  24 initial = alslab.Copy()
  25 initial.append(Atom('O',(0.166586,0.33341, -0.043448*2.),tag=1))
  26 
  27 final = alslab.Copy()
  28 final.append(Atom('O',(0.33331, 0.166677, -0.04417119*2. ),tag=1))
  29 
  30 unitcell = [[5.72756492761103, 0, 0], 
  31             [-2.86378246380552, 4.96021672913593, 0], 
  32             [0,0,18.7061487217439/2.]]
  33 
  34 initial.SetUnitCell(unitcell) 
  35 final.SetUnitCell(unitcell)  
  36 
  37 mask=[a.GetTag()==1 for a in initial]
  38 
  39 calc = Dacapo(planewavecutoff = 340, 
  40               densitycutoff = 500,
  41               nbands = 22) 
  42 
  43 calc.StayAliveOff()
  44 calc.SetNetCDFFile('initial.nc') 
  45 initial.SetCalculator(calc) 
  46 initialenergy = initial.GetPotentialEnergy() 
  47 # Create a qn object:
  48 subset = Subset(initial,mask) 
  49 relax = QuasiNewton(subset,fmax=0.05)
  50 relax.Converge(maxsteps=1)
  51 initialenergy1 = initial.GetPotentialEnergy() 
  52 
  53 calc.SetNetCDFFile('final.nc') 
  54 final.SetCalculator(calc) 
  55 finalenergy = final.GetPotentialEnergy() 
  56 # Create a qn object:
  57 subset = Subset(final,mask) 
  58 relax = QuasiNewton(subset,fmax=0.05)
  59 relax.Converge(maxsteps=1)
  60 finalenergy1 = final.GetPotentialEnergy() 
  61 
  62 print 'initial state energy             : ',initialenergy
  63 print 'initial state energy (minimized) : ',initialenergy1
  64 print 'final state energy               : ',finalenergy
  65 print 'final state energy (minimized)   : ',finalenergy1
  66 
  67 atomslist = [Dacapo.ReadAtoms('initial.nc')]
  68 configs   = [Subset(atomslist[0], mask=mask)]
  69 for n in range(2): 
  70     atoms = Dacapo.ReadAtoms('initial.nc') 
  71     atomslist.append(atoms)
  72     configs.append(Subset(atoms, mask=mask))
  73 
  74 atoms = Dacapo.ReadAtoms('final.nc') 
  75 configs.append(Subset(atoms, mask=mask))
  76 atomslist.append(atoms)
  77 
  78 # setup each calculator
  79 for n in range(len(atomslist)): 
  80     calc = atomslist[n].GetCalculator() 
  81     calc.StayAliveOff()
  82     calc.SetTxtFile('out.'+str(n)+'.txt') 
  83     calc.SetNetCDFFile('out.'+str(n)+'.nc') 
  84 
  85 band = NudgedElasticBand(configs)
  86 band.SetInterpolatedPositions()
  87 
  88 # Create a qn object:
  89 relax = QuasiNewton(band,fmax=0.05,forcemin=False)
  90 
  91 # Create a trajectory for the each image
  92 listoftraj = []
  93 for n in range(len(atomslist)): 
  94     path = NetCDFTrajectory('image'+str(n)+'.nc', atomslist[n])
  95     print 'n= ',n,atomslist[n].GetPotentialEnergy()
  96     listoftraj.append(path) 
  97     path.Update()
  98     relax.Attach(path) 
  99 
 100 
 101 relax.Converge()
 102 
 103 # make a trajectory of the final configurations in neb-path.nc
 104 atomslist = [listoftraj[n].GetListOfAtoms(-1) for n in range(len(listoftraj))]
 105 
 106 atom0 = atomslist[0]
 107 newtraj = NetCDFTrajectory('neb-path.nc',atom0) 
 108 newtraj.Update()
 109 
 110 for atom in atomslist[1:]: 
 111     atom0.SetCartesianPositions(atom.GetCartesianPositions())
 112     atom0.SetCalculator(atom.GetCalculator())
 113     newtraj.Update()

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.