"Engine::lmax_exceeded -- angular momentum limit exceeded" during optimization

I’m trying to optimize the geometry of some simple metal carbonyls (e.g., MoCO6) by DFT but psi4 stops and throws the Engine::lmax_exceeded -- angular momentum limit exceeded error after the first SCF calculation converges but before the second step of the optimization begins. The program runs as expected if asking just for the energy.

I’ve attached the output of one of these failed runs. But here is the input:

with open('MoCO6_orca.xyz') as f:
        MoCO6_xyz = f.read()

MoCO6 =  psi4.core.Molecule.from_string(MoCO6_xyz, dtype='xyz')
mol = MoCO6

memory 32 GB
set reference rks
basis {
        assign def2-svp

E_revpbe = optimize('bp86')

and the error message:

Traceback (most recent call last):
  File "/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx2/MPI/intel2020/openmpi4/psi4/1.4/bin/psi4", line 333, in <module>
  File "<string>", line 32, in <module>
  File "/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx2/MPI/intel2020/openmpi4/psi4/1.4/lib//python3.9/site-packages/psi4/driver/driver.py", line 1339, in optimize
    G, wfn = gradient(lowername, return_wfn=True, molecule=moleculeclone, **kwargs)
  File "/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx2/MPI/intel2020/openmpi4/psi4/1.4/lib//python3.9/site-packages/psi4/driver/driver.py", line 739, in gradient
    wfn = procedures['gradient'][lowername](lowername, molecule=molecule, **kwargs)
  File "/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx2/MPI/intel2020/openmpi4/psi4/1.4/lib//python3.9/site-packages/psi4/driver/procrouting/proc.py", line 2494, in run_scf_gradient
    grad = core.scfgrad(ref_wfn)

RuntimeError: Engine::lmax_exceeded -- angular momentum limit exceeded

Printing out the relevant lines from the Psithon --> Python processed input file:
        basstrings = {}
        mol.set_basis_all_atoms("def2-svp", role=role)
        return basstrings
    qcdb.libmintsbasisset.basishorde['ANONYMOUS642F11AF'] = basisspec_psi4_yo__anonymous642f11af
    core.set_global_option("BASIS", "anonymous642f11af")
--> E_revpbe = optimize('bp86')

!                                                           !
!  Engine::lmax_exceeded -- angular momentum limit exceeded !
!                                                           !

This occurs with the def2-SVP and LANL2DZ basis sets and is agnostic of the density functional (e.g., BLYP, BP86, revPBE).

I’m running psi4 v1.4 installed from source on the Compute Canada Cedar cluster. I’m not sure of the exact build configuration, but could ask for details if needed. libint is not explicitly loaded so I’m also not sure if it is the issue (like previous old posts on these forums).

The maximum angular momentum is determined at the build time for the libint2 library.
The default is MAX_AM_ERI=5 which does not seem enough for the gradient using default aux.basis set.

You have 2 options, I think. Build psi4 with -DMAX_AM_ERI=6 or delete the highest angular momentum from the aux.basis set (you dont need them for a DZ basis set).

I will ask the admin team if we can build psi4 with a higher AM value. If I wanted to go up to quadruple-zeta quality basis sets, would I need MAX_AM_ERI=7?

With respect to the behaviour I’m seeing, if the issue was with the maximum AM allowed from build options, how come psi4 completes one optimization cycle (i.e., one single-point calculation) but then crashes when setting up the second? It shouldn’t be able to run either if that were the case.

Deleting the higher angular momentum functions from the basis set may be a workaround, but then I would be limited to small bases on the metals. Generally, I’d like to be able to use larger basis sets on the metals to get the best possible energies (i.e., quadruple-zeta if not higher).

(Apparently I am not allowed to attach the output file, even though I forgot to anyway in the OP. Please let me know if you need specific details.)

The output file looks like it completes an energy but crashes when trying to take the energy gradient. Energy gradients require one more AM than the energy.

I see. That makes sense and clears things up. I’ll mark this as solved and talk to admin about rebuilding it to allow for higher functions.
Thank you!!

-DMAX_AM_ERI=7 is fine. Larger than that should not be necessary and would require some tweaking in fact.

There is a pre-generated libint2 for AM=7 so compilation time should not be an issue:

This file also contains the rather complicated details of the libint2 setup.