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

1# SPDX-FileCopyrightText: 2023 The eminus developers 

2# SPDX-License-Identifier: Apache-2.0 

3"""Slater LDA exchange. 

4 

5Reference: Phys. Rev. 81, 385. 

6""" 

7 

8import math 

9 

10from eminus import backend as xp 

11 

12 

13def lda_x(n, **kwargs): 

14 """Slater exchange functional (spin-paired). 

15 

16 Corresponds to the functional with the label LDA_X and ID 1 in Libxc. 

17 

18 Reference: Phys. Rev. 81, 385. 

19 

20 Args: 

21 n: Real-space electronic density. 

22 

23 Keyword Args: 

24 **kwargs: Throwaway arguments. 

25 

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) 

31 

32 ex = f / rs 

33 

34 vx = 4 / 3 * ex 

35 return ex, xp.stack([vx]), None 

36 

37 

38def lda_x_spin(n, zeta, **kwargs): 

39 """Slater exchange functional (spin-polarized). 

40 

41 Corresponds to the functional with the label LDA_X and ID 1 in Libxc. 

42 

43 Reference: Phys. Rev. 81, 385. 

44 

45 Args: 

46 n: Real-space electronic density. 

47 zeta: Relative spin polarization. 

48 

49 Keyword Args: 

50 **kwargs: Throwaway arguments. 

51 

52 Returns: 

53 Exchange energy density and potential. 

54 """ 

55 f = -3 / 4 * (3 / math.pi) ** (1 / 3) 

56 

57 rho13p = ((1 + zeta) * n) ** (1 / 3) 

58 rho13m = ((1 - zeta) * n) ** (1 / 3) 

59 

60 ex_up = f * rho13p 

61 ex_dw = f * rho13m 

62 ex = 0.5 * ((1 + zeta) * ex_up + (1 - zeta) * ex_dw) 

63 

64 vx_up = 4 / 3 * ex_up 

65 vx_dw = 4 / 3 * ex_dw 

66 return ex, xp.stack([vx_up, vx_dw]), None