plot

Module for plotting

Functions

band_plot_vasp_line(mpid, compound)

Function to plot the bandstructure in line mode.

band_wann_plot([fileout])

Function to plot Wannier interpolated bandstructure.

dos_plot(filedos[, out])

Function to plot density of states and partial density of states in different rows.

dos_plot_vasp([outfile])

Function to plot DOS and partial DOS (pDOS) using the vasprun.xml file from VASP using the pymatgen package.

kptline()

Generate k-path for VASP-line format.

main()

Main function to execute plotting tasks based on command-line arguments.

plot(plottype, file, comp[, proj, ...])

Function to create quick plots.

plot_gamma(xdata, ydata, color, min_)

Function to plot different sections with respect to different colors.

plot_projection(scf_file, projection_file, ...)

Function to plot atomic projection on phonon bandstructure.

write_filedos(comp)

Function to write a 'filedos.in' file required for PDOS plot.

plot.kptline()[source]

Generate k-path for VASP-line format.

Reads KPOINTS file and vasprun.xml file to generate the k-path for the VASP-line format. Returns: - nkpt (numpy.ndarray): Array containing distances between k-points. - sympoint (numpy.ndarray): Array containing the special k-points along the path. - symname (list): List of special k-point names formatted for LaTeX.

This function computes the k-path for the VASP-line format based on the KPOINTS file and vasprun.xml file. It calculates the distances between k-points and identifies special k-points along the path.

Example usage: nkpt, sympoint, symname = kptline()

plot.plot(plottype, file, comp, proj=None, read_kpoint=None, colormap=None)[source]

Function to create quick plots.

Parameters:

plottypestr

Type of plot. ‘band’ for electronic bandstructure and DOS side by side, ‘phonband’ for phonon bandstructure, ‘gammaband’ for phonon band with lambda projection, ‘a2f’ for Eliashberg spectral function.

filestr

QE scf input file to generate k-point mesh.

compstr

Compound name.

Returns:

None

This function creates various types of plots based on the input parameters.

plot.plot_gamma(xdata, ydata, color, min_)[source]

Function to plot different sections with respect to different colors.

Parameters:

xdataarray-like

x-axis data.

ydataarray-like

y-axis data.

colorarray-like

Projection data.

min_float

Minimum threshold for binary classification.

Returns:

None

This function plots different sections of the data with respect to different colors. If the color value is less than or equal to the minimum threshold, the section is plotted in black. Otherwise, the section is plotted in green with marker sizes proportional to the color values.

plot.dos_plot(filedos, out='pdos.pdf')[source]

Function to plot density of states and partial density of states in different rows.

Parameters:

filedosstr

DOS file in .dos format obtained from QE calculations.

outstr, optional

Output plot in PDF format. Default is ‘pdos.pdf’.

Returns:

None

This function reads the DOS file and performs DOS and PDOS calculations. It requires a ‘filedos.in’ with ion and orbital contribution from different lines. It also uses ‘sumpdos.sh’ scripts as “sumpdos.sh element orbital” to create ‘element-orbital.dat’ files. For example, for boron and s orbital, element = B, orbital = s, B-s.dat file is created. The function then plots the density of states and partial density of states in different rows.

plot.band_wann_plot(fileout='plot.pdf')[source]

Function to plot Wannier interpolated bandstructure.

Parameters:

filebandstr, optional

Bandstructure file. Default is ‘ex_band.dat’.

fileoutstr, optional

Output file. Default is ‘plot.pdf’.

Returns:

None

This function reads the bandstructure file and plots the Wannier interpolated bandstructure. It extracts data from the provided files and plots the bandstructure accordingly. The function also checks for bands below the Fermi level and prints a message if found.

plot.plot_projection(scf_file, projection_file, phonon_freq, outfile, nkpt)[source]

Function to plot atomic projection on phonon bandstructure.

Parameters:

scf_filestr

QE scf.in file to extract structure.

projection_filestr

File containing atomic projection data.

phonon_freqstr

File containing phonon dispersion data.

outfilestr

Output plot file.

nkptint

Number of q points.

proj_cutofffloat, optional

Cutoff to apply filter. Plotting only colors that have projection larger than the cutoff. If not provided, it will be calculated based on the number of atoms.

Returns:

None

This function reads the necessary files and plots the atomic projection on the phonon bandstructure. It calculates the projection cutoff based on the number of atoms if not provided explicitly. The function generates a plot showing the atomic projection on the phonon dispersion.

plot.write_filedos(comp)[source]

Function to write a ‘filedos.in’ file required for PDOS plot.

Parameters:

compstr

Composition.

Returns:

None

This function writes the ‘filedos.in’ file based on the composition provided. It extracts the elements and their electronic structure to determine the orbital contributions for PDOS.

plot.dos_plot_vasp(outfile='pdos.pdf')[source]

Function to plot DOS and partial DOS (pDOS) using the vasprun.xml file from VASP using the pymatgen package.

Parameters:

outfilestr, optional

Output plot file name (default is “pdos.pdf”).

Returns:

None

This function reads the ‘filedos.in’ file to determine which elements and orbitals to include in the pDOS plot. It uses the Vasprun object from the pymatgen package to parse the vasprun.xml file. The function plots the Total DOS and pDOS for the specified elements and orbitals.

Note:

‘filedos.in’ should be present in the current directory to specify the elements and orbitals for pDOS plotting.

plot.band_plot_vasp_line(mpid, compound)[source]

Function to plot the bandstructure in line mode.

Parameters:

mpidstr

Materials ID.

compoundstr

Name of the compound.

Returns:

None

This function generates a PDF plot of the bandstructure in line mode using data from the vasprun.xml file. The plot is saved with the filename format: “<mpid>-<compound>-band.pdf”. The band structure is obtained using the Vasprun object from the pymatgen package. The BSPlotter object is used to generate the band structure plot with specified settings.

Note:

Ensure that the vasprun.xml file containing band structure data is present in the current directory.

plot.main()[source]

Main function to execute plotting tasks based on command-line arguments.

This function reads command-line arguments to determine the type of plot and other required parameters. It performs different plotting tasks based on the specified plot type.

Command-line Arguments:

plottypestr

Type of plot to generate.

mpidstr

Materials ID.

compstr

Name of the compound.

Returns:

None

Plotting Tasks:

  • For ‘pdos’ plot type:
    • Checks if ‘filedos.in’ exists, creates one if not found.

    • Determines the type of calculation (QE or VASP).

    • Calls ‘dos_plot_vasp’ function if VASP calculation is detected, otherwise ‘dos_plot’ function.

  • For ‘wann_band’ plot type:
    • Calls ‘band_wann_plot’ function.

  • For ‘phonproj’ plot type:
    • Reads the number of k-points from command-line argument.

    • Calls ‘plot_projection’ function with appropriate parameters.

  • For other plot types:
    • Calls ‘plot’ function with specified plot type, file name, and compound name.

Note:

Ensure proper command-line arguments are provided. Only QE and VASP outputs are allowed for plotting tasks.