Read in from scf with psi4.core.Wavefunction.from_file()?

I see I can save the wavefunction with `psi4.core.Wavefunction.to_file() and in another calculation run psi4.core.Wavefunction.from_file() to import the wavefunction, but then I don’t know if I can use this wavefunction to compute the energy. Is there any way to do this? I have the inputs:

0 1
He 0 0 0
He 2 0 0
symmetry c1
}
set {
basis cc-pvdz
}
en, wfn = energy('b3lyp', return_wfn=True)
wfn.to_file('he_wfn') ```

and

molecule mol{
0 1
He 0 0 0
He 2 0 0
symmetry c1
}

wfn = psi4.core.Wavefunction.from_file('he_wfn')

en=wfn.energy()
print(en)

set {
basis cc-pvdz
guess read
}
energy('pbe0')

This prints en successfully from wfn, but my "guess read" fails and the calculation starts over from scratch.

First, please enclose code snippets in triple backticks (```) in the future so people who want to help can copy-paste these into an input file. Otherwise, there’s some manual processing we need to do. Anyways.

“use this wavefunction to compute the energy” means different things in different contexts. Your question, as I understand it, is how to use an imported wavefunction’s orbitals as a guess for an SCF computation. (For DFT, this will get you the energy almost immediately. For correlated wavefunctions, it won’t.)

As for how you do that, add the following to the start of your script:

import shutil
wfnpath = wfn.get_scratch_filename(180) + '.npy'
shutil.copy(path_to_old_wavefunction, wfnpath)

That moves your wavefunction to the place Psi looks for it when it reads.

…This should really be documented and/or simplified, and I’ll make an issue about it.