--- title: User API keywords: fastai sidebar: home_sidebar nb_path: "MainAPI.ipynb" ---
{% raw %}
{% endraw %} {% raw %}

  Index 
  XmlElementTree 
  StaticPlots 
  InteractivePlots 
  Utilities 
  StructureIO 
  Widgets 
  MainAPI● 

{% endraw %} {% raw %}
{% endraw %} {% raw %}
{% endraw %} {% raw %}

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.

  • Parameters
    • formula: chemical formula of the material.
    • mp_id: Materials project id of material.
    • max_sites: maximum number of sites in structure to download.
    • min_sites: minimum number of sites in structure to download.

      max_sites and min_sites are used to filter the number of sites in structure, or use mp_id to download a specific structure.

  • One Time API Key
    • api_key: API key from Materials project websit, if you use save_key=True, never required again.
    • save_key: Save API key to file. You can save any time of key or device changed.
  • Return
    • structure: Structure data containing attributes poscars and cifs as list.
            Each item in list has attributes `content` and `write` to write to file.
{% endraw %} {% raw %}
{% endraw %} {% raw %}
{% endraw %} {% raw %}

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.

  • Parameters
    • hsk_list : N x 3 list of N high symmetry points, if broken path then [[N x 3],[M x 3],...].
            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]]`.
    • n : int, number per unit length, this makes uniform steps based on distance between points.
    • weight : Float, if None, auto generates weights.
    • ibzkpt : Path to ibzkpt file, required for HSE calculations.
    • labels : Hight symmetry points labels. Good for keeping record of lables and points indices for later use.
            > Note: If you do not want to label a point, label it as 'skip' at its index and it will be removed.
    • outfile: Path/to/file to write kpoints.

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

    • kpath_str: str, a multiline string similiar to line mode of KPOINTS, initial 4 lines are not required.
      • If you do not want to label a point, label it as 'skip' and it will be removed.
      • You can add an interger at end of a line to customize number of points in a given patch.
      • Each empty line breaks the path, so similar points before and after empty line are useless here.
    • n : int, number per unit length, this makes uniform steps based on distance between points.
    • weight : Float, if None, auto generates weights.
    • ibzkpt : Path to ibzkpt file, required for HSE calculations.
    • outfile: Path/to/file to write kpoints.
  • 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.

  • Parameters
    • X, Y, Z : 1D arrays of coordinates of arrows' tail point.
    • U, V, W : 1D arrays of dx,dy,dz of arrows.
    • ax: 3D axes, if not given, auto created.
    • C : 1D colors array mapping for arrows. Could be one color.
    • L : 1D linwidths array mapping for arrows. Could be one linewidth.
    • mutation_scale: Arrow head width/size scale. Default is 10.
    • kwargs: FancyArrowPatch's keyword arguments excluding positions,color, lw and mutation_scale, shrinkA, shrinkB which are already used. An important keyword argument is 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.

  • Usage Example
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.

  • Usage

    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.iplot[source]

KPathApp.iplot()

Returns disconnected current plotly figure

KPathApp.get_kpath[source]

KPathApp.get_kpath(n=5, weight=None, ibzkpt=None, outfile=None)

See Docs of pp.str2kpath for details.

set_dir[source]

set_dir(path)

work in some directory and come back

get_child_items[source]

get_child_items(path='E:\\Research\\pivotpy', depth=None, recursive=True, include=None, exclude=None, filesOnly=False, dirsOnly=False)

  • Returns selected directories/files recursively from a parent directory.
  • Parameters
    • path : path to a parent directory, default is "."
    • depth : int, subdirectories depth to get recursively, default is None to list all down.
    • recursive : If False, only list current directory items, if True,list all items recursively down the file system.
    • include: Default is None and includes everything. String of patterns separated by | to keep, could be a regular expression.
    • exclude: Default is None and removes nothing. String of patterns separated by | to drop,could be a regular expression.
    • filesOnly : Boolean, if True, returns only files.
    • dirsOnly : Boolean, if True, returns only directories.
  • Returns
    • GLOB : Tuple (children,parent), children is list of selected directories/files and parent is given path. Access by index of by get_child_items().{children,path}.

transform_color[source]

transform_color(arr, s=1, c=1, b=0, mixing_matrix=None)

  • Color transformation such as brightness, contrast, saturation and mixing of an input color array. c = -1 would invert color,keeping everything else same.
  • Parameters
    • arr: input array, a single RGB/RGBA color or an array with inner most dimension equal to 3 or 4. e.g. [[[0,1,0,1],[0,0,1,1]]].
    • c : contrast, default is 1. Can be a float in [-1,1].
    • s : saturation, default is 1. Can be a float in [-1,1]. If s = 0, you get a gray scale image.
    • b : brightness, default is 0. Can be a float in [-1,1] or list of three brightnesses for RGB components.
    • mixing_matrix: A 3x3 matrix to mix RGB values, such as pp.color_matrix.

Recoloring Rainmeter

interpolate_data[source]

interpolate_data(x, y, n=10, k=3)

  • Returns interpolated xnew,ynew. If two points are same, it will add 0.1*min(dx>0) to compensate it.
  • Parameters

    • x: 1D array of size p,
    • y: ndarray of size pqr,....
    • n: Number of points to add between two given points.
    • k: Polynomial order to interpolate.
  • 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 interploation

split_vasprun[source]

split_vasprun(path=None)

  • Splits a given vasprun.xml file into a smaller _vasprun.xml file plus _set[1,2,3,4].txt files which contain projected data for each spin set.
  • Parameters
    • path: path/to/vasprun.xml file.
  • Output
    • _vasprun.xml file with projected data.
    • _set1.txt for projected data of colinear calculation.
    • _set1.txt for spin up data and _set2.txt for spin-polarized case.
    • _set[1,2,3,4].txt for each spin set of non-colinear calculations.

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.

  • The only paramenter xmlnode_or_filepath is either a path to an xml file or an xml.etree.ElementTree.Element object.
  • Each node has 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)

  • Writes plotly's figure as HTML file or display in IPython which is accessible when online. It is different than plotly's 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.
  • Parameters
    • fig : A plotly's figure object.
    • filename : Name of file to save fig. Defualt is None and show plot in Colab/Online or return hrml string.
    • out_string: If True, returns HTML string, if False displays graph if possible.

plt2html[source]

plt2html(plt_fig=None, transparent=True, dash_html=None)

  • Returns base64 encoded Image to display in notebook or HTML or plotly's dash_html_components.Img object.
  • Parameters
    • plt_fig : Matplotlib's figure instance, auto picks as well.
    • transparent: True of False for fig background.
    • dash_html : Default is None which results in an image display in jupyter notebook.
      • If True, returns html.Img object for plotly's dash.
      • If False, returns object to embed in HTML DOM.

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().

  • Parameters
    • plt_fig: Matplotlib's figure instance. Auto picks if not given.
    • width : Character width in terminal, default is 144. Decrease font size when width increased.
    • vscale : Useful to tweek aspect ratio. Default is 0.96 and prints actual aspect in Cascadia Code PL. It is approximately 2*width/height when you select a single space in terminal.
    • colorful: Default is False, prints colored picture if terminal supports it, e.g Windows Terminal.
    • invert : Defult is False, could be useful for grayscale image.
    • crop : Default is False. Crops extra background, can change image color if top left pixel is not in background, in that case set this to False.
    • outfile: If None, prints to screen. Writes on a file.

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.

{% endraw %} {% raw %}

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)

  • Reads a sliced array from txt,csv type files and return to array. Also manages if columns lengths are not equal and return 1D array. It is faster than loading whole file into memory. This single function could be used to parse EIGENVAL, PROCAR, DOCAR and similar files with just a combination of exclude, include,start,stop,step arguments.
  • Parameters
    • path: Path/to/file to be parsed.
    • dtype: float by default. Data type of output array, it is must have argument.
    • start,nlines: The indices of lines to start reading from and number of lines after start respectively. Both could be None or int, while start could be a list to read slices from file provided that nlines is int. The spacing between adjacent indices in start should be equal to or greater than nlines as pointer in file do not go back on its own. These parameters are not required if slice_rows and old_shape are given.

      Note: start should count comments if exclude is None.

    • count: np.size(output_array) = nrows x ncols, if it is known before execution, performance is increased.
    • delimiter: Default is \s+. Could be any kind of delimiter valid in numpy and in the file.
    • cols: List of indices of columns to pick. Useful when reading a file like PROCAR which e.g. has text and numbers inline. This parameter is in output of slice_data.
    • include: Default is None and includes everything. String of patterns separated by | to keep, could be a regular expression.
    • exclude: Default is '#' to remove comments. String of patterns separated by | to drop,could be a regular expression.
    • raw : Default is False, if True, returns list of raw strings. Useful to select cols.
    • fix_format: Default is True, it sepearates numbers with poor formatting like 1.000-2.000 to 1.000 2.000 which is useful in PROCAR. Keep it False if want to read string literally.
    • new_shape : Tuple of shape Default is None. Will try to reshape in this shape, if fails fallbacks to 2D or 1D. Not required if slice_rows and old_shape are given.
    • old_shape: It is required when you need to pick blocks of data from rows.
        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.
    • slice_rows: It is required when you need to pick blocks of data from rows.
        [(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.
  • Examples

    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.

{% endraw %} {% raw %}
{% endraw %} {% raw %}
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.      ]])
{% endraw %} {% raw %}

class POSCAR[source]

POSCAR(path=None, content=None, _other_data=None)

POSACR class to contain data and related methods

{% endraw %} {% raw %}
{% endraw %} {% raw %}

POSCAR.get_bz[source]

POSCAR.get_bz(loop=True, digits=8, primitive=False)

  • Return required information to construct first Brillouin zone in form of tuple (basis, normals, vertices, faces).
  • Parameters
    • loop : If True, joins the last vertex of a BZ plane to starting vertex in order to complete loop.
    • digits : int, rounding off decimal places, no effect on intermediate calculations, just for pretty final results.
    • primitive: Defualt is False and returns Wigner-Seitz cell, If True returns parallelipiped in rec_basis.
  • Attributes
    • basis : get_bz().basis, recprocal lattice basis.
    • normals : get_bz().normals, all vertors that are perpendicular BZ faces/planes.
    • vertices: get_bz().vertices, all vertices of BZ, could be input into ConvexHull for constructing 3D BZ.
    • faces : get_bz().faces, vertices arranged into faces, could be input to Poly3DCollection of matplotlib for creating BZ from faces' patches.
    • specials : get_bz().specials, Data with attributes 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.get_cell[source]

POSCAR.get_cell(loop=True, digits=8)

See docs of get_bz, same except space is inverted.

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)

  • Plots matplotlib's static figure.
  • Parameters
    • fill : True by defult, determines whether to fill surface of BZ or not.
    • color : color to fill surface and stroke color.
    • vectors : Plots basis vectors, default is True.
    • v3 : Plots 3rd vector as well. Only works in 2D and when vectors=True.
    • plane : Default is None and plots 3D surface. Can take 'xy','yz','zx' to plot in 2D.
    • ax : Auto generated by default, 2D/3D axes, auto converts in 3D on demand as well.
    • vname : Default is 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.
    • colormap : If None, single color is applied, only works in 3D and fill=True. Colormap is applied along z.
    • light_from: Point from where light is thrown on BZ planes, default is (1,1,1). Only works on plane in 3D.
    • alpha : Opacity of filling in range [0,1]. Increase for clear viewpoint.
  • Returns
    • ax : Matplotlib's 2D axes if plane=None.
    • ax3d : Matplotlib's 2D axes if 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.

  • Parameters
    • vertex: vertex index nearby which to plot path. There are as many vertices as there are in BZ's shape.
    • knn_inds: list of indices of k nearest points e.g. [2,3,1] will trace path linking as 2-3-1. 0 is Gamma point and 1 is the selected vertex itself. Points are taken internally from BZ, you can see from self.bz.specials.
    • labels: list of labels for each k-point in same order as knn_inds.
    • color, line_width, marker_size, marker_style are passed to 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.splot_cell[source]

POSCAR.splot_cell(ax=None, plane=None, color='blue', fill=True, vectors=True, v3=False, vname='a', colormap='plasma', light_from=(1, 1, 1), alpha=0.4)

See docs of splot_bz, everything is same except space is inverted.

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)

  • Plots interactive figure showing axes,BZ surface, special points and basis, each of which could be hidden or shown.
  • Parameters
    • fill : True by defult, determines whether to fill surface of BZ or not.
    • color : color to fill surface 'rgba(168,204,216,0.4)` by default.
    • background : Plot background color, default is 'rgb(255,255,255)'.
    • vname : Default is 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.
    • alpha : Opacity of BZ planes.
    • ortho3d : Default is True, decides whether x,y,z are orthogonal or perspective.
    • fig : (Optional) Plotly's go.Figure. If you want to plot on another plotly's figure, provide that.
  • Returns
    • fig : plotly.graph_object's Figure instance.

