Visualizing Wavefunctions

I've been interested in visualizing wavefunctions, and the local energy. To this end, I've been playing with the Visualization Toolkit (VTK), Python, and Tk (the Python interface to Tk is usally included in a Python install)

Function of 2 variables

For starters, I wrote a program to draw a function of 2 variables, plotter_2d.py.

Run it with "vtkpython plotter_2d.py" (vtkpython is built by vtk when python wrapping is turned on)
Enter a function of x and y into the box and press the "update" button to draw the function. The Python "math" module has been imported, so you can use anything defined there.

Screen shot:
Screen shot of plotter_2d.py

Function of 3 variables

I've written a program to draw a function of 3 variables, plotter_3d.py. The display is split into left and right windows. The left window draws the function in 3d, using transparent iso-surface contours. An opaque cut plane is also drawn in the left window. The value of the function on the cut plane is dislayed in the right window (similar to the 2D plotter).

Run it with "vtkpython plotter_3d.py". Enter a function of x, y and z in the box and press "update" to draw the function. The Python "math" module has been imported, so you can use anything defined there.

The "Manipulate cut plane" button brings up the white cube (seen in the left window in the screen shot). The cut plane can be translated by grabbing the plane, or rotated by grabbing the normal vector. Press the button again to make the white cube disappear.

Screen shot:
Screen shot of plotter_3d.py

Back to index page

Mark Dewing. First posted Sept. 4, 2004. Last updated Oct 16, 2004.