Density of States
The rsgrad dos
command calculates the Density of States (DOS) of current system.
rsgrad
DOES NOT read the DOSCAR, but calculates the DOS from PROCAR instead by
$$ D(E) = \frac{1}{V} \sum_{i=1}^{N} \delta(E-E(\mathbf{k}_i)) $$
Because rsgrad
uses arbitrary unit, the factor \(\frac{1}{V}\) is omitted. The \(\delta(x)\)
is replaced by Gaussian function or Lorentzian function:
$$ g(x) = \frac{1}{\sigma\sqrt{2\pi}} \exp \left( -\frac{1}{2} \frac{(x-\mu)^2}{\sigma^2} \right) \\ l(x) = \frac{1}{\pi} \frac{\sigma}{(x-\mu)^2 + \sigma^2} $$
where \(\mu\) is \(E(\mathbf{k}_i)\) and \(\sigma\) is sigma
of configuration in the implementation.
This method makes it easier to calculate projected DOS with projection of specific atoms, angular moments and k-points.
However, this method sometimes differs from DOSCAR with ISMEAR = -5
. For detailed explaination, see the
document here.
The OUTCAR is also needed to get the Fermi level.
Help Message
$ rsgrad dos -h
rsgrad-dos
Calculate density of states from PROCAR and OUTCAR
USAGE:
rsgrad dos [OPTIONS]
OPTIONS:
-c, --config <CONFIG> Projected DOS configuration file path
--gen-template Generate projected DOS configuration template
-h, --help Print help information
--htmlout <HTMLOUT> Save the projected DOS plot as HTML. Then you can view it in the
browser [default: dos.html]
--outcar <OUTCAR> OUTCAR path [default: ./OUTCAR]
--procar <PROCAR> PROCAR path [default: ./PROCAR]
--show Open the browser and show the plot immediately
--show-brief Print brief info of PROCAR, this may be helpful when you write the
configuration
--to-inline-html Render the plot and print the rendered code to stdout
--txtout <TXTOUT> Save the raw data of projected DOS. Then you can replot it with more
advanced tools [default: dos_raw.txt]
--xlim <XLIM> <XLIM> Set the x-range of the plot [default: -1 6]
Configuration Template
The configuration template can be generated by running rsgrad dos --gen-template
. The following configuration
is written to pband.toml
by default:
# rsgrad DOS configuration in toml format.
# multiple tokens inside string are seperated by whitespace
method = "Gaussian" # smearing method
sigma = 0.05 # smearing width, (eV)
procar = "PROCAR" # PROCAR path
outcar = "OUTCAR" # OUTCAR path
txtout = "dos_raw.txt" # save the raw data as "dos_raw.txt"
htmlout = "dos.html" # save the pdos plot as "dos.html"
totdos = true # plot the total dos
fill = true # fill the plot to x axis or not
xlim = [-1, 6] # x-range of plot
[pdos.plot1] # One label produces one plot, the labels CANNOT be repetitive.
# This label is 'plot1', to add more pdos, write '[pdos.plot2]' and so on.
kpoints = "1 3..7 -1" # selects 1 3 4 5 6 7 and the last kpoint for pdos plot.
atoms = "1 3..7 -1" # selects 1 3 4 5 6 7 and the last atoms' projection for pdos plot.
orbits = "s px dxy" # selects the s px and dx orbits' projection for pdos plot.
factor = 1.01 # the factor multiplied to this pdos
[pdos.plot2] # One label produces one plot, the labels CANNOT be repetitive.
# This label is 'plot2', to add more pdos, write '[pdos.plot2]' and so on.
kpoints = "1 3..7 -1" # selects 1 3 4 5 6 7 and the last kpoint for pdos plot.
atoms = "1 3..7 -1" # selects 1 3 4 5 6 7 and the last atoms' projection for pdos plot.
orbits = "s px dxy" # selects the s px and dx orbits' projection for pdos plot.
factor = 1.01 # the factor multiplied to this pdos
# The fields can be left blank, if you want select all the components for some fields,
# just comment them. You can comment fields with '#'
Example (without configuration file)
This command can calculate total DOS only. To calculate projected DOS, use configuration instead (see next section).
$ rsgrad dos
[2022-07-14T18:42:55Z INFO rsgrad::commands::dos] Parsing PROCAR file "./PROCAR"
[2022-07-14T18:42:55Z INFO rsgrad::commands::dos] Parsing OUTCAR file "./OUTCAR" for Fermi level
[2022-07-14T18:42:55Z INFO rsgrad::commands::dos] Found Fermi level = -1.9018, eigenvalues will be shifted.
[2022-07-14T18:42:55Z INFO rsgrad::commands::dos] Plotting Total DOS ...
[2022-07-14T18:42:55Z INFO rsgrad::commands::dos] Total DOS plot time usage: 29.055µs
[2022-07-14T18:42:55Z INFO rsgrad::commands::dos] Writing DOS plot to "dos.html"
[2022-07-14T18:42:55Z INFO rsgrad::commands::dos] Writing raw DOS data to "dos_raw.txt"
[2022-07-14T18:42:55Z INFO rsgrad] Time used: 124.426652ms
The output html should be like something in the following
Example (with configuration file)
To plot multiple PDOS, using configuration file is suggested.
With the configuration (pdos.toml
) in the following
method = "Gaussian"
sigma = 0.05
procar = "PROCAR"
outcar = "OUTCAR"
txtout = "dos_raw.txt"
htmlout = "dos.html"
totdos = true
fill = true
xlim = [-1, 6]
[pdos.Benzene]
atoms = "37..48"
[pdos.AgSurf]
atoms = "3 6 10 14 21 23 25 33 36"
then rsgrad dos -c pdos.toml
$ rsgrad dos -c pdos.toml
[2022-07-14T18:43:34Z INFO rsgrad::commands::dos] Reading PDOS configuration from Some("pdos.toml")
[2022-07-14T18:43:34Z INFO rsgrad::commands::dos] Parsing PROCAR file "PROCAR"
[2022-07-14T18:43:34Z INFO rsgrad::commands::dos] Parsing OUTCAR file "OUTCAR" for Fermi level
[2022-07-14T18:43:34Z INFO rsgrad::commands::dos] Found Fermi level = -1.9018, eigenvalues will be shifted.
[2022-07-14T18:43:34Z INFO rsgrad::commands::dos] Plotting Total DOS ...
[2022-07-14T18:43:34Z INFO rsgrad::commands::dos] Total DOS plot time usage: 42.878µs
[2022-07-14T18:43:34Z INFO rsgrad::commands::dos] Plotting PDOS ...
[2022-07-14T18:43:34Z INFO rsgrad::commands::dos] PDOS plot time usage: 6.223076ms
[2022-07-14T18:43:34Z INFO rsgrad::commands::dos] Writing DOS plot to "dos.html"
[2022-07-14T18:43:34Z INFO rsgrad::commands::dos] Writing raw DOS data to "dos_raw.txt"
[2022-07-14T18:43:34Z INFO rsgrad] Time used: 61.982958ms
you will get something in the following
Usage of txtout
rsgrad
can write the raw data of plot by setting txtout (dos_raw.txt
by default). The organization of it
shows the energy, total DOS and projected dos respectively:
# E-Ef TotDOS Benzene AgSurf
...
-7.921938 0.002969 0.002158 0.000004
-7.899296 0.016032 0.011655 0.000019
-7.876654 0.070713 0.051408 0.000085
-7.854012 0.254749 0.185212 0.000307
-7.831371 0.749573 0.544998 0.000910
-7.808729 1.801235 1.309709 0.002202
-7.786087 3.534640 2.570233 0.004349
-7.763446 5.663677 4.118580 0.007011
-7.740804 7.409459 5.388357 0.009226
-7.718162 7.913407 5.755104 0.009908
-7.695520 6.898991 5.017578 0.008683
-7.672879 4.909619 3.570876 0.006208
-7.650237 2.854880 2.076535 0.003622
-7.627595 1.373037 0.998928 0.001724
-7.604953 0.617183 0.449840 0.000672
-7.582312 0.494734 0.362904 0.000231
-7.559670 0.977346 0.718873 0.000173
-7.537028 2.169137 1.593003 0.000599
-7.514387 4.077126 2.981347 0.002383
-7.491745 6.295459 4.560748 0.007858
-7.469103 8.005154 5.685401 0.021128
...
The first line shows the labels of each series and have a hastag #
in the beginning in order to let numpy.loadtxt
can read it directly.
Then you can throw it into other plotters like Excel, Matplotlib, OriginPro GnuPlot etc. and do whatever fancy things you prefer.