Pizza.py WWW Site

Pizza.py FAQ (Frequently Asked Questions)

This is a simple FAQ for the Pizza.py toolkit. More complete information is given in the Pizza.py documentation.


1.1 What is Pizza.py?
1.2 How can I use Pizza.py?
1.3 What is the philosophy behind Pizza.py?
1.4 Why Python?

2.1 What can I do with LAMMPS log files (thermodynamic data)?
2.2 What can I do with LAMMPS dump files (atom snapshots)?
2.3 What can I do with OpenGL from within Pizza.py?
2.4 What can I do with RasMol from within Pizza.py?
2.5 What can I do with Raster3d from within Pizza.py?
2.6 What can I do with SVG (scalable vector graphics) via Pizza.py?
2.7 What can I do with GnuPlot from within Pizza.py?
2.8 What can I do with MatLab from within Pizza.py?
2.9 What can I do with image files from within Pizza.py?

1.1 What is Pizza.py?

Pizza.py is a loosely integrated collection of tools written in Python, many of which provide pre- and post-processing capability for the LAMMPS molecular dynamics package. There are tools to create input files, convert between file formats, process log and dump files, create plots, and visualize and animate simulation snapshots. Eventually it will include tools for other simulations as well.

More generally, Pizza.py is two things. The top-level of Pizza.py extends the Python interpreter in a few simple ways to make it easier to invoke shell commands, launch scripts, and query help on tools. Secondly, the Pizza.py tools are Python modules designed with interfaces that allow them to interact with and/or replace each other in simple, yet powerful ways.


1.2 How can I use Pizza.py?

Pizza.py can be used in several different ways:

Other than a few basic syntax rules, you do not need to know any Python to use Pizza.py tools. However, if you are familiar with Python, you will be able to use the tools in more sophisticated ways, write your own scripts for analysis purposes, add methods to existing tools, or even create new tools of your own.

A Pizza.py tool (just a *.py file) can be used directly in Python, without the rest of Pizza.py. Pizza.py scripts can be run by others, who don't have Pizza.py, to run in their Python (so long as you also give them any tool files the script uses).

New tools you write need not have anything to do with LAMMPS. They could be a stand-alone tool or interact with existing Pizza.py tools in various ways. For example, you could write a new tool that


1.3 What is the philosophy behind Pizza.py?

In the pizza metaphor ...

A "tool", as implemented in Pizza.py, has the following characteristics:

The 1st point means that GUI operations can also be done at the commmand line, so any tool's capabilities can be scripted. The 2nd point means that if a tool opens a GUI window, it does not lock the mouse to it; multiple instances of the same tool or of other tools can be operational at the same time. The 3rd point means that groups of tools share identical (or at least similar) methods so they be used interchangeably. Examples of this are:

plotting tools gnu, matlab
visualization tools gl, rasmol, raster, svg (partially)
file format tools ensight, pdb, xyz, vtk, pdb (partially)
vector processing clog, log, vec

1.4 Why Python?

Sometimes a toolkit like Pizza.py is called a framework. My view is that Python itself is the ideal framework for glueing together various tools and third-party applications. Aside from its snake-like ability to wrap other software, Python is a powerful object-oriented programming language in its own right.

I've dabbled in other scripting languages (Perl, Tcl/Tk, shell) but Python is my favorite. For non-parallel, non-CPU-intensive programming, it's my language of choice, for these reasons:



2.1 What can I do with LAMMPS log files (thermodynamic data)?

With the log tool you can:

For example, making a plot of a thermodynamic quantity vs time from a series of log files is as simple as:

lg = log("log.*")
s,t = lg.get("Step","Temp")
m = matlab()
m.plot(s,t) 

2.2 What can I do with LAMMPS dump files (atom snapshots)?

With the dump tool you can:

For example, converting a set of dump file snapshots to XYZ format is as simple as:

d = dump("dump.*")
x = xyz(d)
x.many() 

which could also be written as one line:

xyz(dump("dump.*")).many() 

2.3 What can I do with OpenGL from within Pizza.py?

The gl tool in Pizza.py is a wrapper on OpenGL graphics via the PyOpenGL package. The vcr tool puts a GUI wrapper around one or more OpenGL windows. With these tools you can:


2.4 What can I do with RasMol from within Pizza.py?

The rasmol tool in Pizza.py is a wrapper on the popular RasMol molecular visualization program. With the rasmol and pdb tools you can:

For example, to make an MPEG movie from RasMol images of LAMMPS snapshots using "peptide.pdb" as a template PDB file, you could type:

d = dump("dump.*")
p = pdb("peptide",d)
r = rasmol(p)
r.all()
!convert image*gif protein.mpg 

The last line is not part of Pizza.py; it simply invokes the ImageMagick "convert" program to turn a series of GIF files into an MPEG movie.


2.5 What can I do with Raster3d from within Pizza.py?

The raster tool in Pizza.py is a wrapper on the Raster3d molecular visualization program which creates ray-traced images of a molecular model. With the raster tool you can:

For example, to create an image sequence of LAMMPS snapshots from a chosen viewpoint, and view them in the animate tool, you could type:

d = dump("dump.*")
r = raster(d)
r.rotate(45,120)
r.all()
animate("image*.png") 

2.6 What can I do with SVG (scalable vector graphics) via Pizza.py?

SVG is a portable file format that can be used to visualize many, many things, including atoms and bonds. It's particularly nice for solid-state systems with atoms on lattices.

The svg tool in Pizza.py creates SVG files from LAMMPS snapshots. The tool's interface is the same as for the raster tool discussed in the previous FAQ question. Thus you can create SVG images in place of Raster3d images by changing one line in the example above, i.e. "r = svg(d)".


2.7 What can I do with GnuPlot from within Pizza.py?

GnuPlot is an open-source plotting package from the GNU folks. The "gnuplot tool" in Pizza.py lets you:

Only a small subset of GnuPlot commands are wrapped as gnu tool methods by Pizza.py, but any GnuPlot operation can be performed from within Pizza.py by issuing using native GnuPlot commands.


2.8 What can I do with MatLab from within Pizza.py?

MatLab is a commercial numerical analysis program that does many, many things, one of which is make nice plots. The Pizza.py matlab tool wraps the plotting functionality in MatLab with the same interface as it does GnuPlot. So you can do exactly the same things with MatLab plots as listed in the previoue FAQ question for GnuPlot, i.e. creating MatLab plots instead of GnuPlot plots is as simple as changing one line in your script.

As with GnuPlot, you can drive MatLab interactively either one-command-at-a-time or via the MatLab shell (as if you were typing at the MatLab prompt). This means your Python and LAMMPS data can be exported to MatLab (as a file), and you can then operate on it with any MatLab commands or functions you wish.


2.9 What can I do with image files from within Pizza.py?

The image tool in Pizza.py displays thumbnails for a set of image files, that can be clicked on to display the full file. The tool is also a wrapper on the ImageMagick "convert" and "montage" commands, so that