18.11.2012 Views

ASE Manual Release 3.6.1.2825 CAMd - CampOS Wiki

ASE Manual Release 3.6.1.2825 CAMd - CampOS Wiki

ASE Manual Release 3.6.1.2825 CAMd - CampOS Wiki

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

view(slab, viewer=’VMD’, data=array)<br />

Molecular dynamics<br />

<strong>ASE</strong> <strong>Manual</strong>, <strong>Release</strong> 3.6.1.2828<br />

Let us look at the nitrogen molecule as an example of molecular dynamics with the VelocityVerlet algorithm.<br />

We first create the VelocityVerlet object giving it the molecule and the time step for the integration<br />

of Newton’s law. We then perform the dynamics by calling its run() method and giving it the number of steps<br />

to take:<br />

from ase.md.verlet import VelocityVerlet<br />

from ase import units<br />

dyn = VelocityVerlet(molecule, dt=1.0 * units.fs)<br />

for i in range(10):<br />

pot = molecule.get_potential_energy()<br />

kin = molecule.get_kinetic_energy()<br />

print ’%2d: %.5f eV, %.5f eV, %.5f eV’ % (i, pot + kin, pot, kin)<br />

dyn.run(steps=20)<br />

6.2.2 Manipulating atoms<br />

XXX rewrite this: use fcc111() function and do some relaxation ...<br />

We will set up a one layer slab of Ni atoms with one Ag adatom.<br />

Define the slab atoms:<br />

>>> from ase import Atoms<br />

>>> atoms = Atoms(’Ni4’, [(0, 0, 0),<br />

... (0.45, 0, 0),<br />

... (0, 0.5, 0),<br />

... (0.5, 0.5, 0)])<br />

Have a look at the individual atoms:<br />

>>> atoms[0]<br />

Atom(’Ni’, [0.0, 0.0, 0.0], atoms=..., index=0)<br />

>>> atoms[1]<br />

Atom(’Ni’, [0.45, 0.0, 0.0], atoms=..., index=1)<br />

>>> atoms[2]<br />

Atom(’Ni’, [0.0, 0.5, 0.0], atoms=..., index=2)<br />

>>> atoms[3]<br />

Atom(’Ni’, [0.5, 0.5, 0.0], atoms=..., index=3)<br />

Let us assume we forgot how many atoms we set up:<br />

>>> atoms[4]<br />

Traceback (most recent call last):<br />

File "", line 1, in ?<br />

IndexError: list index out of range<br />

Wrong because we only have four atoms<br />

>>> len(atoms)<br />

4<br />

Change the position of the 2nd atom in the list<br />

>>> atoms[1].x = 0.5<br />

>>> atoms.get_positions()<br />

array([[ 0. , 0. , 0. ],<br />

[ 0.5, 0. , 0. ],<br />

6.2. <strong>ASE</strong> 21

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!