地域密着型エリア広告配信リクルートの地域密着型広告ドコイク?アドネットワーク Ads by ドコイク?[無料でホームページを作成] [通報・削除依頼]
[無料でホームページを作成] [通報・削除依頼]

VASP (sequential calculation, simple version)

------------------------------------------------------------------------------
■ Youtube動画:
基本的な使い方: https://www.youtube.com/watch?v=A4tvitLdKi8 
------------------------------------------------------------------------------
■ Usage
1. chmod +x vasp_run
2. chmod +x gplot
3. chmod +x fenergy
4. gedit vasp_run
change
------
#set vasp_adress = $HOME'/vasp/vasp.5.3/vasp'
set vasp_adress = $HOME'/vasp/vasp.5.4.1/bin/vasp_std'
set pseudo_potential_adress = $HOME'/vasp/potpaw_PBE'
set standard_input_adress = $HOME'/Desktop/Link to vasp_work/standard_input_files'
------
5. put gplot, fenergy, INCAR_opt_template, INCAR_scf_template and INCAR_dos_template in same directory.
6. put vasp_run and cif files in same directory.
7. vasp_run
8. fenergy
------------------------------------------------------------------------------
■ vasp_run
----------
#! /bin/csh -f
# VASP run command
#
# user settting
#set vasp_adress = $HOME'/vasp/vasp.5.3/vasp'
set vasp_adress = $HOME'/vasp/vasp.5.4.1/bin/vasp_std'
set pseudo_potential_adress = $HOME'/vasp/potpaw_PBE'
set standard_input_adress = $HOME'/Desktop/Link to vasp_work/standard_input_files'
#
# Automatically setting
setenv OMP_NUM_THREADS 1
set node = `grep 'physical id' /proc/cpuinfo | sort -u | wc -l`
set num_core = `grep 'core id' /proc/cpuinfo | sort -u | wc -l`
echo ""
set DATE = `date`
echo $DATE
echo "Automatically setting environments"
echo "------------------------------------------------------------"
echo "OpenMP threads = 1"
echo "automatic setting Parallel calculation (MPI) = "$num_core" core"" / ""$node"" node"
set NPAR = `echo 4-"sqrt($num_core)" | bc`
echo "automatic setting NPAR = "$NPAR
sed 's/#NPAR/NPAR = '${NPAR}'/g' "${standard_input_adress}/INCAR_opt_template" > "${standard_input_adress}/INCAR_opt"
sed 's/#NPAR/NPAR = '${NPAR}'/g' "${standard_input_adress}/INCAR_scf_template" > "${standard_input_adress}/INCAR_scf"
sed 's/#NPAR/NPAR = '${NPAR}'/g' "${standard_input_adress}/INCAR_dos_template" > "${standard_input_adress}/INCAR_dos"
echo "------------------------------------------------------------"
echo $vasp_adress
echo $pseudo_potential_adress
echo $standard_input_adress
echo "------------------------------------------------------------"
#
# current adress setting
set address = `pwd`
echo "$address"
echo "$address" >> "$address/log"
set DATE = `date`
echo "start: "$DATE > "$address/log"
#
# get cif data
set cif_list=`ls *.cif`
foreach cif_name ( $cif_list )
  # remove extension
  set cif_folder_name = `echo $cif_name:r`
  mkdir ${cif_folder_name}
  cp "$address/$cif_name" "$address/${cif_folder_name}/$cif_name"
