Add new dft functional from python side

Dear all,
I am trying to reproduce some results from LC-blyp, which makes me to customize functional. And I found http://forum.psicode.org/t/implementing-lc-blyp/ has already a solution to this question. However, when I add the same code from the post to my code, and using psi4.energy(“awLCBLYP”) for a test. It reports functional no found. Is there any way to add new functional from the python side?

psi4 version: 1.3.2

Thank you very much

could you post your input?

The whole code is quite lengthy, here is the main part:

import psi4
import numpy as np
def mod_lcblyp(name, npoints, deriv, restricted=True):

    # Build a empty superfunctional
    sup = core.SuperFunctional.blank()

    # Name the functional and provide a description
    sup.set_name('awLCBLYP')
    sup.set_description('    LC-BLYP Hyb-GGA Exchange-Correlation Functional\n')

    # Set the correlation functional
    sup.add_c_functional(core.LibXCFunctional('XC_GGA_C_LYP', restricted))

    b_x = core.LibXCFunctional('XC_GGA_X_B88', restricted)
    b_x.set_alpha(0.70)

    sup.add_x_functional(b_x)
   #Set exchange functional ( static + long-range contribution)

   # set the parameters for S7:
   sup.set_x_alpha(0.30)
   sup.set_x_beta(0.70)
   sup.set_x_omega(0.33)

    return sup

def main():
    
    psi4.set_output_file('ethylene.dat', False)
    molecule_geo = psi4.geometry("
    C                 -0.66631400    0.00000000    0.00000000
    C                  0.66631400    0.00000000    0.00000000
    H                 -1.23960500    0.91940200    0.00000000
    H                 -1.23960500   -0.91940200    0.00000000
    H                  1.23960500   -0.91940200    0.00000000
    H                  1.23960500    0.91940200    0.00000000")

    eng, wfn = psi4.energy('scf', dft_functional='awLCBLYP', return_wfn=True, molecule=molecule_geo_dimer)

if  __name__ == '__main__':
    main()

At this stage PSI4 doesn’t know your functional name.

You want to use energy('scf',dft_functional=mod_lcblyp)

The other thread talked about some modified LC-BLYP, I think. So be careful about the used parameters!
There usually isn’t a global HF exchange (set_x_alpha(0.30)) in the LC scheme.

It could be easier to use the dictionary interface like shown here:
http://psicode.org/psi4manual/1.3.2/dft.html#advanced-functional-use-and-manipulation

Thanks!! It works.
I will check the parameter.