Frequencies: "returned NULL without setting an error"

I have been trying to implement the frequency function into my code but the goal is to have the frequency be part of the optimization function parameters if that is possible. However, in python, I have followed a similar style for inputs as psi4.energy and psi4.optimize functions but my frequency function is not working after around 2 hours of trying to fix it. Thank you for the help.

import numpy as np
import pandas as pd
import psi4
import matplotlib.pyplot as plt
import qcelemental as qcel
psi4.set_memory(1.267e11)
psi4.set_num_threads(32)
psi4.set_output_file('BenzeneFreq.dat', True)
psi4.set_options({
    'geom_maxiter': 100
})
benzene = psi4.geometry("""
0 1
  C   -3.2575983    1.7216438    0.0000000
  C   -3.2985531    0.3232005    0.0000000
  C   -2.0260332    2.3853977   -0.0000000
  C   -0.8354231    1.6507079   -0.0000000
  C   -0.8763782    0.2522646   -0.0000000
  C   -2.1079431   -0.4114892    0.0000000
  H   -4.1786881    2.2900201    0.0000000
  H   -4.2513263   -0.1902984    0.0000000
  H   -1.9943487    3.4672729   -0.0000000
  H    0.1173503    2.1642064   -0.0000000
  H    0.0447112   -0.3161121   -0.0000000
  H   -2.1396273   -1.4933642    0.0000000 
units angstrom 
""")
psi4.core.set_global_option('cubeprop_tasks',['frontier_orbitals'])
E, wfn = psi4.optimize("B3LYP-D3/6-31G(d,p)", molecule = benzene,  return_wfn=True)
psi4.frequency("B3LYP-D3/6-31G(d,p)", molecule = benzene)
psi4.cubeprop(wfn)

Output:

Optimizer: Optimization complete!
---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
 in 
      1 psi4.core.set_global_option('cubeprop_tasks',['frontier_orbitals'])
      2 psi4.optimize("B3LYP-D3/6-31G(d,p)", molecule = polymer, return_wfn=True)
----> 3 b3lyp_e, b3lyp_wfn = psi4.frequency("B3LYP-D3/6-31G(d,p)", molecule = polymer)
      4 psi4.wfn.frequencies.get(0)
      5 ##E, wfn = psi4.frequencies("B3LYP-D3/6-31G(d,p)", molecule = polymer, return_efn = True)

~/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver.py in frequency(name, **kwargs)
   1462 
   1463     # Compute the hessian
-> 1464     H, wfn = hessian(name, return_wfn=True, molecule=molecule, **kwargs)
   1465 
   1466     # Project final frequencies?

~/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver.py in hessian(name, **kwargs)
   1204     # Check if this is a CBS extrapolation
   1205     elif gradient_type == "cbs_gufunc":
-> 1206         return driver_cbs._cbs_gufunc(hessian, name.lower(), **kwargs, ptype="hessian")
   1207     elif gradient_type == "cbs_wrapper":
   1208         return driver_cbs.cbs(hessian, "cbs", **kwargs, ptype="hessian")

~/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver_cbs.py in _cbs_gufunc(func, total_method_name, **kwargs)
   1947         optstash = p4util.OptionsState(['BASIS'])
   1948         core.set_global_option('BASIS', basis)
-> 1949         ptype_value, wfn = func(method_name, return_wfn=True, molecule=molecule, **kwargs)
   1950         core.clean()
   1951 

~/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver.py in hessian(name, **kwargs)
   1283 
   1284         # Obtain list of displacements
-> 1285         findif_meta_dict = driver_findif.hessian_from_gradient_geometries(molecule, irrep)
   1286 
   1287         # Record undisplaced symmetry for projection of displaced point groups

