When running the following code, the geometry optimization for Li4 fails due to an UnboundLocalError.
I am using psi4 as a python module with
python 3.12.8
psi4 1.9.1
import psi4
#psi4.set_memory('800 MB')
Li2 = psi4.geometry("""
Li -2.04006 -0.01759 -0.00000
Li 1.04348 -0.01759 0.00000
""")
psi4.set_options({'reference': 'rhf'})
psi4.optimize('scf/6-311G*', molecule=Li2)
Li4 = psi4.geometry("""
Li -1.77550 0.22110 0.00000
Li -0.12630 2.35160 0.00000
Li 0.77100 -0.18870 0.00000
Li -0.87810 -2.31930 0.00000
""")
psi4.energy('scf/6-311G*')
psi4.optimize('scf/6-311G*', molecule=Li4)
The energy calculation and geometry optimization for Li2 work and the energy calculation for Li4 works, but at the very beginning of the geometry optimization I get following error:
Traceback (most recent call last):
File "... ./test.py", line 21, in <module>
psi4.optimize('scf/6-311G*', molecule=Li4)
File "... /lib/python3.12/site-packages/psi4/driver/driver.py", line 1212, in optimize
opt_object = optking.opt_helper.CustomHelper(molecule, params=optimizer_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/ ... /lib/python3.12/site-packages/optking/opt_helper.py", line 400, in __init__
self.build_coordinates()
File "... /lib/python3.12/site-packages/optking/opt_helper.py", line 147, in build_coordinates
make_internal_coords(self.molsys, self.params)
File ".../lib/python3.12/site-packages/optking/optimize.py", line 664, in make_internal_coords
o_molsys.fragments[0].add_intcos_from_connectivity(connectivity)
File "... /lib/python3.12/site-packages/optking/frag.py", line 146, in add_intcos_from_connectivity
addIntcos.add_intcos_from_connectivity(connectivity, self._intcos, self._geom)
File "... /lib/python3.12/site-packages/optking/addIntcos.py", line 136, in add_intcos_from_connectivity
add_oofp_from_connectivity(C, intcos, geom)
File "... lib/python3.12/site-packages/optking/addIntcos.py", line 409, in add_oofp_from_connectivity
if errors:
^^^^^^
UnboundLocalError: cannot access local variable 'errors' where it is not associated with a value
The only similar topic I found is Optimizing a P4 molecule causes error "local variable 'errors'..." . Unfortunately, because of particular reasons, I cannot change any code in the psi4 python package. Is there another workaround?
Similar issues arise with other molecules as well.