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
« 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.
5Reference: J. Chem. Phys. 145, 021101.
6"""
8import math
10from eminus import backend as xp
13def lda_c_chachiyo(n, **kwargs):
14 """Chachiyo parametrization of the correlation functional (spin-paired).
16 Corresponds to the functional with the label LDA_C_CHACHIYO and ID 287 in Libxc.
18 Reference: J. Chem. Phys. 145, 021101.
20 Args:
21 n: Real-space electronic density.
23 Keyword Args:
24 **kwargs: Throwaway arguments.
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
32 rs = (3 / (4 * math.pi * n)) ** (1 / 3)
33 rs2 = rs**2
34 ecinner = 1 + b / rs + b / rs2
36 ec = a * xp.log(ecinner)
38 vc = ec + a * b * (2 + rs) / (3 * (b + b * rs + rs2))
39 return ec, xp.stack([vc]), None
42def chachiyo_scaling(zeta):
43 """Weighting factor between the paramagnetic and the ferromagnetic case.
45 Reference: J. Chem. Phys. 145, 021101.
47 Args:
48 zeta: Relative spin polarization.
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))
55 dfdzeta = (2 * (1 - zeta) ** (1 / 3) - 2 * (1 + zeta) ** (1 / 3)) / (3 - 3 * 2 ** (1 / 3))
56 return fzeta, dfdzeta
59def lda_c_chachiyo_spin(n, zeta, weight_function=chachiyo_scaling, **kwargs):
60 """Chachiyo parametrization of the correlation functional (spin-polarized).
62 Corresponds to the functional with the label LDA_C_CHACHIYO and ID 287 in Libxc.
64 Reference: J. Chem. Phys. 145, 021101.
66 Args:
67 n: Real-space electronic density.
68 zeta: Relative spin polarization.
70 Keyword Args:
71 weight_function: Functional function.
72 **kwargs: Throwaway arguments.
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
82 rs = (3 / (4 * math.pi * n)) ** (1 / 3)
83 rs2 = rs**2
85 fzeta, dfdzeta = weight_function(zeta)
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)
92 ec = ec0 + (ec1 - ec0) * fzeta
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
101 vc_up = prefactor + decdf * (1 - zeta)
102 vc_dw = prefactor - decdf * (1 + zeta)
103 return ec, xp.stack([vc_up, vc_dw]), None