atomsk 安装与使用

介绍

  • 强大的结构建模工具;同 latgen 相比,可生成孪晶、晶界、位错、层错等更多复杂构型

  • 示例丰富,文档详细

  • atomsk 中的 cfg 格式文件可用 OVITO 打开,VESTA 无法打开

  • 暂时没有的功能:

    • 无法直接构造八面体、四面体间隙的点缺陷(需自己手动将间隙原子插入到正确的位点中)
  • 只能构建 BCC、FCC、HCP 结构的特殊取向,其他结构不能(如四方结构,会报错)


安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 编译 LAPACK
cp make.inc.example make.inc
make # 耗时较长

# 拷贝编译得到的静态库文件
make -p ${HOME}/local/lib/lapack
cp *.a ${HOME}/lib


# atomsk 编译、安装
# 下载 atomsk 源代码,进入 src 目录,修改 Makefile 文件
LAPACK=-L${HOME}/local/lib/lapack -llapack -lrefblas
INSTPATH=$HOME/local/atomsk
CONFPATH=${INSTPATH}/etc

# 编译
make atomsk # 或 make -j4 atomsk

# 安装
make -p ${HOME}/local/atomsk/bin
# 方式 1
make install
# 方式 2
make INSTPATH=${HOME}/local/atomsk install

# 编译成功
\o/ Compilation was successful!

<i> To install Atomsk system-wide, you may now run:
sudo make install
  • 编译 ifort 版本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 导入 Intel OneAPI 套件
module purge

module load intel-oneapi-compilers/2021.4.0
module load intel-oneapi-mpi/2021.4.0
module load intel-oneapi-mkl/2021.4.0

git clone https://github.com/pierrehirel/atomsk.git

cd atomsk/src

make -f Makefile.ifort atomsk

# 超算(思源)使用 atomsk 时
# 需设置 libiomp5.so 文件的软链接
# 或使用前 module load intel-oneapi-compilers/2021.4.0
ln -s /dssg/opt/icelake/linux-centos8-icelake/gcc-8.5.0/intel-oneapi-compilers-2021.4.0-rszhbg2vjwqqeddqqdryjwxromenbfmr/compiler/2021.4.0/linux/compiler/lib/intel64_lin/libiomp5.so ~/lib/libiomp5.so
  • macOS 编译 atomsk(详细编译说明查看 Makefile.macos 文件内容)
1
2
3
4
# 需安装 LAPACK 和 OpenMP(非必需)
# 修改 Makefile.macos 中的 LAPACK lib 路径
# 并将 -lrefblas 改为 -lblas,最后编译
make -f Makefile.macos atomsk

使用

基本

1
2
3
4
atsk abin bop bx cfg cel cif coo csv d12
dat dd dlp fdf gin imd jems lmp mol
pdb pos pw str vesta xmd xsf xv
xyz exyz sxyz
1
2
3
4
5
6
# 配置文件路径
~/.config/atomsk.conf

# 内容
colour yes
colour_error red bold blink

结构建模

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
               <structure> | N.lattice cst. | N.at.sp.
-------------+----------------+----------
CUBIC sc | 1 | 1
LATTICES bcc | 1 | 1 or 2
fcc | 1 | 1 or 2
diamond | 1 | 1 or 2
L1_2 | 1 | 2
fluorite | 1 | 2
rock-salt | 1 | 2
perovskite | 1 | 3
A15 | 1 | 2
C15 | 1 | 2
-------------+----------------+----------
TETRAGONAL st | 2 (a and c) | 1 or 2
LATTICES bct | 2 (a and c) | 1 or 2
fct | 2 (a and c) | 1 or 2
-------------+----------------+----------
HEXAGONAL hcp | 2 (a and c) | 1 or 2
LATTICES wurtzite | 2 (a and c) | 2
graphite | 2 (a and c) | 1 or 2
BN | 2 (a and c) | 2
C14 | 2 (a and c) | 2
C36 | 2 (a and c) | 2


st, simple tetragonal # 简单四方
bct, body-centered tetragonal # 体心四方
fct, face-centered tetragonal # 面心四方(L1_0)
BN, B12 phase
A15, Cr3Si type
C15, laves phase
C14, laves phase
C36, laves phase

