I am a first time Psi4 user and I am trying to setup an input file for performing a dihedral scan around a rotatable bond. I am having problems assigning Python variables inside a “set optking” command. Any help will be greatly appreciated. I would like the following code to work with Cartesian input.

```
# Constrained minimization with H-O-O-H dihedral fixed to 120.0 degrees.
molecule HOOH {
H
O 1 0.90
O 2 1.40 1 100.0
H 3 0.90 2 100.0 1 115.0
}
# optimize molecule at different dihedral angles
# Psithon wraps strings in quotes by default
# use $ to tell Psithon that $var is a Python variable
steps = 36
step_size = 10
start_angle = 0
for counter in range (0, steps):
# set smaller basis set for geometry HT geometry optimization
set {
basis 6-31G*
scf_type df
guess sad
ints_tolerance 1.0E-8
}
dihedral = 1.0 * counter * step_size + start_angle
dihedral_string = "(\" 1 2 3 4 %.1f \")" % dihedral
# how to set optking so that dihedral angle changes
# for each step?
set optking {
frozen_dihedral = ""
fixed_dihedral = (" 1 2 3 4 $dihedral ")
}
optimize('scf') # geometry optimization with HF
# change basis set for single point energy calculation
set {
basis 6-311+G**
scf_type df
guess sad
}
DFT_energy = energy ('b3lyp') # single point energy
MP2_energy = energy ('df-mp2') # calculate single point energy with MP2
print "Dihedral=%.1f" % dihedral
print "DFT_Energy(kcal/mol)=%.4f" % (DFT_energy * psi_hartree2kcalmol)
print "MP2_Energy(kcal/mol)=%.4f" % (MP2_energy * psi_hartree2kcalmol)
```

Thanks,

JW