将VASP的OUTCAR里的能带信息可视化通常是个比较头疼的事,如果要将这些信息粘贴到Origin之类的软件里进行可视化,需要大量的数据格式处理。这里我们教大家用awk文本处理程序和gnuplot画图程序简单快捷地画VASP的能带结构图。我们在这里将不详细介绍awk或者gnuplot的语法和功能,而仅仅给出一个用它们画VASP能带图的解决方案。 首先我们将OUTCAR里的从k-point 105到k-point 105的部分存成另外一个文件,不妨称之为Band.raw。 ExtractBand.awk #!/usr/bin/awk –f /k-point/ { printf "%d ", $2 getline for ( i=1; i=9; i++ ) { getline printf "%8.3f ", $2 } printf "\n" } 然后我们运行如下的awk script。./ExtractBand.awk Band.raw band.dat 这个awk script的功能是将OUTCAR里的输出信息进行格式化,以便于gnuplot画图 OUTCAR里的原始格式 …… k-point 98 : 0.3250 0.3250 0.6500 band No. band energies occupation 1 1.8846 2.00000 2 2.8157 2.00000 3 3.7368 2.00000 4 5.4560 2.00000 5 6.6622 2.00000 6 11.3258 0.00000 7 16.2724 0.00000 8 16.7466 0.00000 9 24.2900 0.00000 k-point 99 : 0.3500 0.3500 0.7000 band No. band energies occupation 1 1.6640 2.00000 2 2.5342 2.00000 3 4.1600 2.00000 4 5.7507 2.00000 5 6.9403 1.99944 6 12.1407 0.00000 7 15.0639 0.00000 8 16.8554 0.00000 9 23.0580 0.00000 …… 经过ExtractBand.awk处理后的band.dat的格式 …… 98 1.885 2.816 3.737 5.456 6.662 11.326 16.272 16.747 24.290 99 1.664 2.534 4.160 5.751 6.940 12.141 15.064 16.855 23.058 …… 然后我们运行以下的gnuplot脚本文件,来得到能带图。运行plotBand.sh,就得到band.eps,如图所示。 plotBand.sh #!/bin/bash x1=21 x2=41 x3=61 x4=81 x5=101 ymin=-10 ymax=20 ylabel=-10.6 ef_v=7.3089 #pls use E-fermi in the self consistent calculation gnuplot EOF set term post landscape enhanced color dashed defaultplex "Helvetica" 14 set output 'band.ps' set key outside set title "Pt Band Structure (VASP)" set ylabel "Energy (eV)" set noxtics set xrange set yrange set label "{/Symbol G}" at 0, $ylabel set label "{/Symbol D}" at 0.5*$x1, $ylabel set label "X" at $x1, $ylabel set label "Z" at 0.5*($x1+$x2), $ylabel set label "W" at $x2, $ylabel set label "Q" at 0.5*($x2+$x3), $ylabel set label "L" at $x3, $ylabel set label "{/Symbol L}" at 0.5*($x3+$x4), $ylabel set label "{/Symbol G}" at $x4, $ylabel set label "{/Symbol S}" at $x4+0.4*($x5-$x4), $ylabel set label "{/Symbol K}" at $x4+($x5-$x4)/2**0.5, $ylabel set label "X" at $x5, $ylabel set label "E_f" at -5.0, 0 set arrow from 0, 0 to $x5, 0 nohead set arrow from $x1, $ymin to $x1, $ymax nohead set arrow from $x2, $ymin to $x2, $ymax nohead set arrow from $x3, $ymin to $x3, $ymax nohead set arrow from $x4, $ymin to $x4, $ymax nohead set arrow from $x4+1+($x5-$x4)/2**0.5,$ymin to $x4+1+($x5-$x4)/2**0.5, $ymax nohead plot \ "band.dat" u 1:(\$2-$ef_v) w lines lt 1 t "", "band.dat" u 1:(\$3-$ef_v) w lines lt 1 t "",\ "band.dat" u 1:(\$4-$ef_v) w lines lt 1 t "", "band.dat" u 1:(\$5-$ef_v) w lines lt 1 t "",\ "band.dat" u 1:(\$6-$ef_v) w lines lt 1 t "", "band.dat" u 1:(\$7-$ef_v) w lines lt 1 t "",\ "band.dat" u 1:(\$8-$ef_v) w lines lt 1 t "", "band.dat" u 1:(\$9-$ef_v) w lines lt 1 t "" EOF 最终得到的Pt的能带图