7
$\begingroup$

I am wondering if you could show me how to use gnuplot to draw bandstructure and DOS plots starting from VASP outputs. If you have any scripts please share them with us. Thanks.

$\endgroup$
7
  • 1
    $\begingroup$ What is the format for the bands file? $\endgroup$
    – Camps
    Apr 19, 2021 at 12:09
  • 1
    $\begingroup$ I have an script to plot bands and DOS but from SIESTA calculations. In this case my band/dos files as text file with three column: k, energy for spin up, energy for spin down (similar for DOS/PDOS). $\endgroup$
    – Camps
    Apr 19, 2021 at 12:25
  • 2
    $\begingroup$ If it's only a few thousands lines long, the script can perhaps go in an answer to this question, in a code block. $\endgroup$ Apr 19, 2021 at 19:49
  • 1
    $\begingroup$ You can use P4vasp Or vaspkit as alternative or check this github.com/QijingZheng/pyband $\endgroup$ Apr 20, 2021 at 3:19
  • 2
    $\begingroup$ @pranavkumar Do you think you could turn one of those 3 suggestions into an answer by perhaps explaining a bit more or giving an example of how it works? $\endgroup$ Apr 20, 2021 at 20:51

2 Answers 2

5
$\begingroup$

I will share here the script I use to plot bands/DOS/PDOS from SIESTA output.

After working with thee raw output from SIESTA, if a spin polarized calculation was done, we have two files (one for each spin) for the bands in the form:
(the file consist in three columns with k energy spin)

# GNUBANDS: Utility for SIESTA to transform bands output into Gnuplot format
#
#                                                  Emilio Artacho, Feb. 1999
#                                                   Alberto Garcia, May 2012
#                                         Nick Papior, April 2013, July 2016
# --------------------------------------------------------------------------
# Only bands for spin 2
# E_F               =    -2.9812
# k_min, k_max      =     0.0000    0.1300
# E_min, E_max      =    -6.1000   -0.1000
# Nbands, Nspin, Nk =   1575     2   201
# Using min_band, max_band =      1  1575
# Total number of bands =   1575
#
#        k            E[eV]
# --------------------------------------------------------------------------

      0.094253     -6.098700  2
      0.094903     -6.097100  2
      0.095553     -6.095400  2
      0.096203     -6.093800  2
      0.096853     -6.092200  2 

For the DOS/PDOS:
(the file consist in three column with energy DOS_spin_up DOS_spin_down)

#
#    Energy          spin 1        spin2
#
   -6.9999925    12.14227672    12.02303660
   -6.9919845    11.73120115    11.76512099
   -6.9839765    11.48849750    11.61787403
   -6.9759685    11.43686413    11.57040674
   -6.9679605    11.56064946    11.60338643
   -6.9599525    11.81124343    11.69537446 

The script I used is (output to PDF):

##########################################################
#                                                        #
#  Input data para fazer os gráficos, escalas de forma   #
#  automatica                                            #
#                                                        #
##########################################################

# Dados nomes dos arquivos
BANDS_PRISTINE_down = "BN-puro-b-down.dat"
BANDS_PRISTINE_up = "BN-puro-b-up.dat"
BANDS_METAL_down = "BN-Ni-p5-b-down.dat"
BANDS_METAL_up = "BN-Ni-p5-b-up.dat"
DOS_TOTAL = "BN-Ni-p5-d-DOS.dat"

# Dados escalas graficos
ENERGY_min = -6.1096
ENERGY_max = -0.1096
K_min = 0.0
K_max = 0.13
FERMI_PRISTINE = -4.257
FERMI_METAL = -2.9812
DOS_min = -48 
DOS_max = 44
PDOSNANO_min = -1.2 
PDOSNANO_max = 1.0
PDOSMETAL_min = -12 
PDOSMETAL_max = 14


set terminal pdf font "Helvetica,9" enhanced color
set output "BANDS-DOS-PDOS-BN-Ni-p5.pdf"
load 'multiplot.gp'

eval(init_margins(0.045, 0.98, 0.05, 0.94, 0.035, 0.08, 1, 5))
#                 left,  right, bottom, top, dx, dy, rows, cols
set multiplot


# Para definir os tipos de dash
set termoption dash
set for [i=1:5] linetype i dt i
show style line
set key off # texto associado a data no grafico
set key below



# Grafico 1
# Bandas BN puro
eval(set_margins(1,1))
set title "(a) BN pristine" offset 0.0, -0.5
set ylabel 'Energy (eV)' offset 1.0, 0.0
set mytics 2
set xtics ("{/Symbol G}"  K_min, "Z"  K_max) offset 0.0, 0.5
set arrow 1 from K_min,FERMI_PRISTINE to K_max,FERMI_PRISTINE nohead dt 2 lc rgb "green" lw 1.5

