Atoms Python Library

PyAtoms is now deprecated and has been replaced by quippy.

I've written a simple Python packaged called PyAtoms for playing with atomic configurations interactively. It works with the extended XYZ file format, and can also write files in AtomEye CFG format, and read CASTEP .cell and .geom files.

There's also written a simple wrapper to communicate with an AtomEye process. This is useful as it lets you manipulate the atoms structure programatically at the same time as visualising it.

The packages is designed to be used interactively from within a python console, or, even better, from ipython. The PyAtoms package is also used by some of my XYZ scripts.

Requirements

You need to have the following packages installed to use these modules.

And for the AtomEye interface you also need

Usage Example

Here's an example of a python console session using the Atoms and AtomEye modules.

   1 from pyatoms import *         # Load PyAtoms modules
   2 
   3 a = Atoms('filepot.xyz')      # Load from an extended XYZ file
   4 
   5 a.add_property('norm2_pos',norm2(a.pos))
   6 
   7 a.write_xyz('out.xyz') # Write it to a new file
   8 
   9 print count(a.pos[:,1] < 0)   # How many atoms with x < 0?
  10 
  11 b = a.filter(a.pos[:,0] < 0)  # Make a new atoms object 
  12                               # containing just these atoms
  13 
  14 as = [a for a in frame_reader('movie.xyz')] # Load a list of Atoms
  15 
  16 from pyatoms.atomeye import * # Load the AtomEye module
  17 
  18 ae = AtomEye()              # Initialise from a list of Atoms
  19 ae.view(as[0],align='CoM')  # Show first frame, centre on centre of mass
  20 ae.animate(as)              # Animate configs from list

Download

You can get the latest development version of PyAtoms here


CategoryResearch

PyAtoms (last edited 2010-11-02 14:37:17 by JamesKermode)