Coverage for eminus/xc/lda_c_chachiyo.py: 100.00%

37 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"""Chachiyo LDA correlation. 

4 

5Reference: J. Chem. Phys. 145, 021101. 

6""" 

7 

8import math 

9 

10from eminus import backend as xp 

11 

12 

13def lda_c_chachiyo(n, **kwargs): 

14 """Chachiyo parametrization of the correlation functional (spin-paired). 

15 

16 Corresponds to the functional with the label LDA_C_CHACHIYO and ID 287 in Libxc. 

17 

18 Reference: J. Chem. Phys. 145, 021101. 

19 

20 Args: 

21 n: Real-space electronic density. 

22 

23 Keyword Args: 

24 **kwargs: Throwaway arguments. 

25 

26 Returns: 

27 Chachiyo correlation energy density and potential. 

28 """ 

29 a = -0.01554535 # (xp.log(2) - 1) / (2 * math.pi**2) 

30 b = 20.4562557 

31 

32 rs = (3 / (4 * math.pi * n)) ** (1 / 3) 

33 rs2 = rs**2 

34 ecinner = 1 + b / rs + b / rs2 

35 

36 ec = a * xp.log(ecinner) 

37 

38 vc = ec + a * b * (2 + rs) / (3 * (b + b * rs + rs2)) 

39 return ec, xp.stack([vc]), None 

40 

41 

42def chachiyo_scaling(zeta): 

43 """Weighting factor between the paramagnetic and the ferromagnetic case. 

44 

45 Reference: J. Chem. Phys. 145, 021101. 

46 

47 Args: 

48 zeta: Relative spin polarization. 

49 

50 Returns: 

51 Weighting factor and its derivative. 

52 """ 

53 fzeta = ((1 + zeta) ** (4 / 3) + (1 - zeta) ** (4 / 3) - 2) / (2 * (2 ** (1 / 3) - 1)) 

54 

55 dfdzeta = (2 * (1 - zeta) ** (1 / 3) - 2 * (1 + zeta) ** (1 / 3)) / (3 - 3 * 2 ** (1 / 3)) 

56 return fzeta, dfdzeta 

57 

58 

59def lda_c_chachiyo_spin(n, zeta, weight_function=chachiyo_scaling, **kwargs): 

60 """Chachiyo parametrization of the correlation functional (spin-polarized). 

61 

62 Corresponds to the functional with the label LDA_C_CHACHIYO and ID 287 in Libxc. 

63 

64 Reference: J. Chem. Phys. 145, 021101. 

65 

66 Args: 

67 n: Real-space electronic density. 

68 zeta: Relative spin polarization. 

69 

70 Keyword Args: 

71 weight_function: Functional function. 

72 **kwargs: Throwaway arguments. 

73 

74 Returns: 

75 Chachiyo correlation energy density and potential. 

76 """ 

77 a0 = -0.01554535 # (xp.log(2) - 1) / (2 * math.pi**2) 

78 a1 = -0.007772675 # (xp.log(2) - 1) / (4 * math.pi**2) 

79 b0 = 20.4562557 

80 b1 = 27.4203609 

81 

82 rs = (3 / (4 * math.pi * n)) ** (1 / 3) 

83 rs2 = rs**2 

84 

85 fzeta, dfdzeta = weight_function(zeta) 

86 

87 ec0inner = 1 + b0 / rs + b0 / rs2 

88 ec1inner = 1 + b1 / rs + b1 / rs2 

89 ec0 = a0 * xp.log(ec0inner) 

90 ec1 = a1 * xp.log(ec1inner) 

91 

92 ec = ec0 + (ec1 - ec0) * fzeta 

93 

94 factor = -1 / rs2 - 2 / rs**3 

95 dec0drs = a0 / ec0inner * b0 * factor 

96 dec1drs = a1 / ec1inner * b1 * factor 

97 decdrs = dec0drs + (dec1drs - dec0drs) * fzeta 

98 prefactor = ec - rs / 3 * decdrs 

99 decdf = (ec1 - ec0) * dfdzeta 

100 

101 vc_up = prefactor + decdf * (1 - zeta) 

102 vc_dw = prefactor - decdf * (1 + zeta) 

103 return ec, xp.stack([vc_up, vc_dw]), None