Tip: iplot_bz(rec_basis,primitive=True) will plot cell in real space.

POSCAR.iplot_cell[source]

POSCAR.iplot_cell(fill=True, color='rgba(168,204,216,0.4)', background='rgb(255,255,255)', vname='a', alpha=0.4, ortho3d=True, fig=None)

See docs of iplot_bz, everything is same except space is iverted.

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.

  • Main Parameters
    • sizes : Size of sites. Either one int/float or list equal to type of ions.
    • bond_length: Length of bond in fractional unit [0,1]. It is scaled to V^1/3 and auto calculated if not provides.
    • colors: List of colos. If given, preffered over colormap, should have same length as type of ions. Other parameters just mean what they seem to be.

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.

  • Main Parameters
    • sizes : Size of sites. Either one int/float or list equal to type of ions.
    • colors : Colors of sites. Either one colors or list equal to type of ions.
    • bond_length: Length of bond in fractional unit [0,1]. It is scaled to V^1/3 and auto calculated if not provides. Other parameters just mean what they seem to be.

POSCAR.write[source]

POSCAR.write(sd_list=None, outfile=None, overwrite=False)

Writes poscar data object to a file or returns string

  • Parameters
    • sd_list : A list ['T T T','F F F',...] strings to turn on selective dynamics at required sites. len(sd_list)==len(sites) should hold.
    • outfile : str,file path to write on.
    • overwrite: bool, if file already exists, overwrite=True changes it.

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.

  • Parameters
    • direction: The joining direction. It is general and can join in any direction along basis. Expect one of ['a','b','c','x','y','z'].
    • tol: Default is 0.01. It is used to bring sites near 1 to near zero in order to complete sites in plane. Vasp relaxation could move a point, say at 0.00100 to 0.99800 which is not useful while merging sites.

