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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

pre_write_attach(function, interval=1, *args, **kwargs)<br />

Attach a function to be called before writing begins.<br />

function: The function or callable object to be called.<br />

interval: How often the function is called. Default: every time (1).<br />

All other arguments are stored, and passed to the function.<br />

set_atoms(atoms=None)<br />

Associate an Atoms object with the trajectory.<br />

Mostly for internal use.<br />

write(atoms=None)<br />

Write the atoms to the file.<br />

If the atoms argument is not given, the atoms object specified when creating the trajectory object is<br />

used.<br />

Note that there is apparently no methods for reading the trajectory. Reading is instead done by indexing the<br />

trajectory, or by iterating over the trajectory: traj[0] and traj[-1] return the first and last Atoms object in<br />

the trajectory.<br />

Examples<br />

Reading a configuration:<br />

from ase.io.trajectory import PickleTrajectory<br />

traj = PickleTrajectory("example.traj")<br />

atoms = traj[-1]<br />

Reading all configurations:<br />

traj = PickleTrajectory("example.traj")<br />

for atoms in traj:<br />

# Analyze atoms<br />

Writing every 100th time step in a molecular dynamics simulation:<br />

# dyn is the dynamics (e.g. VelocityVerlet, Langevin or similar)<br />

traj = PickleTrajectory("example.traj", "w", atoms)<br />

dyn.attach(traj.write, interval=100)<br />

dyn.run(10000)<br />

traj.close()<br />

7.25.2 BundleTrajectory<br />

The BundleTrajectory has the interface<br />

class ase.io.bundletrajectory.BundleTrajectory(filename, mode=’r’, atoms=None,<br />

backup=True)<br />

Reads and writes atoms into a .bundle directory.<br />

The BundleTrajectory is an alternative way of storing trajectories, intended for large-scale molecular dynamics<br />

simulations, where a single flat file becomes unwieldy. Instead, the data is stored in directory, a<br />

‘bundle’ (the name bundle is inspired from bundles in Mac OS, which are really just directories the user is<br />

supposed to think of as a single file-like unit).<br />

Parameters:<br />

filename: The name of the directory. Preferably ending in .bundle.<br />

170 Chapter 7. Documentation for modules in <strong>ASE</strong>

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

Saved successfully!

Ooh no, something went wrong!