常用 options、modes

  • 查看所有的 options 和 modes 及其用法:Documentioin - Atomsk

  • options:应用于体系的变换(transformations),用 - 区分

  • modes:允许执行特定的操作,构造,分析或操纵多个数据文件(operations, constructions, analysis, manipulate),用 -- 区分

  • 常用 options

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-orient                     # 晶体取向
-duplicate # -dup;扩胞
-rotate # 旋转轴
-orthogonal-cell # 转变为正交胞
-reduce-cell # 保持周期性的同时减小胞的大小;参数值 x/y/z/p
-fractional # -frac;分数坐标(VASP 格式)
-sort # 根据 properties 对原子进行排序
-fix # 固定原子坐标轴
-shift # 移动原子
-substitute # 元素替换
-wrap # 将胞外原子施加 PBC 移至胞内
-cell # 修改 box 的 cell vector;可 add、set、rm
-center # 使体系移至 box 的中心
-add-atom # 添加原子
-wrap # 将胞外原子通过 PBC 到胞内
-properties # 设置 properties
-remove-doubles # 删除重复的原子
-remove-atom # -rmatom;删除原子
-mirror # 施加镜像操作(mirror transformation)
-deform # -def;使体系变形:通过施加正/切应变(box 和 原子一起)
-disturb # 随机移动原子位置(随机扰动)
-select # 根据准则选择原子
-dislocation # 插入位错(位错线、位错环)
  • 常用 modes
1
2
3
4
5
6
--create                # 构建晶体结构
--merge # 合并两个构型
--rdf # RDF 计算

# 报错内容:一次只能使用一个 mode
X!X ERROR: only one mode can be used at a time.
  • Program behaviour
1
2
3
4
5
6
7
-ov            # overwrite;覆写文件
-v N # verbosity;
# N 可选值
0 # 不会输出内容到屏幕/log 文件,Errors、warnings、questions 仍会输出到屏幕
1 # 只输出内容到屏幕
2 # 只输出内容到 log 文件
3 # 输出内容到屏幕、log 文件

常用命令实例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# 构建晶体结构
--create fcc 4.02 Al # FCC
--create hcp 2.92 4.61 Ti # HCP,基矢: H1=[2-1-10], H2=[-12-10], H3=[0001]
--create perovskite 3.905 Sr Ti O # 钙钛矿结构

# 构建晶体特定取向的构型
--create fcc 4.041 Al -orient "[1-10]" "[11-2]" "[111]"

-reduce-cell p # 寻找原胞

-duplicate 1 1 4 # 扩胞

-sort species pack # 将相同的元素排在一起(写入 VASP POSCAR 有用)
-sort z up # 按原子 z 坐标从小到大排序

# 笛卡尔、分数坐标互相转换(用于 VASP)
atomsk POSCAR vasp # 笛卡尔坐标
atomsk POSCAR -fractional vasp # 分数坐标

# CONTCAR 转 POSCAR
atomsk CONTCAR -fractional -ow POSCAR

# 添加真空层
# 以下命令能正确地给非正交胞添加真空层,即晶格角度不发生变化
# 但底部和两端时,原子顺序会发生改变,对表面能计算无影响
-cell add 15.0 z # 在 z 轴顶部添加真空层;x、y、z 可写成 H1 H2 H3
-cell add 15.0 z -shift 0 0 15.0 z # 在 z 轴底部添加真空层
-cell add 15.0 z -shift 0 0 7.5 z # 在 z 轴两端添加真空层

# 固定原子坐标轴
-fix x -fix y # 固定原子的 x、y 轴
-fix x below 4.05 z # 根据 z 轴数值固定 x 轴

-def zx 5% # 使 z 轴沿 x 方向进行切应变

-center 0/com # 移动所有原子,使其质心在 box 中心;会使位于 box 边缘的原子位点稍微往胞里靠,和 ase Atoms 的 center 方法效果不同

# 添加原子(分数坐标)
-add-atom Si at 0.25*box 0.33*box 0.5*box

# 给定准则选择原子
# 选择矩形盒子内的原子;矩形盒子区域 X=[0;1.0*box], Y==[0.5*box;1.0*box], Z=[0.48*box;0.52*box]
-select in box 0 0.5*box 0.48*box 1.0*box 1.0*box 0.52*box
-select in box 0 0.48*box 0.48*box 1.0*box 0.52*box 0.52*box
# 多个 select 是 || 的效果,而不是 && 的效果
-select above 0.48*box z -select below 0.52*box z -select above 0.48*box y Ti -substitute Ti Al

# 线性插值;用于 NEB
--interpolate initial.vasp final.vasp 7 vasp

# 随机扰动(最大 0.1 Å)
atomsk POSCAR -disturb 0.1 disturbed.cfg

# 格式转换
# 输出文件可为具体文件名,也可为文件格式;输出文件可以是多个
# 写入 cif 文件时,总是假设空间群为 P1,写入所有原子位置
atomsk POSCAR xyz # 常用: xyz lammps/lmp vasp/pos cif

位错模型

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 螺位错
-dislocation <p1> <p2> screw <ξ> <n> <b>

# 刃位错
-dislocation <p1> <p2> <edge|edge_add|edge_rm> <ξ> <n> <b> <ν>

# 混合位错
-dislocation <p1> <p2> mixed <ξ> <n> <b1> <b2> <b3>

# 位错环
-dislocation loop <x> <y> <z> <n> <radius> <bx> <by> <bz> <ν>

# file 文件含位错线信息
-dislocation file <file> <ν>


