Metadata-Version: 2.4
Name: bandplot
Version: 0.2.0
Summary: Band structure, DOS or phonon band structure plot from VASP, vaspkit or phonopy results.
Author: Kan
License-Expression: MIT
Project-URL: Homepage, https://github.com/lkccrr/bandplot
Keywords: DFT,VASP,DOS,band,plot,Phonon
Platform: Unix
Platform: Windows
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.22.0
Requires-Dist: matplotlib>=3.6.0
Dynamic: license-file

[![bandplot](https://img.shields.io/pypi/v/bandplot?style=flat-square)](https://pypi.org/project/bandplot/)
[![bandplot](https://img.shields.io/pypi/pyversions/bandplot?style=flat-square)](https://pypi.org/project/bandplot/)
[![bandplot](https://img.shields.io/pypi/l/bandplot?style=flat-square)](https://pypi.org/project/bandplot/)
[![bandplot](https://img.shields.io/pypi/dm/bandplot?style=flat-square)](https://pypi.org/project/bandplot/)
[![bandplot](https://img.shields.io/pypi/wheel/bandplot?style=flat-square)](https://pypi.org/project/bandplot/)
[![bandplot](https://img.shields.io/github/last-commit/lkccrr/bandplot?style=flat-square)](https://github.com/lkccrr/bandplot)
[![bandplot](https://img.shields.io/github/release-date/lkccrr/bandplot?style=flat-square)](https://github.com/lkccrr/bandplot)

### bandplot

The <b style="color:green;"><i>bandplot</b></i> is used for electron band structure, DOS or phonon band structure, DOS plotting from ***VASP***, ***vaspkit*** or ***phonopy*** results. The code will provide two scripts, <b style="color:blue;"><i>bandplot</b></i> for band structure or DOS plotting, either directly from the ***VASP*** output files or from ***vaspkit*** <b style="color:darkred;"><i>\*.dat</b></i> files, and <b style="color:blue;"><i>pbandplot</b></i> for phonon band structure or DOS plotting from ***phonopy*** <b style="color:darkred;"><i>\*.dat</b></i> files.

* Install (packaged with `pyproject.toml`, Python &ge; 3.9):
```bash
pip install bandplot          # from PyPI
pip install -e .              # development install from this directory
python -m build               # build sdist + wheel into dist/
```
***
<b style="color:blue;"><i>bandplot</b></i> — VASP output is the default data source, `vaspkit` is optional
* `-i` takes a directory (default: the current directory). The directory is scanned automatically: VASP output (`EIGENVAL` / `DOSCAR` / `PROCAR`) is preferred, otherwise `BAND.dat` / `PBAND*.dat` / `PDOS*.dat` are used.
* `-i` alone plots the band structure; `-d` alone plots the DOS; `-i` together with `-d` plots the band structure and the DOS side by side.
```bash
cd your_calc_dir
bandplot                                     # band structure of the current directory
bandplot -i calc_PBE -l g m k g              # given directory, VASP or .dat auto-detected
bandplot -i calc_PBE -d -z                   # bands + DOS (DOSCAR or PDOS*.dat)
bandplot -d                                  # DOS only
bandplot -i calc_PBE -r -p Mo-d              # projected bands from PROCAR
bandplot -i calc_PBE -b -d                   # spin polarized: up/down panels + spin resolved DOS
bandplot -i calc_PBE -m 0.15                 # effective masses from EIGENVAL
bandplot -i calc_PBE calc_HSE                # compare two or three directories
bandplot -i BAND.dat -d PDOS*.dat            # vaspkit .dat route, unchanged
bandplot --vasp calc_PBE                     # legacy spelling of -i
bandplot -i calc_PBE --no-shift              # keep absolute energies
bandplot -i calc_PBE --export-dat dat        # also dump vaspkit-style .dat files
bandplot -i calc_PBE -d --no-mirror          # keep spin-down DOS positive
```
* Compared with an older release, `bandplot --vasp DIR` still works but is just an alias of `-i DIR`; a bare `bandplot` no longer insists on `BAND.dat` in the current directory.
* Spin resolved DOS is drawn as a mirror plot: spin-up on the positive axis, spin-down on the negative axis. The curve is flipped whenever its label contains `up`/`down` (also `dw`, `_DW`, `$dw$`), so the same rule applies to the DOSCAR route and to `-d PDOS_*_UP.dat PDOS_*_DW.dat`; use `--no-mirror` to keep both positive. When `-x` gives a one sided DOS range, it is expanded symmetrically so that both spin channels stay visible.
* Files used (all optional except one data source):

| File | Used for | Note |
|---|---|---|
| `EIGENVAL` | eigenvalues, k-points, occupations | required for bands / effective mass |
| `PROCAR` | projected bands | needs `LORBIT = 11` |
| `DOSCAR` | total and partial DOS | needs `LORBIT = 11` |
| `OUTCAR` | `E-fermi`, `ISPIN`, element names | Fermi level fallback: `DOSCAR` |
| `KPOINTS` | high-symmetry labels (line mode) | `KLABELS` in the same directory takes priority |
| `POSCAR` / `CONTCAR` | lattice, elements, formula legend | `POSCAR-unitcell` also accepted |

* Energies are shifted so that the Fermi level is 0 eV; use `--no-shift` to keep the raw values.
* k-path distances are computed from the `EIGENVAL` k-points and the reciprocal lattice (units of 1/Å), so no `KLABELS` file is needed.
* The `.dat` reader is untouched: the old workflow `bandplot -i BAND.dat -j KLABELS` still works, and `--export-dat` can generate those files from VASP output for reuse.
***
<b style="color:blue;"><i>pbandplot</b></i>
* To execute <b style="color:blue;"><i>pbandplot</b></i> <b style="color:red;"><i>\-h</b></i> for the parameters to use.
* Example:
```bash
pbandplot -h
pbandplot -i BAND.dat -o BAND.png -l g m k g -d projected_dos.dat -z
pbandplot -b 23 100 -l g m k g -y -2 110
pbandplot -i BAND1.dat BAND2.dat -b 20 100
```

