Convergence error caught: Could not converge geometry optimization in 500 iterations

I find it is hard to converge for the geometry optimization for most cation and anion pairs even with 500 iterations. I have met this issues for most of the ionic liquids. This is one example smile structure “CC[N+]1(C)CCCCC1.[O-]S(=O)(C(F)(F)C(F)F)=O”.

I am using the rdkit and psikit. I have tried many ways to tune the options as shown in the code. Can anyone help me with this issue?

sml = “CC[N+]1(C)CCCCC1.[O-]S(=O)(C(F)(F)C(F)F)=O”
pk = Psikit()
pk.read_from_smiles(sml)|
energy = pk.optimize( “scf/6-311pg**”)

The modified optimize function in psikit module

def optimize(self, basis_sets= "scf/6-311pg**", return_wfn=True, name=None, multiplicity=1, maxiter=500,
             opt_coordinates = "cartesian"):
    if not name:
        name = uuid.uuid4().hex
    self.psi4.core.IO.set_default_namespace(name)
    self.geometry(multiplicity=multiplicity)
    self.psi4.set_options({'GEOM_MAXITER':maxiter,
                           'opt_coordinates': opt_coordinates,
                           #'BASIS_GUESS': True,
                           #'DAMPING_CONVERGENCE': 60,
                           #'D_CONVERGENCE': 0.000001,
                           #'E_CONVERGENCE': 0.000001
                           })
    try:
        #Geometry optimization
        print("The basis set is ", basis_sets)
        scf_energy, wfn = self.psi4.optimize(basis_sets, return_wfn=return_wfn)
        self.wfn = wfn
        #scf_e, scf_wfn = self.psi4.frequency(basis_sets,  return_wfn=True, ref_gradient=self.wfn.gradient())
        #print(scf_wfn.frequencies().get(0, 0))

    except self.psi4.OptimizationConvergenceError as cError:
        print('Convergence error caught: {0}'.format(cError))
        self.wfn = cError.wfn
        scf_energy = self.wfn.energy()
        self.psi4.core.clean()
    self.mol = self.xyz2mol()

    if not self.debug:
        self.psi4.core.opt_clean() # Seg fault will occured when the function is called before optimize.
    return scf_energy

What Psi version are you using?

print(psi4.version)
1.7a1.dev44

I am trying to calculate the binding energy of a cation and anion, which is the optimized energy of the pair minus of the optimized cation and anion. However, I either get the convergence error, or get positive binding energy, which is apparently not possible, since the binding energy of the cation anion pair should be negative for the attractive interaction between them. I need to getting back to the response of a paper under review. Thanks a lot!

I need the entire conda list - Psikit refuses to install on my Python 3.9 installation.

packages in environment at /home/ywang/.conda/envs/p4env:

Name Version Build Channel

