势函数模块 (potentials)

顶层包

ThermoElasticSim - 势能模块

这是一个包,提供了各种用于分子动力学模拟的原子间势。 采用延迟导入模式以避免循环依赖并提高加载性能。

Added in version 4.0.0.

本模块提供各种原子间相互作用势函数。

基类

ThermoElasticSim - 势能基类模块

class thermoelasticsim.potentials.base.Potential(parameters, cutoff)[源代码]

基类:ABC

势能计算的抽象基类。

提供原子间势能模型的统一接口,约定最小方法集以支持分子动力学 (MD) 中的力与能量评估。

参数:
  • parameters (dict) -- 势能参数字典(按具体模型定义)。

  • cutoff (float) -- 势能截断距离,单位 Å。

备注

  • 所有具体势能模型至少需实现 calculate_forcescalculate_energy

  • 单位约定:能量 eV,长度 Å,力 eV/Å。

__init__(parameters, cutoff)[源代码]
abstractmethod calculate_forces(cell, neighbor_list)[源代码]

计算系统中所有原子的作用力。

参数:
  • cell (Cell) -- 晶胞与原子集合。

  • neighbor_list (NeighborList) -- 邻居列表(按模型需要使用)。

返回类型:

None

备注

  • 需就地写入 force (单位 eV/Å)。

  • 抽象方法,必须由子类实现。

abstractmethod calculate_energy(cell, neighbor_list)[源代码]

计算系统的总势能。

参数:
  • cell (Cell) -- 晶胞与原子集合。

  • neighbor_list (NeighborList) -- 邻居列表(按模型需要使用)。

返回:

系统总势能,单位 eV。

返回类型:

float

备注

抽象方法,必须由子类实现。

EAM势

ThermoElasticSim - EAM 势模块

该模块实现了嵌入式原子方法 (Embedded Atom Method, EAM) 势, 特别是基于 Mendelev et al. (2008) 参数化的铝 (Al) 和铜 (Cu) 势。

EAM势将系统的总能量表示为对势项和嵌入能的总和。每个原子的嵌入能 取决于其所处位置的局部电子密度,而局部电子密度则由周围原子贡献的电子密度叠加而成。

总能量表达式为:

\[E = \sum_i F(\rho_i) + \frac{1}{2} \sum_{i \neq j} \phi(r_{ij})\]

其中,\(F(\rho_i)\) 是嵌入能函数,\(\rho_i\) 是原子 \(i\) 处的局部电子密度, \(\phi(r_{ij})\) 是原子 \(i\)\(j\) 之间的对势函数。

局部电子密度 \(\rho_i\) 由以下公式计算:

\[\rho_i = \sum_{j \neq i} \psi(r_{ij})\]

其中,\(\psi(r_{ij})\) 是原子 \(j\) 在原子 \(i\) 处产生的电子密度贡献函数。

作用在原子 \(i\) 上的力 \(\mathbf{F}_i\) 由总能量对原子位置的负梯度给出:

\[\mathbf{F}_i = -\nabla_i E = -\sum_{j \neq i} \left[ \phi'(r_{ij}) + F'(\rho_i) \psi'(r_{ij}) + F'(\rho_j) \psi'(r_{ji}) \right] \frac{\mathbf{r}_{ij}}{r_{ij}}\]

引用

  • Daw, M. S., & Baskes, M. I. (1984). Embedded-atom method: Derivation and application to impurities, surfaces, and other defects in metals. Phys. Rev. B 29, 6443. doi:10.1103/PhysRevB.29.6443

  • Mendelev, M. I., Kramer, M. J., Becker, C. A., & Asta, M. (2008). Analysis of semi-empirical interatomic potentials appropriate for simulation of crystalline and liquid Al and Cu. Philosophical Magazine, 88(12), 1723–1750. doi:10.1080/14786430802206482

Classes:

EAMAl1Potential: 铝的EAM势能实现。 EAMCu1Potential: 铜的EAM势能实现。

class thermoelasticsim.potentials.eam.EAMAl1Potential(cutoff=6.5)[源代码]

基类:Potential

铝的嵌入式原子方法 (EAM) 势实现。

基于 Mendelev et al. (2008) Phil. Mag. 88(12) 的Al参数化。

参数:

cutoff (float, optional) -- 截断距离(Å),默认 6.5。

备注

  • 绑定 C++ 后端 eam_al1;单位:能量 eV,长度 Å,力 eV/Å。

  • 理论背景与方法见模块“References”。

__init__(cutoff=6.5)[源代码]
参数:

cutoff (float)

calculate_forces(cell, neighbor_list=None)[源代码]

使用EAM势计算系统中所有原子的作用力。

参数:
  • cell (Cell) -- 包含原子信息的晶胞对象。

  • neighbor_list (NeighborList, optional) -- 在此实现中未使用,但为保持接口一致性而保留。

返回类型:

None

calculate_energy(cell, neighbor_list=None)[源代码]

使用EAM势计算系统的总势能。

参数:
  • cell (Cell) -- 包含原子信息的晶胞对象。

  • neighbor_list (NeighborList, optional) -- 在此实现中未使用,但为保持接口一致性而保留。

返回:

系统的总势能,单位 eV。

返回类型:

float

class thermoelasticsim.potentials.eam.EAMCu1Potential(cutoff=6.0)[源代码]

基类:Potential

铜的嵌入式原子方法 (EAM) 势实现(Mendelev 族参数化)。

参数:

cutoff (float, optional) -- 截断距离(Å),默认 6.0。

备注

  • 绑定 C++ 后端 eam_cu1;单位:能量 eV,长度 Å,力 eV/Å。

  • 理论背景与方法见模块“References”。

__init__(cutoff=6.0)[源代码]
参数:

cutoff (float)

calculate_forces(cell, neighbor_list=None)[源代码]

使用EAM Cu1势计算系统中所有原子的作用力。

参数:
  • cell (Cell) -- 包含原子信息的晶胞对象。

  • neighbor_list (NeighborList, optional) -- 在此实现中未使用,但为保持接口一致性而保留。

返回类型:

None

calculate_energy(cell, neighbor_list=None)[源代码]

使用EAM Cu1势计算系统的总势能。

参数:
  • cell (Cell) -- 包含原子信息的晶胞对象。

  • neighbor_list (NeighborList, optional) -- 在此实现中未使用,但为保持接口一致性而保留。

返回:

系统的总势能,单位 eV。

返回类型:

float

Lennard-Jones势

ThermoElasticSim - Lennard-Jones 势模块

Lennard–Jones (12–6) 势用于近似描述惰性原子间的范德华作用:

\[V(r) = 4\,\varepsilon\Big[\Big(\frac{\sigma}{r}\Big)^{12} - \Big(\frac{\sigma}{r}\Big)^6\Big]\]

其中 \(\varepsilon\) 为势阱深度(eV),\(\sigma\) 为零势能点对应长度(Å)。

引用

  • J. E. Jones (1924), On the Determination of Molecular Fields. I. From the Variation of the Viscosity of a Gas with Temperature. Proceedings of the Royal Society A, 106(738), 441–462. doi:10.1098/rspa.1924.0081

class thermoelasticsim.potentials.lennard_jones.LennardJonesPotential(epsilon, sigma, cutoff)[源代码]

基类:Potential

Lennard–Jones (12–6) 对势实现。

参数:
  • epsilon (float) -- 势阱深度 epsilon(eV)。

  • sigma (float) -- 零势能点对应长度 sigma(Å)。

  • cutoff (float) -- 截断距离(Å)。

备注

  • 势函数见模块 References 中的 Jones (1924)。

  • 单位:能量 eV,长度 Å,力 eV/Å。

__init__(epsilon, sigma, cutoff)[源代码]
参数:
calculate_forces(cell, neighbor_list)[源代码]

计算作用力并写入 cell.atoms[i].force (eV/Å)。

参数:
  • cell (Cell) -- 晶胞与原子集合。

  • neighbor_list (NeighborList) -- 预先构建的邻居列表。

返回类型:

None

calculate_energy(cell, neighbor_list)[源代码]

计算系统总势能(eV)。

参数:
  • cell (Cell) -- 晶胞与原子集合。

  • neighbor_list (NeighborList) -- 预先构建的邻居列表。

返回:

系统总势能(eV)。

返回类型:

float

Tersoff势

ThermoElasticSim - Tersoff 势模块

Tersoff 多体势用于共价材料(Si、C 等),本实现提供 C(1988) 版本的参数化, 并通过 C++ 后端计算能量、力与维里张量(支持可选的平衡键长 shift=delta)。

引用

  • Tersoff, J. (1988). Empirical Interatomic Potential for Carbon, with Applications to Amorphous Carbon. Phys. Rev. Lett. 61, 2879–2882.

  • Tersoff, J. (1988). New empirical approach for the structure and energy of covalent systems. Phys. Rev. B 37, 6991–7000.

class thermoelasticsim.potentials.tersoff.TersoffC1988Potential(params=None, delta=0.0)[源代码]

基类:Potential

Tersoff (1988, C) 多体势实现(C++ 后端)。

参数:
  • params (dict | None, optional) -- 自定义参数;若为 None 则使用 C++ 内置的 1988 年碳默认参数。

  • delta (float, optional) -- LAMMPS 风格的可选键长 shift(r → r + delta),默认 0.0。

备注

  • 单位:能量 eV,长度 Å,力 eV/Å。

  • 截断半径自动取 :code:`R + D`(由参数决定)。

  • 该实现直接使用 C++ 多体解析力,维里按 \(-\sum_i r_i \otimes F_i\) 计算。

__init__(params=None, delta=0.0)[源代码]
参数:
calculate_forces(cell, neighbor_list=None)[源代码]

计算并更新原子受力。

参数:
  • cell (Cell) -- 原子系统

  • neighbor_list (NeighborList | None) -- 邻居列表(未使用)

返回类型:

None

calculate_energy(cell, neighbor_list=None)[源代码]

计算系统总能量。

参数:
  • cell (Cell) -- 原子系统

  • neighbor_list (NeighborList | None) -- 邻居列表(未使用)

返回:

总能量(eV)

返回类型:

float

机器学习势(开发中)

ThermoElasticSim - 机器学习势接口模块

提供与外部机器学习势(如基于 PyTorch / TensorFlow / JAX 或 KIM 模型)的 统一接口框架。当前类为框架占位,需在具体项目中集成实际模型推理。

class thermoelasticsim.potentials.mlp.MLPotential(model_path, cutoff)[源代码]

基类:Potential

机器学习势 (MLP) 的通用接口框架(占位,未实现推理)。

参数:
  • model_path (str) -- 预训练模型路径。

  • cutoff (float) -- 截断距离(Å)。

备注

  • 需实现模型加载与推理以提供力与能量。

  • 单位:能量 eV,长度 Å,力 eV/Å。

__init__(model_path, cutoff)[源代码]
参数:
calculate_forces(cell, neighbor_list)[源代码]

计算力(未实现)。

抛出:

NotImplementedError -- 需提供模型推理计算力。

参数:
返回类型:

None

calculate_energy(cell, neighbor_list)[源代码]

计算能量(未实现)。

抛出:

NotImplementedError -- 需提供模型推理计算能量。

参数:
返回类型:

float