POSCAR.scale[source]

POSCAR.scale(scale=(1, 1, 1), tol=0.01)

Create larger/smaller cell from a given POSCAR.

  • Parameters
    • scale: Tuple of three values along (a,b,c) vectors. int or float values. If number of sites are not as expected in output, tweak tol instead of scale. You can put a minus sign with tol to get more sites and plus sign to reduce sites.
    • tol: It is used such that site positions are blow 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.

  • Parameters
    • angle_deg: Rotation angle in degrees.
    • axis_vec : (x,y,z) of axis about which rotation takes place. Axis passes through origin.

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.

  • Parameters
    • tol : Tolerance value. Default is 0.01.
    • eqv_sites: If True, add sites on edges and faces. If False, just fix coordinates, i.e. pos > 1 - tol -> pos - 1, useful for merging poscars to make slabs.
    • translate: A number(+/-) or list of three numbers to translate in x,y,z directions.

POSCAR.get_kmesh[source]

POSCAR.get_kmesh(n_xyz=[5, 5, 5], weight=None, ibzkpt=None, outfile=None)

  • Generates uniform mesh of kpoints. Options are write to file, or return KPOINTS list.
  • Parameters
    • n_xyz : List of [nx ny nz] or integer. If integer given, it represents numbers of kpoints along smallest side in reciprocal space and kmesh is autoscaled.
    • weight : Float, if None, auto generates weights.
    • ibzkpt : Path to ibzkpt file, required for HSE calculations.
    • outfile: Path/to/file to write kpoints.

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.

