{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n\n# Plotting Atomic Levels\n\nThis example illustrates how to plot atomic energy levels for the compound hBN-CNCN at the GAMMA point using the `pyprocar` package.\n\n## Preparation\nBefore diving into plotting, we need to download the example files. Use the following code to do this. Once downloaded, specify the `data_dir` to point to the location of the downloaded data.\n\n.. code-block::\n   :caption: Downloading example\n\n    import pyprocar\n\n    data_dir = pyprocar.download_example(\n                                save_dir='', \n                                material='hBN-CNN',\n                                code='vasp', \n                                spin_calc_type='spin-polarized-colinear',\n                                calc_type='gamma'\n                               )\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Setting up the environment\nFirst, we will import the necessary libraries and set up our data directory path.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import os\n\nimport pyprocar\n\n# Define the directory containing the example data\ndata_dir = os.path.join(pyprocar.utils.DATA_DIR, \"examples\", \"hBN-CNCN\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Plotting in Atomic Mode\nThe atomic mode is used to plot the energy levels at a specific k-point. In this example, we focus on the GAMMA point.\nThe plot will display energy levels for specific atoms in the range of -6 to 6 eV.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# Define the atom indices we're interested in\natoms = [96, 97, 0, 1, 2, 3, 42, 44]\n\n# Plot the atomic bands\npyprocar.bandsplot(\n    code=\"vasp\",  # Specify the DFT code used. In this case, it's VASP.\n    dirname=data_dir,\n    mode=\"atomic\",\n    elimit=[-6, 6],  # Energy range for the plot\n    clim=[-0.4, 0.4],  # Color limit for the plot\n    atoms=atoms,  # Atoms for which we want to plot the energy levels\n)"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.9.20"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}