Jupyter notebooks Usability

Dear all,

I’m trying to facilitate my life using psi4 in Jupyter notebooks.

However, it is being impossible to use other basis than STO-3G. I have no ideia what is happening, I’ve looked into the documentation, tried to reinstall etc, but it keeps coming to:

import psi4
import numpy as np

psi4.core.set_output_file('output.dat', False)

psi4.set_options({'basis': 'cc-pvdz',
                  'e_convergence': 1e-8,
                  'd_convergence': 1e-8})

h2o = psi4.geometry("""0 1
H 0.0 0.0 -0.37
H 0.0 0.0  0.37

#rhf_wfn = psi4.core.Wavefunction.build(h2o, psi4.core.get_global_option('basis'))
rhf_e, rhf_wfn = psi4.energy('scf', return_wfn=True)

what it comes to the following message:

RuntimeError                              Traceback (most recent call last)
<ipython-input-3-20d0a4627526> in <module>
     16 #rhf_wfn = psi4.core.Wavefunction.build(h2o, psi4.core.get_global_option('basis'))
---> 17 rhf_e, rhf_wfn = psi4.energy('scf', return_wfn=True)
     19 nbf = rhf_wfn.nso()

~/opt/anaconda3/lib/python3.6/site-packages/psi4/driver/driver.py in energy(name, **kwargs)
    554             shutil.copy(item, targetfile)
--> 556     wfn = procedures['energy'][lowername](lowername, molecule=molecule, **kwargs)
    558     for postcallback in hooks['energy']['post']:

~/opt/anaconda3/lib/python3.6/site-packages/psi4/driver/procrouting/proc.py in run_scf(name, **kwargs)
-> 2002     scf_wfn = scf_helper(name, post_scf=False, **kwargs)
   2003     returnvalue = core.variable('CURRENT ENERGY')

~/opt/anaconda3/lib/python3.6/site-packages/psi4/driver/procrouting/proc.py in scf_helper(name, post_scf, **kwargs)
   1361         use_c1 = True
-> 1363     e_scf = scf_wfn.compute_energy()
   1364     for obj in [core]:

~/opt/anaconda3/lib/python3.6/site-packages/psi4/driver/procrouting/scf_proc/scf_iterator.py in scf_compute_energy(self)
     82         self.initialize_jk(self.memory_jk_)
     83     else:
---> 84         self.initialize()
     86     try:

~/opt/anaconda3/lib/python3.6/site-packages/psi4/driver/procrouting/scf_proc/scf_iterator.py in scf_initialize(self)
    195             mints.set_rel_basisset(self.get_basisset('BASIS_RELATIVISTIC'))
--> 197         mints.one_electron_integrals()
    198         self.initialize_jk(self.memory_jk_, jk=jk)
    199         if self.V_potential():

Fatal Error: PSIO Error
Error occurred in file: /Users/github/builds/conda-builds/psi4-multiout_1557977521159/work/psi4/src/psi4/libpsio/error.cc on line: 128
The most recent 5 function calls were

Could someone help me to fix this as it has no sense in only using a small basis set.

Simply no tutorial in GitHub is working.

Best regards,

Wilken M.

That is not normal.

What happens if you try the input file not in a Jupyter notebook?

Using in a terminal it works. However I’m following a procedure in Jupyter notebook. Thus, I’ll try to fix this… but it doesn’t make any sense.

That’s very strange. You’re definitely restarting the Jupyter kernel between the sto-3g and larger basis attempts? What’s the Psi4 version and OS (I can figure it out from conda list if you send that)? Is Python 3.6 a requirement? Is it definitely the same conda env when you’re running successfully from command-line?

I think the problem is your set_memory call. Integer inputs to set_memory are interpreted in units of bytes (see here), so you’re only giving the program 512 bytes to work with, which is far too small.

What version of psi4 are you using? The last few versions have a minimum memory specification of 500 MiB.

Oops, I misread 2e9 as 2 ** 9; your memory is fine. Is it possible that your scratch directory is correctly set when you run psi4 through the command line, but not in the jupyter notebook?

You can check this by adding the following lines to the start of your notebook and command line script:

import os

This looks strange, does restarting the kernel and running the cell again help?

Could you add the following line just before you try any other higher basis set.


I’m using the following version:

psi4 1.3.2+ecbda83 py36h4f228a9_0 psi4

After I’ve updated conda, sometimes it works using safari, however in Visual Studio (using python 3.7.10) it doesn’t work.

Can you try, installing your environment containing psi4 library as a separate kernel.

conda activate psi4env
python -m ipykernel install --user --name psi4env --display-name "psi4"

Also, consider updating you Jupyter plugin on VScode, if it isn’t running on the latest release.

Selecting the newly installed psi4 as your python kernel in VScode should solve any issues with the python interpreter interfacing with psi4.

After updating conda and jupyter it is working well on safari, in visual studio it’s still the same problem. I’ll keep on with safari.