Thursday 6 October 2011

Automatic plotting of orbitals

Back to computational chemsitry: I want to introduce a script that allows you to plot a number of molecular orbitals automatically in batch mode and yields nicely rendered image files without the need to sit there and wait for your program to compute every single orbital. All you need is VMD and a program that can make surface files (.plt, .cube, ...) for VMD to read. [1] In Turbomole, for example, you only have to add the line

$pointval mo 65-74


Then you would call the following script "vmd_get_plt.bash"

#!/bin/bash
# 1. call this script
# 2. open the molecular structure file in VMD
# 3. load the .plt files and some settings
# - "Load state" load_all_plt.vmd
# - click "Apply" in "Graphical Representations"
# 4. adjust perspective
# 5. "Load state" plot_all.vmd

out=load_all_plt.vmd
plot=plot_all.vmd
rm $out $plot

echo "axes location Off" >> $out
echo "display projection Orthographic" >> $out
echo "color Display Background white" >> $out
echo "menu graphics on" >> $out
echo "mol modstyle 0 0 Bonds 0.100000 10.000000" >> $out
echo "mol addrep 0" >> $out
echo "mol addrep 0" >> $out
echo "mol modmaterial 1 0 AOShiny" >> $out
echo "mol modmaterial 2 0 AOShiny" >> $out
echo "mol modstyle 1 0 Isosurface 0.035000 0 0 0 1 1" >> $out
echo "mol modstyle 2 0 Isosurface -0.035000 0 0 0 1 1" >> $out
echo "mol modcolor 1 0 ColorID 0" >> $out
echo "mol modcolor 2 0 ColorID 1" >> $out

N=0
for I in *plt
do
echo "mol addfile $I" >> $out
echo "mol modstyle 1 0 Isosurface 0.035000 $N 0 0 1 1" >> $plot
echo "mol modstyle 2 0 Isosurface -0.035000 $N 0 0 1 1" >> $plot
echo "render TachyonInternal $I.bmp" >> $plot
N=$(($N+1))
done



This script will create two TCl scripts, which can be accessed by VMD through "Load State". The first one "load_all_plt.vmd" will load the plot files into VMD and set some parameters in a way that I think looks good. You can of course modify the initial bash script to change some of those parameters.

axes location Off
display projection Orthographic
color Display Background white
menu graphics on
mol modstyle 0 0 Bonds 0.100000 10.000000
mol addrep 0
mol addrep 0
mol modmaterial 1 0 AOShiny
mol modmaterial 2 0 AOShiny
mol modstyle 1 0 Isosurface 0.050000 0 0 0 1 1
mol modstyle 2 0 Isosurface -0.050000 0 0 0 1 1
mol modcolor 1 0 ColorID 0
mol modcolor 2 0 ColorID 1
mol addfile 11ag.plt
mol addfile 11b1u.plt
mol addfile 12ag.plt
mol addfile 13ag.plt
mol addfile 7au.plt
mol addfile 7b1g.plt



The second one is used for the actual plotting. First arrange the settings in a way that you like. Then call "plot_all.vmd" through "Load State" and it will create the image files.

mol modstyle 1 0 Isosurface 0.035000 0 0 0 1 1
mol modstyle 2 0 Isosurface -0.035000 0 0 0 1 1
render TachyonInternal 11ag.plt.bmp
mol modstyle 1 0 Isosurface 0.035000 1 0 0 1 1
mol modstyle 2 0 Isosurface -0.035000 1 0 0 1 1
render TachyonInternal 11b1u.plt.bmp
mol modstyle 1 0 Isosurface 0.035000 2 0 0 1 1
mol modstyle 2 0 Isosurface -0.035000 2 0 0 1 1
render TachyonInternal 12ag.plt.bmp


With knowledge of TCl programming it could of course be done in a more integrated fashion but I think it is convenient as it is. I will show some of the pictures soon.

Actually I found out that Jmol might be able to do it even faster because it can directly read the output files of quantum chemical programs and it computes the orbitals itself. And scripting in Jmol appears to be very straight forward. Maybe I will use that as well.

1 comment:

Cocoon Bobbins said...
This comment has been removed by a blog administrator.