#! PsiAPI pubchem access

import psi4
from psi4.driver.constants.physconst import hartree2ev

psi4.set_output_file("output.dat", False)

benz = psi4.geometry("""
    pubchem:benzene
""")

psi4.set_options({"REFERENCE"                : "RHF",
                  "MAX_ENERGY_G_CONVERGENCE" : 8,
                  "BASIS"                    : "STO-3G",
                  "DF_BASIS_SCF"             : "CC-PVDZ-RI"})

psi4.optimize('scf')

psi4.set_options({"REFERENCE"    : "RHF",
                  "BASIS"        : "CC-PVDZ",
                  "DF_BASIS_SCF" : "CC-PVDZ-JKFIT"})

e_sing_rhf = psi4.energy('scf')

benz.set_multiplicity(3)

psi4.set_options({"REFERENCE" : "ROHF"})
e_trip_rohf = psi4.energy('scf')
psi4.set_options({"REFERENCE" : "UHF"})
e_trip_uhf  = psi4.energy('scf')

vertical_uhf  = hartree2ev * (e_trip_uhf  - e_sing_rhf)
vertical_rohf = hartree2ev * (e_trip_rohf - e_sing_rhf)
psi4.core.print_out("\nSinglet-Triplet gap (vertical, UHF)   = %8.2f eV\n" % vertical_uhf)
psi4.core.print_out("\nSinglet-Triplet gap (vertical, ROHF)  = %8.2f eV\n" % vertical_rohf)

