Hi,
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 psi4.energy 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
plt
import pandas as pd
import psi4
psi4.set_num_threads(2)
psi4.set_memory(‘2 GB’)
import sys
sys.path.append(“…”)
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
“”")
psi4.core.clean_options()
psi4.core.clean()
psi4.core.clean_variables()
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
phenol.print_in_input_format()
psi4.core.clean_options()
psi4.core.clean()
psi4.core.set_output_file(‘phenol_relaxed_scan_dihedrals.log’,False)
#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’,
molecule=phenol)
energies.append(E)
geometries.append(phenol)
print(“OPTIMIZATIONS COMPLETED”)