Psi4 doesn't run the optimization


I am performing a PES relaxed on a phenol molecule, where the fixed dihedral is the one of the OH group. For this, I wrote the code on psi4 but the psi4.optimize() doesn’t work, and the error is : OptError: List does not have 6*n entries as expected

The works with this code, nut not the psi4.optimize(). Would you know how to fix this error?
I use VS code and my psi4 should be the 1.7 or 1.8 version, I downloaded it some days ago. Thank you,

Here is my code :

import numpy as np
import matplotlib.pyplot as
import pandas as pd
import psi4

psi4.set_memory(‘2 GB’)

import sys
from helper import *

phenol = psi4.geometry(“”"
symmetry c1
0 1
C -0.10632 0.14068 0.90806
C 1.13441 0.12910 0.25075
C 1.18824 0.03205 -1.14365
C 0.00617 -0.05363 -1.88566
C -1.23097 -0.04234 -1.23399
C -1.28738 0.05463 0.16036
O -0.17556 0.23368 2.25134
H 2.05460 0.19503 0.81751
H 2.14550 0.02326 -1.64870
H 0.04877 -0.12869 -2.96456
H -2.14558 -0.10869 -1.80895
H -2.24834 0.06288 0.65922
H 0.61646 0.29503 2.80427


dihedrals = np.linspace(0,360, 37) #We set here the dihedrals that we are going to use for the scan
energies = [] #Here we will store the optimized energy for each dihedral.
geometries = [] #Here we will store the optimized geometries. This is a list

dihedral_atoms = "6 1 7 13 " #OPEN figure in pymol and set
atoms ID to define the numbers of the atoms for the dihedral


#relaxed scan to perform here

for dihedral in dihedrals:
print(F’The value of the frozen dihedrals is {dihedral}')

#set up the string for psi4
frozen_dihedral = F’{dihedral_atoms} {dihedral}’
psi4.set_module_options(‘optking’,{‘ranged_dihedral’: frozen_dihedral})
E = psi4.optimize(‘b3lyp-d3/def2-SVP’,

I tried to look into this, but was not able to reproduce your problem because you didn’t follow our instructions on posting help topics. In particular:

  • First, I tried to reproduce your example. I couldn’t do that the easy because your code isn’t enclosed in backticks, so the forums auto-formats in a way that isn’t suitable for copy-pasting. Enclose your code in triple backticks.
  • So because I couldn’t do that, I tried to create a “small” version of your bug because of the second issue. Please give us a minimal working example, with everything unimportant removed. Just at a glance, there is no reason for numpy, matplotlib, or pandas to be here.
  • …And then, I still couldn’t reproduce the issue. We need an exact Psi4 version number. I’m surprised that your frozen_dihedral gets as far as it does. I’d expect that keyword to take six numbers, not five. This discrepancy may be due to a version difference.

I’ll be happy to give it another look once you fix all of those problems.

If you want the dihedral angle frozen at its initial value during the optimization, then the most robust approach would not be to use the ranged_dihedral keyword. Construct an input geometry first (before the optimization begins) with the desired torsional angle and then use frozen_dihedral: a b c d. This can be done with psi’s molecule class, or in a variety of other ways.

If you wish to try to construct the new geometry using optking, then it might work to use ranged_dihedral: a b c d [min_val] [max_val], where you set the min and max to the same value. However, the first “optimization step” to comply with the restraint might be awkward and fail. It is also possible to apply a force along the dihedral coordinate if it were necessary to more gently change the value. However in a case like this, with a well isolated coordinate, that shouldn’t be necessary.