How can I change max iteration in energy method?


#1

Hi, I’m a newbie in Psi4, and I’m having trouble writing a psi4-python code.

My script said “Fatal Error: Iterations did not converge.”, so I wanted to change max iteration and add maxiter option in the energy method.

scf_energy, wfn = psi4.energy("scf/6-31g**", return_wfn=return_wfn, maxiter=500)

But it doesn’t work well.

Please tell me if you have any advice.

Thank you,
kzfm


#2

Instead of supplying maxiter as an argument to the energy function, treat it as an option. Just include one of the following lines before your energy call:

set maxiter 500 to apply to all methods, or
set scf maxiter 500 to apply to just scf.

Might I ask for the coordinates of this troublesome molecule? Improving our SCF code is high on the developer to-do list, and we’d appreciate any examples of molecules we can use to test the SCF changes.


#3

Thank you for your advice, and as you mentioned the coordinates of the molecule cause trouble. I want to calculate torsion energy of the molecule gaining dihedral angle in 10 degrees from 0 to 360.

I use my own library psikit(https://github.com/Mishima-syk/psikit), and this is my whole code

from rdkit import Chem
from rdkit.Chem import rdMolTransforms
from psikit import Psikit

pk = Psikit()
pk.read_from_smiles("CNS(=O)(=O)CC")
pk.optimize(basis_sets="scf/sto-3g")

conformer = pk.mol.GetConformer(0)

for dihedral_degree in range(0, 360, 10):
    rdMolTransforms.SetDihedralDeg(conformer, 0, 1, 2, 3, dihedral_degree) # C-N-S-O dihedral angle
    print(dihedral_degree, pk.energy(basis_sets="scf/sto-3g", maxiter=500))

and this is the coordinates of the molecule.

C 4.1849348070947405 -1.7924348429601273 -1.3799272940965122
N 2.84385380774969 0.6704251410262807 -1.2943204629125742
S 0.04279646300828439 0.6222406801042148 0.4580332088292887
O -1.3526430954985227 3.7220850053069308 -0.13212277347509963
O 0.84730520881222 -1.064849617058772 3.346549936962613
C -1.9808929419126597 -1.5621970383882722 -1.317891473501073
C -4.69892399334976 -1.4094671557700051 -0.30289755933589646
H 3.239892498121687 -3.207206103234504 -2.5491088281086873
H 6.0695509123425 -1.463660901576179 -2.139476640284267
H 4.349485483910852 -2.50938090852209 0.5426187252955574
H 2.417734051237826 1.2940252363261038 -3.096551475837313
H -1.225227863560315 -3.4615053542407934 -1.1053693679927319
H -1.910129694750547 -1.0224499650561665 -3.3013290044687893
H -4.7670500895862675 -1.996162869540755 1.6629212744325275
H -5.912865977583351 -2.648060642810516 -1.4006534937099253
H -5.406344934503997 0.5124787385120418 -0.4461539329691137
units angstrom

Thank you,
kzfm


#4

Are you sure that your units are correct? Your coordinates seem to be in bohr, not angstroms.


#5

Thank you for your correction, that is my mistake.


#6

Since your question seems answered, I marked one of my previous posts as solving the issue. Let me know if you’re still having problems, and I should be able to unmark it.


#7

Thank you for your suggestion, now my code works well.
This is my jupyter notebook,

kzfm