计算化学公社

标题: 一个简单的线性内插 (LIIC) 脚本 [打印本页]

作者
Author:
gravitylead    时间: 2026-4-1 15:08
标题: 一个简单的线性内插 (LIIC) 脚本
本帖最后由 gravitylead 于 2026-4-1 15:09 编辑

分享一个我自己使用的线性内插(linear interpolations in internal coordinates,LIICs)脚本。
脚本如下:
(, 下载次数 Times of downloads: 8)
1. 脚本的使用环境需求:
Python > 3.11 (使用了 tomllib 库)和 numpy(进行矩阵运算)
使用方法:
计算参数通过 liic-config.toml 文件进行配置。如果当前文件夹下没有 liic-config.toml 文件,脚本会自动生成一个 liic-config.toml 文件模板,内容如下:
  1. [settings]  
  2. step       = 10         # The number of points requires in LIIC  
  3. inputcoord = true       # Whether add the input coordinates to the output file. (true or false )  
  4. sort       = false      # Reordering atoms during the construction of internal coordinates   
  5.                         # This option will not impact on the atomic order of the output structure  
  6. mod        = 'onexyz'   # choose output mod:   
  7.                         # 'onexyz'  Write all structures into one .xyz file  
  8.                         # 'manyxyz' Each structure will be written into a separate file  
  9.                      
  10. [coords]  
  11. # The first point of LIIC  
  12. StartCoord = """  
  13.   
  14. """  
  15. # The final point of LIIC  
  16. EndCoord = """  
  17.   
  18. """
复制代码

将需要进行插值的两个分子坐标以标准 .xyz 格式分别放入 [coords] 下的 StartCoord 和 EndCoord 中,保存 .toml 文件后重新运行脚本,即可得到插值的坐标点。

[settings] 中的参数含义:


2. 线性内插算法简述

其核心算法非常简单。将插值前后的分子内坐标分别记为 A,B,插值点的总数为n,则第 i 个插值点 Ci 的内坐标为:

Ci = A + i × (B-A)/(n+1)

从公式中不难看出,线性插值是一个纯粹的数学过程,可以在任何坐标下进行。
实践中一般采用内坐标而非笛卡尔坐标进行插值。举一个简单的例子,对于一个甲基发生旋转的体系,内坐标下的线性插值氢原子会旋转到目标位置,C-H 键长不变;而笛卡尔坐标下氢原子会以直线路径移动到目标位置,C-H 键长先缩短后拉长。从插值得到的势能面来看,笛卡尔坐标下的插值会造成一个高达数个 eV 的异常能垒(C-H 键异常缩短所致),而内坐标下的插值更符合化学直觉。
我的脚本选择输入笛卡尔坐标,自动转为内坐标进行插值,再转回笛卡尔坐标输出的方案。坐标转换的算法在脚本内实现,不借助多余的第三方库。输出结构时,使用点云对齐算法 (Kabsch_fit) 使得结构之间具备最大重叠,这能让输出的结构不会发生整体旋转。
3. 备注







欢迎光临 计算化学公社 (http://bbs.keinsci.com/) Powered by Discuz! X3.3