Basic psi4numpy question for the DFT potential

Hi, I’m trying to code the DFT with psi4numpy with ks_helper.py.

I made the V potential with

sup = psi4.driver.dft_funcs.build_superfunctional(“PBE”, True)[0]
sup.set_deriv(2)
sup.allocate()
vname = “RV”
Vpot = psi4.core.VBase.build(wfn.basisset(), sup, vname)
Vpot.initialize()

and tried to calculate V matrix with

ks_e = 0.0
Vpot.set_D([D])
Vpot.properties()[0].set_pointers(D)
V = V_builder(D, Vpot)
if V is None:
    ks_e = 0.0
else:
    ks_e, V = V
    V = psi4.core.Matrix.from_array(V)

but having a problem with V_builder.
I think I need to use DFT kernel as for the V_builder.

So, my question is, is there any kernel that I can use right away?
If so, where can I find them?

Thank you in advance!

*It also will be great if someone adds psi4numpy DFT tutorial 4c GGA and Meta Kernels.

Hello,
Thanks for your interest in the Psi4NumPy tutorials. The DFT tutorials are still in beta and hopefully we will get to GGA/meta at some point.

V_builder is the name of a function defined in the VV10 and GRAC tutorials and passed to ks_helper.py. If you want to compute V potentials from an arbitrary kernel you can use:

import psi4
import numpy as np

mol = psi4.geometry("""
He
symmetry c1
""")

scf_e, wfn = psi4.energy("PBE/6-31G", return_wfn=True)

# Grab relevant data
nbf = wfn.nmo()
Vpot = wfn.V_potential()

# Set a density
D = wfn.Da()
Vpot.set_D([D])

# Compute V by passing in a matrix to populate
V = psi4.core.Matrix(nbf, nbf)
Vpot.compute_V([V])
print(V.np)

print(wfn.Va().np)

Hi, would it be possible to compute V potential from an arbitrary Hermitian complex density matrix? I am having some trouble with the set_D function since it seems that D must be passed as psi4.core.Matrix object. If I define such psi4 Matrix using “from_array” function, any imaginary part will be discarded

Unfortunately none of the code (including our XC evaluator) is able to handle complex values. If you know of a code that can evaluate complex XC derivatives we could probably patch something together however.

I don’t think the imaginary part contributes to the XC potential, so you can just pass the real part as a Matrix object. The appendix here might be useful. https://pubs.acs.org/doi/pdf/10.1021/ct200137z

Thank you so much for your help