[转载]DOSCAR——读懂split_dos(再贴)
原⽂地址:DOSCAR——读懂split_dos(再贴)作者:原⼦修补匠
下⾯是处理VASP输出数据得到态密度的脚本⽂件split_dos,与它配合的vp没有贴出来。学习vasp如果会⼀些shell编程,对vasp的运⽤会更灵活⽅便。这个程序听说⽐较⽼,有些问题,不能直接⽤来处理vasp4.6及以上版本的数据,也不能处理f电⼦。有兴趣的可以关注⼀下,看看语法本⾝,或者提出修改意见,都有BB⿎励。
:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D
#!/bin/ksh
# Script to break the VASP DOSCAR file into segments for
# each atomic site.
# JMS NRL 5/0/02
# Modified to also align the Fermi level from the ground state
# to E=0.0
# JMS NRL 6/19/02
# Executables reside here
BIN=~/bin                      #把这⾥修改为vp保存的路径。然后把split_dos的路径添加到PATH中。
if [ $# -ne 0 ]; then      #直接在shell提⽰符下输⼊split_dos运⾏,否则提醒Usage: split_dos,返回信息2.
echo "Usage: split_dos"
exit 2
fi
# Script to split the DOSCAR file into the atomic
# projections labeled by atom number
dosfile=DOSCAR
outfile=OUTCAR
infile=INCAR
# Token for splitting the files
token=$(sed -n '6 p' $dosfile | awk '{print $1}')  #这个token后⾯好像没有⽤到,有什么⽤呢?
# Number of points
nl=$(sed -n '6 p' $dosfile | awk '{print $3}')
# Number of atoms
natom=$(sed -n '1 p' $dosfile | awk '{print $1}')
# Get the Fermi level if the OUTCAR file is present,
# else we set it to zero.
if [ -a $outfile ]; then
echo "The" $outfile "exists, we use it to get the Fermi level,"
echo "the RWIGS tag and the number of spins."
efermi=$(grep "E-fermi" $outfile | tail -1 | awk '{print $3}')
echo "Fermi level:" $efermi
nspin=$(grep "ISPIN" $outfile | tail -1 | awk '{print $3}')
if [ $nspin -eq 2 ]; then
echo "Spin polarized calculation"
else
echo "Unpolarized calculation"
fi
# 2.a
# JMS 2/3/03 Modified to accept specification by LORBIT token.
#
lorbit=$(grep "LORBIT" $outfile | tail -1 | awk '{print $3}')
if [ $lorbit -ge 10 ]; then
echo "LORBIT > 10"
echo "WARNING: not completely test for vasp.4.*"
echo "Use at your own risk. Please check results for consistency."
form=1
else
# 2.a
rwigs=$(grep "RWIGS" $outfile | tail -1 | awk '{print $3}' | sed 's/.//g')
if [ $rwigs -eq -100 ]; then
echo "RWIGS token not set"
form=0
else
echo "RWIGS token set"
form=1
fi
# 2.a
fi
# 2.a
else
echo "The" $outfile "does not exist, we set the Fermi level to 0"
echo "assume an unpolarized calculation, and RWIGS not set"
form=0
nspin=1
efermi=0.0
fi
# If the outcar file is not present and you wish to set something by hand
# you should do it here. Uncomment the tokens below and set them by hand. #efermi=2.255
#form=
#nspin=
printform# Get the atomic coordinates
$BIN/vp >| tmp.dat
tail -$natom tmp.dat | awk '{printf "%s .8f .8f .8f n", "#", $2, $3, $4}' >| tmp.dat2 # Total is first DOS
if [ $form -eq 0 ]; then  #这个很怪,为什么不直接i=0呢?
i=0
else
i=0
fi
start=7
end=$((start+nl-1))
#echo $start $end
#exit 0
rm -f DOS0
if [ $form -eq 1 ]; then
while [ $i -le $natom ]; do
#echo $i $start $end
if [ $i -gt 0 ]; then
sed -n ''$i' p' tmp.dat2 >| DOS$i #读⼊对应原⼦位置坐标到DOSi第⼀⾏
fi
if [ $i -gt 0 ]; then
# Atomic projected DOS
if [ $nspin -eq 2 ]; then
sed -n ''$start','$end' p' $dosfile | awk '{printf ".8f .8f .8f .8f .8f .8f .8f n", $1+(-1)*'$efermi', $2, -1*$3, $4, -1*$5, $6, -1*$7}' >> DOS$i
else
sed -n ''$start','$end' p' $dosfile | awk '{printf ".8f .8f .8f .8f n", $1+(-1)*'$efermi', $2, $3, $4 }' >> DOS$i
fi
else
# Total DOS
if [ $nspin -eq 2 ]; then
sed -n ''$start','$end' p' $dosfile | awk '{printf ".8f .8f .8f .8f .8f n", $1+(-1)*'$efermi', $2, -1*$3, $4, -1*$5 }' >> DOS$i            else
sed -n ''$start','$end' p' $dosfile | awk '{printf ".8f .8f .8f n", $1+(-1)*'$efermi', $2, $3 }' >> DOS$i
fi
fi
start=$((end+2))
end=$((start+nl-1))
i=$((i+1))
done
else
while [ $i -le 0 ]; do    #这个奇怪,为什么要讨论i<0呢?不是只需考虑i>=0吗?前⾯已经全部包含了的呀?
#echo $i $start $end
if [ $i -gt 0 ]; then
sed -n ''$i' p' tmp.dat2 >| DOS$i
fi
if [ $i -gt 0 ]; then
# Atomic projected DOS
if [ $nspin -eq 2 ]; then
sed -n ''$start','$end' p' $dosfile | awk '{printf ".8f .8f .8f .8f .8f .8f .8f n", $1+(-1)*'$efermi', $2, -1*$3, $4, -1*$5, $6, -1*$7}' >> DOS$i
else
sed -n ''$start','$end' p' $dosfile | awk '{printf ".8f .8f .8f .8f n", $1+(-1)*'$efermi', $2, $3, $4 }' >> DOS$i
fi
else
# Total DOS
if [ $nspin -eq 2 ]; then
sed -n ''$start','$end' p' $dosfile | awk '{printf ".8f .8f .8f .8f .8f n", $1+(-1)*'$efermi', $2, -1*$3, $4, -1*$5 }' >> DOS$i            else
sed -n ''$start','$end' p' $dosfile | awk '{printf ".8f .8f .8f n", $1+(-1)*'$efermi', $2, $3 }' >> DOS$i
fi
fi
start=$((end+2))
end=$((start+nl-1))        i=$((i+1))
done
fi
exit 0

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。