# Obtain a SCF Wavefunction
mol = psi4.geometry("He\nsymmetry c1")
scf_e, scf_wfn = psi4.energy("PBE/sto-3g", return_wfn=True)
# Grab a few matrices
D = scf_wfn.Da().clone()
V_out = scf_wfn.Da().clone()
V_out.np[:] = 0
Vpotential = scf_wfn.V_potential()
# Set arbitrary density
D.np[:] = 1
# Compute V which evaluates the energy as well
# Actual values exist on this dictionary
Building out a Vpotential can be done without the wavefunction, but it’s slightly tricky to do so. In principle the signature is here, but (and I am recalling) there is some sort of issue:
Perfect. Can indeed confirm that seems to work for obtaining the energy with varying density matrix (which was my main goal).
In future I’ll see if I can work out a sneaky way to use it for changing the functional itself (e.g. for density-driven / functional-driven analysis and density corrected DFT). But that’s lower priority for me right now.