QE专题

QE 有限位移、能带展开与介电响应

从硅晶胞的实际计算出发,生成位移、提取力和能带,绘制介电谱虚部。

更新于 2026-12-01约 9 分钟阅读按任务与环境选择适用配置
阅读本篇目录

在 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. fd.x 生成位移,fd_ifc.x 从原子力求二阶力常数#

mkdir -p ~/qe-practice/silicon
cd ~/qe-practice/silicon
QE_SOURCE=/public/software/package/qe/7.6/source/q-e

实算使用两个 Si 原子的原胞和 2×2×2 位移超胞。下面给出输入,de=0.01 是位移长度(Å);自洽与位移输入都应使用同一赝势。

cp "$QE_SOURCE/pseudo/Si.pz-vbc.UPF" .
cat > si.scf.in <<'INPUT_FILE'
&control
   calculation='scf',
   prefix='silicon',
   restart_mode='from_scratch',
   tstress = .true.,
   tprnfor = .true.,
   pseudo_dir='./',outdir='./'
/
&system    
   ibrav=  2, celldm(1) =10.2, nat=  2, ntyp= 1,
   ecutwfc = 18.0
/
&electrons
/
ATOMIC_SPECIES
 Si  28.086  Si.pz-vbc.UPF
ATOMIC_POSITIONS
 Si 0.00 0.00 0.00 
 Si 0.25 0.25 0.25 
K_POINTS {automatic}
4 4 4 1 1 1
INPUT_FILE
cat > fd.in <<'INPUT_FILE'
!fd_prefix     Prefix of the preceding pw.x run
!fd_outdir     Outdir of the preceding pw.x run
!fd_outfile    Prefix for the generated macrocell input files
!fd_outdir_dir Directory for the generated macrocell input files
!nrx1,2,3      Number of unitcell repetitions along the lattice vectors
!              (for the generation of the macrocell)
!de            Cartesian displacement for the atoms, in Angs.
!
&inputfd
 fd_prefix      = 'silicon' 
 fd_outdir      = './'
 fd_outfile     = 'displaced'
 fd_outfile_dir = './fd_files'
 nrx1           = 2
 nrx2           = 2
 nrx3           = 2
 innx           = 1
 de             = 0.01
/

!The following namelist is for additional flexibility
!1. Each string (everything between a pair of single quotation marks)
!   will be pasted verbatim to the generated input files.
!   Within the corresponding namelist
!2. Mind not using single quotation marks within strings
!3. Mind keeping "system2" instead of "system". Fortran conflict
!   within the corresponding
!4. Asterisks (*) inside the "kpoints" string represent change of line
!
&verbatim
control =
'
prefix="silicon_fd",
pseudo_dir="./",
outdir="./"
'

electrons =
'
conv_thr=1.0d-16,
mixing_beta=0.7
'

system2 =
'

'

kpoints = '
K_POINTS {automatic} *
1 1 1 1 1 1
'

/
INPUT_FILE
cat > fd_ifc.in <<'INPUT_FILE'
&input
  prefix='silicon'
  nrx1=2,
  nrx2=2,
  nrx3=2,
  de=0.01, 
  file_force='./fd_files/force',
  file_out='./silicon'
  innx=1
  nodispsym=.false.
  noatsym=.false.
  verbose=.true.
  hex=.false.
/
INPUT_FILE
qe_job <<'QE_JOB'
mkdir -p fd_files
pw.x < si.scf.in > scf.out
fd.x < fd.in > fd.out
for f in fd_files/displaced.*.in; do
  n=${f%.in}; pw.x < "$f" > "$n.out"
  awk '/atom / && /force =/{print $7,$8,$9}' "$n.out" > "fd_files/force.${n#fd_files/displaced.}"
done
fd_ifc.x < fd_ifc.in > ifc.out

ls -lh silicon.fc
QE_JOB

fd.x 生成 displaced.*.in。每个位移单独跑 pw.x,从其输出提取三分量的原子力后再运行 fd_ifc.x。输出 silicon.fc 可交给 matdyn.x。更换超胞时,应同步修改 fd.in 与 fd_ifc.in 的复制数、位移和前缀。

2. bands_unfold.x、epsilon_Gaus.x 和 nscf2supercond.x 读取同一套波函数#