end
echo "include"
set list=`find . -maxdepth 1 -mindepth 1 -type d | awk -F/ '{print $NF}'`
echo $list
echo "folder list: "$list >> "$address/log"
echo "------------------------------------------------------------"
#
# make directory
mkdir graph
mkdir cif
# initial setting
echo `date` > fermi_energy.txt
echo `date` > total_energy.txt
# setting for formation energy calculation
set compound_no = 0
#
# loop
foreach folder_name_list ( $cif_list )
  set folder_name = `echo $folder_name_list:r`
  echo "--------------------" >> "$address/log"
  set DATE = `date`
  echo $DATE >> "$address/log"
  #
  echo ""
  echo "vasp calculation start: ""$folder_name"
  echo ""
  date
  #
  cd "$address/$folder_name"
  echo "folder name: "$folder_name >> "$address/log"
  echo "absolute adress: "`pwd` >> "$address/log"
  #
  echo "run cif2cell"
  cif2cell -p vasp --setup-all --vasp-format=5 --vasp-encutfac=1.0 --vasp-pseudo-libdr="${pseudo_potential_adress}" --vasp-cartesian-lattice-vectors -f *.cif
  cp INCAR INCAR_cif2cell
  #
  echo "set standard input files"
  cp "${standard_input_adress}/INCAR_opt" INCAR_opt
  cp "${standard_input_adress}/INCAR_scf" INCAR_scf
  cp "${standard_input_adress}/INCAR_dos" INCAR_dos
  cp "${standard_input_adress}/gplot" "$address/gplot"
  cp "${standard_input_adress}/fenergy" "$address/fenergy"
  chmod +x "$address/gplot"
  chmod +x "$address/fenergy"
  # structure optimization
  date
  set DATE = `date`
  echo "optimize structure calculation"
  echo "optimize structure calculation: "$DATE >> "$address/log"
  mpirun -np $num_core $vasp_adress # run opt calculation
  cp OUTCAR OUTCAR_opt
  cp CONTCAR POSCAR
  # scf calculation (use optimized structure)
  date
  set DATE = `date`
  echo "scf calculation"
  echo "scf calculation: "$DATE >> "$address/log"
  cp INCAR_scf INCAR
  mpirun -np $num_core $vasp_adress # run scf calculation
  cp OUTCAR OUTCAR_scf
  # dos calculation
  date
  set DATE = `date`
  echo "dos calculation"
  echo "dos calculation: "$DATE >> "$address/log"
  # setting automatically dos energy range
  grep "Fermi energy:" OUTCAR | tail -1 > fermi_temp1
  awk '{print $4}' fermi_temp1 > fermi_energy_temp1
  sed -e 's/;.*//g' fermi_energy_temp1 > fermi_energy_temp2
  set fermi_energy = `sed -n 1p fermi_energy_temp2`
  set energy_min = `echo "${fermi_energy} - 13.0" | bc -l`
  set energy_max = `echo "${fermi_energy} + 6.0" | bc -l`
  cp INCAR_dos INCAR_dos_temp
  sed -e 's/#ELOW#/'${energy_min}'/g' -e 's/#EHIGH#/'${energy_max}'/g' INCAR_dos_temp > INCAR_dos
  rm -f fermi_temp1
  rm -f fermi_energy_temp1
  rm -f fermi_energy_temp2
  rm -f fermi_energy
  rm -f INCAR_dos_temp
  #
  cp INCAR_dos INCAR
  mpirun -np $num_core $vasp_adress # run dos calculation
  cp OUTCAR OUTCAR_dos
  # data file
  date
  grep "Fermi energy:" OUTCAR | tail -1 >> "$address/log"
  grep "TOTEN" OUTCAR | tail -1 >> "$address/log"
  # new file
  echo "folder name: " "$folder_name" >> "$address/fermi_energy.txt"
  grep "Fermi energy:" OUTCAR | tail -1 >> "$address/fermi_energy.txt"
  echo "$folder_name" >> "$address/total_energy.txt"
  grep "TOTEN" OUTCAR | tail -1 >> "$address/total_energy.txt"
  # formation energy data
  set atom_chara = `awk 'NR==6 {print $1}' POSCAR`
  set check_single = `awk 'NR==6 {print $2}' POSCAR`
  if(${check_single} == "")then
    echo $atom_chara >> "$address/atom_total_energy.txt"
    sed -n 7p POSCAR >> "$address/atom_total_energy.txt"
    grep "TOTEN" OUTCAR | tail -1 >> "$address/atom_total_energy.txt"
  else
    @ compound_no += 1
    echo "${compound_no}"
    echo "${compound_no}" > "$address/compound_num.txt"
    #echo ${compound_no} >> "$address/compound_total_energy.txt"
    echo "$folder_name" >> "$address/compound_total_energy.txt"
    sed -n 6p POSCAR >> "$address/compound_total_energy.txt"
    sed -n 7p POSCAR >> "$address/compound_total_energy.txt"
    grep "TOTEN" OUTCAR | tail -1 >> "$address/compound_total_energy.txt"
  endif
  # calculating file
  echo "folder name: " "$folder_name" >> "$address/$folder_name/log"
  grep "Fermi energy:" OUTCAR | tail -1 >> "$address/$folder_name/log"
  echo "$folder_name" >> "$address/$folder_name/log"
  grep "TOTEN" OUTCAR | tail -1 >> "$address/$folder_name/log"
  # dos plot data
  set DATE = `date`
  echo "dos plot: "$DATE >> $address/log
  sed -n 6p DOSCAR > dos_num_line
  awk '{print $3}' dos_num_line > dos_num
  set end_line = `sed -n 1p dos_num`
  @ end_line += 6
  sed -n 7,${end_line}p DOSCAR > tdos_temp
  awk '{print $4}' dos_num_line > fermi_temp
  set fermi_energy = `sed -n 1p fermi_temp`
  echo "${fermi_energy}"
  awk -v p="${fermi_energy}" '{print $1-p,$2,$3}' tdos_temp > tdos
  awk -v p="${fermi_energy}" '{print $1-p,$2,$3}' tdos_temp > "tdos_$folder_name"
  cp "tdos_$folder_name" "$address/graph/tdos_$folder_name"
  rm -f dos_num_line
  rm -f dos_num
  rm -f tdos_temp
  rm -f fermi_temp
  echo "$folder_name" >> "$address/$folder_name/title"
  # dos plot
  "$standard_input_adress/gplot"
  cp *.ps "$address/graph/${folder_name}.ps"
  mv "$address/$folder_name.cif" "$address/cif/$folder_name.cif"
  rm -f title
