--- title: User API keywords: fastai sidebar: home_sidebar nb_path: "MainAPI.ipynb" ---
download_structure
[source]
download_structure
(formula
,mp_id
=None
,max_sites
=None
,min_sites
=None
,api_key
=None
,save_key
=False
)
Download structure data from Materials project website.
max_sites and min_sites are used to filter the number of sites in structure, or use mp_id to download a specific structure.
poscars
and cifs
as list.
Each item in list has attributes `content` and `write` to write to file.
get_kpath
[source]
get_kpath
(hsk_list
=[]
,labels
=[]
,n
=5
,weight
=None
,ibzkpt
=None
,outfile
=None
)
Generate list of kpoints along high symmetry path. Options are write to file or return KPOINTS list.
It generates uniformly spaced point with input n
as just a scale factor of number of points per unit length.
You can also specify custom number of kpoints in an interval by putting number of kpoints as 4th entry in left kpoint.
Optionally you can put a 4 values point where 4th entry will decide number of kpoints in current interval.
Make sure that points in a connected path patch are at least two i.e. `[[x1,y1,z1],[x2,y2,z2]]` or `[[x1,y1,z1,N],[x2,y2,z2]]`.
> Note: If you do not want to label a point, label it as 'skip' at its index and it will be removed.
If outfile = None
, KPONITS file content is printed.
str2kpath
[source]
str2kpath
(kpath_str
,n
=5
,weight
=None
,ibzkpt
=None
,outfile
=None
)
Get Kpath from a string of kpoints (Line-Mode like). Useful in Terminal.
Parameters
Example
str2kpath('''0 0 0 !$\Gamma$ 3 0.25 0.25 0.25 !L''') Automatically generated using PivotPy with HSK-INDS = [0, -1], LABELS = ['$\Gamma$', 'L'], SEG-INDS = [] 3 Reciprocal Lattice 0.0000000000 0.0000000000 0.0000000000 0.333333 0.1250000000 0.1250000000 0.1250000000 0.333333 0.2500000000 0.2500000000 0.2500000000 0.333333
fancy_quiver3d
[source]
fancy_quiver3d
(X
,Y
,Z
,U
,V
,W
,ax
=None
,C
='r'
,L
=0.7
,mutation_scale
=10
, **kwargs
)
Plots 3D arrows on a given ax. See FancyArrowPatch.
arrowstyle
which could be '->','-|>', their inverted forms and many more. See on matplotlib.rotation
[source]
rotation
(angle_deg
,axis_vec
)
Get a scipy Rotation object at given angle_deg
around axis_vec
.
Usage:
rot = rotation(60,[0,0,1])
rot.apply([1,1,1])
[-0.3660254 1.3660254 1.] #give this
generate_summary
[source]
generate_summary
(paths_list
=None
)
class
VasprunApp
[source]
VasprunApp
(height
=580
)
Display a GUI for vasp output analysis. self.theme_colors
can be used to edit custom theme.
import pivotpy as pp
va = pp.VasprunApp()
va.cache_data = False #Turn off cache globally.
va.evr_kws['elim'] = [-2,2] #Only Bands in this range will be included. Global accross project, can change anytime.
va.evr_kws['try_pwsh'] = False #Defult is True. Tries to load Powershell exported data.
va.ibands_kws['mode'] = 'bands' #Change graph mode from 'markers' to 'bands'. Setting it to 'lines' is not recommended in live graph, it could hang all UI.
va.show() #Displays App and do work!
va.theme_colors = pp.dark_colors #Set theme to dark externally and edit dictionary values to make your own theme
va.splot(**kwargs) #Get matplotlib plot of current data.
va.df #After you do some analysis and hit `Project Summary` button, get DataFrame.
va.fig #Get current fig in Notebook cell.
VasprunApp.show
[source]
VasprunApp.show
()
VasprunApp.splot
[source]
VasprunApp.splot
(**kwargs
)
Returns matplotlib Axes.kwargs
are passed to splot_rgb_lines
or splot_dos_lines
based on current figure. kwargs
should exclude whatever inside self.input
and path_evr
VasprunApp.iplot
[source]
VasprunApp.iplot
(**kwargs
)
Returns a detached interactive Figure. kwargs
are passed to iplot_rgb_lines
or iplot_dos_lines
based on current figure. kwargs
should exclude whatever inside self.input
and path_evr
VasprunApp.set_theme_colors
[source]
VasprunApp.set_theme_colors
(theme_colors
)
Get self.theme_colors and after edit set back
class
KPathApp
[source]
KPathApp
(path
='POSCAR'
)
View and trace path on BZ.
ka = KPathApp() ka.show() #Display app ka.splot() #get matplotlib figure
KPathApp.show
[source]
KPathApp.show
()
KPathApp.splot
[source]
KPathApp.splot
(**kwargs
)
Same as pp.splot_bz
except it also plots path on BZ. kwargs
are passed to pp.splot_bz
KPathApp.get_kpath
[source]
KPathApp.get_kpath
(n
=5
,weight
=None
,ibzkpt
=None
,outfile
=None
)
See Docs of pp.str2kpath for details.
get_child_items
[source]
get_child_items
(path
='E:\\Research\\pivotpy'
,depth
=None
,recursive
=True
,include
=None
,exclude
=None
,filesOnly
=False
,dirsOnly
=False
)
"."
get_child_items().{children,path}
.transform_color
[source]
transform_color
(arr
,s
=1
,c
=1
,b
=0
,mixing_matrix
=None
)
c = -1
would invert color,keeping everything else same.pp.color_matrix
.interpolate_data
[source]
interpolate_data
(x
,y
,n
=10
,k
=3
)
Parameters
Only axis 0 will be interpolated. If you want general interploation, use from scipy.interpolate import make_interp_spline, BSpline
General Usage: K(p),E(p,q) input from bandstructure.
Knew,Enew= interpolate_data(K,E,n=10,k=3)
. cubic interploationsplit_vasprun
[source]
split_vasprun
(path
=None
)
xml2dict
[source]
xml2dict
(xmlnode_or_filepath
)
Convert xml node or xml file content to dictionary. All output text is in string format, so further processing is required to convert into data types/split etc.
xmlnode_or_filepath
is either a path to an xml file or an xml.etree.ElementTree.Element
object.tag,text,attr,nodes
attributes. Every text element can be accessed via
xml2dict()['nodes'][index]['nodes'][index]...
tree which makes it simple.iplot2html
[source]
iplot2html
(fig
,filename
=None
,out_string
=False
,modebar
=True
)
fig.to_html
as it is minimal in memory. If you need to have offline working file, just use fig.write_html('file.html')
which will be larger in size.plt2html
[source]
plt2html
(plt_fig
=None
,transparent
=True
,dash_html
=None
)
plt2text
[source]
plt2text
(plt_fig
=None
,width
=144
,vscale
=0.96
,colorful
=True
,invert
=False
,crop
=False
,outfile
=None
)
Displays matplotlib figure in terminal as text. You should use a monospcae font like Cascadia Code PL
to display image correctly. Use before plt.show().
Cascadia Code PL
. It is approximately 2*width/height
when you select a single space in terminal.show
[source]
show
(transparent
=False
)
Displays all available figures in browser without blocking terminal
savefig
[source]
savefig
(filename
,dpi
=600
, **kwargs
)
Save matplotlib's figure while handling existing files. kwargs
are passed to plt.savefig
append_axes
[source]
append_axes
(ax
,position
='right'
,size
=0.2
,pad
=0.1
,sharex
=False
,sharey
=False
, **kwargs
)
Append an axes to the given ax
at given position
|top|right|left|bottom|. Useful for adding custom colorbar.
kwargs are passed to mpl_toolkits.axes_grid1.make_axes_locatable.append_axes
.
Returns appended axes.
parse_text
[source]
parse_text
(path
,dtype
=float
,delimiter
='\\s+'
,include
=None
,exclude
='#'
,raw
=False
,fix_format
=True
,start
=0
,nlines
=None
,count
=-1
,new_shape
=None
,cols
=None
,old_shape
=None
,slice_rows
=None
)
exclude, include,start,stop,step
arguments.slice_rows
and old_shape
are given.Note:
start
should count comments ifexclude
is None.
np.size(output_array) = nrows x ncols
, if it is known before execution, performance is increased.\s+
. Could be any kind of delimiter valid in numpy and in the file.slice_data
.cols
.slice_rows
and old_shape
are given. columns should be last entry, like (2,2,3) means 3 columns and two different indexed blocks are there.
Only works if `slice_rows` is given too.
[(0,1),(0,1)] will pick lines at index 0,1,3,4 if first dimension has size 3. It is like N1*i+j for N1=3.
General formula to pick rows is `inner_block_index + inner_block_size*second_block_index + inner_most_size*second_block_size*third_block_index + ...`
`i_1 + N_1*i_2 + N_1*N_2*i_3 + ...` where i_1 is inner most index.
Only works if `old_shape` is given too.
parse_text('path/to/PROCAR',start=3,include='k-point',cols=[3,4,5])[:2]
array([[ 0.125, 0.125, 0.125], [ 0.375, 0.125, 0.125]])parse_text('path/to/EIGENVAL',start=7,exclude='E',cols=[1,2])[:2]
array([[-11.476913, 1. ], [ 0.283532, 1. ]]) Note: Slicing a dimension to 100% of its data is faster than let say 80% for inner dimensions, so if you have to slice more than 50% of an inner dimension, then just load full data and slice after it.
print(parse_text('POSCAR',raw=True))
parse_text('POSCAR',start=8,cols=[0,1,2])
2.46803100000000 1.0000000000000000 0.0000000000000000 0.0000000000000000 -0.4999997974093519 0.8660251836382931 0.0000000000000000 0.0000000000000000 0.0000000000000000 8.1029342824300024 C 2 Selective Dynamics Direct 0.3333330000000000 0.6666670000000000 0.0000000000000000 T T T 0.6666670000000000 0.3333330000000000 0.0000000000000000 F F F
array([[0.333333, 0.666667, 0. ], [0.666667, 0.333333, 0. ]])
class
POSCAR
[source]
POSCAR
(path
=None
,content
=None
,_other_data
=None
)
POSACR class to contain data and related methods
POSCAR.get_bz
[source]
POSCAR.get_bz
(loop
=True
,digits
=8
,primitive
=False
)
coords
,kpoints
and near
in on-one correspondence for high symmetry KPOINTS in recirprocal coordinates space. near
gives indices of nearest special points around a vertex. All vertices with z > 0 are included.POSCAR.set_bz
[source]
POSCAR.set_bz
(primitive
=False
,loop
=True
,digits
=8
)
Set BZ in primitive or regular shape. returns None, just set self._bz
POSCAR.splot_bz
[source]
POSCAR.splot_bz
(ax
=None
,plane
=None
,color
='blue'
,fill
=True
,vectors
=True
,v3
=False
,vname
='b'
,colormap
='plasma'
,light_from
=(1, 1, 1)
,alpha
=0.4
)
vectors=True
.b
for reciprocal space, can set a
for plotting cell as after get_bz(get_bz().basis)
you get real space lattice back if primitive=True
both times.fill=True
. Colormap is applied along z.plane=None
.plane
is given.Tip:
splot_bz(rec_basis,primitive=True)
will plot cell in real space.
POSCAR.splot_kpath
[source]
POSCAR.splot_kpath
(vertex
=0
,knn_inds
=None
,labels
=None
,color
='k'
,line_width
=0.8
,marker_size
=10
,marker_style
='.'
, **labels_kwargs
)
Plot k-path over existing BZ.
self.bz.specials
.knn_inds
.plt.plot
.labels_kwargs are passed to plt.text
.
Tip: You can use this function multiple times to plot multiple/broken paths over same BZ.
POSCAR.iplot_bz
[source]
POSCAR.iplot_bz
(fill
=True
,color
='rgba(168,204,216,0.4)'
,background
='rgb(255,255,255)'
,vname
='b'
,alpha
=0.4
,ortho3d
=True
,fig
=None
)
b
for reciprocal space, can set a
for plotting cell as after get_bz(get_bz().basis)
you get real space lattice back if primitive=True
both times.go.Figure
. If you want to plot on another plotly's figure, provide that.Tip:
iplot_bz(rec_basis,primitive=True)
will plot cell in real space.
POSCAR.splot_lat
[source]
POSCAR.splot_lat
(sizes
=50
,colors
=[]
,colormap
=None
,bond_length
=None
,tol
=0.1
,eps
=0.01
,eqv_sites
=True
,translate
=None
,line_width
=1
,edge_color
=(1, 0.5, 0, 0.4)
,vectors
=True
,v3
=False
,plane
=None
,light_from
=(1, 1, 1)
,fill
=False
,alpha
=0.4
,ax
=None
)
Static plot of lattice.
Tip: Use
plt.style.use('ggplot')
for better 3D perception.
POSCAR.iplot_lat
[source]
POSCAR.iplot_lat
(sizes
=10
,colors
='blue'
,bond_length
=None
,tol
=0.1
,eps
=0.01
,eqv_sites
=True
,translate
=None
,line_width
=4
,edge_color
='black'
,fill
=False
,alpha
=0.4
,ortho3d
=True
,fig
=None
)
Interactive plot of lattice.
POSCAR.write
[source]
POSCAR.write
(sd_list
=None
,outfile
=None
,overwrite
=False
)
Writes poscar data object to a file or returns string
POSCAR.join
[source]
POSCAR.join
(other
,direction
='z'
,tol
=0.01
)
Joins two POSCARs in a given direction. In-plane lattice parameters are kept from poscar1
and basis of other
parallel to direction
is modified while volume is kept same.
POSCAR.scale
[source]
POSCAR.scale
(scale
=(1, 1, 1)
,tol
=0.01
)
Create larger/smaller cell from a given POSCAR.
tol
instead of scale
. You can put a minus sign with tol
to get more sites and plus sign to reduce sites.1 - tol
, as 1 belongs to next cell, not previous one.Tip: scale = (2,2,2) enlarges a cell and next operation of (1/2,1/2,1/2) should bring original cell back.
POSCAR.rotate
[source]
POSCAR.rotate
(angle_deg
,axis_vec
)
Rotate a given POSCAR.
POSCAR.fix_sites
[source]
POSCAR.fix_sites
(tol
=0.01
,eqv_sites
=True
,translate
=None
)
Add equivalent sites to make a full data shape of lattice. Returns same data after fixing.
pos > 1 - tol -> pos - 1
, useful for merging poscars to make slabs.POSCAR.get_kmesh
[source]
POSCAR.get_kmesh
(n_xyz
=[5, 5, 5]
,weight
=None
,ibzkpt
=None
,outfile
=None
)
If outfile = None
, KPOINTS file content is printed.
POSCAR.bring_in_cell
[source]
POSCAR.bring_in_cell
(points
)
Brings atoms's positions inside Cell and returns their R3 coordinates.
import matplotlib.pyplot as plt, pivotpy as pp
poscar = POSCAR('POSCAR')
axs = pp.get_axes(ncols=4,figsize=(8,2))
poscar.splot_cell(ax=axs[0],colormap='hot',color='white').set_axis_off()
poscar.splot_cell(ax=axs[1],plane='xy').set_axis_off()
poscar.splot_bz(ax=axs[2],color='white').set_axis_off()
poscar.splot_bz(ax=axs[3],plane='xy').set_axis_off()
# Next commnad plot path on most recent BZ from line above
poscar.splot_kpath(4,[0,2,4],['$\Gamma$','K','M'],color='r',ha='right',va='bottom')
pos = poscar.bring_in_cell(poscar.data.positions)
axs[1].scatter(pos[:,0],pos[:,1],c='c',s=200)
axs[1].add_text(xs=pos[:,0],ys=pos[:,1],txts=poscar.data.labels,transform=False)
_ = plt.gcf().suptitle('Cell, Cell on XY, BZ, BZ on XY')
class
LOCPOT
[source]
LOCPOT
(path
=None
,e
=True
,m
=False
)
LOCPOT.splot_e
[source]
LOCPOT.splot_e
(operation
='mean_z'
,ax
=None
,period
=None
,lr_pos
=(0.25, 0.75)
,lr_widths
=[0.5, 0.5]
,labels
=('$V(z)$', '$\\langle V \\rangle _{roll}(z)$', '$\\langle V \\rangle $')
,colors
=((0, 0.2, 0.7), 'b', 'r')
,annotate
=True
)
export_potential().basis
.LOCPOT.splot_m
[source]
LOCPOT.splot_m
(operation
='mean_z'
,ax
=None
,period
=None
,lr_pos
=(0.25, 0.75)
,lr_widths
=[0.5, 0.5]
,labels
=('$M(z)$', '$\\langle M \\rangle _{roll}(z)$', '$\\langle M \\rangle $')
,colors
=((0, 0.2, 0.7), 'b', 'r')
,annotate
=True
)
export_potential().basis
.LOCPOT.view_period
[source]
LOCPOT.view_period
(period_guess
=0.25
,operation
='mean_z'
,nslice
=10
,e_or_m
=None
)
view_period()
will try to get data itself from top class in order of self._data.[e,m,m_x,m_y,m_z]
and if self._data.e
exists it never goes to others, so you can overwrite this by setting e_or_m = self._data.[your choice]
.get_axes
[source]
get_axes
(figsize
=(3.4, 2.6)
,nrows
=1
,ncols
=1
,widths
=[]
,heights
=[]
,axes_off
=[]
,axes_3d
=[]
,sharex
=False
,sharey
=False
,azim
=45
,elev
=15
,ortho3d
=True
, **subplots_adjust_kwargs
)
- Returns flatten axes of initialized figure, based on plt.subplots(). If you want to access parent figure, use ax.get_figure() or current figure as plt.gcf().
- **Parameters**
- figsize : Tuple (width, height). Default is (3.4,2.6).
- nrows : Default 1.
- ncols : Default 1.
- widths : List with len(widths)==nrows, to set width ratios of subplots.
- heights : List with len(heights)==ncols, to set height ratios of subplots.
- share(x,y): Share axes between plots, this removes shared ticks automatically.
- axes_off : Turn off axes visibility, If `nrows = ncols = 1, set True/False`, If anyone of `nrows or ncols > 1`, provide list of axes indices to turn off. If both `nrows and ncols > 1`, provide list of tuples (x_index,y_index) of axes.
- axes_3d : Change axes to 3D. If `nrows = ncols = 1, set True/False`, If anyone of `nrows or ncols > 1`, provide list of axes indices to turn off. If both `nrows and ncols > 1`, provide list of tuples (x_index,y_index) of axes.
azim,elev : Matplotlib's 3D angles, defualt are 45,15.
ortho3d : Only works for 3D axes. If True, x,y,z are orthogonal, otherwise perspective.
- **subplots_adjust_kwargs : These are same as `plt.subplots_adjust()`'s arguements.
There are extra methods added to each axes (only 2D) object.
axs = get_axes(nrows=2,ncols=2,widths=[1,2],heights=[1,2],axes_3d=[(1,1)])
axs[0,0].add_text(0.5,0.5,'ax[0,0]')
axs[0,1].add_text(0.5,0.5,'ax[0,1]',colors='blue')
axs[1,0].add_text(0.5,0.5,'ax[1,0]',colors='olive')
axs[1,0].break_spines(['top'])
axs[0,0].break_spines(['bottom'])
axs[0,1].color_wheel(colormap='RGB')
poscar.splot_bz(axs[1,1],colormap='RGB').set_axis_off()
class
Vasprun
[source]
Vasprun
(path
=None
,skipk
=None
,elim
=[]
,shift_kpath
=0
,try_pwsh
=True
,data_str
=None
)
All plotting functions that depend on export_vasprun
are joined under this class and renamed.
Main Parameter
`.json/.pickle` files are also accepted if they are saved previously using `to_json/to_pickle` methods.
`.json` file is useful to load data in other languages.
Optional Parameters (only useful if path is vasprun.xml
file)
Vasp2Visual.Export-Vasprun
command.to_json/to_pickle
methods.Attributes and Methods
.json
file. Useful for transport to other langauges..pickle
file. Useful for fast reload in python.Tip: If KPOINTS file is generated by this module, ticks on kpath are auto-picked.
Vasprun.get_poscar
[source]
Vasprun.get_poscar
()
Returns POSCAR object that can be used for plotting BZ/Lattice etc.
New in 1.1.5
Vasprun.to_json
[source]
Vasprun.to_json
(outfile
=None
,indent
=1
)
Vasprun.to_pickle
[source]
Vasprun.to_pickle
(outfile
=None
)
Vasprun.select
[source]
Vasprun.select
(kpoints_inds
=None
,bands_inds
=None
,kseg_inds
=None
)
Seletc data based on kpoints and bands indices.
This is useful to select only a subset of data and even reorder kpoints after calculations.
Both kpoints_inds
and bands_inds
are based on current data and should be based on zero indexing.
kseg_inds
is index of disconnected kpoints in kpoints_inds
, e.g. in kpoints_inds = [0,5,6,7]
, if 0 and 5 are disconnected, kseg_inds = [1]
.
Returns Vasprun
object with selected data that can be plotted using splot_[...]
or iplot_[...]
functions.
New in version 1.1.4
Vasprun.splot_bands
[source]
Vasprun.splot_bands
(ax
=None
, **kwargs
)
export_vasprun
.Additional kwargs are passed to matplotlib.lines.Lin2D. For passing a keyword to spindown channel, append an underscore, e.g 'lw' goes to SpinUp and 'lw_' goes to SpinDown.
Vasprun.splot_dos_lines
[source]
Vasprun.splot_dos_lines
(elements
=[[0]]
,orbs
=[[0]]
,labels
=['s']
,ax
=None
,query_data
={}
, **kwargs
)
↑
,↓
for ISPIN=2.export_vasprun
.splot_rgb_lines
with 3 projection inputs (len(orbs)==3). Example: {'s':([0,1],[0]),'p':([0,1],[1,2,3]),'d':([0,1],[4,5,6,7,8])} will pick up s,p,d orbitals of first two ions of system.
Vasprun.splot_rgb_lines
[source]
Vasprun.splot_rgb_lines
(elements
=[[], [], []]
,orbs
=[[], [], []]
,labels
=['', '', '']
,ax
=None
,query_data
={}
, **kwargs
)
↑
,↓
for ISPIN=2. If a label is empty i.e. '', it will not show up in colorbar ticks or legend.export_vasprun
.uni_width=True, width=max_width/2
. Default is None and linewidth at any point = 2.5*sum(ions+orbitals projection of all three input at that point). Linewidth is scaled to max_width if an int or float is given.scale_color==True
. 3x3 or 3x4 numpy array or list to transform from RGB to another space,provided that sum(color_matrix[i,:3]) <= 1.
4th column, if given can be used to control the saturation,contrast and brightness as s,c,b = color_matrix[:,3]
For simply changing the color intensity use np.diag([r,g,b]) with r,g,b interval in [0,1].
Try `pivotpy.color_matrix` as suggested color matrix and modify, which at s=0 returns gray scale.!
Example: {'s':([0,1],[0]),'p':([0,1],[1,2,3]),'d':([0,1],[4,5,6,7,8])} will pick up s,p,d orbitals of first two ions of system.
RGB_m
to use in DOS to plot in same colors and RGB_f
to display bands colorbar on another axes.Note: Two figures made by this function could be comapred quantitatively only if
scale_data=False, max_width=None, scale_color=False
as these parameters act internally on data.
Vasprun.splot_color_lines
[source]
Vasprun.splot_color_lines
(elements
=[[0]]
,orbs
=[[0]]
,labels
=['s']
,axes
=None
,query_data
={}
, **kwargs
)
↑
,↓
for ISPIN=2. If a label is empty i.e. '', it will not show up in legend.export_vasprun
. Example: {'s':([0,1],[0]),'p':([0,1],[1,2,3]),'d':([0,1],[4,5,6,7,8])} will pick up s,p,d orbitals of first two ions of system.
Note: Two figures made by this function could be comapred quantitatively only if
scale_data=False, max_width=None
as these parameters act internally on data.
Vasprun.iplot_dos_lines
[source]
Vasprun.iplot_dos_lines
(elements
=[[0]]
,orbs
=[[0]]
,labels
=['s']
,query_data
={}
, **kwargs
)
export_vasprun
.iplot_rgb_lines
with 3 projection inputs (len(orbs)==3). Example: {'s':([0,1],[0]),'p':([0,1],[1,2,3]),'d':([0,1],[4,5,6,7,8])} will pick up s,p,d orbitals of first two ions of system.
Vasprun.iplot_rgb_lines
[source]
Vasprun.iplot_rgb_lines
(elements
=[[], [], []]
,orbs
=[[], [], []]
,labels
=['', '', '']
,query_data
={}
, **kwargs
)
elements
,orbs
and labels
are required to be one-to-one lists of size 3 where each item in list could be another list or integer.Parameters
mode : Three plotting modes are available:
matplotlib LineCollection
object. It plots at each point separately, slower than other two modes.interp_nk : Dictionary with keys 'n' and 'k' for interpolation.
Example: {'s':([0,1],[0]),'p':([0,1],[1,2,3]),'d':([0,1],[4,5,6,7,8])} will pick up s,p,d orbitals of first two ions of system.
Vasprun.get_band_info
[source]
Vasprun.get_band_info
(b_i
,k_i
=None
)
Get band information for given band index b_i
. If k_i
is given, returns info at that point
Fermi energy is subtracted from all energies. When a plot commnad is called, the Fermi energy is updated if provided.
Vasprun.get_en_diff
[source]
Vasprun.get_en_diff
(b1_i
,b2_i
,k1_i
=None
,k2_i
=None
)
Get energy difference between two bands at given two kpoints indices. Index 2 is considered at higher energy.
If k1_i and k2_i are not provided,
min(b2_i) - max(b1_i)
is calculated which is equivalent to band gap.
Returns: Data with follwoing attributes which can be used to annotate the difference on plot. de : energy difference coords : np.array([[k1,e1],[k2,e2]]) #E_Fermi is subtracted either from system or when user provides in a plot command. eqv_coords: list(coords) at equivalent k-points if exit. Do not appear if k1_i and k2_i are provided.
For spin-polarized case, 4 blocks of above data are returned which are accessible by
u1u2, u1d2, d1u2, d1d2
and they collects energy difference between 2 given bands at 2 different spin.
Vasprun.splot_en_diff
[source]
Vasprun.splot_en_diff
(coords
,ax
, **kwargs
)
Plot energy difference at given ax. Provide coords
from output of get_en_diff().coords
or get_en_diff().eqv_coords[i]
if exist.
Provide ax
on which bandstructure is plotted.
E_Fermi is already subtracted in coords
from system or by user input when bandstructure plot commands are run.
kwargs are passed to ax.step
.
Returns ax.
Use Vasprun
class to plot all related figures.
from pivotpy import Vasprun, iplot2html, color_matrix
vr = Vasprun(path='../graphene_example/ISPIN_1/bands/vasprun.xml')
Loading from PowerShell Exported Data...
ax = vr.splot_bands(E_Fermi=0)
delta = vr.get_en_diff(4,6,30,60)
#ax.annotate('',xy=delta.coords[0],xytext=delta.coords[1], arrowprops=dict(arrowstyle='<->',color='g'))
vr.splot_en_diff(delta.coords, ax, color='k',lw=0.5)
ax.add_text(delta.coords[:,0].mean() + 0.2, delta.coords[:,1].mean(), f'$ΔE = {np.round(delta.de,2)}$ eV', colors = 'k',transform=False)
vr.splot_rgb_lines(color_matrix=color_matrix,scale_color=True)
<AxesSubplot:>
iplot2html(vr.iplot_rgb_lines(),modebar=False) #iplot2html is required to show in docs properly
ax1 = vr.splot_dos_lines()
# You can annotate special points using `ax.annotate`
ax1.annotate('Peak to talk about',xy=(9,4),xytext=(-10,3), color='r',arrowprops=dict(arrowstyle='-|>',color='m'))
Text(-10, 3, 'Peak to talk about')