Table of Contents

XCFunctional

New in 0.9.1

e, dedn, dedsigma = XCFunctional(method, n, sigma) evaluates an exchange-correlation functional of density functional theory at one point: the exchange-correlation energy per volume $e(n, \sigma)$ of a spin-unpolarized electron density $n$ with $\sigma = |\nabla n|^2$, and its two derivatives $\partial e/\partial n$ and $\partial e/\partial \sigma$. The exchange-correlation energy of a density $n(\mathbf{r})$ is $$ E_{xc} = \int e\big(n(\mathbf{r}), \sigma(\mathbf{r})\big) \, \mathrm{d}^3 r. $$ These are the functionals of the density functional methods of CalculateAtomicBasisFunctions (option “Method”).

For the local density approximations (LDA) $e$ depends on $n$ only and $\partial e/\partial n$ is the exchange-correlation potential $V_{xc}$. For the gradient corrected functionals (PBE) the potential is $$ V_{xc}(\mathbf{r}) = \frac{\partial e}{\partial n} - 2 \nabla \cdot \left( \frac{\partial e}{\partial \sigma} \nabla n \right). $$ All quantities are in Hartree atomic units.

Input

Output

For $n \le 0$ all three are 0.

Example

The uniform electron gas in LDA. Its density is given by the Wigner-Seitz radius $r_s$, $n = 3/(4\pi r_s^3)$. The exchange energy per electron is known in closed form, $\epsilon_x = -\frac{3}{4\pi} \left(\frac{9\pi}{4}\right)^{1/3} \frac{1}{r_s} = -0.458165/r_s$ Hartree, and is equal to the exchange part of e/n; the rest is the correlation energy per electron $\epsilon_c$. The Perdew-Wang and the VWN correlation are two fits to the same quantum Monte Carlo energies of Ceperley and Alder and agree to better than $10^{-3}$ Hartree.

Input

Example.Quanty
-- the exchange-correlation energy of the uniform electron gas in LDA
-- rs is the Wigner-Seitz radius in bohr, n = 3/(4 pi rs^3) the density in bohr^-3
print("  rs      n         eps_xc     eps_x      eps_c     eps_c(VWN)   v_xc")
for _, rs in ipairs({0.5, 1, 2, 5, 10}) do
  local n = 3/(4*math.pi*rs^3)
  local e, dedn = XCFunctional("LDA", n)
  local eVWN = XCFunctional("LDA-VWN", n)
  local epsx = -3/(4*math.pi)*(9*math.pi/4)^(1/3)/rs   -- Slater exchange per electron
  print(string.format("%5.1f  %9.6f  %9.6f  %9.6f  %9.6f  %9.6f  %9.6f", rs, n, e/n, epsx, e/n - epsx, eVWN/n - epsx, dedn))
end

Result

  rs      n         eps_xc     eps_x      eps_c     eps_c(VWN)   v_xc
  0.5   1.909859  -0.992950  -0.916331  -0.076619  -0.077063  -1.306883
  1.0   0.238732  -0.517939  -0.458165  -0.059774  -0.060019  -0.678346
  2.0   0.029842  -0.273842  -0.229083  -0.044760  -0.044783  -0.356936
  5.0   0.001910  -0.119849  -0.091633  -0.028216  -0.028134  -0.155654
 10.0   0.000239  -0.064389  -0.045817  -0.018572  -0.018545  -0.083667

All functionals without a density gradient. With $\sigma = 0$ “PBE” is equal to “LDA” and “PBE-VWN” to “LDA-VWN”. The relativistic correction of “RLDA-MV” depends on $k_F/c$, with the Fermi wave vector $k_F = (3\pi^2 n)^{1/3}$. It is small at ordinary densities. At the very high densities near the nucleus of the heaviest atoms it reduces the exchange energy to a few percent of its nonrelativistic value, and the potential becomes positive.

Input

Example.Quanty
-- all functionals without a gradient (sigma = 0), at a low and at a very high density
print(string.format("c = %.6f, the speed of light used by RLDA-MV", PhysicalConstants.cAU.value))
for _, n in ipairs({1, 1e6}) do
  local kF = (3*math.pi^2*n)^(1/3)
  print(string.format("n = %g bohr^-3, kF/c = %.4f", n, kF/PhysicalConstants.cAU.value))
  for _, method in ipairs({"LDA", "LDA-VWN", "RLDA-MV", "PBE", "PBE-VWN"}) do
    local e, dedn = XCFunctional(method, n)
    print(string.format("  %-8s e/n = %11.6f   de/dn = %11.6f", method, e/n, dedn))
  end
end

Result

c = 137.035999, the speed of light used by RLDA-MV
n = 1 bohr^-3, kF/c = 0.0226
  LDA      e/n =   -0.809759   de/dn =   -1.064202
  LDA-VWN  e/n =   -0.810151   de/dn =   -1.064683
  RLDA-MV  e/n =   -0.809901   de/dn =   -1.064182
  PBE      e/n =   -0.809759   de/dn =   -1.064202
  PBE-VWN  e/n =   -0.810151   de/dn =   -1.064683
n = 1e+06 bohr^-3, kF/c = 2.2576
  LDA      e/n =  -74.060819   de/dn =  -98.689730
  LDA-VWN  e/n =  -74.060913   de/dn =  -98.689799
  RLDA-MV  e/n =   -5.103448   de/dn =    7.862728
  PBE      e/n =  -74.060819   de/dn =  -98.689730
  PBE-VWN  e/n =  -74.060913   de/dn =  -98.689799

PBE with a density gradient, given by the reduced gradient $s = |\nabla n|/(2 k_F n)$, so $\sigma = (2 k_F n s)^2$. The gradient lowers the energy below that of the LDA. The derivative dedsigma is compared with a finite difference. At $\sigma = 0$ it is 0: in PBE the gradient corrections of exchange and correlation cancel for a slowly varying density.

Input

Example.Quanty
-- PBE at n = 0.1 bohr^-3 for a few reduced gradients s = |grad n|/(2 kF n)
n = 0.1
kF = (3*math.pi^2*n)^(1/3)
eLDA = XCFunctional("LDA", n)
e, dedn, dedsigma = XCFunctional("PBE", n, 0)
print(string.format("sigma = 0: e/e_LDA = %.5f, de/dn = %.6f, de/dsigma = %.6f", e/eLDA, dedn, dedsigma))
print("  s     sigma     e/e_LDA     de/dn     de/dsigma  finite difference")
for _, s in ipairs({0.5, 1, 2, 5}) do
  local sigma = (2*kF*n*s)^2
  local e, dedn, dedsigma = XCFunctional("PBE", n, sigma)
  local h = 1e-4*sigma
  local fd = (XCFunctional("PBE", n, sigma + h) - XCFunctional("PBE", n, sigma - h))/(2*h)
  print(string.format("%4.1f  %8.5f  %9.5f  %10.6f  %10.6f  %10.6f", s, sigma, e/eLDA, dedn, dedsigma, fd))
end

Result

sigma = 0: e/e_LDA = 1.00000, de/dn = -0.517632, de/dsigma = 0.000000
  s     sigma     e/e_LDA     de/dn     de/dsigma  finite difference
 0.5   0.02062    1.00778   -0.508824   -0.025290   -0.025290
 1.0   0.08248    1.06191   -0.472618   -0.037525   -0.037525
 2.0   0.32991    1.23769   -0.483475   -0.019197   -0.019197
 5.0   2.06196    1.47286   -0.696504   -0.001477   -0.001477

Table of contents