Kinetic Energy Functionals#
Kinetic Energy Functional Template Class#
- class functionals.KineticFunctional#
Template kinetic functional class
This is a class that represents a kinetic functional which can be useful for functionals that require an initialized kernel to be saved for repeated use via interpolation or otherwise. This class is also useful for functionals with tunable parameters (e.g. machine-learned functionals) as it allows for Pytorch-based optimization of those parameters.
- __init__(init_args=None)#
- Parameters:
init_args (tuple or None) – Functional parameters for initialization
- initialize()#
Sets the optimizer (default is Rprop) and make all functional parameters have
requires_grad = False.
- set_device(device=device(type='cpu'))#
Moves all functional parameter tensors to the specified device. By default, the device is set to a GPU if is avaliable, otherwise the device is set as a CPU.
- Parameters:
device (torch.device) – Device
- param_grad(requires_grad=True)#
Sets whether the functional parameters’
requires_gradisTrueorFalse.- Parameters:
requires_grad (boo) – Whether the functional parameters’
requires_gradisTrueorFalse
- save(PATH)#
Saves the functional parameters in a file.
- Parameters:
PATH (string) – Path to the file where the parameters are saved
- classmethod load(PATH)#
Loads the functional parameters from a file.
- Parameters:
PATH (string) – Path to the file where the parameters to be loaded are
- grid_error(target, prediction, norm=False)#
Utility function to compute errors on a grid.
- Parameters:
target (torch.Tensor) – The expected result
prediction (torch.Tensor) – Prediction from the functional
norm (boo) – Whether to normalize the error by the range of the
target
- Returns:
Mean error
- Return type:
torch.Tensor
- scalar_error(target, prediction)#
Utility function to compute scalar errors.
- Parameters:
target (torch.Tensor) – The expected result
prediction (torch.Tensor) – Prediction from the functional
- Returns:
Relative error
- Return type:
torch.Tensor
- update_params(loss)#
Updates the functional parameters based on a loss function to be minimized.
- Parameters:
loss (torch.Tensor) – Quantity to be minimized
Exact Kinetic Energy Functionals#
Thomas-Fermi Functional#
- functionals.ThomasFermi(box_vecs, den)#
Thomas-Fermi functional
The Thomas-Fermi functional is exact for the free electron gas and can be considered the local density approximation (LDA) for non-interacting kinetic energy functionals. It is given by
\[T_\text{TF}[n] = \int d^3\mathbf{r} ~\frac{3}{10} (3\pi)^{2/3} n^{5/3}(\mathbf{r})\]- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
- Returns:
Thomas-Fermi kinetic energy
- Return type:
torch.Tensor
von Weizsaecker Functional#
- functionals.Weizsaecker(box_vecs, den)#
von Weizsaecker functional
The von Weizsaecker functional is exact for single-orbital systems It is given by
\[T_\text{vW}[n] = \int d^3\mathbf{r} ~\frac{1}{8} \frac{|\nabla n(\mathbf{r})|^2}{n(\mathbf{r})}\]- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
- Returns:
von Weizsaecker kinetic energy
- Return type:
torch.Tensor
Semi-local Kinetic Energy Functionals#
Semi-local functionals generally take the form
where \(T_\text{vW}[n]\) is the von Weizsaecker kinetic energy functional, \(\tau_\text{TF}(\mathbf{r})\) is the Thomas-Fermi kinetic energy density and \(F_\theta[n](\mathbf{r})\) is the Pauli enhancement factor to be approximated.
Often, the Pauli enhancement factor is made a function of the reduced gradient,
and the reduced Laplacian,
vWGTF Functionals#
- functionals.vWGTF1(box_vecs, den)#
vWGTF1 functional
The vWGTF1 functional [Phys. Rev. B 91, 045124] has a Pauli enhancement factor given by
\[F_\theta^\text{vWGTF1}(d) = 0.9892 \cdot d^{-1.2994}\]where \(d = n/n_0\) for average density \(n_0\).
- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
- Returns:
vWGTF1 kinetic energy
- Return type:
torch.Tensor
- functionals.vWGTF2(box_vecs, den)#
vWGTF2 functional
The vWGTF2 functional [Phys. Rev. B 91, 045124] has a Pauli enhancement factor given by
\[F_\theta^\text{vWGTF2}(d) = \sqrt{\frac{1}{\text{ELF}} - 1}\]with the electron localization function (ELF) parameterized as
\[\text{ELF} = \frac{1}{2} \left(1 + \tanh(5.7001 \cdot d^{0.2563} - 5.7001) \right)\]where \(d = n/n_0\) for average density \(n_0\).
- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
- Returns:
vWGTF2 kinetic energy
- Return type:
torch.Tensor
Luo-Karasiev-Trickey (LKT) Functional#
- functionals.LuoKarasievTrickey(box_vecs, den)#
Luo-Karasiev-Trickey (LKT) functional
The Luo-Karasiev-Trickey (LKT) GGA kinetic functional [Phys. Rev. B 98, 041111(R)] has a Pauli enhancement factor given by
\[F_\theta^\text{LKT}(s) = \frac{1}{\cosh(1.3 s)}\]- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
- Returns:
LKT kinetic energy
- Return type:
torch.Tensor
Pauli-Gaussian Functionals#
- class functionals.PauliGaussian#
Pauli-Gaussian functional
The Pauli-Gaussian class of GGA kinetic energy functionals [J. Phys. Chem. Lett. 2018, 9, 15, 4385–4390, J. Chem. Theory Comput. 2019, 15, 5, 3044–3055] have Pauli enhancement factors with the form
\[F_\theta^\text{PG}(s,q) = e^{-\mu s^2} + \beta q^2 - \lambda q s^2 + \sigma s^4\]- __init__(init_args=None)#
- Parameters:
init_args (tuple) – \((\mu,~\beta,~\lambda,~\sigma)\) where each parameter is a float. These are key parameters of the Pauli-Gaussian functionals. The default parameters are that of the PGSL0.25 functional’s, \((\mu,~\beta,~\lambda,~\sigma) = (40/27,~0.25,~0,~0)\).
- set_PG1()#
Set \((\mu,~\beta,~\lambda,~\sigma) = (1,~0,~0,~0)\)
- set_PGS()#
Set \((\mu,~\beta,~\lambda,~\sigma) = (40/27,~0,~0,~0)\)
- set_PGSL025()#
Set \((\mu,~\beta,~\lambda,~\sigma) = (40/27,~0.25,~0,~0)\)
- set_PGSLr()#
Set \((\mu,~\beta,~\lambda,~\sigma) = (40/27,~0.25,~0.4,~0.2)\)
- forward(box_vecs, den)#
- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
- Returns:
Pauli-Gaussian kinetic energy
- Return type:
torch.Tensor
Yukawa GGA Functionals#
- class functionals.YukawaGGA#
Yukawa GGA functional
The Yukawa GGA class of kinetic energy functionals [Phys. Rev. B 103, 155127, Computation 2022, 10(2), 30] have Pauli enhancement factors \(F_\theta(y, s^2, q)\) that depend on the Yukawa potential term,
\[y_{\alpha \beta}(\mathbf{r}) = \frac{3\pi\alpha^2}{4 k_F(\mathbf{r}) n^{\beta-1}(\mathbf{r})} \int d^3\mathbf{r}' \frac{n^\beta(\mathbf{r}') e^{-\alpha k_F(\mathbf{r}) |\mathbf{r}-\mathbf{r}'|}}{|\mathbf{r}-\mathbf{r}'|}\]where \(k_F(\mathbf{r}) = [3\pi^2 n(\mathbf{r})]^{1/3}\), as an ingredient besides the reduced gradient and laplacian.
- __init__(init_args=None)#
- Parameters:
init_args (tuple) – \((\alpha,~\beta,~F_\theta,~\kappa)\) where (alpha,~beta) are key parameters of the Yukawa GGA functional, \(F_\theta\) is the Pauli enhancement factor that takes as arguments the Yukawa descriptor, reduced gradient and reduced laplacian, i.e. \(F_\theta(y, s^2, q)\), and \(\kappa\) is a parameter for the spline-based field dependent convolution. Note that a geometric progression based spline is used so \(\kappa > 1\) The default parameters are that of the Yuk1 functional’s, \((\mu,~\beta,~f,~\kappa) = (1,~1,~y,~1.2)\).
- set_yuk1()#
Set \((\alpha,~\beta) = (1,~1)\) and
\[F_\theta(y,~s^2,~q) = y\]
- set_yuk2()#
Set \((\alpha,~\beta) = (1.36297,~1)\) and
\[F_\theta(y,~s^2,~q) = y~ \left(1 + \frac{40}{27} (q-s^2) \right)\]Warning
Unstable for density optimizations as it violates Pauli positivity
- set_yuk3(a=4)#
Set \((\alpha,~\beta) = (1.36297,~1)\) and
\[F_\theta(y,~s^2,~q) = y~ T_a \left(-\frac{40}{27} (q-s^2) \right)\]where
\[T_a(x) = \frac{4}{a} \frac{e^{ax}}{e^{ax} + 1} + \frac{a-2}{a}.\]
- set_yuk4(a=3.3)#
Set \((\alpha,~\beta) = (1.36297,~1)\) and
\[F_\theta(y,~s^2,~q) = y~ T_a \left(-\frac{40}{27} s^2 \right) T_2\left(-\frac{40}{27} q \right)\]where
\[T_a(x) = \frac{4}{a} \frac{e^{ax}}{e^{ax} + 1} + \frac{a-2}{a}.\]
- set_yuk2beta(alpha, beta)#
Set \((\alpha,~\beta)\) according to user input and
\[F_\theta(y,~s^2,~q) = 1 - G_0 + y(G_0 + G)\]where
\[G_0 = \frac{\alpha^2 (\alpha^2 - 60)}{108 \beta (9\beta - 10)}\]and
\[G = \left(\frac{40}{27\beta} - \frac{4}{\alpha^2} (\beta-1) G_0\right) (q - \beta s^2).\]Warning
Unstable for density optimizations as it violates Pauli positivity
- set_yuk3beta(alpha, beta, a=2)#
Set \((\alpha,~\beta)\) according to user input and
\[F_\theta(y,~s^2,~q) = T_a\left( - G_0 + y(G_0 + G) \right)\]where
\[G_0 = \frac{\alpha^2 (\alpha^2 - 60)}{108 \beta (9\beta - 10)},\]\[G = \left(\frac{40}{27\beta} - \frac{4}{\alpha^2} (\beta-1) G_0\right) (q - \beta s^2)\]and
\[T_a(x) = \frac{4}{a} \frac{e^{ax}}{e^{ax} + 1} + \frac{a-2}{a}.\]
- forward(box_vecs, den)#
- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
- Returns:
Yukawa GGA kinetic energy
- Return type:
torch.Tensor
Non-local Kinetic Energy Functionals#
Wang-Teter (WT) Functional#
- functionals.WangTeter(box_vecs, den)#
Wang-Teter (WT) functional
The Wang-Teter (WT) functional [Phys. Rev. B 45, 13196] is a Wang-Teter style non-local kinetic functional with a density-independent kernel and parameters \((\alpha,~\beta) = (5/6,~5/6)\).
- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
- Returns:
WT kinetic energy
- Return type:
torch.Tensor
Perrot Functional#
- functionals.Perrot(box_vecs, den)#
Perrot functional
The Perrot functional [J. Phys.: Condens. Matter 6 431] is a Wang-Teter style non-local kinetic functional with a density-independent kernel and parameters \((\alpha,~\beta) = (1,~1)\).
- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
- Returns:
Perrot kinetic energy
- Return type:
torch.Tensor
Smargiassi-Madden (SM) Functional#
- functionals.SmargiassiMadden(box_vecs, den)#
Smargiassi-Madden (SM) functional
The Smargiassi-Madden (SM) functional [Phys. Rev. B 49, 5220] is a non-local kinetic Wang-Teter style functional with a density-independent kernel and parameters \((\alpha,~\beta) = (1/2,~1/2)\).
- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
- Returns:
SM kinetic energy
- Return type:
torch.Tensor
Wang-Govind-Carter 98 (WGC98) Functional#
- functionals.WangGovindCarter98(box_vecs, den)#
Wang-Govind-Carter 98 (WGC98) functional
The Wang-Govind-Carter 98 (WGC98) functional [Phys. Rev. B 58, 13465] is a non-local kinetic Wang-Teter style functional with a density-independent kernel and parameters \((\alpha,~\beta) = ((5+\sqrt{5})/6,~(5-\sqrt{5})/6)\).
- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
- Returns:
WGC98 kinetic energy
- Return type:
torch.Tensor
Wang-Teter Style Functional#
- class functionals.WangTeterStyleFunctional#
Wang-Teter style functional
This class represents a general Wang-Teter style non-local kinetic energy functional with user-chosen \((\alpha,~\beta)\) parameters. Conventional choices of these parameters include
\((\alpha,~\beta)=(5/6,5/6)\) in the Wang-Teter functional [Phys. Rev. B 45, 13196]
\((\alpha,~\beta)=(1,1)\) in the Perrot functional [J. Phys.: Condens. Matter 6 431]
\((\alpha,~\beta)=(1/2,1/2)\) in the Smargiassi-Madden functional [Phys. Rev. B 49, 5220]
\((\alpha,~\beta) = ((5+\sqrt{5})/6,~(5-\sqrt{5})/6)\) in the Wang-Govind-Carter 98 functional [Phys. Rev. B 58, 13465]
This class also allows for the use of a Pauli-positivity stabilization function [J. Phys. Chem. A 2021, 125, 7, 1650–1660].
- __init__(init_args=None)#
- Parameters:
init_args (tuple) – \((\alpha,~\beta,~f)\) where \((\alpha,~\beta)\) are floats and \(f\) is a function. \((\alpha,~\beta)\) are key parameters of the Wang-Teter style functionals while \(f\) is the Pauli-positivity stabilization function, which must obey \(f(0) = 1\). The default parameters are \((\alpha,~\beta,~f) = (5/6,~5/6,~f(x) = 1 +x)\).
- forward(box_vecs, den)#
- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
- Returns:
WT-style functional kinetic energy
- Return type:
torch.Tensor
Wang-Govind-Carter 99 (WGC99) Functional#
- class functionals.WangGovindCarter99#
Wang-Govind-Carter 99 (WGC99) functional
The Wang-Govind-Carter 99 (WGC99) functional [Phys. Rev. B 60, 16350] is non-local kinetic functional that extends the Wang-Govind-Carter 98 functional to have a density-dependent kernel. In practice however, a Taylor-expansion is used to avoid the unattractive computational scaling resulting from the density-dependent kernel.
- __init__(init_args=None)#
- Parameters:
init_args (tuple) – \((\alpha,~\beta,~\gamma,~\kappa)\) where each parameter is a float. \(\alpha,~\beta,~\gamma\) are key parameters of the WGC99 functional, while \(\kappa\) is an enhancement factor for the reference uniform density such that \(n^* = κ n_0\) The default parameters are \((\alpha,~\beta,~\gamma,~\kappa) = ((5+\sqrt{5})/6,~(5-\sqrt{5})/6,~2.7,~1)\)
- generate_kernel(num_terms=100)#
Generates the WGC99 kernel based on its analytical form given in Phys. Rev. B 78, 045105.
- Parameters:
num_terms (int) – Number of terms at which the infinite summation is truncated
- forward(box_vecs, den)#
- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
- Returns:
WGC99 kinetic energy
- Return type:
torch.Tensor
Foley-Madden (FM) Functional#
- class functionals.FoleyMadden#
Foley-Madden (FM) functional
The Foley-Madden (FM) functional [Phys. Rev. B 53, 10589] is a non-local kinetic functional that includes a kernel meant to enforce the correct quadratic response in the homogeneous electron gas limit, in addition to the Wang-Teter style non-local kernel integral term meant to enforce the correct linear response.
- __init__(init_args=None)#
- Parameters:
init_args (tuple) – \((\alpha,~\beta,~f)\) where \((\alpha,~\beta)\) are floats and \(f\) is a function. \((\alpha,~\beta)\) are key parameters of the Foley-Madden functional while \(f\) is the Pauli-positivity stabilization function, which must obey \(f(0) = f'(0) = 1\). The default parameters are \((\alpha,~\beta,~f) = (5/6,~1,~f(x) = 1 +x)\).
- forward(box_vecs, den)#
- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
- Returns:
FM kinetic energy
- Return type:
torch.Tensor
KGAP Functional#
- functionals.KGAP(box_vecs, den, E_gap, f=<function <lambda>>)#
KGAP functional
The KGAP functional [Phys. Rev. B 97, 205137] is a Wang-Teter style non-local kinetic functional with a density-independent kernel that allows the functional to satisfy the homogeneous limit linear response of a gapped-jellium, instead of the usual Lindhard response of the free electron gas.
- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
E_gap (float) – Band gap of the system of interest (in eV)
- Returns:
KGAP kinetic energy
- Return type:
torch.Tensor
Huang-Carter (HC) Functional#
- class functionals.HuangCarter#
Huang-Carter (HC) functional
The Huang-Carter (HC) functional [Phys. Rev. B 81, 045206] is a non-local kinetic functional that has a single-point density dependent kernel.
- __init__(init_args)#
- Parameters:
init_args (tuple) – \((\lambda,~\beta,~\kappa)\) where each parameter is a float. \(\lambda,~\beta\) are key parameters of the HC functional, while \(\kappa\) is a parameter for the spline-based field dependent convolution. Recommended values for the parameters are \((\lambda,~\beta) = (0.01177,~0.7143)\). Note that a geometric progression based spline is used so \(\kappa > 1\). It is recommended to start with \(\kappa = 1.2\) and reduce \(\kappa\) until the energy is converged.
- generate_kernel(eta_max=50, N_eta=10000)#
Generates the Huang-Carter kernel, \(\omega(\eta)\), by solving an initial value problem with Xitorch. The associated ordinary differential eqaution (ODE) is obtained by imposing the Lindhard response of a homogeneous electron gas on the Huang-Carter functional.
- Parameters:
eta_max (float) – Upper bound of \(\eta\) to solve the ODE from
N_eta (int) – Number of data points in \([0, \eta_\text{max}]\)
- forward(box_vecs, den)#
- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
- Returns:
HC kinetic energy
- Return type:
torch.Tensor
Revised Huang-Carter (revHC) Functional#
- class functionals.RevisedHuangCarter#
revised Huang-Carter (revHC) functional
The revised Huang-Carter (revHC) functional [Phys. Rev. B 104, 045118] is a non-local kinetic functional that has a single-point density dependent kernel. The revision of the Huang-Carter functional is to handle cases where the reduced gradient term is large due to small densities, such as for surface calculations.
- __init__(init_args)#
- Parameters:
init_args (tuple) – \((a,~b,~\beta,~\kappa)\) where each parameter is a float. \(a,~b,~\beta\) are key parameters of the revHC functional, while \(\kappa\) is a parameter for the spline-based field dependent convolution. Recommended values for the parameters are \((a,~b,~\beta) = (0.45,~0.10,~2/3)\). Note that a geometric progression based spline is used so \(\kappa > 1\). It is recommended to start with \(\kappa = 1.15\) and reduce \(\kappa\) until the energy is converged.
- generate_kernel(eta_max=50, N_eta=10000)#
Generates the Huang-Carter kernel, \(\omega(\eta)\), by solving an initial value problem with Xitorch. The associated ordinary differential eqaution (ODE) is obtained by imposing the Lindhard response of a homogeneous electron gas on the Huang-Carter functional.
- Parameters:
eta_max (float) – Upper bound of \(\eta\) to solve the ODE from
N_eta (int) – Number of data points in \([0, \eta_\text{max}]\)
- forward(box_vecs, den)#
- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
- Returns:
revHC kinetic energy
- Return type:
torch.Tensor
Mi-Genova-Pavanello (MGP) Functional#
- class functionals.MiGenovaPavanello#
Mi-Genova-Pavanello (MGP) functional
The Mi-Genova-Pavanello (MGP) functional [J. Chem. Phys. 148, 184107] is a non-local kinetic functional based on line integrals.
- __init__(init_args)#
- Parameters:
init_args (tuple) – \((a,~b)\) where each parameter is a float. They are key parameters of the Mi-Genova-Pavanello functional.
- generate_kernel(eta_max=60, N_eta=2000, N_int=10000)#
Generates the integral part of the MGP kernel in one-dimension for later interpolation. This process involves perform numerical integration.
- Parameters:
eta_max (float) – \(\eta_\text{max}\) is the upper bound for which the kernel \(K(\eta)\) is generated up to
N_eta (int) – Number of data points in \([0, \eta_\text{max}]\)
N_int (int) – Number of integration points for numerical integration of the kernel
- forward(box_vecs, den)#
- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
- Returns:
MGP kinetic energy
- Return type:
torch.Tensor
Xu-Wang-Ma (XWM) Functional#
- functionals.XuWangMa(box_vecs, den, kappa=0)#
Xu-Wang-Ma (XWM) functional
The Xu-Wang-Ma (XWM) functional [Phys. Rev. B 100, 205132] is a non-local kinetic functional based on line integrals, with a density-dependent kernel. In practice however, a Taylor-expansion is used to avoid the unattractive computational scaling resulting from the density-dependent kernel.
- Parameters:
box_vecs (torch.Tensor) – Lattice vectors
den (torch.Tensor) – Electron density
kappa (float) – Adjustable parameter (default \(\kappa=0\))
- Returns:
XWM kinetic energy
- Return type:
torch.Tensor