Hi everybody,
I’m trying to interface with the psi4 API in a library fashion. All examples always specify a full geometry input file as input, which is then parsed by psi4. Is there any possibility to actually interface with actual binary data in the code?
The closest I found was:
from psi4.driver.qcdb.molparse import from_arrays
p4_mol = from_arrays(geom=coordinates, elem=elements, units="Angstrom", fix_symmetry=None)
but this only returns some dictionary and not an actual Molecule object. Do I have to write the intermediate string representation and parse it before instantiating a molecule?
Best,
Timo
This here seems to work:
from psi4.driver.qcdb.molparse import from_arrays
coordinates is a Nx3 numpy array, elements is a list of Elements [“C”,“H”,…]
p4_dict = from_arrays(geom=coordinates, elem=elements, units="Angstrom", fix_symmetry=None)
p4_mol = psi4.core.Molecule.from_dict(p4_dict)
1 Like
You got it. The from_arrays
is a fairly new feature, strangely. We’ve been accustomed to be mostly from_string
. The only thing different you may notice about the molecule you built (compared to psi4.geometry(mol_str)
is that the molecule isn’t “activated”, so you’ll have to pass it (e.g., psi4.energy(..., molecule=p4_mol)
) rather than having it magically plucked from the environment.