POSCAR.bring_in_bz[source]

POSCAR.bring_in_bz(kpoints)

Brings KPOINTS inside BZ. Applies to_R3 only if primitive=True.

  • Parameters
    • kpoints : List or array of KPOINTS to transorm into BZ or R3.
    • primitive: Default is False and brings kpoints into regular BZ. If True, returns to_R3().
{% endraw %} {% raw %}
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')
2022-04-24T13:54:43.110009 image/svg+xml Matplotlib v3.3.3, https://matplotlib.org/
{% endraw %} {% raw %}

class LOCPOT[source]

LOCPOT(path=None, e=True, m=False)

{% endraw %} {% raw %}
{% endraw %} {% raw %}

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)

  • Returns tuple(ax,Data) where Data contains resultatnt parameters of averaged potential of LOCPOT.
  • Parameters
    • basis : export_potential().basis.
    • operation: Default is 'mean_z'. What to do with provided volumetric potential data. Anyone of these 'mean_x','min_x','max_x','mean_y','min_y','max_y','mean_z','min_z','max_z'.
    • ax: Matplotlib axes, if not given auto picks.
    • period: Periodicity of potential in fraction between 0 and 1. For example if a slab is made of 4 super cells in z-direction, period=0.25.
    • lr_pos: Locations around which averages are taken.Default (0.25,0.75). Provide in fraction between 0 and 1. Center of period is located at these given fractions. Work only if period is given.
    • lr_widths: Default is [0.5,0.5], you may have slabs which have different lengths on left and right side. Provide a pair proportional to widths e.g (1,1), (1,1.1) etc. and it is auto normalized to 1. Works only if period is given.
    • labels: List of three labels for legend. Use plt.legend() or pp.add_legend() for labels to appear. First entry is data plot, second is its convolution and third is complete average.
    • colors: List of three colors for lines.
    • annotate: True by default, writes difference of right and left averages on plot.

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)

  • Returns tuple(ax,Data) where Data contains resultatnt parameters of averaged potential of LOCPOT.
  • Parameters
    • basis : export_potential().basis.
    • operation: Default is 'mean_z'. What to do with provided volumetric potential data. Anyone of these 'mean_x','min_x','max_x','mean_y','min_y','max_y','mean_z','min_z','max_z'.
    • ax: Matplotlib axes, if not given auto picks.
    • period: Periodicity of potential in fraction between 0 and 1. For example if a slab is made of 4 super cells in z-direction, period=0.25.
    • lr_pos: Locations around which averages are taken.Default (0.25,0.75). Provide in fraction between 0 and 1. Center of period is located at these given fractions. Work only if period is given.
    • lr_widths: Default is [0.5,0.5], you may have slabs which have different lengths on left and right side. Provide a pair proportional to widths e.g (1,1), (1,1.1) etc. and it is auto normalized to 1. Works only if period is given.
    • labels: List of three labels for legend. Use plt.legend() or pp.add_legend() for labels to appear. First entry is data plot, second is its convolution and third is complete average.
    • colors: List of three colors for lines.
    • annotate: True by default, writes difference of right and left averages on plot.

