Coverage for eminus/xc/gga_x_chachiyo.py: 100.00%
23 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"""Chachiyo GGA exchange.
5Reference: Molecules 25, 3485.
6"""
8import numpy as np
9from scipy.linalg import norm
11from .lda_x import lda_x
14def gga_x_chachiyo(n, dn_spin=None, **kwargs):
15 """Chachiyo parametrization of the exchange functional (spin-paired).
17 Corresponds to the functional with the label GGA_X_CHACHIYO and ID 298 in Libxc.
19 Reference: Molecules 25, 3485.
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 exchange energy density, potential, and vsigma.
30 """
31 norm_dn = norm(dn_spin[0], axis=1)
32 ex, _, _ = lda_x(n, **kwargs)
34 x = norm_dn / n ** (4 / 3) * 2 / 9 * (np.pi / 3) ** (1 / 3)
35 x1 = x + 1
36 logx1 = np.log(x1)
37 div = 3 * x + np.pi**2
38 tmpgex = 3 * x**2 + np.pi**2 * logx1
39 gex = tmpgex / (div * logx1)
41 term1 = 8 * ex / tmpgex * (x**2 + x * np.pi**2 / (6 * x1)) + 2 / 3 * norm_dn / n * (
42 1 / div + 1 / (3 * logx1 * x1)
43 )
44 gvx = (1 + 1 / 3) * ex - term1
46 vsigmax = n * 3 * term1 / (8 * norm_dn**2)
47 return ex * gex, np.array([gvx]) * gex, np.array([vsigmax]) * gex
50def gga_x_chachiyo_spin(n, zeta, dn_spin=None, **kwargs):
51 """Chachiyo parametrization of the exchange functional (spin-polarized).
53 Corresponds to the functional with the label GGA_X_CHACHIYO and ID 298 in Libxc.
55 Reference: Molecules 25, 3485.
57 Args:
58 n: Real-space electronic density.
59 zeta: Relative spin polarization.
61 Keyword Args:
62 dn_spin: Real-space gradient of densities per spin channel.
63 **kwargs: Throwaway arguments.
65 Returns:
66 Chachiyo exchange energy density, potential, and vsigma.
67 """
68 # Use the spin-scaling relationship Exc(n_up, n_down)=(Exc(2 n_up)+Exc(2 n_down))/2
69 n_up = zeta * n + n # 2 * n_up
70 n_dw = -zeta * n + n # 2 * n_down
71 ex_up, vx_up, vsigma_up = gga_x_chachiyo(n_up, np.array([2 * dn_spin[0]]), **kwargs)
72 ex_dw, vx_dw, vsigma_dw = gga_x_chachiyo(n_dw, np.array([2 * dn_spin[1]]), **kwargs)
74 vsigmax = np.array([2 * vsigma_up, np.zeros_like(vsigma_up), 2 * vsigma_dw])
75 return 0.5 * (ex_up * n_up + ex_dw * n_dw) / n, np.array([vx_up, vx_dw]), vsigmax