end
# go back adress
cd "$address"
#
----------
------------------------------------------------------------------------------
■ gplot
----------
#!/bin/csh -f

set tempfile = `sed -n 1p title`
set filename  = $tempfile
set psformat  = $filename".ps"
set epsformat = $filename".eps"

gnuplot -persist << EOF

set title "$filename"
set size 0.7,1.0
set xr[-12.0:6.0]
set xl "{/=30 Energy  / eV}"
set yr[0.0:*]
set yl "{/=30 Density of States / eV}"

set yzeroaxis lt 2 lw 2 lc rgb "black"

# linetype=lt, linecolor=lc, linewidth=lw, pointtype=pt, pointsize=ps
# with=w, line=l, color setting=lc rgb "",
set key box center top

# dos_updn
#plot "dos_updn" using 1:2 w l lt 1 lw 2 lc rgb "black" title "{/=30 up spin}", "dos_updn" using 1:3 w l lt 1 lw 2 lc rgb "black" title "{/=30 down spin}"

# tdos
plot "tdos" using 1:2 w l lt 1 lw 2 lc rgb "black" title "{/=30 total}"

unset key
#set key left top

set size 1.0,1.0
set terminal postscript color enhanced "Arial" 30
set out "$psformat"
replot

#set size 1.5,2.1
#set terminal postscript eps color enhanced "Arial" 30
#set out "$epsformat"
#replot

set terminal x11

