ESP cube generation failure

Dear all,

I seem to be facing the same issue as described in this post a while ago:

i.e. that I get an “Auxiliary basis is required for ESP computations.” error when trying to write ESP cube files from a wavefunction, although I am running 1.3.2. I noticed that I can write those files when I have just computed the wavefunction, but that this error occurs when I loaded the wavefunction from file.

Example:

import psi4

xyz_str = """
8

C     -0.756352   -0.078834    0.019827
C      0.749569    0.011173   -0.076652
H     -1.192742   -0.817993   -0.659960
H     -1.139596    0.947289   -0.214959
H     -1.043422   -0.352756    1.052083
H      1.071472    0.622253   -0.951047
H      1.059241    0.618515    0.822155
H      1.251830   -0.949648    0.008553
"""

psi4.set_options({"basis": "6-31G*"})
p4mol = psi4.core.Molecule.from_string(xyz_str, dtype="xyz+", fix_com=True)
E, wfn = psi4.energy("b3lyp", return_wfn=True, molecule=p4mol)
psi4.set_options(
            {
                "cubeprop_tasks": ["ESP"],
                "cubeprop_filepath": ".",
                "cubic_grid_spacing": [1, 1, 1,],
            }, 
        )
psi4.cubeprop(wfn)
# --> writes ESP.cube to current directory as expected 

wfn.to_file(filename="./saved_wfn.npy")
wfn_loaded = psi4.core.Wavefunction.from_file("./saved_wfn.npy")
psi4.cubeprop(wfn_loaded)
# --> Fatal Error: Auxiliary basis is required for ESP computations. 
#     Error occurred in file: /Users/github/builds/conda-builds/psi4-multiout_1557977521159/work/psi4/src/psi4/libcubeprop/csg.cc on line: 319
#     The most recent 5 function calls were: (<<nothing follows>>)

Adding something like "DF_BASIS_SCF": "6-31G*" to psi4.set_options does not seem to help.

Any ideas on how to fix this would be appreciated.

Thanks and best,
Clemens

Could you try using this https://github.com/psi4/psi4/issues/1871#issuecomment-615401912 ?
wfn_loaded=

Hi Holger, thanks as always for the quick reply. As mentioned in the link, now I am getting a segfault (but not the original error anymore):

forrtl: severe (174): SIGSEGV, segmentation fault occurred
forrtl: severe (174): SIGSEGV, segmentation fault occurred
forrtl: severe (174): SIGSEGV, segmentation fault occurred
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Segmentation fault (core dumped)

OK, so I was slightly wrong. I had a look in the code and it actually needs a DF basis set.

You can get one like this:

wfn_loaded = psi4.core.Wavefunction.from_file("./saved_wfn.npy")
aux_basis = psi4.core.BasisSet.build(wfn_loaded.molecule(), "DF_BASIS_SCF",
                                        psi4.core.get_option("SCF", "DF_BASIS_SCF"),
                                        "JKFIT", psi4.core.get_global_option('BASIS'),
                                        puream=wfn_loaded.basisset().has_puream())
wfn_loaded.set_basisset("DF_BASIS_SCF", aux_basis)
psi4.cubeprop(wfn_loaded)

This should auto-selects the DF basis set, but you can set one with normal options as well.

Thanks for taking the time to write this up. Here I got the error

Validation Error: Orbital basis argument must not be empty.

which I assume relates to the third argument, as psi4.core.get_option("SCF", "DF_BASIS_SCF") returns an empty string (so does psi4.core.get_global_option("BASIS")) as I apparently have not set global options for PSI4. Can I infer those from the wavefunction object, or pass those along as arguments to the function which should convert a wavefunction file from disk to a cube-file containing the ESP?

My code was not meant to stand alone. On mobile now, but the basis set name is saved on the wfn object and you can avoid global options I think.

A complete script could look like this:

import psi4

wfn_loaded = psi4.core.Wavefunction.from_file("./saved_wfn.npy")
psi4.set_options(
            {
                "cubeprop_tasks": ["ESP"],
                "cubeprop_filepath": ".",
                "cubic_grid_spacing": [1, 1, 1,],
                "basis" : wfn_loaded.basisset().name()
            },
        )

aux_basis = psi4.core.BasisSet.build(wfn_loaded.molecule(), "DF_BASIS_SCF",
                                        psi4.core.get_option("SCF", "DF_BASIS_SCF"),
                                        "JKFIT", psi4.core.get_global_option('BASIS'),
                                        puream=wfn_loaded.basisset().has_puream())
wfn_loaded.set_basisset("DF_BASIS_SCF", aux_basis)
psi4.cubeprop(wfn_loaded)
1 Like

Hi Holger, works perfectly, thank you very much!