I have installed psi4 as an importable python module according to the instructions in the FAQ and most things seem to be working fine for me, but as soon as I try to either “set_legacy_molecule” or “set_active_molecule”, it causes a seg fault. Is there something I should be calling beforehand in order for this to work? I thought @loriab or @dgasmith might know the answer.
Here’s a minimal example:
import psi4
# this part works:
xyzstring = """
units angstrom
O 0.0000000000 0.0000000000 -0.0711762954
H 0.0000000000 -0.8916195680 0.5648097613
H 0.0000000000 0.8916195680 0.5648097613
"""
psi4.efp_init()
molecule = psi4.Molecule.create_molecule_from_string(xyzstring)
molecule.update_geometry()
molecule.print_out()
# this fails with "Segmentation fault (core dumped)":
psi4.set_legacy_molecule(molecule)
I believe you but it works for me just now on Mac. Is your psi4.so Mac or Linux and maybe give the me otool -L or ldd -v (respectively)?
>>> import psi4
>>> psi4.set_global_option('BASIS', 'CC-PVDZ')
True
>>> print psi4.get_option('SCF', 'BASIS')
CC-PVDZ
>>>
>>> # this part works:
... xyzstring = """
... units angstrom
... O 0.0000000000 0.0000000000 -0.0711762954
... H 0.0000000000 -0.8916195680 0.5648097613
... H 0.0000000000 0.8916195680 0.5648097613
... """
>>> psi4.efp_init()
<psi4.EFP object at 0x1007366e0>
>>> molecule = psi4.Molecule.create_molecule_from_string(xyzstring)
>>> molecule.update_geometry()
>>> molecule.print_out()
Molecular point group: c2v
Full point group: C2v
Geometry (in Angstrom), charge = 0, multiplicity = 1:
Center X Y Z Mass
------------ ----------------- ----------------- ----------------- -----------------
O 0.000000000000 0.000000000000 -0.071176298939 15.994914619560
H 0.000000000000 -0.891619568000 0.564809757761 1.007825032070
H -0.000000000000 0.891619568000 0.564809757761 1.007825032070
>>> psi4.set_legacy_molecule(molecule)
>>> qw = psi4.get_legacy_molecule()
>>> qw.print_out()
Molecular point group: c2v
Full point group: C2v
Geometry (in Angstrom), charge = 0, multiplicity = 1:
Center X Y Z Mass
------------ ----------------- ----------------- ----------------- -----------------
O 0.000000000000 0.000000000000 -0.071176298939 15.994914619560
H 0.000000000000 -0.891619568000 0.564809757761 1.007825032070
H -0.000000000000 0.891619568000 0.564809757761 1.007825032070
@loriab I just tried cloning a fresh copy of psi4 and re-compiling to make sure my version is up to date, and the problem persists. I did notice something odd though – when I run the same commands in python interactive mode (like you did), I don’t see a seg fault complaint. I only see it if I run in normal mode (by which I mean executing “python script.py” or “./script.py” at the command line).
@dgasmith I’m writing a script that needs to call psi4.optking(). Basically, it implements a continuous sow-reap optimization that can run the single-point jobs for each gradient in parallel on our cluster. I need it in order to optimize structures with a research code (not ours – it’s from another group) that isn’t currently interfaced with an optimizer. I would prefer to avoid legacy/active molecules as well, but I believe optking still relies on them.
Yup, for now it does. RKing will be down here next week, hopefully we can patch some of this up.
Something to check: see is if the set_legacy is what actually creates the seg fault. You can do this simply by setting a print statement after the set_legacy call. If the set is not the source, but instead you get a seg fault when Psi is shutting down, try adding the following line at the very end of your infile.
@dgasmith Oh – with psi4.set_legacy_molecule(None) I no longer get a seg fault complaint. Just adding a print statement after the call, the seg fault doesn’t show up until after the print statement is executed.
I can confirm the different behavior between interactive and script. And that psi4.set_active_molecule(mol) triggers it, too. But at the moment, I’m just confused.