EOF
----------
------------------------------------------------------------------------------
■ fenergy
----------
#! /bin/csh -f
# VASP run command
#
set nc = `awk '{print $1}' compound_num.txt`
set n = 1
while (${n} <= ${nc})
  set n1 = `echo "((${n}-1)*4+1)" | bc`
  set n2 = `echo "((${n}-1)*4+2)" | bc`
  set n3 = `echo "((${n}-1)*4+3)" | bc`
  set n4 = `echo "((${n}-1)*4+4)" | bc`
  set atom_list=`sed -n ${n2}p compound_total_energy.txt`
  set atom_num=`sed -n ${n3}p compound_total_energy.txt`
  sed -n ${n4}p compound_total_energy.txt > formation_energy
  awk -v p="${n4}" 'NR==p {print $5}' compound_total_energy.txt > formation_energy
  #cat formation_energy
  #awk 'NR==4 {print $5}' compound_total_energy.txt > formation_energy
  set No = 0
  #echo "----------------"
  foreach atom_name ( ${atom_list} )
    @ No += 1
    #echo ${atom_name}
    set atom_line = `grep -e ${atom_name} -n atom_total_energy.txt | sed -e 's/:.*//g'`
    #echo ${atom_line}
    set atom_total_energy_num = `awk -v p="${atom_line}" 'NR==(p+1) {print $1}' atom_total_energy.txt`
    set atom_total_energy_unitcell = `awk -v p="${atom_line}" 'NR==(p+2) {print $5}' atom_total_energy.txt`
    set atom_total_energy = `echo "${atom_total_energy_unitcell}/${atom_total_energy_num}" | bc -l`
    #echo ${atom_total_energy}" eV/atom"
    if(${No} == 1)then
      set natom = `awk -v n="${n3}" 'NR==n {print $1}' compound_total_energy.txt`
      set AETOT = `echo "${natom}*${atom_total_energy}" | bc`
      #awk -v n="${n3}" 'NR==n {print $1, "atoms"}' compound_total_energy.txt
    else if(${No} == 2)then
      set natom = `awk -v n="${n3}" 'NR==n {print $2}' compound_total_energy.txt`
      set AETOT = `echo "${natom}*${atom_total_energy}" | bc`
      #awk -v n="${n3}" 'NR==n {print $2, "atoms"}' compound_total_energy.txt
    else if(${No} == 3)then
      set natom = `awk -v n="${n3}" 'NR==n {print $3}' compound_total_energy.txt`
      set AETOT = `echo "${natom}*${atom_total_energy}" | bc`
      #awk -v n="${n3}" 'NR==n {print $3, "atoms"}' compound_total_energy.txt
    else if(${No} == 4)then
      set natom = `awk -v n="${n3}" 'NR==n {print $4}' compound_total_energy.txt`
      set AETOT = `echo "${natom}*${atom_total_energy}" | bc`
      #awk -v n="${n3}" 'NR==n {print $4, "atoms"}' compound_total_energy.txt
    else if(${No} == 5)then
      set natom = `awk -v n="${n3}" 'NR==n {print $5}' compound_total_energy.txt`
      set AETOT = `echo "${natom}*${atom_total_energy}" | bc`
      #awk -v n="${n3}" 'NR==n {print $5, "atoms"}' compound_total_energy.txt
    else if(${No} == 6)
      set natom = `awk -v n="${n3}" 'NR==n {print $6}' compound_total_energy.txt`
      set AETOT = `echo "${natom}*${atom_total_energy}" | bc`
      #awk -v n="${n3}" 'NR==n {print $6, "atoms"}' compound_total_energy.txt
    else if(${No} == 7)then
      set natom = `awk -v n="${n3}" 'NR==n {print $7}' compound_total_energy.txt`
      set AETOT = `echo "${natom}*${atom_total_energy}" | bc`
      #awk -v n="${n3}" 'NR==n {print $7, "atoms"}' compound_total_energy.txt
    endif
    #echo "total energy: "${AETOT} " eV"
    awk -v p="${AETOT}" '{print $1-p}' formation_energy > formation_energy_temp
    awk '{print $1}' formation_energy_temp > formation_energy
    #cat formation_energy
    #echo "----------------"
  end
  #
  echo "----------------" >> formation_energy.txt
  sed -n ${n1}p compound_total_energy.txt >> formation_energy.txt
  #echo ${atom_list} >> formation_energy.txt
  #echo ${atom_num} >> formation_energy.txt
  awk '{print "formation energy: ", $1, "eV"}' formation_energy >> formation_energy.txt
  #
  cat formation_energy.txt
  #
  rm -f formation_energy_temp
  rm -f formation_energy
  #
  @ n = $n + 1
end
#
----------
------------------------------------------------------------------------------
■ INCAR_opt_template
----------
#NPAR

#
SYSTEM = system
# Common
ALGO = Fast
EDIFF = 1.0E-5
#EDIFF = 0.0001
EDIFFG = -0.01
LREAL = Auto
LWAVE = .TRUE.
#LCHARG = .TRUE
#LVTOT = .TRUE
#MAGMON = 0 0 1
#NELM = 200
#NPAR= 1
PREC = Accurate
#ISTART = 0

# cut off energy, eV unit
#ENCUT = 500

#spin 2, nonspin 1
#ISPIN = 2

#XC potential
GGA = PE

#SCF
#ISMEAR = -5
#SIGMA = 0.2
NSW = 100
IBRION = 2
ICHARG = 1
LORBIT = 11

