.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\05-other\plot_kpath_generation.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_05-other_plot_kpath_generation.py: .. _ref_example_kpath_generator: Example of kpath_generator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In order to plot a band structure, one must define a set of :math:`k`-points following a desired :math:`k`-path in momentum space. PyProcar's :math:`k`-path generation utility enables a the user to automatically generate a suitable and sufficient :math:`k`-path given the crystal structure, typically read from the POSCAR file (VASP). .. code-block:: :caption: General Format pyprocar.kpath(infile, outfile, grid-size, with-time-reversal, recipe, threshold, symprec, angle-tolerance,supercell_matrix) First download the example files with the code below. Then replace data_dir below. .. code-block:: :caption: Downloading example data_dir = pyprocar.download_example(save_dir='', material='Fe', code='vasp', spin_calc_type='non-spin-polarized', calc_type='bands') This information is automatically written to a KPOINTS file. The retrieved :math:`k`-path can be used for other DFT codes with slight modifications. More details regarding these parameters can be found in the `SeeK-path manual `_. The :math:`k`-path generation utility within PyProcar is based on the Python library **seekpath** developed by Hinuma et al:: Y. Hinuma, G. Pizzi, Y. Kumagai, F. Oba, I. Tanaka, Band structure diagram paths based on crystallography, Computational Materials Science 128 (2017) 140–184.doi:10.1016/j.commatsci.2016.10.015. .. GENERATED FROM PYTHON SOURCE LINES 39-41 .. code-block:: Python # sphinx_gallery_thumbnail_number = 1 .. GENERATED FROM PYTHON SOURCE LINES 42-44 Plotting K Path +++++++++++++++++++++++++++++++++++++++ .. GENERATED FROM PYTHON SOURCE LINES 44-48 .. code-block:: Python import pyvista # You do not need this. This is to ensure an image is rendered off screen when generating exmaple gallery. pyvista.OFF_SCREEN = True .. GENERATED FROM PYTHON SOURCE LINES 49-50 importing pyprocar and specifying local data_dir .. GENERATED FROM PYTHON SOURCE LINES 50-87 .. code-block:: Python import os import numpy as np import pyprocar data_dir = f"{pyprocar.utils.ROOT}{os.sep}data{os.sep}examples{os.sep}Fe{os.sep}vasp{os.sep}spin-polarized-colinear{os.sep}bands" poscar = f"{data_dir}{os.sep}POSCAR" k_path, k_labels = pyprocar.kpath(poscar,'KPOINTS',40,True,'hpkot',1e-07,1e-05,-1.0,np.eye(3)) # Getting unique points for plotting unique_labels = [] unique_kpath= [] for i,k_label in enumerate(k_labels): if k_label not in unique_labels: unique_labels.append(k_label) unique_kpath.append(k_path[i]) plotter=pyvista.Plotter() # plotting connecting lines for ik,points in enumerate(k_path): if ik == len(k_path) - 1: plotter.add_lines(np.array([k_path[ik-1],k_path[ik]]), color='red', width = 10) else: plotter.add_lines(np.array([k_path[ik],k_path[ik+1]]), color='red', width = 10 ) # plotting points and labels plotter.add_point_labels(unique_kpath, unique_labels, point_color = 'blue', text_color='blue', render_points_as_spheres=True, point_size=20, font_size=36, always_visible=True) plotter.show_axes() plotter.show_grid() plotter.view_yz() plotter.show() .. image-sg:: /examples/05-other/images/sphx_glr_plot_kpath_generation_001.png :alt: plot kpath generation :srcset: /examples/05-other/images/sphx_glr_plot_kpath_generation_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none ____ ____ | _ \ _ _| _ \ _ __ ___ ___ __ _ _ __ | |_) | | | | |_) | '__/ _ \ / __/ _` | '__| | __/| |_| | __/| | | (_) | (_| (_| | | |_| \__, |_| |_| \___/ \___\__,_|_| |___/ A Python library for electronic structure pre/post-processing. Version 6.2.0 created on Jun 10th, 2021 Please cite: Uthpala Herath, Pedram Tavadze, Xu He, Eric Bousquet, Sobhit Singh, Francisco Muñoz and Aldo Romero., PyProcar: A Python library for electronic structure pre/post-processing., Computer Physics Communications 251 (2020):107080. Developers: - Francisco Muñoz - Aldo Romero - Sobhit Singh - Uthpala Herath - Pedram Tavadze - Eric Bousquet - Xu He - Reese Boucher - Logan Lang - Freddy Farah .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.480 seconds) .. _sphx_glr_download_examples_05-other_plot_kpath_generation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_kpath_generation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_kpath_generation.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_