Name 'Wavefunction' is not defined......a beginner with problems


#1

Hi there, I am a pre-grade student so please be kind. I’m in trouble with my hf script project.
I was trying with a preliminar program to test the psi4 with this code:
import psi4

def hfcalculation(molecule):
wfn= Wavefunction.build(mol=molecule,basis=[sto-g8])
mints= MintsHelper(wfn.basisset())
S = mints.ao_overlap()
T = mints.ao_potential()
V = mints.ao_kinetic()
I = mints.ao_eri()
Enuc = molecule.nuclear_repulsion_energy()
print (Enuc)

molecule= psi4.geometry("""
0 1
O
H 1 1.0
H 1 1.0 2 104.5"""
)

hfcalculation(molecule)

but when I run the code I get this error:
NameError: name ‘Wavefunction’ is not defined
And I don´t know what to do.


#2
import psi4

def hfcalculation(molecule):
    wfn= psi4.core.Wavefunction.build(mol=molecule,basis='sto-3g')
    mints= psi4.core.MintsHelper(wfn.basisset())
    S = mints.ao_overlap()
    T = mints.ao_potential()
    V = mints.ao_kinetic()
    I = mints.ao_eri()
    Enuc = molecule.nuclear_repulsion_energy()
    print (Enuc)

molecule= psi4.geometry("""
0 1
O
H 1 1.0
H 1 1.0 2 104.5"""
)

hfcalculation(molecule)

Psi4 has an input file mode of operation molecule {...} known as Psithon and a python mode of operation psi4.geometry("""...""") known as PsiAPI. The latter requires proper Python namespacing that is hidden away from user in Psithon. So you often need to add psi4 (py driver) or psi4.core (export from C++) to calls. The above works.

The psi4numpy project also has good resources.