root / ase / examples / neb1.py @ 1
Historique | Voir | Annoter | Télécharger (1,31 ko)
1 |
from ase import * |
---|---|
2 |
from math import sqrt |
3 |
|
4 |
a = 4.0614
|
5 |
b = a / sqrt(2)
|
6 |
h = b / 2
|
7 |
initial = Atoms([Atom('Al', (0, 0, 0)), |
8 |
Atom('Al', (a / 2, b / 2, -h))], |
9 |
pbc=(1, 1, 0), |
10 |
cell=(a, b, 2 * h))
|
11 |
initial *= (2, 2, 2) |
12 |
initial.append(Atom('Al', (a / 2, b / 2, 3 * h))) |
13 |
|
14 |
#view(initial)
|
15 |
|
16 |
#initial.set_cell((2*2,2*b,)
|
17 |
final = initial.copy() |
18 |
final.positions[-1, 1] += b |
19 |
|
20 |
# Construct a list of images:
|
21 |
images = [initial] |
22 |
for i in range(5): |
23 |
images.append(initial.copy()) |
24 |
images.append(final) |
25 |
|
26 |
# Make a mask of zeros and ones that select the dynamic atoms (the
|
27 |
# three topmost layers):
|
28 |
mask = initial.positions[:, 2] < 0.5 * h |
29 |
constraint = FixAtoms(mask=mask) |
30 |
print mask
|
31 |
print 'Fixed atoms:', constraint.fixed |
32 |
|
33 |
for image in images: |
34 |
# Let all images use an EMT calculator:
|
35 |
image.set_calculator(EMT()) |
36 |
image.set_constraint(constraint) |
37 |
|
38 |
# Relax the initial and final states:
|
39 |
QuasiNewton(initial).run(fmax=0.05)
|
40 |
QuasiNewton(final).run(fmax=0.05)
|
41 |
|
42 |
# Create a Nudged Elastic Band:
|
43 |
neb = NEB(images) |
44 |
|
45 |
# Mak a starting guess for the minimum energy path (a straight line
|
46 |
# from the initial to the final state):
|
47 |
neb.interpolate() |
48 |
|
49 |
# Use MDMin to relax the path:
|
50 |
minimizer = QuasiNewton(neb) |
51 |
minimizer.run(fmax=0.05)
|
52 |
|
53 |
# Write the path to a trajectory:
|
54 |
traj = PickleTrajectory('jump1.traj', 'w') |
55 |
neb.write(traj) |