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.

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

h = 1.85<br />

add_adsorbate(slab, molecule, h, ’ontop’)<br />

In order to speed up the relaxation, let us keep the Cu atoms fixed in the slab by using FixAtoms from the<br />

constraints module. Only the N2 molecule is then allowed to relax to the equilibrium structure:<br />

from ase.constraints import FixAtoms<br />

constraint = FixAtoms(mask=[a.symbol != ’N’ for a in slab])<br />

slab.set_constraint(constraint)<br />

Now attach the QuasiNewton minimizer to the system and save the trajectory file. Run the minimizer with the<br />

convergence criteria that the force on all atoms should be less than some fmax:<br />

from ase.optimize import QuasiNewton<br />

dyn = QuasiNewton(slab, trajectory=’N2Cu.traj’)<br />

dyn.run(fmax=0.05)<br />

Note: The general documentation on structure optimizations contains information about different algorithms,<br />

saving the state of an optimizer and other functionality which should be considered when performing expensive<br />

relaxations.<br />

Input-output<br />

Writing the atomic positions to a file is done with the write() function:<br />

from ase.io import write<br />

write(’slab.xyz’, slab)<br />

This will write a file in the xyz-format. Possible formats are:<br />

format description<br />

xyz Simple xyz-format<br />

cube Gaussian cube file<br />

pdb Protein data bank file<br />

traj <strong>ASE</strong>’s own trajectory format<br />

py Python script<br />

Reading from a file is done like this:<br />

from ase.io import read<br />

slab_from_file = read(’slab.xyz’)<br />

If the file contains several configurations, the default behavior of the write() function is to return the last<br />

configuration. However, we can load a specific configuration by doing:<br />

read(’slab.traj’) # last configuration<br />

read(’slab.traj’, -1) # same as above<br />

read(’slab.traj’, 0) # first configuration<br />

Visualization<br />

The simplest way to visualize the atoms is the view() function:<br />

from ase.visualize import view<br />

view(slab)<br />

This will pop up a gui window. Alternative viewers can be used by specifying the optional keyword<br />

viewer=... - use one of ‘ase.gui’, ‘gopenmol’, ‘vmd’, or ‘rasmol’. (Note that these alternative viewers are not<br />

a part of <strong>ASE</strong> and will need to be installed by the user separately.) The VMD viewer can take an optional data<br />

argument to show 3D data:<br />

20 Chapter 6. Tutorials

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

Saved successfully!

Ooh no, something went wrong!