_libgcc_mutex 0.1 main
_openmp_mutex 5.1 1_gnu
_py-xgboost-mutex 2.0 cpu_0
ambit 0.6 py310h53dec33_2 psi4/label/dev
anyio 3.6.1 pypi_0 pypi
argon2-cffi 21.3.0 pypi_0 pypi
argon2-cffi-bindings 21.2.0 pypi_0 pypi
asgiref 3.5.2 pypi_0 pypi
asttokens 2.0.8 pypi_0 pypi
attrs 21.4.0 pyhd3eb1b0_0
backcall 0.2.0 pypi_0 pypi
beautifulsoup4 4.11.1 pypi_0 pypi
blas 1.0 mkl
bleach 5.0.1 pypi_0 pypi
brotlipy 0.7.0 py310h5764c6d_1004 conda-forge
bzip2 1.0.8 h7b6447c_0
ca-certificates 2022.12.7 ha878542_0 conda-forge
cairocffi 1.4.0 pypi_0 pypi
cairosvg 2.5.2 pypi_0 pypi
certifi 2022.12.7 pyhd8ed1ab_0 conda-forge
cffi 1.15.1 py310h74dc2b5_0
charset-normalizer 2.1.1 pyhd8ed1ab_0 conda-forge
chemps2 1.8.11 hbe8a562_0 psi4/label/dev
cryptography 3.4.8 py310h685ca39_1 conda-forge
cssselect2 0.7.0 pypi_0 pypi
cudatoolkit 11.1.1 ha002fc5_10 conda-forge
debtcollector 2.5.0 pypi_0 pypi
debugpy 1.6.3 pypi_0 pypi
decorator 5.1.1 pypi_0 pypi
defusedxml 0.7.1 pypi_0 pypi
dftd3 3.2.1 h84218bc_2 psi4/label/dev
django 4.1.3 pypi_0 pypi
dkh 1.2 h173d85e_2 psi4/label/dev
entrypoints 0.4 pypi_0 pypi
et-xmlfile 1.1.0 pypi_0 pypi
executing 1.1.1 pypi_0 pypi
fastjsonschema 2.16.2 pypi_0 pypi
ffmpeg 4.3 hf484d3e_0 pytorch
freetype 2.10.4 h0708190_1 conda-forge
gau2grid 2.0.7 hd18ef5c_0 psi4/label/dev
gcp 2.0.2 he991be0_2 psi4/label/dev
gdma 2.2.6 h0e1e685_6 psi4/label/dev
giflib 5.2.1 h36c2ea0_2 conda-forge
gmp 6.2.1 h58526e2_0 conda-forge
gnutls 3.6.13 h85f3911_1 conda-forge
hdf5 1.10.6 hb1b8bf9_0
idna 3.4 pyhd8ed1ab_0 conda-forge
importlib-metadata 4.11.3 py310h06a4308_0
importlib_metadata 4.11.3 hd3eb1b0_0
importlib_resources 5.2.0 pyhd3eb1b0_1
iniconfig 1.1.1 pyhd3eb1b0_0
intel-openmp 2021.4.0 h06a4308_3561
ipykernel 6.16.0 pypi_0 pypi
ipython 8.5.0 pypi_0 pypi
ipython-genutils 0.2.0 pypi_0 pypi
ipywidgets 8.0.2 pypi_0 pypi
jedi 0.18.1 pypi_0 pypi
jinja2 3.1.2 pypi_0 pypi
joblib 1.1.1 py310h06a4308_0
jpeg 9e h166bdaf_1 conda-forge
jsonschema 4.16.0 pypi_0 pypi
jupyter 1.0.0 pypi_0 pypi
jupyter-client 7.4.2 pypi_0 pypi
jupyter-console 6.4.4 pypi_0 pypi
jupyter-core 4.11.1 pypi_0 pypi
jupyter-server 1.21.0 pypi_0 pypi
jupyterlab-pygments 0.2.2 pypi_0 pypi
jupyterlab-widgets 3.0.3 pypi_0 pypi
lame 3.100 h7f98852_1001 conda-forge
lcms2 2.12 hddcbb42_0 conda-forge
ld_impl_linux-64 2.38 h1181459_1
lerc 3.0 h9c3ff4c_0 conda-forge
libdeflate 1.8 h7f8727e_5
libecpint 1.0.7 hfebba4c_0 psi4/label/dev
libffi 3.3 he6710b0_2
libgcc-ng 11.2.0 h1234567_1
libgfortran-ng 7.5.0 ha8ba4b0_17
libgfortran4 7.5.0 ha8ba4b0_17
libgomp 11.2.0 h1234567_1
libiconv 1.17 h166bdaf_0 conda-forge
libint2 2.7.1 h2fe1556_15 psi4/label/dev
libpng 1.6.37 hbc83047_0
libstdcxx-ng 11.2.0 h1234567_1
libtiff 4.4.0 hecacb30_0
libuuid 1.0.3 h7f8727e_2
libwebp 1.2.4 h11a3e52_0
libwebp-base 1.2.4 h5eee18b_0
libxc 5.1.5 h84b9e52_1 psi4/label/dev
libxgboost 1.5.0 h6a678d5_2
lz4-c 1.9.3 h9c3ff4c_1 conda-forge
markupsafe 2.1.1 pypi_0 pypi
matplotlib-inline 0.1.6 pypi_0 pypi
mistune 2.0.4 pypi_0 pypi
mkl 2021.4.0 h06a4308_640
mkl-service 2.4.0 py310h7f8727e_0
mkl_fft 1.3.1 py310hd6ae3a3_0
mkl_random 1.2.2 py310h00e6091_0
msgpack-python 1.0.3 py310hd09550d_0
nbclassic 0.4.5 pypi_0 pypi
nbclient 0.7.0 pypi_0 pypi
nbconvert 7.2.1 pypi_0 pypi
nbformat 5.7.0 pypi_0 pypi
ncurses 6.3 h5eee18b_3
nest-asyncio 1.5.6 pypi_0 pypi
nettle 3.6 he412f7d_0 conda-forge
networkx 2.8.4 py310h06a4308_0
notebook 6.5.1 pypi_0 pypi
notebook-shim 0.2.0 pypi_0 pypi
numpy 1.21.5 py310h1794996_3
numpy-base 1.21.5 py310hcba007f_3
nvidia-cublas-cu11 11.10.3.66 pypi_0 pypi
nvidia-cuda-nvrtc-cu11 11.7.99 pypi_0 pypi
nvidia-cuda-runtime-cu11 11.7.99 pypi_0 pypi
nvidia-cudnn-cu11 8.5.0.96 pypi_0 pypi
openh264 2.1.1 h4ff587b_0
openpyxl 3.0.10 pypi_0 pypi
openssl 1.1.1s h7f8727e_0
packaging 21.3 pyhd3eb1b0_0
pandas 1.5.0 pypi_0 pypi
pandocfilters 1.5.0 pypi_0 pypi
parso 0.8.3 pypi_0 pypi
pcmsolver 1.2.1.1 py310h92d4acf_3 psi4/label/dev
pexpect 4.8.0 pypi_0 pypi
pickleshare 0.7.5 pypi_0 pypi
pillow 9.2.0 pypi_0 pypi
pint 0.17 pyhd8ed1ab_0 psi4/label/dev
pip 22.2.2 py310h06a4308_0
pluggy 1.0.0 py310h06a4308_1
prometheus-client 0.15.0 pypi_0 pypi
prompt-toolkit 3.0.31 pypi_0 pypi
psi4 1.7a1.dev44+2792bff py310hba79491_0 psi4/label/dev
psikit 0.2.0 pypi_0 pypi
psutil 5.9.0 py310h5eee18b_0
ptyprocess 0.7.0 pypi_0 pypi
pure-eval 0.2.2 pypi_0 pypi
py 1.11.0 pyhd3eb1b0_0
py-cpuinfo 8.0.0 pyhd3eb1b0_1
py-xgboost 1.5.0 py310h06a4308_2
pycparser 2.21 pyhd8ed1ab_0 conda-forge
pydantic 1.9.0 py310h7f8727e_1
pygments 2.13.0 pypi_0 pypi
pyopenssl 20.0.1 pyhd8ed1ab_0 conda-forge
pyparsing 3.0.9 py310h06a4308_0
pyrsistent 0.18.1 pypi_0 pypi
pysocks 1.7.1 pyha2e5f31_6 conda-forge
pytest 7.1.2 py310h06a4308_0
python 3.10.6 haa1d7c7_0
python-dateutil 2.8.2 pypi_0 pypi
python_abi 3.10 2_cp310 conda-forge
pytorch 1.13.0 py3.10_cpu_0 pytorch
pytorch-mutex 1.0 cpu pytorch
pytz 2022.5 pypi_0 pypi
pyyaml 6.0 pypi_0 pypi
pyzmq 24.0.1 pypi_0 pypi
qcelemental 0.25.0 pyhd8ed1ab_0 psi4/label/dev
qcengine 0.24.1 pyhd8ed1ab_0 psi4/label/dev
qtconsole 5.3.2 pypi_0 pypi
qtpy 2.2.1 pypi_0 pypi
rdkit 2022.3.5 pypi_0 pypi
readline 8.1.2 h7f8727e_1
requests 2.28.1 pyhd8ed1ab_1 conda-forge
scikit-learn 1.2.0 pypi_0 pypi
scipy 1.7.3 py310hfa59a62_0
send2trash 1.8.0 pypi_0 pypi
setuptools 63.4.1 py310h06a4308_0
simint 0.7 h642920c_1 psi4/label/dev
six 1.16.0 pyhd3eb1b0_1
sklearn 0.0.post1 pypi_0 pypi
sniffio 1.3.0 pypi_0 pypi
soupsieve 2.3.2.post1 pypi_0 pypi
sqlite 3.39.3 h5082296_0
sqlparse 0.4.3 pypi_0 pypi
stack-data 0.5.1 pypi_0 pypi
terminado 0.16.0 pypi_0 pypi
threadpoolctl 2.2.0 pyh0d69192_0
tinycss2 1.2.1 pypi_0 pypi
tk 8.6.12 h1ccaba5_0
tomli 2.0.1 py310h06a4308_0
torch 1.13.0 pypi_0 pypi
torch-geometric 2.2.0 pypi_0 pypi
torch-scatter 2.1.0 pypi_0 pypi
torch-sparse 0.6.9 pypi_0 pypi
torchaudio 0.13.0 py310_cpu pytorch
torchvision 0.14.0 py310_cpu pytorch
tornado 6.2 pypi_0 pypi
tqdm 4.64.1 pypi_0 pypi
traitlets 5.5.0 pypi_0 pypi
typing-extensions 4.3.0 py310h06a4308_0
typing_extensions 4.3.0 py310h06a4308_0
tzdata 2022e h04d1e81_0
urllib3 1.26.13 pyhd8ed1ab_0 conda-forge
wcwidth 0.2.5 pypi_0 pypi
webencodings 0.5.1 pypi_0 pypi
websocket-client 1.4.1 pypi_0 pypi
wheel 0.37.1 pyhd3eb1b0_0
widgetsnbextension 4.0.3 pypi_0 pypi
wrapt 1.14.1 pypi_0 pypi
xgboost 1.5.0 py310h06a4308_2
xz 5.2.6 h5eee18b_0
yaml 0.2.5 h7b6447c_0
zipp 3.8.0 py310h06a4308_0
zlib 1.2.12 h5eee18b_3
zstd 1.5.2 ha4553b6_0