#SCF OPTIMIZATION
ISIF = 3

#SCF energy range Ry
#EINT -3 30

# NBANDS, see OUTCAR, for HRplot
#NBANDS = 580

#DOS
#ISMEAR = -5
#NSW = 0
#IBRION = -1
#ICHARG = 11
#LORBIT = 11

#DOS range eV
#EMIN = -15.0
#EMAX = 15.0
#NEDOS = 6001

#EMIN = -10.0
#EMAX = 17.0
#NEDOS = 1001

#band
#ICHARG=11 #charge read file
#ISMEAR = 0; SIGMA = 0.1;
#LORBIT=11

## HSE
#LHFCALC = .TRUE. ; HFSCREEN = 0.2 ; AEXX = 0.25
#ALGO = D ; TIME = 0.4 ; LDIAG = .TRUE.

##VASP2WANNIER
#LWANNIER90=.TRUE.
----------
------------------------------------------------------------------------------
■ INCAR_scf_template
----------
#NPAR

#
SYSTEM = system
# Common
ALGO = Fast
EDIFF = 1.0E-5
#EDIFF = 0.0001
EDIFFG = -0.01
LREAL = Auto
LWAVE = .TRUE.
#LCHARG = .TRUE
#LVTOT = .TRUE
#MAGMON = 0 0 1
#NELM = 200
#NPAR= 1
PREC = Accurate
#ISTART = 0

# cut off energy
ENCUT = 500

#spin 2, nonspin 1
#ISPIN = 2

#XC potential
GGA = PE

#SCF
ISMEAR = -5
SIGMA = 0.2
NSW = 100
IBRION = 2
ICHARG = 1
LORBIT = 11

#SCF OPTIMIZATION
#ISIF = 3

#SCF energy range Ry
#EINT -3 30

# NBANDS, see OUTCAR, for HRplot
#NBANDS = 580

#DOS
#ISMEAR = -5
#NSW = 0
#IBRION = -1
#ICHARG = 11
#LORBIT = 11

#DOS range eV
#EMIN = -15.0
#EMAX = 15.0
#NEDOS = 6001

#EMIN = -10.0
#EMAX = 17.0
#NEDOS = 1001

#band
#ICHARG=11 #charge read file
#ISMEAR = 0; SIGMA = 0.1;
#LORBIT=11

## HSE
#LHFCALC = .TRUE. ; HFSCREEN = 0.2 ; AEXX = 0.25
#ALGO = D ; TIME = 0.4 ; LDIAG = .TRUE.

##VASP2WANNIER
#LWANNIER90=.TRUE.
----------
------------------------------------------------------------------------------
■ INCAR_dos_template
----------
#NPAR

#
SYSTEM = system
# Common
ALGO = Fast
EDIFF = 1.0E-5
#EDIFF = 0.0001
EDIFFG = -0.01
LREAL = Auto
LWAVE = .TRUE.
#LCHARG = .TRUE
#LVTOT = .TRUE
#MAGMON = 0 0 1
#NELM = 200
#NPAR= 1
PREC = Accurate
#ISTART = 0

# cut off energy, eV unit
ENCUT = 500

#spin 2, nonspin 1
#ISPIN = 2

#XC potential
GGA = PE

#SCF
#ISMEAR = -5
#SIGMA = 0.2
#NSW = 100
#IBRION = 2
#ICHARG = 1
#LORBIT = 11

#SCF OPTIMIZATION
#ISIF = 3

#SCF energy range Ry
#EINT -3 30

# NBANDS, see OUTCAR, for HRplot
#NBANDS = 500

#DOS
ISMEAR = -5
NSW = 0
IBRION = -1
#ICHARG = 11
#LORBIT = 11

#DOS range eV
EMIN = #ELOW#
EMAX = #EHIGH#
NEDOS = 4500

#band
#ICHARG=11 #charge read file
#ISMEAR = 0; SIGMA = 0.1;
#LORBIT=11

## HSE
#LHFCALC = .TRUE. ; HFSCREEN = 0.2 ; AEXX = 0.25
#ALGO = D ; TIME = 0.4 ; LDIAG = .TRUE.

##VASP2WANNIER
#LWANNIER90=.TRUE.
----------
------------------------------------------------------------------------------
アクセス数
ページビュー数