Coverage for eminus/xc/lda_x.py: 100.00%
18 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-21 12:19 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-21 12:19 +0000
1# SPDX-FileCopyrightText: 2023 The eminus developers
2# SPDX-License-Identifier: Apache-2.0
3"""Slater LDA exchange.
5Reference: Phys. Rev. 81, 385.
6"""
8import math
10from eminus import backend as xp
13def lda_x(n, **kwargs):
14 """Slater exchange functional (spin-paired).
16 Corresponds to the functional with the label LDA_X and ID 1 in Libxc.
18 Reference: Phys. Rev. 81, 385.
20 Args:
21 n: Real-space electronic density.
23 Keyword Args:
24 **kwargs: Throwaway arguments.
26 Returns:
27 Exchange energy density and potential.
28 """
29 f = -3 / 4 * (3 / (2 * math.pi)) ** (2 / 3)
30 rs = (3 / (4 * math.pi * n)) ** (1 / 3)
32 ex = f / rs
34 vx = 4 / 3 * ex
35 return ex, xp.stack([vx]), None
38def lda_x_spin(n, zeta, **kwargs):
39 """Slater exchange functional (spin-polarized).
41 Corresponds to the functional with the label LDA_X and ID 1 in Libxc.
43 Reference: Phys. Rev. 81, 385.
45 Args:
46 n: Real-space electronic density.
47 zeta: Relative spin polarization.
49 Keyword Args:
50 **kwargs: Throwaway arguments.
52 Returns:
53 Exchange energy density and potential.
54 """
55 f = -3 / 4 * (3 / math.pi) ** (1 / 3)
57 rho13p = ((1 + zeta) * n) ** (1 / 3)
58 rho13m = ((1 - zeta) * n) ** (1 / 3)
60 ex_up = f * rho13p
61 ex_dw = f * rho13m
62 ex = 0.5 * ((1 + zeta) * ex_up + (1 - zeta) * ex_dw)
64 vx_up = 4 / 3 * ex_up
65 vx_dw = 4 / 3 * ex_dw
66 return ex, xp.stack([vx_up, vx_dw]), None