Coverage for eminus/xc/lda_x.py: 100.00%
17 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-18 08:43 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-18 08:43 +0000
1# SPDX-FileCopyrightText: 2021 The eminus developers
2# SPDX-License-Identifier: Apache-2.0
3"""Slater LDA exchange.
5Reference: Phys. Rev. 81, 385.
6"""
8import numpy as np
11def lda_x(n, **kwargs):
12 """Slater exchange functional (spin-paired).
14 Corresponds to the functional with the label LDA_X and ID 1 in Libxc.
16 Reference: Phys. Rev. 81, 385.
18 Args:
19 n: Real-space electronic density.
21 Keyword Args:
22 **kwargs: Throwaway arguments.
24 Returns:
25 Exchange energy density and potential.
26 """
27 f = -3 / 4 * (3 / (2 * np.pi)) ** (2 / 3)
28 rs = (3 / (4 * np.pi * n)) ** (1 / 3)
30 ex = f / rs
32 vx = 4 / 3 * ex
33 return ex, np.array([vx]), None
36def lda_x_spin(n, zeta, **kwargs):
37 """Slater exchange functional (spin-polarized).
39 Corresponds to the functional with the label LDA_X and ID 1 in Libxc.
41 Reference: Phys. Rev. 81, 385.
43 Args:
44 n: Real-space electronic density.
45 zeta: Relative spin polarization.
47 Keyword Args:
48 **kwargs: Throwaway arguments.
50 Returns:
51 Exchange energy density and potential.
52 """
53 f = -3 / 4 * (3 / np.pi) ** (1 / 3)
55 rho13p = ((1 + zeta) * n) ** (1 / 3)
56 rho13m = ((1 - zeta) * n) ** (1 / 3)
58 ex_up = f * rho13p
59 ex_dw = f * rho13m
60 ex = 0.5 * ((1 + zeta) * ex_up + (1 - zeta) * ex_dw)
62 vx_up = 4 / 3 * ex_up
63 vx_dw = 4 / 3 * ex_dw
64 return ex, np.array([vx_up, vx_dw]), None