Molecule from file in optking

Hello,

I want to loop through a bunch of xyz files for geometry optimization.

I tried:

with open('structures/pep_0.xyz') as f:
    xyz = f.read()
PEP = Molecule.from_string(xyz)
PEP.set_multiplicity(1)
PEP.set_molecular_charge(-3)

Do I then add the line:

molecule PEP

Then I want to freeze the dihedral but it doesn’t seem to accept the same string input for the dihedral as when I entered the coordinates as a copy and pasted string inside of brackets.

Like:

molecule PEP {
x y z
x y z
}

How can I use the Molecule class so that I can add the proper charge and multiplicity and still use the frozen_dihedral string?

Thank you,

Dan

Removing the line

molecule PEP

And including

energy = optimize(functional, molecule=PEP)

seems to work.

The output file appears to be treating the specified dihedral as frozen according to what’s specified in

set optking {
    frozen_dihedral = $dihedral
    }

Thank you,

Dan

For posterity: You only need to add a line like molecule PEP when you’re using Psi4 as an input file, to start a molecule block. When you’re using Psi4 as a script that you import or creating a molecule from a function, there’s no need for it. Just use standard Python syntax.

Are there any other questions?