6. Lattice ops — strain / vacuum / recenter
三个最高频晶格操作
| 操作 | 顶层快捷 | 资源形式 | 用途 |
|---|---|---|---|
| 施应变 | mat strain 2% | mat /lattice update strain=2% | 应力-能量曲线 / heterostructure 适配 |
| 改真空层 | mat vacuum 20 | mat /lattice update vacuum=20 | 2D 材料镜像分离 |
| slab 居中 | mat recenter | mat /lattice update recenter=z | 真空对称 / VASP 输入清理 |
mat strain
等比双轴
bash
mat strain 2% # a, b 各 +2%
mat strain -1% # 压 1%
mat strain 0.03 # 小数 = +3%各向异性
bash
mat strain a:1%,b:-0.5% # a +1%, b -0.5%
mat strain a:3%,b:-1% # 经典 uniaxial-like
mat strain c:1% # 单 c 轴(少见)施 (a:+3%, b:-1%) 后的 MoS2:

实现细节
- 应变是 affine 变换:新晶格 = 旧晶格 · diag(1+εa, 1+εb, 1+εc)
- 原子分数坐标保持不变 → 笛卡尔坐标随晶格缩放
- 2D 安全:c 轴默认不参与(除非显式
c:N%) - 保 motif:因为只是 affine,配位拓扑不变(但键长会变)
mat vacuum
bash
mat vacuum 20 # 真空层调到 20 Å
mat vacuum 12 -q # quiet机制:调整 c 长度,使得 (c - slab_thickness) = vacuum。slab 厚度自动测(最高 atom z − 最低 atom z)。
安全护栏
vacuum < 8 Å→ 报错(TwoDViolation)。避免 2D 材料镜像间相互作用过强。- 强制:
mat vacuum 5 force=1。
应用大真空(25 Å):

mat recenter
bash
mat recenter # slab 居中沿 c机制:把 slab 的几何中心移到 cell c 中点。
复合操作(一条命令搞定 build + 调)
mat build 接受同样的 lattice 参数:
bash
mat build mos2 strain=2% vacuum=22 recenter=z等价于:
bash
mat build mos2 -q
mat strain 2% -q
mat vacuum 22 -q
mat recenter -q但一条命令一次完成,比链式快很多(不重新读写四次 .vasp)。
/lattice get 看现状
bash
mat /lattice get输出:
✓ lattice runs/001-run/mos2.vasp
a, b, c 3.16 3.16 15.0 Å
angles α=90.0 β=90.0 γ=120.0°
volume 129.7167 ų
slab z [5.94, 9.06] (thickness 3.12 Å)
vacuum 11.88 Å含 2D 解读(slab 厚度、真空层)——比单纯打 a/b/c 信息密度高。
JSON:
bash
mat /lattice get --json --jq '.vacuum'
# → 11.88
mat /lattice get --json --jq '{a:.a,b:.b,vac:.vacuum}'
# → {"a": 3.16, "b": 3.16, "vac": 11.88}2D-aware 字段
/lattice get 在结构看起来像 slab 时(c >> a, b 且有明显空隙),额外报告:
| 字段 | 含义 |
|---|---|
slab_z | slab 在 c 方向的范围 |
slab_thickness | 最高 - 最低 atom z |
vacuum | c - slab_thickness |
is_slab | 是否判定为 slab |
centered | slab 是否近似居中 |
一个完整的 strain ladder 例子
为应力-应变扫描,agent 一般会跑:
bash
for p in -2 -1 0 1 2 3 4 5; do
mat build mos2 strain=${p}% out=runs/001-run/mos2-s${p}.vasp -q
done每个产物自带 PNG + summary,方便逐张看变化。
或者直接生成 supercell + 不同 strain:
bash
mat build mos2 -q
mat /structures update supercell=3,3,1 out=runs/001-run/mos2-3x3.vasp
for p in 1 2 3 4; do
mat strain ${p}% out=runs/001-run/mos2-3x3-s${p}.vasp
done