htesp.plot¶
Module for plotting
Functions
|
Function to plot the bandstructure in line mode. |
|
Function to plot Wannier interpolated bandstructure. |
|
Function to plot density of states and partial density of states in different rows. |
|
Function to plot DOS and partial DOS (pDOS) using the vasprun.xml file from VASP using the pymatgen package. |
|
Read the Fermi level from a VASP |
|
Read the Fermi level from a QE |
|
Return the high-symmetry labels of a line-mode VASP k-point file. |
|
Generate k-path for VASP-line format. |
|
Main function to execute plotting tasks based on command-line arguments. |
|
Read NELECT from a VASP OUTCAR (last occurrence). |
|
Read 'number of electrons' from a QE output (last occurrence). |
|
Parse the |
|
Function to create quick plots. |
|
Function to plot different sections with respect to different colors. |
|
Function to plot atomic projection on phonon bandstructure. |
|
Return the Fermi level from whichever of the two outputs is present. |
|
Report whether spin-orbit coupling is switched on. |
|
Choose which el-ph smearing to report, defaulting to today's behaviour. |
|
Function to write a 'filedos.in' file required for PDOS plot. |
- htesp.plot.fermi_from_qe_out(path)[source]¶
Read the Fermi level from a QE
scf.out.FIX(14): the old code was
grep Fermi scf.out | awk '{print $5}'and then took the FIRST line - the first ionic step of a relaxation - and it also matched “Fermi-Dirac”. The LAST genuine statement is used now, and a spin-polarised run (which prints two energies) is handled explicitly.- Parameters:
path (str) – Path to the QE output.
- Returns:
The Fermi energy in eV.
- Return type:
float
- htesp.plot.fermi_from_outcar(path)[source]¶
Read the Fermi level from a VASP
OUTCAR(VASP 5 or 6).FIX(14): the old code grepped only one of the two wordings, then called
.item()on the loaded array - which raises for any relaxation with more than one ionic step, because OUTCAR then holds one such line per step. Both wordings are matched here and the LAST value is returned.- Parameters:
path (str) – Path to the OUTCAR.
- Returns:
The Fermi energy in eV.
- Return type:
float
- htesp.plot.read_fermi(qe_out='scf.out', outcar='../relax/OUTCAR')[source]¶
Return the Fermi level from whichever of the two outputs is present.
- Parameters:
qe_out (str) – QE output to try first. Default ‘scf.out’.
outcar (str) – VASP output to try second. Default ‘../relax/OUTCAR’.
- Returns:
The Fermi energy in eV.
- Return type:
float
- htesp.plot.nelect_from_qe_out(path)[source]¶
Read ‘number of electrons’ from a QE output (last occurrence).
- htesp.plot.read_lsorbit(incar='INCAR')[source]¶
Report whether spin-orbit coupling is switched on.
FIX(15): the old test was
grep LSORBIT INCAR | wc -l, so an INCAR holdingLSORBIT = .FALSE.counted as spin-orbit ON and the band index at the Fermi level was then left un-halved. The value is parsed now.- Parameters:
incar (str) – Path to the INCAR. Default ‘INCAR’.
- Returns:
True when LSORBIT is true.
- Return type:
bool
- htesp.plot.parse_lambda_out(filename='lambda.out')[source]¶
Parse the
lambda / omega_log / T_ctable written by QE’s lambda.x.FIX(17): lambda used to be read out of the hard-coded line 12 of lambda.out, i.e. one arbitrary smearing out of the ten el-ph smearings. The whole table is parsed here so the caller can choose a smearing.
- Parameters:
filename (str) – Path to lambda.out. Default ‘lambda.out’.
- Returns:
(rows, header_index)- rows is an (nsigma, 3) array of lambda/omega_log/Tc and header_index is the 0-based line number of the ‘omega_log’ header, which is what the legacy default is measured against.- Return type:
tuple
- htesp.plot.select_smearing(rows, header_index, smearing_index=None, legacy_line=12)[source]¶
Choose which el-ph smearing to report, defaulting to today’s behaviour.
- Parameters:
rows (numpy.ndarray) – Table returned by
parse_lambda_out().header_index (int) – Header line index returned by
parse_lambda_out().smearing_index (int or None) – 1-based smearing number. None reproduces the historical choice (
lambda.outline legacy_line) so existing plots do not change.legacy_line (int) – The line the old code hard-coded. Default 12.
- Returns:
(index, row)where index is 1-based.- Return type:
tuple
- htesp.plot.kpt_labels(kpoints_files=('KPOINTS', 'KPOINTS_OPT'))[source]¶
Return the high-symmetry labels of a line-mode VASP k-point file.
FIX(16):
Kpoints.from_file("KPOINTS").labelsis None whenever the run usedkpt_opt: true(the shipped default), because the line-mode path then lives in KPOINTS_OPT and KPOINTS holds a plain mesh. The old code fed that None straight intolen()and every VASP band plot died with a TypeError. KPOINTS_OPT, and then thelabel/lbpointfiles the wannier band step writes, are tried in turn.- Parameters:
kpoints_files (sequence of str) – Candidate k-point files, in order of preference.
- Returns:
(labels, num_kpts); num_kpts is None when the labels came from the label file rather than from a KPOINTS file.- Return type:
tuple
- htesp.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()
- htesp.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.
- htesp.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_floatMinimum 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.
- htesp.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.
- htesp.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.
- htesp.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.
- htesp.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.
- htesp.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.
- htesp.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.
- htesp.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.