atomscf.hf.exchange
HF 交换算子模块
本模块实现 Hartree-Fock 非局域交换算子的径向中心场形式。
物理背景
在径向 HF 中心场近似下,交换算子对目标态 u_l(r) 的作用为:
其中: - \(a_k(\ell,\ell')\) 是角动量耦合因子 - \(R^k_{i,u}(r)\) 是 Slater 径向积分 - \(n_i\) 是占据态 i 的占据数 - 求和遍历所有占据态 i(轨道 \(\ell'\))
s 轨道特化
对于 s 轨道(l=0),选择规则简化为: - 仅允许 k=0(库仑项) - a_0(0,0) = 1.0 - 交换仅与其他 s 轨道耦合
交换公式变为:
实现策略
本模块采用**算子-作用式**(operator-action formulation):
交换算子返回闭包函数 K[·],而非显式矩阵
每次调用 K[u] 时实时计算 Slater 积分(避免 O(N²) 存储)
占据态间的 R^k_{i,j} 可缓存(数量有限)
目标态 u 的 R^k_{i,u} 每次重算(避免存储爆炸)
使用示例
from atomscf.hf import SlaterIntegralCache, exchange_operator_s
from atomscf.grid import radial_grid_linear, trapezoid_weights
# 准备网格
r, _ = radial_grid_linear(n=1000, rmin=1e-6, rmax=50.0)
w = trapezoid_weights(r)
# 占据态(例:氢原子 1s)
u_1s = np.sqrt(2) * np.exp(-r)
u_occ = [u_1s]
occ_nums = [1.0]
# 创建交换算子
cache = SlaterIntegralCache()
K = exchange_operator_s(r, w, u_occ, occ_nums, cache=cache)
# 应用到目标态
Ku = K(u_1s) # 返回 K[u_1s](r)
引用
Cowan, R. D. (1981) "The Theory of Atomic Structure and Spectra" University of California Press, Chapter 7
Slater, J. C. (1960) "Quantum Theory of Atomic Structure" McGraw-Hill, Volume 1
Functions
|
创建任意角动量 l 的通用交换算子。 |
|
构造自旋分辨的通用交换算子(UHF)。 |
|
创建 s 轨道 (l=0) 交换算子。 |
- atomscf.hf.exchange.exchange_operator_s(r, w, u_occ, occ_nums, cache=None)[源代码]
创建 s 轨道 (l=0) 交换算子。
返回闭包函数 K[u],对目标波函数 u 应用 HF 交换作用:
\[K[u](r) = -\sum_i n_i \cdot a_0(0,0) \cdot R^0_{i,u}(r) \cdot u_i(r)\]由于 a_0(0,0) = 1.0,公式简化为:
\[K[u](r) = -\sum_i n_i \cdot R^0_{i,u}(r) \cdot u_i(r)\]- 参数:
r (np.ndarray) -- 径向网格点(长度 n)
w (np.ndarray) -- 积分权重(长度 n)
u_occ (list[np.ndarray]) -- 占据态径向波函数列表(每个长度 n)
cache (SlaterIntegralCache | None, optional) -- Slater 积分缓存(默认 None,内部创建新缓存)
- 返回:
交换算子闭包 K[u],接受波函数 u(r) 返回 K[u](r)
- 返回类型:
Callable[[np.ndarray], np.ndarray]
备注
- 性能优化:
占据态间 R^0_{i,j} 可预先缓存
目标态 u 的 R^0_{i,u} 实时计算(避免存储)
- 符号约定:
负号来自 HF 交换的物理定义
对闭壳层自旋求和已隐含在 n_i 中
示例
氢原子 1s 自交换:
>>> r, _ = radial_grid_linear(n=1000, rmin=1e-6, rmax=50.0) >>> w = trapezoid_weights(r) >>> u_1s = np.sqrt(2) * np.exp(-r) # 归一化径向波函数 >>> K = exchange_operator_s(r, w, [u_1s], [1.0]) >>> Ku = K(u_1s) >>> # Ku(r) ≈ -u_1s(r) / r 在远处
参见
exchange_operator_general
任意 l 的通用交换算子
slater_integral_k0
k=0 Slater 积分特化版本
- atomscf.hf.exchange.exchange_operator_general(r, w, l_target, u_occ_by_l, occ_nums_by_l, cache=None)[源代码]
创建任意角动量 l 的通用交换算子。
返回闭包函数 K[u],对目标态 u_l(r) 应用完整 HF 交换:
\[K_\ell[u](r) = -\sum_{\ell'} \sum_{k} a_k(\ell,\ell') \sum_i n_i \cdot R^k_{i,u}(r) \cdot u_{\ell',i}(r)\]- 参数:
- 返回:
交换算子闭包 K[u]
- 返回类型:
Callable[[np.ndarray], np.ndarray]
备注
- 角动量耦合:
不同 l 通道通过允许的 k 值耦合
例:p-p 允许 k=[0,2],s-p 允许 k=[1]
- 性能:
复杂度 O(N_occ * n),n 为网格点数
缓存占据态间积分减少重复计算
示例
碳原子 HF(1s² 2s² 2p²):
>>> u_occ_by_l = { ... 0: [u_1s, u_2s], # s 轨道 ... 1: [u_2p], # p 轨道 ... } >>> occ_nums_by_l = { ... 0: [2.0, 2.0], # 1s² 2s² ... 1: [2.0], # 2p²(球对称平均) ... } >>> K_p = exchange_operator_general(r, w, l_target=1, ... u_occ_by_l, occ_nums_by_l) >>> Ku_2p = K_p(u_2p)
参见
exchange_operator_s
s 轨道特化版本
allowed_k_values
k 值选择规则
- atomscf.hf.exchange.exchange_operator_general_spin(r, w, l_target, spin_target, u_occ_by_l_spin, occ_nums_by_l_spin, cache=None)[源代码]
构造自旋分辨的通用交换算子(UHF)。
- 参数:
r (np.ndarray) -- 径向网格点
w (np.ndarray) -- 积分权重
l_target (int) -- 目标轨道的角动量量子数
spin_target (str) -- 目标轨道的自旋通道('up' 或 'down')
u_occ_by_l_spin (dict[tuple[int, str], list[np.ndarray]]) -- 占据态波函数,按 (l, spin) 索引 例如:{(0, 'up'): [u_1s_up], (0, 'down'): [u_1s_down], ...}
occ_nums_by_l_spin (dict[tuple[int, str], list[float]]) -- 占据数,按 (l, spin) 索引 例如:{(0, 'up'): [1.0], (0, 'down'): [1.0], ...}
cache (SlaterIntegralCache, optional) -- Slater 积分缓存(可选)
- 返回:
交换算子闭包 K[u],接受目标波函数返回交换作用后的结果
- 返回类型:
callable
备注
UHF 交换仅在**同自旋**占据态间发生:
\[K_{\ell,\sigma}[u](r) = -\sum_{\ell'} \sum_{k \in \text{allowed}} a_k(\ell,\ell') \sum_{i \in \sigma} n_i \cdot R^k_{i,u}(r) \cdot u_{\ell',i}(r)\]与 RHF 的区别: - 求和仅遍历与目标态同自旋的占据态 - 占据数 n_i 已按自旋分离,无需除以 2 - 保持 m 简并度归一化(除以 2l+1)