~/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver_findif.py in hessian_from_gradient_geometries(molecule, irrep)
    889         Dictionary of finite difference data, specified in _geom_generator docstring.
    890     """
--> 891     return _geom_generator(molecule, irrep, "2_1")
    892 
    893 

~/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver_findif.py in _geom_generator(mol, freq_irrep_only, mode)
    338         mol = core.Molecule.from_dict(mol.to_dict())
    339 
--> 340     data = _initialize_findif(mol, freq_irrep_only, mode, init_string, 1)
    341 
    342     # We can finally start generating displacements.

~/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver_findif.py in _initialize_findif(mol, freq_irrep_only, mode, initialize_string, verbose)
    168 
    169     # Populate salc_indices_pi for all irreps.
--> 170     for i, salc in enumerate(salc_list):
    171         salc_indices_pi[salc.irrep_index()].append(i)
    172 

SystemError:  returned NULL without setting an error

Please read our guidelines on posting help topics.

What version of Psi4 are you using? How are you running this file - through a Jupyter notebook?

I am running the code in vscode which is using Python3.8.2 with a local Jupyter server. I have just recently updated to the newest psi4 version available using conda update psi4 -c psi4

This is a known issue that is fixed in the developer version of Psi4.

You have four options to get around this bug:

  1. Wait for Psi4 1.4.
  2. Don’t use Jupyter - the bug only triggers there.
  3. Use a version of Psi4 where the bug is fixed, like the nightly build
  4. Manually apply the changes from here into ~/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver_findif.py The line numbers won’t be exactly the same, mind you.

Thank you very much for the help

I have done the same format for the input file and have disabled jupyter, however, the error output after is now

SystemError                               Traceback (most recent call last)
<ipython-input-6-eb019fe439d9> in <module>
      1 psi4.core.set_global_option('cubeprop_tasks',['frontier_orbitals'])
      2 psi4.optimize("B3LYP-D3/6-31G(d,p)", molecule = polymer, return_wfn=True)
----> 3 E, wfn = psi4.frequency("B3LYP-D3/6-31G(d,p)", molecule = polymer)
      4 psi4.wfn.frequencies.get(0)
      5 ##E, wfn = psi4.frequencies("B3LYP-D3/6-31G(d,p)", molecule = polymer, return_efn = True)

~/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver.py in frequency(name, **kwargs)
   1462 
   1463     # Compute the hessian
-> 1464     H, wfn = hessian(name, return_wfn=True, molecule=molecule, **kwargs)
   1465 
   1466     # Project final frequencies?

~/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver.py in hessian(name, **kwargs)
   1204     # Check if this is a CBS extrapolation
   1205     elif gradient_type == "cbs_gufunc":
-> 1206         return driver_cbs._cbs_gufunc(hessian, name.lower(), **kwargs, ptype="hessian")
   1207     elif gradient_type == "cbs_wrapper":
   1208         return driver_cbs.cbs(hessian, "cbs", **kwargs, ptype="hessian")

~/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver_cbs.py in _cbs_gufunc(func, total_method_name, **kwargs)
   1947         optstash = p4util.OptionsState(['BASIS'])
   1948         core.set_global_option('BASIS', basis)
-> 1949         ptype_value, wfn = func(method_name, return_wfn=True, molecule=molecule, **kwargs)
   1950         core.clean()
   1951 

~/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver.py in hessian(name, **kwargs)
   1283 
   1284         # Obtain list of displacements
-> 1285         findif_meta_dict = driver_findif.hessian_from_gradient_geometries(molecule, irrep)
   1286 
   1287         # Record undisplaced symmetry for projection of displaced point groups

~/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver_findif.py in hessian_from_gradient_geometries(molecule, irrep)
    889         Dictionary of finite difference data, specified in _geom_generator docstring.
    890     """
--> 891     return _geom_generator(molecule, irrep, "2_1")
    892 
    893 

~/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver_findif.py in _geom_generator(mol, freq_irrep_only, mode)
    338         mol = core.Molecule.from_dict(mol.to_dict())
    339 
--> 340     data = _initialize_findif(mol, freq_irrep_only, mode, init_string, 1)
    341 
    342     # We can finally start generating displacements.

~/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver_findif.py in _initialize_findif(mol, freq_irrep_only, mode, initialize_string, verbose)
    168 
    169     # Populate salc_indices_pi for all irreps.