LOCPOT.view_period[source]

LOCPOT.view_period(period_guess=0.25, operation='mean_z', nslice=10, e_or_m=None)

  • Periodicity check by plotly's interactive plot.
  • Parameters
    • period_guess: Initial guess of period. Default is 0.25. Should be in [0,1].
    • operation : Any of ['mean_x','min_x','max_x','mean_y','min_y','max_y','mean_z','min_z','max_z'].
    • nslice : Default is 10. Number of periods around and including period_guess. e.g. If you give 0.25 as period_guess and nslice is 10, you will get 10 lines of rolling average over given data from where you can choose best fit or try another guess and so on.
    • e_or_m : None by default. Not required in most cases as 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].
{% endraw %} {% raw %}

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.

  • add_text
  • add_legend
  • add_colorbar
  • color_wheel
  • break_spines
  • modify_axes
  • append_axes
{% endraw %} {% raw %}
{% endraw %} {% raw %}
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()
2022-04-24T13:54:43.841262 image/svg+xml Matplotlib v3.3.3, https://matplotlib.org/
{% endraw %} {% raw %}

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

    • path: str: path/to/vasprun.xml. Auto picks in CWD.
        `.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)

    • skipk : int: Skip initial kpoints.
    • elim : list: Energy range e.g. [-5,5].
    • shift_kpath: float: Shift in kpath values for side by side plotting.
    • try_pwsh : bool: True by default, tries to load data exported using Powershell's Vasp2Visual.Export-Vasprun command.
    • data_str : json/pickle: Data in json/pickle format saved from to_json/to_pickle methods.
  • Attributes and Methods

    • data : Exported data from given file. This has it's own attributes as well to save as json/pickle etc.
    • to_json : Saves data in .json file. Useful for transport to other langauges.
    • to_pickle : Saves data in .pickle file. Useful for fast reload in python.
    • splot[...] : Plots data using `sp.splot[...]` functions.
    • iplot[...] : Plots data using `sp.iplot[...]` functions.

Tip: If KPOINTS file is generated by this module, ticks on kpath are auto-picked.

{% endraw %} {% raw %}
{% endraw %} {% raw %}

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)

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.

Returns Vasprun object with selected data that can be plotted using splot_[...] or iplot_[...] functions.

New in version 1.1.3

Vasprun.splot_bands[source]

Vasprun.splot_bands(ax=None, **kwargs)

  • Returns axes object and plot on which all matplotlib allowed actions could be performed.
  • Parameters
    • ax : Matplotlib axes object, if not given, one is created.
    • skipk : Number of kpoints to skip, default will be from IBZKPT.
    • kseg_inds : Points where kpath is broken.
    • elim : [min,max] of energy range.
    • E_Fermi : If not given, automatically picked from export_vasprun.
    • ktick_inds : High symmetry kpoints indices.abs
    • ktick_vals : High Symmetry kpoints labels.
    • txt,xytxt and ctxt are extra arguments for text on figure.
    • interp_nk : Dictionary with keys 'n' and 'k' for interpolation.

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.

  • Returns
    • ax : matplotlib axes object with plotted bands.

Vasprun.splot_dos_lines[source]

Vasprun.splot_dos_lines(elements=[[0]], orbs=[[0]], labels=['s'], ax=None, query_data={}, **kwargs)

  • Returns ax object (if ax!=False) and plot on which all matplotlib allowed actions could be performed, returns lists of energy,tdos and pdos and labels. If given,elements,orbs colors, and labels must have same length. If not given, zeroth ions is plotted with s-orbital.
  • Parameters)
    • elements : List [[0],], by defualt and plot first ion's projections.
    • orbs : List [[0],] lists of indices of orbitals, could be empty.
    • labels : List [str,] of orbitals labels. len(labels)==len(orbs) must hold. Auto adds , for ISPIN=2.
    • ax : Matplotlib axes object, if None, one is created. If False, data lists are returned.
    • include_dos: One of {'both','tdos','pdos'}.
    • elim : [min,max] of energy range.
    • E_Fermi : If not given, automatically picked from export_vasprun.
    • colormap : Matplotlib's standard color maps. Default is 'gist_ranibow'. Use 'RGB' if want to compare with splot_rgb_lines with 3 projection inputs (len(orbs)==3).
    • fill_area : Default is True and plots filled area for dos. If False, plots lines only.
    • vertical : False, If True, plots along y-axis.
    • showlegend : True by defualt.
    • spin : Plot spin-polarized for spin {'up','down','both'}. Default is both.
    • interp_nk : Dictionary with keys 'n' and 'k' for interpolation.
    • legend_kwargs: Dictionary to contain legend arguments to fix.
    • query_data : Dictionary with keys as label and values as list of length 2. If given, used in place of elements, orbs and labels arguments.
            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.
  • Returns
    • ax : Matplotlib axes.

Vasprun.splot_rgb_lines[source]

Vasprun.splot_rgb_lines(elements=[[], [], []], orbs=[[], [], []], labels=['', '', ''], ax=None, query_data={}, **kwargs)

  • Returns axes object and plot on which all matplotlib allowed actions could be performed. In this function,orbs,labels,elements all have list of length 3. Inside list, sublists or strings could be any length but should be there even if empty.
  • Parameters
    • elements : List [[],[],[]] by default and plots s,p,d orbital of system..
    • orbs : List [[r],[g],[b]] of indices of orbitals, could be empty, but shape should be same.
    • labels : List [str,str,str] of projection labels. empty string should exist to maintain shape. Auto adds , for ISPIN=2. If a label is empty i.e. '', it will not show up in colorbar ticks or legend.
    • ax : Matplotlib axes object, if not given, one is created.
    • skipk : Number of kpoints to skip, default will be from IBZKPT.
    • kseg_inds : Points where kpath is broken.
    • elim : [min,max] of energy range.
    • E_Fermi : If not given, automatically picked from export_vasprun.
    • ktick_inds : High symmetry kpoints indices.abs
    • ktick_vals : High Symmetry kpoints labels.
    • max_width : Width to scale whole projections. if 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.
    • txt : Text on figure, if None, SYSTEM's name is printed.
    • xytxt : [x_coord,y_coord] of text relative to axes.
    • ctxt : color of text.
    • uni_width : If True, width of bands kept uniform.
    • spin : Plot spin-polarized for spin {'up','down','both'}. Default is both.
    • interp_nk : Dictionary with keys 'n' and 'k' for interpolation.
    • scale_color: Boolean. Default True, colors are scaled to 1 at each point. If False, clips colors in range [0,1] but does not effect linewidth.
    • scale_data : Default is True and normalizes projection data to 1. Has no visual effect if scale_color = True too.
    • colorbar : Default is True. Displays a vertical RGB colorbar.
    • color_matrix: Only works if 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.!
    • query_data : Dictionary with keys as label and values as list of length 2. Should be <= 3 for RGB plots. If given, used in place of elements, orbs and labels arguments.
                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.
  • Returns
    • ax : matplotlib axes object with plotted projected bands.
    • Registers as colormap 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)

  • Returns axes object and plot on which all matplotlib allowed actions could be performed. If given, elements, orbs, and labels must have same length. If not given, zeroth ion is plotted with s-orbital.
  • Parameters
    • elements : List [[0],], by defualt and plot first ion's projections.
    • orbs : List [[0],] lists of indices of orbitals, could be empty.
    • labels : List [str,] of orbitals labels. len(labels)==len(orbs) must hold. Auto adds , for ISPIN=2. If a label is empty i.e. '', it will not show up in legend.
    • axes : Matplotlib axes object with one or many axes, if not given, auto created.
    • skipk : Number of kpoints to skip, default will be from IBZKPT.
    • kseg_inds : Points where kpath is broken.
    • elim : [min,max] of energy range.
    • E_Fermi : If not given, automatically picked from export_vasprun.
    • ktick_inds : High symmetry kpoints indices.abs
    • ktick_vals : High Symmetry kpoints labels.
    • colormap : Matplotlib's standard color maps. Default is 'gist_ranibow'.
    • showlegend : True by defualt and displays legend relative to axes[0]. If False, it writes text on individual ax.
    • scale_data : Default is False, If True, normalize projection data to 1.
    • max_width : Width to scale whole projections. Default is None and linewidth at any point on a line = 2.5*sum(ions+orbitals projection of the input for that line at that point). Linewidth is scaled to max_width if an int or float is given.
    • xytxt : [x_coord,y_coord] of labels relative to axes. Works if showlegend = False.
    • ctxt : color of text of labels
    • spin : Plot spin-polarized for spin {'up','down','both'}. Default is both.
    • interp_nk : Dictionary with keys 'n' and 'k' for interpolation.
    • legend_kwargs: Dictionary containing legend arguments.
    • query_data : Dictionary with keys as label and values as list of length 2. If given, used in place of elements, orbs and labels arguments.
                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.
    • **subplots_adjust_kwargs : plt.subplots_adjust parameters.
  • Returns
    • axes : matplotlib axes object [one or list of axes] with plotted projected bands.

      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)

  • Returns plotly's figure. If given,elements,orbs colors, and labels must have same length. If not given, zeroth ions is plotted with s-orbital.
  • Parameters)
    • elements : List [[0,],] of ions indices, by defualt plot first ion's projections.
    • orbs : List [[0,],] lists of indices of orbitals, could be empty.
    • labels : List [str,] of orbitals labels. len(labels) == len(orbs) must hold.
    • elim : [min,max] of energy range.
    • E_Fermi : If not given, automatically picked from export_vasprun.
    • colormap : Matplotlib's standard color maps. Default is 'gist_ranibow'. Use 'RGB' if want to compare with iplot_rgb_lines with 3 projection inputs (len(orbs)==3).
    • fill_area : Default is True and plots filled area for dos. If False, plots lines only.
    • vertical : False, If True, plots along y-axis.
    • interp_nk : Dictionary with keys 'n' and 'k' for interpolation.
    • figsize : Tuple(width,height) in pixels, e.g. (700,400).
    • query_data : Dictionary with keys as label and values as list of length 2. If given, used in place of elements, orbs and labels arguments.
            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.
  • Returns
    • fig : Plotly's figure object.

Vasprun.iplot_rgb_lines[source]

Vasprun.iplot_rgb_lines(elements=[[], [], []], orbs=[[], [], []], labels=['', '', ''], query_data={}, **kwargs)

  • Returns plotly's figure object, takes care of spin-polarized calculations automatically. 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
    • elements : List of size 3 of list of indices of ions. If not given, picks all ions for each orbital.
    • orbs : List of size 3 of list of orbital indices, if not gievn, s,p,d plotted.
    • labels : List of labels for projection.
    • mode : Three plotting modes are available:
      • 'markers' : Plot whole data as a single scatter object. Its too fast.
      • 'bands' : Plot data such that each band is accessible via legend.
      • 'lines' : A replica of matplotlib LineCollection object. It plots at each point separately, slower than other two modes.
      • interp_nk : Dictionary with keys 'n' and 'k' for interpolation.
      • figsize : Tuple(width,height) in pixels, e.g. (700,400).
      • query_data : Dictionary with keys as label and values as list of length 2. len(query_data) <=3 should hold for RGB plots. If given, used in place of elements, orbs and labels arguments.
              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.
    • Other Parameters
      • ktick_inds, ktick_vals,elim,kseg_inds,max_width,title etc.

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.

  • b1_i, b2_i : band indices of the two bands, minimum energy difference is calculated.
  • k1_i, k2_i : k-point indices of the two bands.

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.

{% endraw %}

Examples

Use Vasprun class to plot all related figures.

{% raw %}
from pivotpy import Vasprun, iplot2html, color_matrix
vr = Vasprun(path='../graphene_example/ISPIN_1/bands/vasprun.xml')
Loading from PowerShell Exported Data...
{% endraw %} {% raw %}
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)
2022-04-24T13:54:44.760034 image/svg+xml Matplotlib v3.3.3, https://matplotlib.org/
{% endraw %} {% raw %}
vr.splot_rgb_lines(color_matrix=color_matrix,scale_color=True)
<AxesSubplot:>
2022-04-24T13:54:44.947537 image/svg+xml Matplotlib v3.3.3, https://matplotlib.org/
{% endraw %} {% raw %}
iplot2html(vr.iplot_rgb_lines(),modebar=False) #iplot2html is required to show in docs properly
{% endraw %} {% raw %}
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')
2022-04-24T13:54:45.651772 image/svg+xml Matplotlib v3.3.3, https://matplotlib.org/
{% endraw %} {% raw %}

  Index 
  XmlElementTree 
  StaticPlots 
  InteractivePlots 
  Utilities 
  StructureIO 
  Widgets 
  MainAPI● 

{% endraw %}