root / ase / optimize / test / neb.py @ 1
Historique | Voir | Annoter | Télécharger (2,12 ko)
1 |
#/usr/bin/env python
|
---|---|
2 |
#PBS -l nodes=4:ppn=8
|
3 |
#PBS -l walltime=13:00:00
|
4 |
from ase.optimize import QuasiNewton |
5 |
from ase.constraints import FixAtoms |
6 |
from ase.calculators.emt import EMT |
7 |
from ase.neb import NEB |
8 |
from ase.lattice.surface import fcc100, add_adsorbate |
9 |
from ase.optimize.test import run_test |
10 |
from gpaw import GPAW, Mixer, PoissonSolver |
11 |
import gpaw.mpi as mpi |
12 |
|
13 |
|
14 |
name = 'neb'
|
15 |
|
16 |
def get_atoms(): |
17 |
# 2x2-Al(001) surface with 3 layers and an
|
18 |
# Au atom adsorbed in a hollow site:
|
19 |
slab = fcc100('Al', size=(2, 2, 3)) |
20 |
add_adsorbate(slab, 'Au', 1.7, 'hollow') |
21 |
slab.center(axis=2, vacuum=4.0) |
22 |
|
23 |
# Fix second and third layers:
|
24 |
mask = [atom.tag > 1 for atom in slab] |
25 |
slab.set_constraint(FixAtoms(mask=mask)) |
26 |
|
27 |
# Use EMT potential:
|
28 |
slab.set_calculator(EMT()) |
29 |
|
30 |
# Initial state:
|
31 |
qn = QuasiNewton(slab, logfile=None)
|
32 |
qn.run(fmax=0.05)
|
33 |
initial = slab.copy() |
34 |
|
35 |
# Final state:
|
36 |
slab[-1].x += slab.get_cell()[0, 0] / 2 |
37 |
qn = QuasiNewton(slab, logfile=None)
|
38 |
qn.run(fmax=0.05)
|
39 |
final = slab.copy() |
40 |
|
41 |
# Setup a NEB calculation
|
42 |
constraint = FixAtoms(mask=[atom.tag > 1 for atom in initial]) |
43 |
|
44 |
images = [initial] |
45 |
for i in range(3): |
46 |
image = initial.copy() |
47 |
image.set_constraint(constraint) |
48 |
images.append(image) |
49 |
|
50 |
images.append(final) |
51 |
|
52 |
neb = NEB(images, parallel=mpi.parallel) |
53 |
neb.interpolate() |
54 |
|
55 |
def set_calculator(calc): |
56 |
i = 0
|
57 |
for image in neb.images[1:-1]: |
58 |
if not mpi.parallel or mpi.rank // (mpi.size // 3) == i: |
59 |
image.set_calculator(calc) |
60 |
i += 1
|
61 |
neb.set_calculator = set_calculator |
62 |
|
63 |
return neb
|
64 |
|
65 |
def get_calculator_emt(): |
66 |
return EMT()
|
67 |
|
68 |
def get_calculator_gpaw(): |
69 |
if mpi.parallel:
|
70 |
assert mpi.size % 3 == 0 |
71 |
s = mpi.size // 3
|
72 |
r0 = mpi.rank // s * s |
73 |
comm = range(r0, r0 + s)
|
74 |
else:
|
75 |
comm = mpi.world |
76 |
calc = GPAW(h=0.25,
|
77 |
kpts=(2, 2, 1), |
78 |
communicator=comm, |
79 |
txt='neb-%d.txt' % r0)
|
80 |
return calc
|
81 |
|
82 |
run_test(get_atoms, get_calculator_emt, name + '-emt')
|
83 |
run_test(get_atoms, get_calculator_gpaw, name + '-gpaw')
|