Coverage for eminus/xc/gga_c_chachiyo.py: 100.00%
57 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-08 12:59 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-08 12:59 +0000
1# SPDX-FileCopyrightText: 2021 The eminus developers
2# SPDX-License-Identifier: Apache-2.0
3"""Chachiyo GGA correlation.
5Reference: Comput. Theor. Chem. 1172, 112669.
6"""
8import numpy as np
9from scipy.linalg import norm
11from .lda_c_chachiyo_mod import chachiyo_scaling_mod as weight_function
14def gga_c_chachiyo(n, dn_spin=None, **kwargs):
15 """Chachiyo parametrization of the correlation functional (spin-paired).
17 Corresponds to the functional with the label GGA_C_CHACHIYO and ID 309 in Libxc.
19 Reference: Comput. Theor. Chem. 1172, 112669.
21 Args:
22 n: Real-space electronic density.
24 Keyword Args:
25 dn_spin: Real-space gradient of densities per spin channel.
26 **kwargs: Throwaway arguments.
28 Returns:
29 Chachiyo correlation energy density, potential and vsigma.
30 """
31 h = 0.06672632 # 0.5 * 0.00847 * 16 * (3 / np.pi)**(1 / 3)
33 # ### Start lda_c_chachiyo_mod ### #
34 a = -0.01554535 # (np.log(2) - 1) / (2 * np.pi**2)
35 b = 20.4562557
37 rs = (3 / (4 * np.pi * n)) ** (1 / 3)
38 rs2 = rs**2
39 ecinner = 1 + b / rs + b / rs2
41 ec = a * np.log(ecinner)
42 # ### End lda_c_chachiyo_mod ### #
44 norm_dn = norm(dn_spin[0], axis=1)
45 t = (np.pi / 3) ** (1 / 6) / 4 * norm_dn / n ** (7 / 6)
46 t2 = t**2
47 gec = 1 + t2
48 expgec = gec ** (h / ec)
50 # ### Start lda_c_chachiyo_mod ### #
51 vc = ec + a * b * (2 + rs) / (3 * (b + b * rs + rs2))
52 # ### End lda_c_chachiyo_mod ### #
54 term1 = h * (1 - 1 / gec)
55 term2 = h * np.log(gec) * (1 - vc / ec)
56 gvc = (vc - 7 / 3 * term1 + term2) * expgec
58 vsigmac = n * expgec * term1 / norm_dn**2
59 return ec * expgec, np.array([gvc]), np.array([vsigmac])
62def gga_c_chachiyo_spin(n, zeta, dn_spin=None, **kwargs):
63 """Chachiyo parametrization of the correlation functional (spin-polarized).
65 Corresponds to the functional with the label GGA_C_CHACHIYO and ID 309 in Libxc.
67 Reference: Comput. Theor. Chem. 1172, 112669.
69 Args:
70 n: Real-space electronic density.
71 zeta: Relative spin polarization.
73 Keyword Args:
74 dn_spin: Real-space gradient of densities per spin channel.
75 **kwargs: Throwaway arguments.
77 Returns:
78 Chachiyo correlation energy density, potential and vsigma.
79 """
80 h = 0.06672632 # 0.5 * 0.00847 * 16 * (3 / np.pi)**(1 / 3)
82 # ### Start lda_c_chachiyo_spin_mod ### #
83 a0 = -0.01554535 # (np.log(2) - 1) / (2 * np.pi**2)
84 a1 = -0.007772675 # (np.log(2) - 1) / (4 * np.pi**2)
85 b0 = 20.4562557
86 b1 = 27.4203609
88 rs = (3 / (4 * np.pi * n)) ** (1 / 3)
89 rs2 = rs**2
91 fzeta, dfdzeta = weight_function(zeta)
93 ec0inner = 1 + b0 / rs + b0 / rs2
94 ec1inner = 1 + b1 / rs + b1 / rs2
95 ec0 = a0 * np.log(ec0inner)
96 ec1 = a1 * np.log(ec1inner)
98 ec = ec0 + (ec1 - ec0) * fzeta
99 # ### End lda_c_chachiyo_spin_mod ### #
101 norm_dn = norm(dn_spin[0] + dn_spin[1], axis=1)
102 t = (np.pi / 3) ** (1 / 6) / 4 * norm_dn / n ** (7 / 6)
103 t2 = t**2
104 gec = 1 + t2
105 expgec = gec ** (h / ec)
107 # ### Start lda_c_chachiyo_spin_mod ### #
108 factor = -1 / rs2 - 2 / rs**3
109 dec0drs = a0 / ec0inner * b0 * factor
110 dec1drs = a1 / ec1inner * b1 * factor
111 decdrs = dec0drs + (dec1drs - dec0drs) * fzeta
112 # prefactor = ec - rs / 3 * decdrs
113 decdf = (ec1 - ec0) * dfdzeta
115 # vcup = prefactor + decdf * (1 - zeta)
116 # vcdw = prefactor - decdf * (1 + zeta)
117 # ### End lda_c_chachiyo_spin_mod ### #
119 dn2 = (
120 norm(dn_spin[0], axis=1) ** 2
121 + 2 * np.sum(dn_spin[0] * dn_spin[1], axis=1)
122 + norm(dn_spin[1], axis=1) ** 2
123 )
124 ht2divgecdn2 = (1 - 1 / gec) * h / norm_dn**2
125 term1 = -7 / 3 * ht2divgecdn2 * dn2
126 term2 = 1 - h * np.log(gec) / ec
127 prefactor = -decdrs * rs / 3
128 gvc = ec + term1 + term2 * prefactor
129 gvcup = gvc + term2 * decdf * (1 - zeta)
130 gvcdw = gvc - term2 * decdf * (1 + zeta)
132 vsigma = n * expgec * 2 * ht2divgecdn2
133 vsigmac = np.array([0.5 * vsigma, vsigma, 0.5 * vsigma])
134 return ec * expgec, np.array([gvcup, gvcdw]) * expgec, vsigmac