接口模块 (interfaces)
Cpp 接口
接口模块。
该模块定义了 CppInterface 类,用于通过 pybind11 调用外部 C++ 函数库。
- class thermoelasticsim.interfaces.cpp_interface.CppInterface(lib_name)[源代码]
基类:
object用于调用 C++ 实现的函数的接口类
@class CppInterface @brief 用于调用 C++ 实现的函数的接口类
- 参数:
lib_name (str) -- 库的名称,用于确定可用的函数集合。
- compute_stress(num_atoms, positions, velocities, forces, masses, volume, box_lengths, stress_tensor)[源代码]
计算应力张量。
本函数允许输入的 positions, velocities, forces 既可以是 (num_atoms, 3) 也可以是 (3*num_atoms,) 的形状。 同理,对于 stress_tensor,既可以是 (3,3) 也可以是 (9,)。
- 参数:
num_atoms (int)
positions (np.ndarray) -- 原子位置数组,可为 (num_atoms, 3) 或 (3*num_atoms, )
velocities (np.ndarray) -- 原子速度数组,可为 (num_atoms, 3) 或 (3*num_atoms, )
forces (np.ndarray) -- 原子力数组,可为 (num_atoms, 3) 或 (3*num_atoms, )
masses (np.ndarray) -- 原子质量数组 (num_atoms,)
volume (float) -- 晶胞体积
box_lengths (np.ndarray) -- 晶胞长度数组 (3,)
stress_tensor (np.ndarray) -- 输出应力张量,可为 (3,3) 或 (9,)
- 返回类型:
None
- calculate_lj_forces(num_atoms, positions, forces, epsilon, sigma, cutoff, box_lengths, neighbor_pairs, num_pairs)[源代码]
调用 C++ 接口计算作用力。
- 参数:
num_atoms (int) -- 原子数。
positions (numpy.ndarray) -- 原子位置数组,形状为 (num_atoms, 3)。
forces (numpy.ndarray) -- 力数组,形状为 (num_atoms, 3),将被更新。
epsilon (float) -- Lennard-Jones 势参数 ε,单位 eV。
sigma (float) -- Lennard-Jones 势参数 σ,单位 Å。
cutoff (float) -- 截断距离,单位 Å。
box_lengths (numpy.ndarray) -- 盒子长度数组,形状为 (3,)。
neighbor_pairs (numpy.ndarray) -- 邻居对数组,形状为 (2*num_pairs,)。
num_pairs (int) -- 邻居对的数量。
- 返回类型:
None
- calculate_lj_energy(num_atoms, positions, epsilon, sigma, cutoff, box_lengths, neighbor_pairs, num_pairs)[源代码]
调用 C++ 接口计算能量。
- 参数:
num_atoms (int) -- 原子数。
positions (numpy.ndarray) -- 原子位置数组,形状为 (num_atoms, 3)。
epsilon (float) -- Lennard-Jones 势参数 ε,单位 eV。
sigma (float) -- Lennard-Jones 势参数 σ,单位 Å。
cutoff (float) -- 截断距离,单位 Å。
box_lengths (numpy.ndarray) -- 盒子长度数组,形状为 (3,)。
neighbor_pairs (numpy.ndarray) -- 邻居对数组,形状为 (2*num_pairs,)。
num_pairs (int) -- 邻居对的数量。
- 返回:
总势能,单位 eV。
- 返回类型:
- calculate_eam_al1_forces(num_atoms, positions, lattice_vectors, forces)[源代码]
计算EAM Al1势的原子力。
- 参数:
num_atoms (int) -- 原子数量
positions (numpy.ndarray) -- 原子位置数组,形状为(num_atoms, 3)
lattice_vectors (numpy.ndarray) -- 晶格向量数组,形状为(3, 3)或(9,)
forces (numpy.ndarray) -- 输出的力数组,形状为(num_atoms, 3),将被更新
- 返回类型:
None
- calculate_eam_al1_energy(num_atoms, positions, lattice_vectors)[源代码]
计算EAM Al1势的总能量。
- 参数:
num_atoms (int) -- 原子数量
positions (numpy.ndarray) -- 原子位置数组,形状为(num_atoms, 3)
lattice_vectors (numpy.ndarray) -- 晶格向量数组,形状为(3, 3)或(9,)
- 返回:
系统的总能量,单位为eV
- 返回类型:
- calculate_tersoff_energy(num_atoms, positions, lattice_vectors, *, A, B, lambda1, lambda2, lambda3, beta, n, c, d, h, R, D, m=3, shift_flag=False, delta=0.0)[源代码]
计算Tersoff势能量。
- calculate_tersoff_forces(num_atoms, positions, lattice_vectors, forces, *, A, B, lambda1, lambda2, lambda3, beta, n, c, d, h, R, D, m=3, shift_flag=False, delta=0.0)[源代码]
计算Tersoff势力。
- calculate_tersoff_virial(num_atoms, positions, lattice_vectors, *, A, B, lambda1, lambda2, lambda3, beta, n, c, d, h, R, D, m=3, shift_flag=False, delta=0.0)[源代码]
计算Tersoff势维里张量。
- calculate_tersoff_c1988_energy(num_atoms, positions, lattice_vectors, *, shift_flag=False, delta=0.0)[源代码]
计算Tersoff C(1988)势能量。
- calculate_tersoff_c1988_forces(num_atoms, positions, lattice_vectors, forces, *, shift_flag=False, delta=0.0)[源代码]
计算Tersoff C(1988)势力。
- calculate_tersoff_c1988_virial(num_atoms, positions, lattice_vectors, *, shift_flag=False, delta=0.0)[源代码]
计算Tersoff C(1988)势维里张量。
- calculate_eam_al1_virial(num_atoms, positions, lattice_vectors)[源代码]
计算EAM Al1的维里张量(未除以体积)。返回形状(3,3)。
- calculate_eam_cu1_forces(num_atoms, positions, lattice_vectors, forces)[源代码]
计算EAM Cu1势的原子力。
- 参数:
num_atoms (int) -- 原子数量
positions (numpy.ndarray) -- 原子位置数组,形状为(num_atoms, 3)
lattice_vectors (numpy.ndarray) -- 晶格向量数组,形状为(3, 3)或(9,)
forces (numpy.ndarray) -- 输出的力数组,形状为(num_atoms, 3),将被更新
- 返回类型:
None
- calculate_eam_cu1_energy(num_atoms, positions, lattice_vectors)[源代码]
计算EAM Cu1势的总能量。
- 参数:
num_atoms (int) -- 原子数量
positions (numpy.ndarray) -- 原子位置数组,形状为(num_atoms, 3)
lattice_vectors (numpy.ndarray) -- 晶格向量数组,形状为(3, 3)或(9,)
- 返回:
系统的总能量,单位为eV
- 返回类型:
- calculate_eam_cu1_virial(num_atoms, positions, lattice_vectors)[源代码]
计算EAM Cu1的维里张量(未除以体积)。返回形状(3,3)。
- nose_hoover(dt, num_atoms, masses, velocities, forces, xi_array, Q, target_temperature)[源代码]
实现 Nose-Hoover 恒温器算法。!!!没有去除质心运动
- 参数:
dt (float) -- 时间步长。
num_atoms (int) -- 原子数。
masses (numpy.ndarray) -- 原子质量数组。
velocities (numpy.ndarray) -- 原子速度数组。
forces (numpy.ndarray) -- 原子受力数组。
xi_array (numpy.ndarray) -- Nose-Hoover 热浴变量数组。
Q (float) -- 热浴质量参数。
target_temperature (float) -- 目标温度。
- 返回:
更新后的 Nose-Hoover 热浴变量。
- 返回类型:
- nose_hoover_chain(dt, num_atoms, masses, velocities, forces, xi_chain, Q, chain_length, target_temperature)[源代码]
实现 Nose-Hoover 链恒温器算法。
- 参数:
dt (float) -- 时间步长。
num_atoms (int) -- 原子数。
masses (numpy.ndarray) -- 原子质量数组。
velocities (numpy.ndarray) -- 原子速度数组。
forces (numpy.ndarray) -- 原子受力数组。
xi_chain (numpy.ndarray) -- Nose-Hoover 链的热浴变量数组。
Q (numpy.ndarray) -- 热浴质量参数数组。
chain_length (int) -- Nose-Hoover 链的长度。
target_temperature (float) -- 目标温度。