# 参数
p1 p2 # 垂直于位错线的 2 个方向的坐标值
ξ # 位错线方向 x/y/z
n # 滑移面法向 x/y/z
b # 伯氏矢量模长
ν # 材料的泊松比(screw mixed 位错类型,缺省)
  • 注意事项

    • atomsk 不会自动寻找/调整位错的伯氏矢量,因此须手动提供精确的 b 值;也不会寻找位错中心的最佳位置,与原子位置完全匹配的坐标可能会出现不合理的位移
    • 一般让 x 为位错的滑移方向,y 方向为滑移面法向(视觉上的 z 轴),z 方向为位错线方向
    • 一般在位错线方向具有周期性(模型沿该方向的长度可以很小),其余两个方向不具有周期性(模型沿该方向的长度需要足够大)
    • 一般需要对滑移面法向的顶部和底部进行固定
    • -dislocation 可给指定输入构型文件(原子位置不都在理想晶格位点上,如 300K 温度下弛豫后)添加位错
    • 添加的位错位置不能是 0.50*box 0.50*box,会出现某个原子的坐标值为 NAN 的错误,而应写成 0.501*box 0.501*box
    • 引入 dipole(位错偶)、quadrupole(4 个) 等多个螺位错,使伯氏矢量之和为 0,可实现 3 个方向都具有周期性
  • 刃位错

1
2
3
4
5
# FCC 滑移系 1/2<110>{111};伯氏矢量 b=1/2[110]
# 刃位错 位错线方向与伯氏矢量垂直
atomsk --create fcc 4.041 Al orient "[110]" "[-111]" "[1-12]" -duplicate 60 20 4 Al_supercell.xsf

atomsk Al_supercell.xsf -dislocation "0.51*box" "0.51*box" edge Z Y 2.860954 0.33 Al_edge.cfg
  • 螺位错
1
2
3
4
# 螺位错 位错线方向与伯氏矢量平行
atomsk --create fcc 4.046 Al orient "[1-12]" "[-111]" "[110]" -duplicate 40 20 1 Al_supercell.xsf

atomsk Al_supercell.xsf -dislocation "0.51*box" "0.501*box" screw Z Y 2.860954 Al_screw.xsf

孪晶模型

1
2
3
4
5
6
7
8
# 通过调整孪晶面法向(沿 y 方向)扩胞的大小,可调整孪晶间距
atomsk --create fcc 4.041 Al orient "[11-2]" "[111]" "[-110]" -duplicate 1 4 1 Al_cell.xsf

# 只有原子位置会被镜像,box 不会,因此该操作后原子会到 box 外面,需使用 -wrap
atomsk Al_cell.xsf -mirror 0 Y -wrap Al_mirror.xsf

# 合并/堆叠至一起
atomsk --merge Y 2 Al_cell.xsf Al_mirror.xsf Al_final.cfg

多晶模型

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 创建单晶的种子
atomsk --create fcc 4.041 Al Al.lmp

# polycrystal.txt
box 100 100 100 # 设置多晶模型盒子大小
random 6 # 设置晶粒数目(随机位置和方向)

# 生成多晶
atomsk --polycrystal Al.lmp polycrystal.txt -wrap Al_polycrystal.lmp

# 删除距离过近的原子
atomsk Al_polycrystal.lmp -remove-doubles 0.2 final.lmp


# 输出信息文件
*_size-dist.txt # 晶粒大小的分布
*_param.txt # 节点的位置和旋转信息
*_nodes.xsf # 最终的节点位置
*_id-size.txt # 晶粒中的原子数目和晶粒体积
*_grain-com.xsf # 晶粒质心的位置

等原子比四元随机固溶体

  • 注意事项:若将 tmp*.cfg 换成 lmp 格式,无替换效果
1
2
3
4
5
6
7
8
9
10
11
12
13
14
a=3.254

# 替换比例 20% 25% 33.33% 50%
# 全部 -> 等原子比五元
# 后 3 个 -> 等原子比四元
# 后 2 个 -> 等原子比三元

atomsk --create bcc ${a} Nb -duplicate 20 20 20 tmp1.cfg
atomsk tmp1.cfg -select random 25% Nb -sub Nb Ti tmp2.cfg
atomsk tmp2.cfg -select random 33.33% Nb -sub Nb Al tmp3.cfg
# -sort species pack vasp 或 TiAlNbMo_random.lmp
atomsk tmp3.cfg -select random 50% Nb -sub Nb Mo -sort species pack vasp

rm -f *.cfg

含孪晶界纳米晶

  • 步骤:构建单晶种子,引入孪晶界(通过 -duplicate 可调控多晶中的孪晶间距?);生成多晶

计算 Nye tensor

1
2
3
4
5
6
7
atomsk --nye reference.xsf dislocation.cfg nye.cfg

# 输出文件
nye.cfg # 一般选取 Nye_33 数据在 OVITO 中进行 Color Coding
nye_G.cfg
nye_rotate.cfg
nye_strain.cfg