I’m running into an issue when I’m loading an .xyz file into psi4 due to the differences after the decimal place for the coordinates. The below code returns a slightly differently positioned molecule than the initial input and I was wondering if there was a way to get a more precise match to the original?
with open(“UPIRUI_uff_psi4.xyz”,“r”) as xyz_f:
xyz = xyz_f.read()
As for your actual question: This is a consequence of Psi shifting the origin of the coordinate system to the center of mass. I can disable it by adding “nocom” to the end of your output file, but then I also need to remove the first two lines of the xyz file (number of atoms and molecule name) when I do that. Behind-the-scenes, specifying “nocom” changes the rules for how the molecule string is parsed.
Whether there’s a way to specify nocom while staying closer to xyz format is a question for @loriab.
Seconding @jmisiewicz on why the geometry is adjusting to Psi4’s internal standard orientation.
For this, I’d read the file into a string (e.g., with open(xyzfile) as fp: mstr = fp.read()) and then create the mol with from_string. The filetype xyz+ is optional here, and the au on the first line just helps show the preservation of coords since .geometry() always returns in bohr. The fix_ flags are what you’re after. Note that you’ll have to activate(mol) or pass it in via energy(..., molecule=mol) since this procedure doesn’t activate the mol to run in any future calcs as the line psi4.geometry(mstr) you had does.
mstr = """
O 4 4 4
H 3 4 4
H 4 3 4
mol = psi4.Molecule.from_string(mstr, dtype="xyz+")
mol = psi4.Molecule.from_string(mstr, dtype="xyz+", fix_com=True, fix_orientation=True)
mol = psi4.Molecule.from_string(mstr, fix_com=True, fix_orientation=True)