--> 170     for i, salc in enumerate(salc_list):
    171         salc_indices_pi[salc.irrep_index()].append(i)
    172 

SystemError: <built-in method __next__ of PyCapsule object at 0x7fc5dc2391b0> returned NULL without setting an error

Again, read our guidelines on posting topics. If absolutely nothing else, you need to enclose long blocks of code and error messages in blockquotes.

How are you running this file? Are you calling it as a pure Python script, or something else?

Sorry about that, I didn’t know how to do formatting for the block quotes.

I am running a ipynb file through python 3.8 in vscode. I also tried running it as a py file but came across the same error

I’m quite surprised to hear that. Can you give me the traceback when you run your script as a .py file? I want to be absolutely sure that you are getting the same error.

Sorry for the late reply, classes have not been friendly.

Input

import numpy as np
import pandas as pd
import psi4
import matplotlib.pyplot as plt
import qcelemental as qcel
psi4.set_memory(1.267e11)
psi4.set_num_threads(32)
psi4.set_output_file(‘CubepropTrials.dat’, True)
psi4.set_options({
‘geom_maxiter’: 100
})
polymer = psi4.geometry("""
0 1
C -3.2575983 1.7216438 0.0000000
C -3.2985531 0.3232005 0.0000000
C -2.0260332 2.3853977 -0.0000000
C -0.8354231 1.6507079 -0.0000000
C -0.8763782 0.2522646 -0.0000000
C -2.1079431 -0.4114892 0.0000000
H -4.1786881 2.2900201 0.0000000
H -4.2513263 -0.1902984 0.0000000
H -1.9943487 3.4672729 -0.0000000
H 0.1173503 2.1642064 -0.0000000
H 0.0447112 -0.3161121 -0.0000000
H -2.1396273 -1.4933642 0.0000000
units angstrom
“”")
psi4.core.set_global_option(‘cubeprop_tasks’,[‘frontier_orbitals’])
psi4.frequency(“B3LYP-D3/6-31G(d,p)”, molecule = polymer, return_wfn=True)
##E, wfn = psi4.frequency(“B3LYP-D3/6-31G(d,p)”, molecule = polymer)
##psi4.wfn.frequencies.get(0)
##E, wfn = psi4.frequencies(“B3LYP-D3/6-31G(d,p)”, molecule = polymer, return_efn = True)
psi4.cubeprop(wfn)

Output

Memory set to 117.999 GiB by Python driver.
Threads set to 32 by Python driver.
Traceback (most recent call last):
File “tester.py”, line 29, in
psi4.frequency(“B3LYP-D3/6-31G(d,p)”, molecule = polymer, return_wfn=True)
File “/home/jman/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver.py”, line 1464, in frequency
H, wfn = hessian(name, return_wfn=True, molecule=molecule, **kwargs)
File “/home/jman/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver.py”, line 1206, in hessian
return driver_cbs._cbs_gufunc(hessian, name.lower(), **kwargs, ptype=“hessian”)
File “/home/jman/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver_cbs.py”, line 1949, in _cbs_gufunc
ptype_value, wfn = func(method_name, return_wfn=True, molecule=molecule, **kwargs)
File “/home/jman/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver.py”, line 1285, in hessian
findif_meta_dict = driver_findif.hessian_from_gradient_geometries(molecule, irrep)
File “/home/jman/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver_findif.py”, line 891, in hessian_from_gradient_geometries
return _geom_generator(molecule, irrep, “2_1”)
File “/home/jman/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver_findif.py”, line 340, in _geom_generator
data = _initialize_findif(mol, freq_irrep_only, mode, init_string, 1)
File “/home/jman/miniconda3/envs/research/lib/python3.7/site-packages/psi4/driver/driver_findif.py”, line 170, in _initialize_findif
for i, salc in enumerate(salc_list):
SystemError: <built-in method next of PyCapsule object at 0x7fedab55c150> returned NULL without setting an error

Huh, that is not what I expected.

In that case, strike option 2 from my previous post. Options 1, 3, and 4 stand.