dftlibs / xcfun

XCFun: A library of exchange-correlation functionals with arbitrary-order derivatives
https://dftlibs.org/xcfun/
Mozilla Public License 2.0
58 stars 32 forks source link

Semi Contracted Mode #92

Open ilfreddy opened 5 years ago

ilfreddy commented 5 years ago

This is a brief summary of the discussion @bast and me have had about the XC_CONTRACTED mode of XCFun and how it is used, for future reference, and what we need to improve it.

When doing response calculation, one needs to separate the different contributions BEFORE contracting with the overlap matrix. For GGA functionals this means that one needs four different calls to XCFun: one for each of the density variables n, nx, ny, and nz. MRChem or any other real-space code has a similar problem, because it needs the potential (or its derivatives for response calculations). In the contracted mode this is the only way of getting the right answer now, because all derivatives are contracted and it is only by setting one of the density variables to one and all the others to zero that one can single out each contribution (@bast checked Dirac and confirmed that XCFun is indeed called four times, and it would be eight for open-shell systems).

What we actually need is a semi-contracted mode where all contractions but one are performed and then all four (or more for open shell, metaGGA...) are recovered with one single call of XCFun.

The way XCFun is used now is suboptimal, because all derivatives are still computed, but most of them discarded at each run.