Animated gifs of molecular orbitals of CO

2017-12-29

Introduction

The electron density of a molecular orbital is basically a three-dimensional scalar field which can be visualized using both contour plots as well as isosurfaces. Typically, we see that isosurfaces are being employed, as they more clearly show the three-dimensional character of the molecular orbital. However, such isosurfaces are nothing more than those set of points in 3D space which have the same value. Thus in some sense, there is loss of information, especially if there are interesting features within the three-dimensional object spanned by the isosurface.

Animated gifs

A very simple way to resolve this, is to use contour plots. As mentioned, the downside of using contour plots though is that we are no longer able to effectively show the three-dimensional character as we are simply projecting planes within the scalar field and colorizing each point on the plane based on the value of that point in the scalar field. We are able to generate a series of contour plots for a set of relevant planes within the three-dimensional space. Using the previously demonstrated EDP program, we are able to efficiently create this contour plots using the command line. In turn, using Imagemagick and a small Python script as shown below, we are able to construct animated gifs that loop over the generated set of contour plots.


#!/usr/bin/env python

from subprocess import call
import numpy

# input file identifier
filestr = "CO_5SIGMA"

# output file name
output = "co_5sigma"

# generate slices and create contour plot
for z in numpy.linspace(2.0, 8.0, 50):
    filename = "%s_%f.png" % (filestr, z)
    call(["/home/ivo/Documents/PROGRAMMING/CPP/edp/build/edp", "-i", "/scratch/ivo/vasp/CO/PARCHG_5SIGMA", "-s", "100", "-v", "1,0,0", "-w", "0,0,1", "-p", "0,%f,0" % z, "-o", filename])
    call(["convert", filename, "-resize", "25%", filename.replace(".png",".gif")])

# combine everything inside a single animated gif
call(["convert", "-delay", "0", "-loop" , "0", "%s*.gif" % filestr, "%s.gif" % output])

Showcase

As usual, we use the electron density of the binding molecular orbitals of CO to demonstrate the tool. Below, you can see that the animated gifs loop over a set of contour planes. One of the things that are now easily visible are the regions of near-zero electron density at the center of the 1π and 5σ orbitals, which would normally not be visible when using isosurfaces.





What other molecular orbitals would you like to see? Share your thoughts in the comments!

If you have questions or comments, feel free to drop a line! Like what you read? Share this page with your friends and colleagues.

Comments

Question:
What is the answer to One + Two?
Please answer with a whole number, i.e. 2, 3, 5, 8,...