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.

CHAPTER<br />

THIRTEEN<br />

PORTING OLD <strong>ASE</strong>-2 CODE TO<br />

VERSION 3<br />

The old Numeric-Python based <strong>ASE</strong>-2 can coexist with the new numpy-based <strong>ASE</strong>-3, because the two packages<br />

have different names: <strong>ASE</strong> and ase respectively. Here is an example of combining both:<br />

from <strong>ASE</strong>.Trajectories.NetCDFTrajectory import NetCDFTrajectory<br />

traj = NetCDFTrajectory(’a.nc’)<br />

loa = traj.GetListOfAtoms(-1)<br />

# Convert to new style Atoms object:<br />

from ase import *<br />

a = Atoms(loa)<br />

The new <strong>ASE</strong> can actually read old NetCDF trajectory files, so this would be simpler:<br />

from ase import *<br />

a = read(’a.nc’)<br />

Note: Reading old NetCDF files in the new <strong>ASE</strong>, works even without having the libnetcdf and<br />

Scientific.IO.NetCDF libraries installed.<br />

13.1 The <strong>ASE</strong>2ase tool<br />

Use the <strong>ASE</strong>2ase tool (source code tools/<strong>ASE</strong>2ase) to convert old scripts:<br />

$ <strong>ASE</strong>2ase oldscript.py<br />

$ diff -u oldscript.py.bak oldscript.py<br />

Check that the differences look OK. The conversion tool isn’t clever enough to get everything right, so you will<br />

have to do some conversion manually also. If you have any problems doing this, then you should not hesitate to<br />

contact the campos-devel mailing list (see Mailing Lists) and ask for help.<br />

201

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

Saved successfully!

Ooh no, something went wrong!