# Legenda bandas
# Down
set arrow 5 from 0,-6.5 to 0.035,-6.5 nohead lt 1 lc rgb "black" lw 1.5
set arrow 55 from 0.045,-6.4 to 0.045,-6.6 head nofilled size screen 0.03,15 dt 1 lc rgb "black" lw 1.5 # Down
# Legenda bandas
# Up
set arrow 6 from 0.065,-6.5 to 0.1,-6.5 nohead lt 2 lc rgb "red" lw 1.5
set arrow 66 from 0.11,-6.6 to 0.11,-6.4 head nofilled size screen 0.03,15 dt 1 lc rgb "black" lw 1.5 # Up

# Legenda Fermi
set arrow 7 from 0.135,-6.5 to 0.170,-6.5 nohead dt 2 lc rgb "green" lw 1.5
set label 1 "E_F" at 0.175,-6.5
set yrange [ENERGY_min:ENERGY_max]
plot BANDS_PRISTINE_down with lines lt 1 lc rgb "black" lw 1.5 title "", \
     BANDS_PRISTINE_up with lines lt 2 lc rgb "red" lw 1.5 title ""
unset arrow 3
unset arrow 5
unset arrow 55
unset arrow 6
unset arrow 66
unset arrow 7
unset label 1

# Grafico 2
# Bandas BN-Ni-p5
eval(set_margins(2,1))
unset ylabel
set title "(b) BN+Ni(p5)"
set ytics
set ytics format " " # Remove os labels, deixando somente os ticks
set xtics ("{/Symbol G}"  K_min, "Z"  K_max) offset 0.0, 0.5
set arrow 1 from K_min,FERMI_METAL to K_max,FERMI_METAL nohead dt 2 lc rgb "green" lw 1.5 # FERMI
set yrange [ENERGY_min:ENERGY_max]
plot BANDS_METAL_down with lines lt 1 lc rgb "black" lw 1.5 title "", \
     BANDS_METAL_up with lines lt 2 lc rgb "red" lw 1.5 title ""
unset arrow 3


# Grafico 3
# DOS total
eval(set_margins(3,1))
unset ylabel
set title "(c) TDOS"
unset ytics
unset xtics
set ytics format " " 
set xtics (gprintf("%1.1f",DOS_min)  DOS_min, gprintf("%1.1f",DOS_max)  DOS_max) offset 0.0, 0.5
set arrow 1 from DOS_min,FERMI_METAL to DOS_max,FERMI_METAL nohead dt 2 lc rgb "green" lw 1.5
set arrow 2 from 0,ENERGY_min to 0,ENERGY_max nohead dt 1 lc rgb "gray" lw 1.5
a_xmin = DOS_min - 0.17 * DOS_min
a_xmax = DOS_max - 0.17 * DOS_max
set arrow 3 from a_xmin,-5.8 to a_xmin,-6.0 head nofilled size screen 0.03,15 dt 1 lc rgb "black" lw 1.5 # Down
set arrow 4 from a_xmax,-6.0 to a_xmax,-5.8 head nofilled size screen 0.03,15 dt 1 lc rgb "black" lw 1.5 # Up
set yrange [ENERGY_min:ENERGY_max]
set xrange [DOS_min:DOS_max]
plot DOS_TOTAL using (-$3):1 with lines lt 1 lc rgb "black" lw 1.5 title "", \
      DOS_TOTAL using 2:1 with lines lt 1 lc rgb "red" lw 1.5 title ""
unset arrow 3
unset arrow 4


# Grafico 4
# PDOS atomos do BN que interagem
eval(set_margins(4,1))
unset ylabel
set title "(d) PDOS nanotube"
unset ytics
set ytics format " " 
set xtics (gprintf("%1.1f",PDOSNANO_min)  PDOSNANO_min, gprintf("%1.1f",PDOSNANO_max)  PDOSNANO_max) offset 0.0, 0.5
set arrow 1 from PDOSNANO_min,FERMI_METAL to PDOSNANO_max,FERMI_METAL nohead dt 2 lc rgb "green" lw 1.5
set arrow 2 from 0,-6.1 to 0,-0.1 nohead dt 1 lc rgb "gray" lw 1.5
a_xmin = PDOSNANO_min - 0.17 * PDOSNANO_min
a_xmax = PDOSNANO_max - 0.17 * PDOSNANO_max
set arrow 3 from a_xmin,-5.8 to a_xmin,-6.0 head nofilled size screen 0.03,15 dt 1 lc rgb "black" lw 1.5 # Down
set arrow 4 from a_xmax,-6.0 to a_xmax,-5.8 head nofilled size screen 0.03,15 dt 1 lc rgb "black" lw 1.5 # Up
set yrange [ENERGY_min:ENERGY_max]
set xrange [PDOSNANO_min:PDOSNANO_max]
plot "BN-Ni-p5-d-B95.dat" using (-$3):1 with lines lt 1 lc rgb "brown" lw 1.5 title "B_{95}+B_{102}", \
     "BN-Ni-p5-d-B95.dat" using 2:1 with lines lt 1 lc rgb "brown" lw 1.5 title "", \
     "BN-Ni-p5-d-B102.dat" using (-$3):1 with lines lt 1 lc rgb "brown" lw 1.5 title "", \
     "BN-Ni-p5-d-B102.dat" using 2:1 with lines lt 1 lc rgb "brown" lw 1.5 title "", \
     "BN-Ni-p5-d-N86.dat" using (-$3):1 with lines lt 1 lc rgb "dark-yellow" lw 1.5 title "N_{86}", \
     "BN-Ni-p5-d-N86.dat" using 2:1 with lines lt 1 lc rgb "dark-yellow" lw 1.5 title ""
