# How do you generate 3D electron density from fchk file without the Gaussian software?

I'm trying to reproduce some results from a paper with fchk output files containing DFT calculations. The paper details how to produce the 3D electron density using Gaussian software, but since I don't have access to the software I have been looking around various Python packages that could accomplish the same task. I tried Open Babel but got an error message "The molecule has no grid" which I assume is due to the fact that I haven't to specify the grid structure for output — not sure how to do this either.

Is there a good Python code or other tools I could use to get the 3D density?

• +1 Are you asking about plotting the electrostatic potential surfaces (like the coloured ones with blue and red) ? Jun 4 at 19:45
• You should try Multiwfn (sobereva.com/multiwfn). It can read .fchk files and get electron density, electrostatic potential surfaces etc. Then you can export that in various formats and also visualise it. Jun 5 at 9:58
• Thanks, it works like charm. All I need for now is 3D electron density for various molecules in my ML pipeline.
– cassandra
Jun 5 at 11:26
• That's great! Feel free to write an answer to your own question (It is encouraged on this site, as it would help people who search and reach this post in future) Jun 5 at 17:33
• Please include a human readable version of the citation. Please also be more specific about what you are trying to accomplish. To me it is totally unclear what the source of the formatted checkpoint file is. I am not sure whether your problem is to calculate the electron density or only to analyse it. If the question actually boils down to How to open and analyse fchk files, then it is off-topic here (cc @Shoubhik) and a better fit for Matter Modeling, where I think it would be on topic. Jun 6 at 16:40

## 3 Answers

The other answers have already covered how to generate the formatted checkpoint file (.fchk). So in my answer I will attempt to explain how to use Multiwfn to get the electron densities from the .fchk file.

First, download the software from http://sobereva.com/multiwfn/ .

Then open the MultiWfn executable, and either type in the name of the .fchk file and press enter, or press enter and then open the file through the GUI file selection interface.

If the file is loaded successfully, it should give you the message Loaded <filename> successfully!.

Then from the Main function menu, selection option 5 and press enter:

This option is for calculating parameters that have to be calculated on a 3D grid.

Then select option 1 for electron density. Then the program will ask you for the size of the grid required.

You can choose one of the inbuilt defaults (low, medium, or high quality grids). Note that grids with more points will take a longer calculation time. The paper you mentioned in the question has used a $$256\times 256\times 256$$ grid with a step size of $$0.1$$ Bohr.

If I have understood everything correctly (and I am not sure), then this is difficult to do in Multiwfn. Because in Multiwfn, you can either set the total number of grid points in each direction, or you can set the step size. This is because the program usually uses an extension distance ($$6.0$$ Bohr by default) to generate the grid. If you want to change both the number of grid points and the step size, then you might have to do some math to determine what would be the extension distance. You could try the options 5 to 10 and see if they work.

After setting the grid size, press enter, and the program will calculate the electron density of the file.

You can press -1 to see the isosurface graph. Select option 2 to save the electron density as a cube file in the folder (by default it saves the file as density.cub. And that's the cube file you need.

However, in the paper, they use cubman utility of Gaussian to get the difference in the electron densities between two cube files (for the same molecule calculated with different methods). Multiwfn can also do this.

It doesn't need to be said that the two cube files must have the same molecule and the exact same grid parameters, otherwise the calculation wouldn't run.

So, you need two cube files in the folder, like density1.cub and density2.cub.

Open Multiwfn and open one cube file. Select option 13 i.e. "Process grid data".

Then select 11 for "Grid data calculation".

Then you will be to see options for subtracting a grid file from the current grid file. (I believe the subtraction option is the one which is required, but I am not entirely sure about how Gaussian's cubman works, and how cube files store data, so please check if it's a simple subtract or a square subtract)

Select 4 to subtract a grid file. The program will ask you for the other grid file. (Note that which is subtracted from which depends on which file you loaded first)

Here, you have to type in the name of the other cube file, say density2.cub. Press enter, and if the calculation was successful, then you will see the message Done, grid data has been updated. If the grid sizes are different it will throw an error.

Then press 0 to save the current grid data to a cube file. Enter the name of the new file, and the difference in electron densities will be saved to that. In the paper the researchers did some further calculations from this point using their own C++ programs.

The advantage of this method is that this isn't restricted to just .fchk files from Gaussian. Multiwfn can open output files from many other programs like GAMESS, Orca etc. So, you can use the output of those programs to do this calculation. Note that the program needs the full SCF solution and the basis set data to calculate the density so those need to be in the file that you are opening.

• It looks like the last part of your answer was cutoff.
– Tyberius
Jun 11 at 19:16

If you need to generate fchk files for other molecules, note that you can do this with a variety of quantum chemistry programs. In addition to Gaussian, also Q-Chem, Psi4, and my ERKALE program can do this for you, the last two being freely available open-source programs.

For generating grid data from a fchk file, there is again a number of packages available for this purpose; e.g. my ERKALE program has a special tool for generating cube files but I am sure many others do as well; e.g. IQmol and Avogadro can both be used to visualize e.g. molecular orbital and electron densities directly from fchk files.

.fchk are known as formatted checkpoint file, a proprietary file format used by GAUSSIAN software where the results of a calculation are saved.

To obtain .fchk files, first, you need to have access to a licensed version of GAUSSIAN. It will produce a checkpoint file, .chk (checkpoint file in binary form). Then, you need to use an utility software called formchk (distributed with GAUSSIAN) to convert from .chk to .fchk [1]:

formchk [options] chkpt-file [formatted-file]


Answering your question:

How do you generate 3D electron density from fchk file without the Gaussian software?

Without GAUSSIAN, you cannot generate .chk either .fchk.

Other question could be: If I already own a .fchk, how do I plot the 3D electron density? (supposing that the .fchk file was generated accordingly).

For this question, some answers could be:

• Using the MULTIWFN package (as already commented by @Shoubhik R Maiti).
• Using Jmol package (site)
• I think Gaussian owners can't actually prohibit people creating or using their own data because it's saved to fchk, just like Microsoft can't prohibit LibreOffice saving files in .doc. At most they could do like Microsoft, and make their file formats horribly complex, full of glitches and corner cases and so hard to implement correctly. As @SusiLehtola pinted, some packages can save to fchk as well. Jun 11 at 1:31