root / ase / examples / COCu111.py @ 3
Historique | Voir | Annoter | Télécharger (1,87 ko)
1 |
from math import sqrt |
---|---|
2 |
from ase import Atoms, Atom |
3 |
from ase.constraints import FixAtoms |
4 |
from ase.optimize import QuasiNewton |
5 |
from ase.io import PickleTrajectory |
6 |
from ase.neb import NEB |
7 |
from ase.calculators.emt import EMT |
8 |
|
9 |
# Distance between Cu atoms on a (111) surface:
|
10 |
a = 3.6
|
11 |
d = a / sqrt(2)
|
12 |
y = d * sqrt(3) / 2 |
13 |
fcc111 = Atoms('Cu',
|
14 |
cell=[(d, 0, 0), |
15 |
(d / 2, y, 0), |
16 |
(d / 2, y / 3, -a / sqrt(3))], |
17 |
pbc=True)
|
18 |
slab = fcc111 * (2, 2, 4) |
19 |
slab.set_cell([2 * d, 2 * y, 1]) |
20 |
slab.set_pbc((1, 1, 0)) |
21 |
slab.set_calculator(EMT()) |
22 |
Z = slab.get_positions()[:, 2]
|
23 |
indices = [i for i, z in enumerate(Z) if z < Z.mean()] |
24 |
constraint = FixAtoms(indices=indices) |
25 |
slab.set_constraint(constraint) |
26 |
dyn = QuasiNewton(slab) |
27 |
dyn.run(fmax=0.05)
|
28 |
Z = slab.get_positions()[:, 2]
|
29 |
print Z[0] - Z[1] |
30 |
print Z[1] - Z[2] |
31 |
print Z[2] - Z[3] |
32 |
|
33 |
b = 1.2
|
34 |
h = 2.0
|
35 |
slab += Atom('C', (d, 2 * y / 3, h)) |
36 |
slab += Atom('O', (3 * d / 2, y / 3, h)) |
37 |
traj = PickleTrajectory('initial.traj', 'w', slab) |
38 |
dyn = QuasiNewton(slab) |
39 |
dyn.attach(traj.write) |
40 |
dyn.run(fmax=0.05)
|
41 |
#view(slab)
|
42 |
# Make band:
|
43 |
images = [slab.copy() for i in range(6)] |
44 |
neb = NEB(images, climb=True)
|
45 |
|
46 |
# Set constraints and calculator:
|
47 |
for image in images: |
48 |
image.set_calculator(EMT()) |
49 |
image.set_constraint(constraint) |
50 |
|
51 |
# Displace last image:
|
52 |
images[-1].positions[-1] = (2 * d, 2 * y / 3, h) |
53 |
traj = PickleTrajectory('final.traj', 'w', images[-1]) |
54 |
dyn = QuasiNewton(images[-1])
|
55 |
dyn.attach(traj.write) |
56 |
dyn.run(fmax=0.05)
|
57 |
|
58 |
# Interpolate positions between initial and final states:
|
59 |
neb.interpolate() |
60 |
|
61 |
for image in images: |
62 |
print image.positions[-1], image.get_potential_energy() |
63 |
|
64 |
traj = PickleTrajectory('mep.traj', 'w') |
65 |
|
66 |
#dyn = MDMin(neb, dt=0.4)
|
67 |
#dyn = FIRE(neb, dt=0.4)
|
68 |
dyn = QuasiNewton(neb) |
69 |
dyn.attach(neb.writer(traj)) |
70 |
dyn.run(fmax=0.05)
|
71 |
|
72 |
for image in images: |
73 |
print image.positions[-1], image.get_potential_energy() |