unset arrow 3
unset arrow 4


# Grafico 5
# PDOS Metal
eval(set_margins(5,1))
unset ylabel
set title "(e) PDOS metal"
set ytics
set ytics format " " 
set xtics (gprintf("%1.1f",PDOSMETAL_min)  PDOSMETAL_min, gprintf("%1.1f",PDOSMETAL_max)  PDOSMETAL_max) offset 0.0, 0.5
set arrow 1 from PDOSMETAL_min,FERMI_METAL to PDOSMETAL_max,FERMI_METAL nohead dt 2 lc rgb "green" lw 1.5
set arrow 2 from 0,-6.1 to 0,-0.1 nohead dt 1 lc rgb "gray" lw 1.5
a_xmin = PDOSMETAL_min - 0.17 * PDOSMETAL_min
a_xmax = PDOSMETAL_max - 0.17 * PDOSMETAL_max
set arrow 3 from a_xmin,-5.8 to a_xmin,-6.0 head nofilled size screen 0.03,15 dt 1 lc rgb "black" lw 1.5 # Down
set arrow 4 from a_xmax,-6.0 to a_xmax,-5.8 head nofilled size screen 0.03,15 dt 1 lc rgb "black" lw 1.5 # Up
set yrange [ENERGY_min:ENERGY_max]
set xrange [PDOSMETAL_min:PDOSMETAL_max]
plot "BN-Ni-p5-d-Ni-3d.dat" using (-$3):1 with lines lt 1 lc rgb '#440154' lw 1.5 title "3d Ni", \
     "BN-Ni-p5-d-Ni-3d.dat" using 2:1 with lines lt 1 lc rgb '#440154' lw 1.5 title "", \
     "BN-Ni-p5-d-Ni-4s.dat" using (-$3):1 with lines lt 1 lc rgb '#f89441' lw 1.5 title "4s Ni", \
     "BN-Ni-p5-d-Ni-4s.dat" using 2:1 with lines lt 1 lc rgb "orange" lw 1.5 title ""

# '#440154' ==> dark purple
# '#f89441' ==> dark orange

unset multiplot

and the multiplot script:
(used to have more than one graph)

init_margins(left, right, bottom, top, dx, dy, rows, cols) = \
  sprintf('left_margin = %f; right_margin = %f; top_margin = %f; bottom_margin = %f; ', left, right, top, bottom) . \
  sprintf('col_count = %d; row_count = %d; gap_size_x = %f; gap_size_y = %f', cols, rows, dx, dy)

get_lmargin(col) = (left_margin + (col - 1) * (gap_size_x + ((right_margin - left_margin)-(col_count - 1) * gap_size_x)/col_count))
get_rmargin(col) = (left_margin + (col - 1) * gap_size_x + col * ((right_margin - left_margin)-(col_count - 1) * gap_size_x)/col_count)
get_tmargin(row) = (top_margin  - (row - 1) * gap_size_y - (row-1) * ((top_margin - bottom_margin  - gap_size_y * row_count) / row_count))
get_bmargin(row) = (top_margin  - (row - 1) * gap_size_y -  row    * ((top_margin - bottom_margin  - gap_size_y * row_count) / row_count))
set_margins(col, row) = \
  sprintf('set lmargin at screen %f;', get_lmargin(col)) . \
  sprintf('set rmargin at screen %f;', get_rmargin(col)) . \
  sprintf('set tmargin at screen %f;', get_tmargin(row)) . \
  sprintf('set bmargin at screen %f;', get_bmargin(row))          

My final figure: enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks brother. $\endgroup$
    – Chi Kou
    Apr 23, 2021 at 8:44
6
$\begingroup$

enter image description hereLet start with p4vasp
p4vasp is postprocessing tool for VASP output written in python and some C++. It is very easy to install and you can check in its official website http://www.p4vasp.at/#/home
For ploting band structure or DOS , this package need vasprun.xml as input which is output of VASP. Once we load input, it will automatically show DOS or you can click on DOS menu. For local density of states or bands , drop down menu electronic and select local DOS and band control. You can select different atoms and orbital to add in plot. Export output in dat file or xmgrace file (nice free plotting tool). You can also select each atom for local band and DOS using GUI. Nice tutorial link: https://youtu.be/RYziHtNFaPs
https://youtu.be/ohDguVFDPlc
enter image description here Vaspkit is another alternative for p4vasp.
It is nice package for both preprocessing and postprocessing with VASP. We can generate high symmetry K-Points for band calculation, we can write INCAR, KPOINTS file for input to calculation. It reads PROCAR file as input and gives output in simple form x y column inside dat file which can be used in xmgrace / gnuplot or other. Kindly check documentation of vaspkit https://vaspkit.com/

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks brother. $\endgroup$
    – Chi Kou
    Apr 23, 2021 at 8:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .