Could Not Converge Geometry Optimization

Sulstice
3 min readFeb 6, 2024

--

Ah, this error. Means a lot to me as it’s my primary morning message from last night’s molecule set. After years of facing this error here are a couple of things I have tried to get to converge. I’ll update as I go a long.

Full Optimization Code:

import psi4

psi4.core.set_num_threads(12)
psi4.set_memory('12000mb')
psi4.set_options({
'scf_type': 'df',
'g_convergence': 'gau_tight',
'freeze_core': 'true',
'reference': 'rhf'
})


def optimizer(zmatrix, name):

universe = psi4.geometry(zmatrix)
universe.update_geometry()

psi4.core.set_output_file('%s.out' % name, False)

try:
psi4.optimize(
'mp2/aug-cc-pvdz',
molecule=universe
)
except:
psi4.optimize(
'hf/6-31g*',
molecule=universe
)
universe.update_geometry()
universe.print_in_input_format()

methanol_zmatrix = '''\
O11
H11 O11 0.9657
C11 O11 1.4349 H11 126.2746
H12 C11 1.1029 O11 111.8699 H11 0.0000
H13 C11 1.1029 O11 111.8699 H11 190.9683
H14 C11 1.1029 O11 111.8699 H11 -118.5158
X11 O11 1.0000 H11 90.0000 C11 180.0000
0 1
'''

#1: Bad Coordinates

Check the coordinates are actually what you think and not some odd geometry. For example, a z-matrix of methanol that looks like this:

O11
H11 O11 0.9657
C11 O11 1.4349 H11 126.2746
H12 C11 1.1029 O11 111.8699 H11 0.0000
H13 C11 1.1029 O11 111.8699 H11 190.9683
H14 C11 1.1029 O11 111.8699 H11 -118.5158
X11 O11 1.0000 H11 90.0000 C11 180.0000
0 1

Produces this:

If we fix the z-matrix on the dihedral angle:

O11
H11 O11 0.9657
C11 O11 1.4349 H11 126.2746
H12 C11 1.1029 O11 111.8699 H11 0.0000
H13 C11 1.1029 O11 111.8699 H11 122.9683
H14 C11 1.1029 O11 111.8699 H11 -118.5158
X11 O11 1.0000 H11 90.0000 C11 180.0000
0 1

Then we fix our molecule:

#2: Allow the Force Around the Atoms to be more Flexible

Figure Abstracted From L.-P. Wang and C. Song, J. Chem. Phys. 144, 214108 (2016).

Meaning in my existing configuration it can be gau or gau_loose allowing more “wiggle” room:

psi4.set_options({
'g_convergence': 'gau',
})

#3: Switch your level of theory and basis set

In the code, I am finding convergence with mp2 that includes the electron correlation. This might be difficult to converge if there is a lot of interactions and dispersion effects where you might have to fall back to a lower level of theory hartree-fock . The same argument can be made for the basis set. I rope the two in a try and except block as a fallback for the convergence.

try:
psi4.optimize(
'mp2/aug-cc-pvdz',
molecule=universe
)
except:
psi4.optimize(
'hf/6-31g*',
molecule=universe
)

Try not to use STO because it’s known as a not as accurate as you may think in terms of finding the true minimum since it’s orbital sets are low.

--

--

Sulstice
Sulstice

No responses yet