留在上节目录,等前一作业完成。下面的均匀网格 NSCF 保留 8 条带和完整 k 点,在同一次作业中依次取出能带、介电函数和 EPW 能带输入。示例取 dim1=dim2=dim3=1,给出原胞参照;真正展开超胞时,要使用该超胞的波函数、相应路径和沿各方向的实际倍数。

cat > nscf.in <<'INPUT_FILE'
&control
   calculation='nscf',
   prefix='silicon',
   restart_mode='from_scratch',
   tstress = .true.,
   tprnfor = .true.,
   pseudo_dir='./',outdir='./'
/
&system    
   ibrav=  2, celldm(1) =10.2, nat=  2, ntyp= 1,
   nbnd=8, nosym=.true., noinv=.true., ecutwfc=18.0
/
&electrons
/
ATOMIC_SPECIES
 Si  28.086  Si.pz-vbc.UPF
ATOMIC_POSITIONS
 Si 0.00 0.00 0.00 
 Si 0.25 0.25 0.25 
K_POINTS {automatic}
4 4 4 0 0 0
INPUT_FILE
cat > bands.in <<'INPUT_FILE'
&bands
 prefix='silicon',outdir='./',filband='bands.dat',lsym=.false., dim1=1,dim2=1,dim3=1
/
INPUT_FILE
cat > eps.in <<'INPUT_FILE'
&inputpp
 prefix='silicon',outdir='./',calculation='eps'
/
&energy_grid
 smeartype='gauss',intersmear=0.1,nw=60,wmin=0.2,wmax=6.0,shift=0
/
INPUT_FILE
cat > epw.in <<'INPUT_FILE'
&bands
 prefix='silicon',outdir='./',filband='silicon.epw.bands'
/
INPUT_FILE
qe_job <<'QE_JOB'
pw.x -in nscf.in > nscf.out
bands_unfold.x -in bands.in > bands.out
epsilon_Gaus.x -in eps.in > eps.out
nscf2supercond.x -in epw.in > epw.out
ls -lh bands*dat epsi_silicon.dat epsr_silicon.dat silicon.epw.bands
QE_JOB

介电文件第一列是光子能量,其后三列为三个方向。硅例子输出 60 个能量点。silicon.epw.bands 是后续电子结构输入,生成该文件并不等于算出了超导转变温度。

3. fd_ef.x 将有限外场极化换算成介电张量#

继续使用上文 silicon.save。输入首行数据是零场极化矢量;随后按 x、y、z 方向先给正场的三个矢量,再给负场的三个矢量。下列对称数字专用于练习列顺序,得到约 1.0474 的对角元,不能作为硅的材料介电常数。正式计算请从同一晶胞在相应外场得到的极化记录提取矢量,保持单位、分支和场幅一致。

cat > field.in <<'INPUT_FILE'
&inputfd
 prefix='silicon',npol_eps=2,de_eps=0.001
/
DIELECTRIC_TENSOR
0 0 0
0.001 0 0
0 0.001 0
0 0 0.001
-0.001 0 0
0 -0.001 0
0 0 -0.001
INPUT_FILE
qe_job <<'QE_JOB'
export ESPRESSO_TMPDIR=./
fd_ef.x < field.in > field.out
grep -A5 'Dielectric tensor' field.out
QE_JOB

整理数据并画图#

在硅算例目录从 epsi_silicon.dat 提取三个方向的介电函数虚部。立方晶体的三条曲线可能重合。 在所述结果目录执行。图可用 MobaXterm 下载到本地。

module load ase/3.29.0
python - <<'PLOT'
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import numpy as np
data=np.loadtxt("epsi_silicon.dat")
for i,axis in enumerate("xyz",1): plt.plot(data[:,0],data[:,i],label=axis)
print("Energy grid points:",len(data))
plt.xlabel("Photon energy (eV)"); plt.ylabel("Imaginary dielectric function"); plt.legend()
plt.tight_layout()
plt.savefig("result.png", dpi=160)
PLOT
ls -lh result.png

硅介电函数虚部

本篇示例文件#

下载本篇的操作步骤、绘图源码和实算结果图。

需要根据你的体系选择资源?联系讨论计算需求。实际可用软件与权限,以当前账户和运行环境为准。

查看配图

放大后可滚动查看细节,按 Esc 关闭。

100%查看原图 ↗