3
$\begingroup$

I'm testing some scaling properties of various density functional approximations, which involves evaluating the functionals on model systems with very low density. I am using the funcition dft.libxc.eval_xc in PySCF, yet I found that when the density is lower than some specific thresholds, the function just returns zero instead of evaluating the functional.

I have read the PySCF python source code and found that this might be caused by the default density threshold of libxc, so I guess maybe I can disable that cut-off by modifying the file pyscf/lib/libxc_itrf.so, but that seems kind of complicated for me. So I wonder if there is a more straightforward way to do such thing?

Thanks in advance for the help!

$\endgroup$

1 Answer 1

2
$\begingroup$

I realize that what I need is only the libxc in PySCF, so I can actually just use libxc rather than PySCF. I installed the python binding of libxc, namely pylibxc, and wrote a function that managed to do what I want:

def eval_xc(xc_code,rho):
    hyb, id_fac = dft.libxc.parse_xc(xc_code)
    inp = {}
    inp["rho"] = rho[0]
    inp["sigma"] = rho[1]**2+rho[2]**2+rho[3]**2
    inp["tau"] = rho[5]
    exc = 0
    for id,fac in id_fac:
        func = pylibxc.LibXCFunctional(id,1)
        func.set_dens_threshold(1E-30)
        ret = func.compute(inp,do_vxc=False)
        temp = ret["zk"].ravel()
        exc = exc + temp*fac
    return exc

Yet I found that when the density is too low, the compute() returns 'nan'. So it seems that the default density threshold is somehow reasonable. Maybe I must a higher precision than float64 to evaluate the functionals on extremely low density systems.

$\endgroup$
1
  • 1
    $\begingroup$ The default cutoff in Libxc is 1e-15, which is necessary to avoid NaN's. However, for realistic densities, you get energies to very high precision with a cutoff of 1e-11, see e.g. pubs.acs.org/doi/10.1021/acs.jctc.3c00183. If you are investigating toy systems, you may have to develop specialized implementations of functionals, since Libxc assumes double precision. $\endgroup$ Aug 23 at 15:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .