Generating electron density plots using Qchem is easy, but how to subtract two/three cube files using Qchem. In Gaussian there is a program for subtraction, “cubman”, is similar program available for Qchem?
Q-Chem does not ship tools to manipulate cube files. However there are very good third-party tools available, for example funkymunkycool/Cube-Toolz: Python tool to manipulate Gaussian cube files (github.com)
Thanks for your help
That’s the sophisticated way, which I have never tried. What I do is to strip out the header info from both cube files (put it back later) and then do
paste file1.cube file2.cube | awk ‘{for (i=1; i<= NF/2; i++) printf("%17.9E",$i-$(i+NF/2));printf("\n")}’ > diff.cube
Note that both file1.cube and file2.cube need to be defined on the same grid.
Thanks for your reply.
I have a naive query, my cube files are in space-separated format should it work in that also?
Thanks
Yes. Actually all cube files are space-delimited. (The cube file format is described here: https://doi.org/10.1002/9781118889886.ch8). As an example, let me generate cube files for H2O ground-state density using the following as my plotting section:
$plots
water ground-state density
50 -5.0 5.0
50 -5.0 5.0
50 -5.0 5.0
0 1 0 0
0
$end
Afterwards, in the job’s plots directory there is a file dens.0.cube. Do something like
head dens.0.cube
and you will see the following:
Cube file for ground state density
Generated using Q-Chem
3 -9.448631 -9.448631 -9.448631
50 0.385658 0.000000 0.000000
50 0.000000 0.385658 0.000000
50 0.000000 0.000000 0.385658
8 8.000000 -0.000000 0.000000 0.219815
1 1.000000 -1.419477 -0.000000 -0.879261
1 1.000000 1.419477 -0.000000 -0.879261
1.994675470E-36 1.767973945E-35 1.417266499E-34 1.027541167E-33 6.737813512E-33 3.995864845E-32
The first 9 lines are what I was calling the header information, contains grid information along with the locations of the nuclei. The remaining lines of the file are the values of the function (ground-state density in this case) printed out on the grid, formatted as described in the aforementioned article. (Please email me for a copy if you can’t access it.) My one-line awk script is intended to subtract these data values and actually doesn’t require you to know how they are formatted so long as you strip out the header info first (from file1.cube and file2.cube), then put it back in once you have generated “diff.cube”
Thanks a lot for your help. I shall be in touch with you.
Regards,
KB