Actually, is this the verision issue? Can you calculate the energy for the sml structure I included based on your setup?

Thanks for your response!

The initial geometry from Psikit is very bad. There are two carbon atoms that are 0.879 A away from each other - completely unphysical.

I strongly recommend that you double-check your SMILES structure. If it still looks reasonable, move your issue to Psikit.

NOTE: A pre-edit version of this post implicated excited states. Upon doing another check, I don’t think that’s at issue here.

Even worse, there’s an N and a C that are less than 0.2 A apart. You need a better guess geometry.

Thanks for your response. The psikit is using rdkit to directly transform the SMILE structure to geometry. In case of the individual cation and anion, the psi4 perform very well. I guess it is the distance between the cation and anion in the intital geometry is very bad. However, I currently cannot think about better way to optimize the geometry, since I am doing he high throughput calculation. Will increase the iteration number help the convergence?

Try it and find out.

With starting geometries that bad, maybe you could use steepest-descent with a Leonard-Jones potential - or something like tha? The Newton-Raphson-based molecular optimizers are not built to handle gracefully things like forces at 0.2 Angstroms.

Seems like it doesn’t work, even through the iteration number set to 2000.

Thanks for your comments. I am quite new to psi4, do you have any guidance to choose the Leonard-Jones potential in the optimization function?

This tool was developed for testing. I don’t know if it will be of practical use, but perhaps it at least gives you a start. At present the function (in optking/lj_functions.py) uses only one set of parameters.

In optking/tests/test_opthelper.py you will find a function test_lj_external_gradient() that shows how to explicitly loop over a L-J gradient from a function in optking.

If you are looking for an easy blackbox solution, you might look for a different software program instead built to generate initial guess structures.

Thanks for your help! I will try Gaussian instead for now.