QE 分子态密度、投影轨道与 Wannier 工具
计算氢链与分子投影谱,建立 NiO 和 FeO 的局域轨道,并查看密度和投影结果。
阅读本篇目录
在 login01 打开自己的工作目录。每节使用独立算例目录。阅读完本节后执行其中的命令;计算程序均通过下面的 Slurm 函数提交。每次重新登录后先定义一次。它读取你输入的命令并逐行写入当前作业的脚本,将该目录作为工作目录。
qe_job() {
local script
script=$(mktemp -p "$PWD" qe-step.XXXXXXXX.sh) || return
cat > "$script" <<'HEADER'
#!/bin/bash
#SBATCH --partition=cpu-8173m
#SBATCH --nodes=1
#SBATCH --ntasks=2
#SBATCH --output=qe-%j.out
set -eo pipefail
source /etc/profile.d/lmod.sh
module load qe/7.6-8173m
export OMP_NUM_THREADS=1
cd "$SLURM_SUBMIT_DIR"
HEADER
cat >> "$script"
sbatch "$script"
}
提交后用 squeue -u "$USER" 看队列,结束后用 sacct -j 作业号 --format=JobID,State,ExitCode 看终态。输出文件与脚本保存在当前目录。
1. molecularpdos.x 将氢链的态密度投影到氢分子#
mkdir -p ~/qe-practice/molecular-pdos
cd ~/qe-practice/molecular-pdos
QE_SOURCE=/public/software/package/qe/7.6/source/q-e
先分别计算链和单独分子。下面的输入来自同一套氢轨道。投影文件在每次计算后单独命名,避免把完整体系与片段混用。换体系时按原子和轨道的真实顺序更新 i_atmwfc 和 i_bnd 范围。
mkdir -p tmp
cp "$QE_SOURCE/pseudo/H_US.van" .
cat > chainH2.scf.in <<'INPUT_FILE'
&CONTROL
calculation = "scf",
prefix = "chainH2",
tstress = .false.,
tprnfor = .false.,
pseudo_dir = './',
outdir='./tmp/'
/
&SYSTEM
ibrav = 6,
celldm(1) = 7.d0
celldm(3) = 2.0d0
nat = 12,
ntyp = 1,
ecutwfc = 20.0,
nbnd = 20
nspin = 1
occupations = 'smearing'
smearing = 'mv'
degauss = 0.01d0
/
&ELECTRONS
/
ATOMIC_SPECIES
H 1.00 H_US.van
ATOMIC_POSITIONS crystal
H 0.0 0.0 0.0
H 0.0 0.0 0.1
H 0.0 0.0 0.2
H 0.0 0.0 0.3
H 0.0 0.0 0.4
H 0.0 0.0 0.5
H 0.0 0.0 0.6
H 0.0 0.0 0.7
H 0.0 0.0 0.8
H 0.0 0.0 0.9
H 0.35 0.35 0.445
H 0.35 0.35 0.555
K_POINTS
4
0.0000000 0.0000000 0.0312500 0.2500000
0.0000000 0.0000000 0.0937500 0.2500000
0.0000000 0.0000000 0.1562500 0.2500000
0.0000000 0.0000000 0.2187500 0.2500000
INPUT_FILE
cat > H2.scf.in <<'INPUT_FILE'
&CONTROL
calculation = "scf",
prefix = "H2",
tstress = .false.,
tprnfor = .false.,
pseudo_dir = './',
outdir='./tmp/'
/
&SYSTEM
ibrav = 6,
celldm(1) = 7.d0
celldm(3) = 2.0d0
nat = 2,
ntyp = 1,
ecutwfc = 20.0,
nspin = 1
occupations = 'smearing'
smearing = 'mv'
degauss = 0.01d0
/
&ELECTRONS
/
ATOMIC_SPECIES
H 1.00 H_US.van
ATOMIC_POSITIONS crystal
H 0.35 0.35 0.445
H 0.35 0.35 0.555
K_POINTS
4
0.0000000 0.0000000 0.0312500 0.2500000
0.0000000 0.0000000 0.0937500 0.2500000
0.0000000 0.0000000 0.1562500 0.2500000
0.0000000 0.0000000 0.2187500 0.2500000
INPUT_FILE
cat > chainH2.projwfc.in <<'INPUT_FILE'
&PROJWFC
outdir='./tmp/'
prefix = 'chainH2'
ngauss = 0
degauss = 0.01470
deltae = 0.05
/
INPUT_FILE
cat > H2.projwfc.in <<'INPUT_FILE'
&PROJWFC
outdir='./tmp/'
prefix = 'H2'
ngauss = 0
degauss = 0.01470
deltae = 0.05
/
INPUT_FILE
cat > chainH2_onto_H2.in <<'INPUT_FILE'
&INPUTMOPDOS
xmlfile_full='chainH2.atomic_proj.xml'
i_atmwfc_beg_full=11,
i_atmwfc_end_full=12,
i_bnd_beg_full=1,
i_bnd_end_full=20,
xmlfile_part='H2.atomic_proj.xml'
i_atmwfc_beg_part=1,
i_atmwfc_end_part=2,
i_bnd_beg_part=1,
i_bnd_end_part=2,
fileout ='chainH2_onto_H2'
ngauss=0,
degauss=0.01470,
DeltaE=0.05,
kresolveddos=.false.
/
INPUT_FILE
qe_job <<'QE_JOB'
for name in chainH2 H2; do
pw.x -in "$name.scf.in" > "$name.scf.out"
projwfc.x -in "$name.projwfc.in" > "$name.projwfc.out"
cp "tmp/$name.save/atomic_proj.xml" "$name.atomic_proj.xml"
done
molecularpdos.x -in chainH2_onto_H2.in > projection.out
head chainH2_onto_H2.mopdos_tot
QE_JOB
总投影谱在 .mopdos_tot,分轨道数据在 .mopdos。能量区间和展宽应与所研究的能带匹配。
2. wannier_ham.x 建立 NiO 哈密顿量,wannier_plot.x 生成空间分布#
mkdir -p ~/qe-practice/nio
cd ~/qe-practice/nio
QE_SOURCE=/public/software/package/qe/7.6/source/q-e
选 Ni 的 5 个 d 轨道和 O 的 3 个 p 轨道。NSCF 使用完整 4×4×4 网格;两个后处理工具都要读 WANNIER_AC 投影卡。用 -in 打开可回读的普通文件,避免并行启动器通过管道传入导致回读失败。集群例子中后处理使用单进程。
mkdir -p tmp
cp "$QE_SOURCE/pseudo/O.pz-rrkjus.UPF" .
for pp in Ni.pz-nd-rrkjus.UPF; do
curl -fL --retry 2 "https://pseudopotentials.quantum-espresso.org/upf_files/$pp" -o "$pp" || break
tail -4 "$pp" | grep -q "</UPF>" || { echo "文件未下载完整:$pp"; break; }
done
cat > NiO.scf.in <<'INPUT_FILE'
&control
calculation = 'scf'
prefix='NiO',
pseudo_dir = './',
outdir='./tmp/',
/
&system
ibrav=0, celldm(1)=7.92664836,
nat=2, ntyp=2,
ecutwfc = 45.0,
occupations='smearing',
degauss = 0.01
nbnd=11
/
&electrons
conv_thr = 1.0d-5
/
CELL_PARAMETERS alat
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0
ATOMIC_SPECIES
Ni 1. Ni.pz-nd-rrkjus.UPF
O 1. O.pz-rrkjus.UPF
ATOMIC_POSITIONS crystal
Ni 0.00 0.00 0.00
O 0.50 0.50 0.50
K_POINTS automatic
4 4 4 0 0 0
INPUT_FILE
cat > NiO.nscf.in <<'INPUT_FILE'
&control
calculation = 'nscf'
prefix='NiO',
pseudo_dir = './',
outdir='./tmp/',
/
&system
ibrav=0, celldm(1)=7.92664836,
nat=2, ntyp=2,
ecutwfc = 45.0,
occupations='smearing',
degauss = 0.01
nosym = .true.
noinv = .true.
nbnd=11
/
&electrons
/
CELL_PARAMETERS alat
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0
ATOMIC_SPECIES
Ni 1. Ni.pz-nd-rrkjus.UPF
O 1. O.pz-rrkjus.UPF
ATOMIC_POSITIONS crystal
Ni 0.00 0.00 0.00
O 0.50 0.50 0.50
K_POINTS automatic
4 4 4 0 0 0
INPUT_FILE
cat > wannier_hamilt.in <<'INPUT_FILE'
&inputpp
prefix='NiO'
outdir='./tmp/'
nwan = 8
/
WANNIER_AC
Wannier# 1 2 9
atom 1
d 1 1.0
Wannier# 2 2 9
atom 1
d 2 1.0
Wannier# 3 2 9
atom 1
d 3 1.0
Wannier# 4 2 9
atom 1
d 4 1.0
Wannier# 5 2 9
atom 1
d 5 1.0
Wannier# 6 2 9
atom 2
p 1 1.0
Wannier# 7 2 9
atom 2
p 2 1.0
Wannier# 8 2 9
atom 2
p 3 1.0
INPUT_FILE
cat > plot.in <<'INPUT_FILE'
&inputpp
prefix='NiO',outdir='./tmp/',nwan=8,plot_wan_num=1,nc=1,1,1,n0=0,0,0
/
WANNIER_AC
Wannier# 1 2 9
atom 1
d 1 1.0
Wannier# 2 2 9
atom 1
d 2 1.0
Wannier# 3 2 9
atom 1
d 3 1.0
Wannier# 4 2 9
atom 1
d 4 1.0
Wannier# 5 2 9
atom 1
d 5 1.0
Wannier# 6 2 9
atom 2
p 1 1.0
Wannier# 7 2 9
atom 2
p 2 1.0
Wannier# 8 2 9
atom 2
p 3 1.0
INPUT_FILE
qe_job <<'QE_JOB'
pw.x -in NiO.scf.in > scf.out
pw.x -in NiO.nscf.in > nscf.out
wannier_ham.x -in wannier_hamilt.in > ham.out
wannier_plot.x -in plot.in > plot.out
ls -lh hamilt wannier.plot.dx atoms.plot.dx
QE_JOB
hamilt 保存模型矩阵,两个 DX 文件分别为所选轨道的空间密度和原子位置。用支持 OpenDX 的可视化程序分别打开它们,对轨道密度取等值面,再叠加原子位置。
3. pmw.x 构造 FeO 的投影 Wannier 函数#
mkdir -p ~/qe-practice/feo
cd ~/qe-practice/feo
QE_SOURCE=/public/software/package/qe/7.6/source/q-e
mkdir -p tmp
cp "$QE_SOURCE/pseudo/O.pz-rrkjus.UPF" .
for pp in Fe.pz-nd-rrkjus.UPF; do
curl -fL --retry 2 "https://pseudopotentials.quantum-espresso.org/upf_files/$pp" -o "$pp" || break
tail -4 "$pp" | grep -q "</UPF>" || { echo "文件未下载完整:$pp"; break; }
done
cat > feo_LDA.in <<'INPUT_FILE'
FeO Wustite in DFT-LDA
&control
calculation = 'scf'
restart_mode='from_scratch',
prefix='feo_af',
pseudo_dir = './',
outdir='./tmp/'
tprnfor = .true., tstress=.true.
/
&system
ibrav= 0, celldm(1)=8.19, nat= 4, ntyp= 3,
ecutwfc = 30.0, ecutrho = 240.0, nbnd=20,
starting_magnetization(1)= 0.0,
starting_magnetization(2)= 0.5,
starting_magnetization(3)=-0.5,
occupations='smearing', smearing='mv', degauss=0.01,
nspin=2,
/
&electrons
mixing_mode = 'plain'
mixing_beta = 0.3
conv_thr = 1.0d-10
mixing_fixed_ns = 0
/
CELL_PARAMETERS alat
0.50 0.50 1.00
0.50 1.00 0.50
1.00 0.50 0.50
ATOMIC_SPECIES
O1 1. O.pz-rrkjus.UPF
Fe1 1. Fe.pz-nd-rrkjus.UPF
Fe2 1. Fe.pz-nd-rrkjus.UPF
ATOMIC_POSITIONS {crystal}
O1 0.25 0.25 0.25
O1 0.75 0.75 0.75
Fe1 0.0 0.0 0.0
Fe2 0.5 0.5 0.5
K_POINTS {automatic}
2 2 2 0 0 0
HUBBARD {atomic}
U Fe1-3d 0.0001
U Fe2-3d 0.0001
INPUT_FILE
cat > pmw.in <<'INPUT_FILE'
&inputpp
outdir='./tmp/',
prefix='feo_af',
first_band=9, last_band=20,
/
INPUT_FILE
qe_job <<'QE_JOB'
mpirun -np 2 pw.x -in feo_LDA.in > feo_LDA.out
mpirun -np 2 pmw.x -in pmw.in > pmw.out
tail -12 pmw.out
ls -lh tmp
QE_JOB
示例选择第 9 至 20 条带。对自己的材料先检查轨道成分,再定能带窗口。查看 pmw.out 末尾的 JOB DONE,保留 tmp 内生成的投影数据供后续 HUBBARD {wf} 计算使用。
4. merge_wann.x 合并不同轨道子空间#
mkdir -p ~/qe-practice/centres
cd ~/qe-practice/centres
QE_SOURCE=/public/software/package/qe/7.6/source/q-e
使用同一个晶胞、相同原子顺序、相同 k 点定义的两个子空间。下面的格式例用两个 X 标记两个中心,Si 是共有原子。真实任务可直接使用 Wannier90 的 *_centres.xyz。
cat > a.xyz <<'INPUT_FILE'
2
centres
X 0.0 0 0
Si 0 0 0
INPUT_FILE
cat > b.xyz <<'INPUT_FILE'
2
centres
X 0.25 0 0
Si 0 0 0
INPUT_FILE
qe_job <<'QE_JOB'
merge_wann.x centres a.xyz b.xyz > merge.out
cat wann_centres.xyz
QE_JOB
结果包含两组中心和一份原子列表。合并同一 k 网格不同能带块的 U 矩阵时可执行 merge_wann.x U first_u.mat second_u.mat,结果写入 wann_u.mat。
整理数据并画图#
回到氢链算例目录。读取投影谱第一列能量和第二列总投影,峰越高表示该能量附近投影到片段的权重越大。 在所述结果目录执行。图可用 MobaXterm 下载到本地。
module load ase/3.29.0
python - <<'PLOT'
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import numpy as np
a=np.loadtxt("chainH2_onto_H2.mopdos_tot")
print("Maximum projection at",a[a[:,1].argmax(),0],"eV")
plt.plot(a[:,0],a[:,1]); plt.xlabel("Energy (eV)"); plt.ylabel("Molecular projected DOS")
plt.tight_layout()
plt.savefig("result.png", dpi=160)
PLOT
ls -lh result.png
