root / ase / test / COCu111_2.py @ 4
Historique | Voir | Annoter | Télécharger (1,82 ko)
| 1 |
from math import sqrt |
|---|---|
| 2 |
from ase import Atoms, Atom |
| 3 |
from ase.constraints import FixAtoms |
| 4 |
from ase.optimize import FIRE, QuasiNewton |
| 5 |
from ase.neb import SingleCalculatorNEB |
| 6 |
from ase.calculators.emt import EMT |
| 7 |
|
| 8 |
Optimizer=FIRE |
| 9 |
Optimizer=QuasiNewton |
| 10 |
|
| 11 |
# Distance between Cu atoms on a (111) surface:
|
| 12 |
a = 3.6
|
| 13 |
d = a / sqrt(2)
|
| 14 |
fcc111 = Atoms(symbols='Cu',
|
| 15 |
cell=[(d, 0, 0), |
| 16 |
(d / 2, d * sqrt(3) / 2, 0), |
| 17 |
(d / 2, d * sqrt(3) / 6, -a / sqrt(3))], |
| 18 |
pbc=True)
|
| 19 |
initial = fcc111 * (2, 2, 4) |
| 20 |
initial.set_cell([2 * d, d * sqrt(3), 1]) |
| 21 |
initial.set_pbc((1, 1, 0)) |
| 22 |
initial.set_calculator(EMT()) |
| 23 |
Z = initial.get_positions()[:, 2]
|
| 24 |
indices = [i for i, z in enumerate(Z) if z < Z.mean()] |
| 25 |
constraint = FixAtoms(indices=indices) |
| 26 |
initial.set_constraint(constraint) |
| 27 |
dyn = Optimizer(initial) |
| 28 |
dyn.run(fmax=0.05)
|
| 29 |
Z = initial.get_positions()[:, 2]
|
| 30 |
print Z[0] - Z[1] |
| 31 |
print Z[1] - Z[2] |
| 32 |
print Z[2] - Z[3] |
| 33 |
|
| 34 |
b = 1.2
|
| 35 |
h = 1.5
|
| 36 |
initial += Atom('C', (d / 2, -b / 2, h)) |
| 37 |
initial += Atom('O', (d / 2, +b / 2, h)) |
| 38 |
s = initial.copy() |
| 39 |
dyn = Optimizer(initial) |
| 40 |
dyn.run(fmax=0.05)
|
| 41 |
#view(initial)
|
| 42 |
|
| 43 |
# create final
|
| 44 |
final = initial.copy() |
| 45 |
final.set_calculator(EMT()) |
| 46 |
final.set_constraint(constraint) |
| 47 |
final[-2].position = final[-1].position |
| 48 |
final[-1].x = d
|
| 49 |
final[-1].y = d / sqrt(3) |
| 50 |
dyn = Optimizer(final) |
| 51 |
dyn.run(fmax=0.1)
|
| 52 |
#view(final)
|
| 53 |
|
| 54 |
# create 2 intermediate step neb
|
| 55 |
neb = SingleCalculatorNEB([initial, final]) |
| 56 |
neb.refine(2)
|
| 57 |
neb.set_calculators(EMT()) |
| 58 |
assert(neb.n() == 4) |
| 59 |
|
| 60 |
dyn = Optimizer(neb, maxstep=0.04, trajectory='mep_2coarse.traj') |
| 61 |
dyn.run(fmax=0.1)
|
| 62 |
#dyn.run(fmax=39.1)
|
| 63 |
|
| 64 |
# read from the trajectory
|
| 65 |
neb = SingleCalculatorNEB('mep_2coarse.traj@-4:')
|
| 66 |
|
| 67 |
# refine in the important region
|
| 68 |
neb.refine(2, 1, 3) |
| 69 |
neb.set_calculators(EMT()) |
| 70 |
dyn = Optimizer(neb, maxstep=0.04, trajectory='mep_2fine.traj') |
| 71 |
dyn.run(fmax=0.1)
|
| 72 |
assert(len(neb.images) == 8) |