10.11.2014 Views

Introduction to ASE - Quantum Espresso

Introduction to ASE - Quantum Espresso

Introduction to ASE - Quantum Espresso

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>Introduction</strong> <strong>to</strong> <strong>ASE</strong><br />

<strong>Introduction</strong>:<br />

The a<strong>to</strong>mic simulation environment (<strong>ASE</strong>)<br />

Doing a calculation:<br />

Installation<br />

Command line<br />

Python scripts<br />

Calcula<strong>to</strong>r interfaces<br />

The future


The a<strong>to</strong>mic simulation environment (<strong>ASE</strong>) Python package<br />

Calcula<strong>to</strong>rs with <strong>ASE</strong> interface:<br />

We use <strong>ASE</strong> for structure optimization, molecular dynamics,<br />

handling constraints, nudged elastic band calculations, vibrational<br />

analysis, simulated STM images, calculation of Wannier<br />

functions, transport calculations and much more<br />

<strong>ASE</strong> also has a graphical user interface and a rich set of file-IO<br />

formats<br />

http://wiki.fysik.dtu.dk/ase


<strong>ASE</strong>-calcula<strong>to</strong>r interface<br />

For <strong>ASE</strong>, a calcula<strong>to</strong>r is a black box that can calculate energies, forces<br />

and stresses. From <strong>ASE</strong> it will get:<br />

a<strong>to</strong>mic positions<br />

a<strong>to</strong>mic numbers<br />

the unit cell<br />

boundary conditions<br />

and maybe also magnetic moments and charges.<br />

More advanced interface:<br />

Eigenvalues.<br />

Electron densities.<br />

Wave functions.<br />

...


Installing <strong>ASE</strong><br />

$ svn co https://svn.fysik.dtu.dk/projects\<br />

> /ase/trunk ase<br />

$ export PYTHONPATH=~/ase<br />

$ export PATH=$PATH:~/ase/<strong>to</strong>ols<br />

$ testase


Where is what?<br />

~/ase/ase:<br />

The <strong>ASE</strong> code.<br />

~/ase/ase/calcula<strong>to</strong>rs:<br />

Python wrappers for electronic structure codes and<br />

empirical potentials.<br />

~/ase/doc:<br />

Documentation (same as on the web-pages).<br />

~/ase/<strong>to</strong>ols:<br />

Tools such as <strong>ASE</strong>’s GUI (ag)


Running a calculation<br />

Command-line interface (still experimental):<br />

$ ase abinit H2 -p ecut=400,xc=PBE -R 0.05<br />

Similar Python script using another calcula<strong>to</strong>r:<br />

from ase.structure import molecule<br />

from ase.optimize import BFGS<br />

from gpaw import GPAW<br />

h2 = molecule(’H2’)<br />

h2.center(vacuum=3)<br />

h2.calc = GPAW(mode=’lcao’,<br />

basis=’dzp’,<br />

xc=’PBE’,<br />

txt=’H2.txt’)<br />

opt = BFGS(h2, trajec<strong>to</strong>ry=’H2.traj’)<br />

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

h2.calc.write(’H2.gpw’)


More <strong>ASE</strong> stuff<br />

Alternative <strong>to</strong> molecule() function:<br />

from ase import A<strong>to</strong>ms<br />

h2 = A<strong>to</strong>ms(’H2’, [(0, 0, 0), (0, 0, 0.74)])<br />

or:<br />

from ase.io import read<br />

h2 = read(’H2.traj’)<br />

There is also a bulk() function and, and, and ...<br />

Use <strong>ASE</strong>’s GUI called ag. It understands the same file-formats<br />

as <strong>ASE</strong>’s read() function: CIF, PDB, CUBE, XYZ, <strong>ASE</strong>’s .traj<br />

files and many mode.


More <strong>ASE</strong> things<br />

How <strong>to</strong> use sys.argv, other <strong>ASE</strong> functions, for-loops and string<br />

interpolation:<br />

import sys<br />

from ase.lattice.surface import fcc111<br />

from gpaw import GPAW, PW<br />

a = float(sys.argv[1])<br />

k = int(sys.argv[2])<br />

for n in range(1, 5):<br />

slab = fcc111(’Cu’, size=(1, 1, n),<br />

a=a, vacuum=5.0)<br />

slab.calc = GPAW(mode=PW(ecut=400),<br />

kpts=(k, k, 1),<br />

txt=’Cu%d.txt’ % n)<br />

slab.get_potential_energy()


Different types of calcula<strong>to</strong>rs<br />

1) <strong>ASE</strong> writes input file<br />

2) <strong>ASE</strong> starts Fortran code (maybe in parallel)<br />

3) <strong>ASE</strong> waits for Fortran code <strong>to</strong> finish<br />

4) <strong>ASE</strong> reads output file<br />

Same as above, except that the Fortran code doesn’t s<strong>to</strong>p - it<br />

waits for a new input file with new coordinates (dacapo).<br />

Pure Python solution. For parallel calculations, the Python<br />

interpreter runs on all processes (GPAW).


What is GPAW?<br />

An implementation of the projec<strong>to</strong>r-augmented wave (PAW)<br />

method<br />

Wave functions are described using<br />

1) real-space uniform grids (fd)<br />

2) a<strong>to</strong>m-centered numerical basis functions (lcao)<br />

3) plane-waves (pw)<br />

It’s written in a combination of the Python and C languages<br />

It’s based on <strong>ASE</strong> and NumPy (a Python library for manipulating<br />

N-dimensional arrays of numbers)<br />

It uses these libraries for the hard work:<br />

BLAS<br />

LAPACK and optionally ScaLAPACK and BLACS<br />

MPI (if you want <strong>to</strong> run GPAW in parallel - which you do)<br />

FFTW (if you want <strong>to</strong> do fast plane-wave based calculations)<br />

The license is GPLv3+


The future<br />

Au<strong>to</strong>matic testing of all calcula<strong>to</strong>r interfaces<br />

New trajec<strong>to</strong>ry file format<br />

...


Finally ...<br />

Check out the webpage:<br />

http://wiki.fysik.dtu.dk/ase<br />

Thanks <strong>to</strong> all contributers<br />

Talk <strong>to</strong> us on our mailing lists: ase-developers, and<br />

ase-users<br />

Thank you for your attention

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

Saved successfully!

Ooh no, something went wrong!