root / ase / test / emt1.py @ 4
Historique | Voir | Annoter | Télécharger (632 octet)
| 1 |
from ase import Atoms |
|---|---|
| 2 |
from ase.calculators.emt import EMT |
| 3 |
from ase.constraints import FixBondLength |
| 4 |
from ase.io import PickleTrajectory |
| 5 |
from ase.optimize import BFGS |
| 6 |
|
| 7 |
a = 3.6
|
| 8 |
b = a / 2
|
| 9 |
cu = Atoms('Cu2Ag',
|
| 10 |
positions=[(0, 0, 0), |
| 11 |
(b, b, 0),
|
| 12 |
(a, a, b)], |
| 13 |
calculator=EMT()) |
| 14 |
e0 = cu.get_potential_energy() |
| 15 |
print e0
|
| 16 |
|
| 17 |
d0 = cu.get_distance(0, 1) |
| 18 |
cu.set_constraint(FixBondLength(0, 1)) |
| 19 |
t = PickleTrajectory('cu2ag.traj', 'w', cu) |
| 20 |
qn = BFGS(cu) |
| 21 |
qn.attach(t.write) |
| 22 |
def f(): print cu.get_distance(0,1) |
| 23 |
qn.attach(f) |
| 24 |
qn.run(fmax=0.01)
|
| 25 |
assert abs(cu.get_distance(0, 1) - d0) < 1e-14 |