## Attachment 'bee2.py'

Download

```   1 from math import pi
2 import Numeric as num
3 from ASE.Utilities.BEE import GetEnsembleEnergies
4 from ASE import Atom, ListOfAtoms
5 from Dacapo import Dacapo
6
7 a = 4.0  # Size of unit cell (Angstrom)
8
9 # Hydrogen molecule:
10 d0 = 0.74  # Experimental bond length
11 molecule = ListOfAtoms([Atom('H', (0, 0, 0)),
12                         Atom('H', (d0, 0, 0))],
13                        cell=(a, a, a), periodic=True)
14 calc = Dacapo(planewavecutoff=400, nbands=1, xc='PBE', out='H2.out')
15 molecule.SetCalculator(calc)
16
17 e2 = molecule.GetPotentialEnergy()
18 e2_i = GetEnsembleEnergies(molecule)
19
20 dd = 0.02
21 molecule[1].SetCartesianPosition([d0 + dd, 0, 0])
22 e3 = molecule.GetPotentialEnergy()
23 e3_i = GetEnsembleEnergies(molecule)
24
25 molecule[1].SetCartesianPosition([d0 - dd, 0, 0])
26 e1 = molecule.GetPotentialEnergy()
27 e1_i = GetEnsembleEnergies(molecule)
28
29 print 'PBE:'
30 print d0 - dd, e1
31 print d0, e2
32 print d0 + dd, e3
33 print
34
35 # Fit to parabola: a * (d - d0)^2 + b * (d - d0) + c
36
37 a = 0.5 * (e1 - 2 * e2 + e3) / dd**2
38 b = 0.5 * (e3 - e1) / dd
39 d = d0 - 0.5 * b / a
40
41 s = 6.62606876e-34 / pi / 1.66053873e-27**0.5 / 1.6021765e-19**0.5 * 1e13
42 print 'd =', d, 'Ang'
43 print 'hv =', a**0.5 * s, 'meV'
44 print
45
46 a_i = 0.5 * (e1_i - 2 * e2_i + e3_i) / dd**2
47 b_i = 0.5 * (e3_i - e1_i) / dd
48 d_i = d0 - 0.5 * b_i / a_i
49
50 n = len(d_i)
51 d = num.sum(d_i) / n
52 sigma = (num.sum((d_i - d)**2) / n)**0.5
53 print 'Best fit:',
54 print 'd =', d, '+-', sigma, 'Ang'
55 hv_i = a_i**0.5 * s
56 hv = num.sum(hv_i) / n
57 sigma = (num.sum((hv_i - hv)**2) / n)**0.5
58 print 'hv =', hv, '+-', sigma, 'meV'
```

## 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.