This collection of tools is designed to analyze and visualize data from first-principles electronic structure calculations. It includes features such as plotting band structures, converting atomic structures, analyzing the density of states (DOS), and preparing inputs for calculations. Various commonly used calculation packages are supported.
Clone the repository and use it as is. The Python scripts are written in Python 3. For convenience, you may add the src directory to your PATH. To install the required dependencies, use the provided requirements.txt file:
pip install -r requirements.txt
In newer versions of Linux that enforce PEP 668, the system's Python environment is treated as externally managed. This prevents using pip
to install packages directly into the system environment to avoid conflicts with the package manager. To install Python packages independently, create a virtual environment:
sudo apt install python3.12-venv
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Alternatively, if you prefer to install the required packages directly into the system's Python environment without using pip
, you can use your package manager, such as apt
:
sudo apt install python3-matplotlib python3-numpy python3-scipy python3-yaml
Script: bands.py
For basic band structure plotting, use:
python3 bands.py package (E1) (E2)
- If both
E1
andE2
are provided, the energy range is [E1, E2] (in eV). - If only
E1
is provided, the energy range is [-E1, E1] (in eV). - If neither is provided, the energy range is [-5 eV, 5 eV].
Supported formats: VASP, QE, PARSEC
VASP inputs: EIGENVAL, KPOINTS, POSCAR, (DOSCAR)
QE inputs: *.xml, kpath.in
PARSEC inputs: bands.dat, parsec.in, kpath.in
To plot projected band structures:
python3 bands.py package atoms orbitals (E1) (E2)
Supported formats: VASP (vaspproj), QE (qeproj)
VASP inputs: EIGENVAL, KPOINTS, POSCAR, PROCAR, (DOSCAR)
QE inputs: *.xml, kpath.in, projwfc.out
To plot band structures from Wannier90:
python3 bands.py wan (pad=*) (E1) (E2)
Inputs: nscf.in, ../bands/*.xml, *_band.kpt, *_band.dat, kpath.in
Script: posconvert.py
To convert the format of the atomic structure:
python3 posconvert.py package1 package2 (filename1)
Supported formats: VASP, QE (.in or .xml), Paratec, PARSEC, .xyz
VASP input: POSCAR
QE input: nscf.in/scf.in/relax.in
QExml input: *.xml
Paratec input: input
PARSEC input: parsec.in
.xyz input: *.xyz
Optional input: posconvert.in
If the optional input file posconvert.in exists, this code modifies the structure before output. The supported operations include move, rotate, flip, vacuum, supercell, add atom, or delete atom. An example of posconvert.in can be found in data/inputs directory.
Scripts: kconvert.py
To convert the format of the k-point path:
python3 kconvert.py package1 package2 (N)
Supported formats: VASP, QE, kpath.in
VASP input: KPOINTS
Examples of the kpath.in file can be found in the data/kpaths directory.
A common use of this code is to create the k-point path for QE band structure calculations:
python3 kconvert.py kpathin qe (N)
Script: dos.py
To plot DOS:
python3 dos.py (v) package (E1) (E2)
v
indicates plot verticallyE1
andE2
define the energy range, as described in the band structure section
Supported formats: VASP, QE
VASP input: DOSCAR
QE input: *.dos
To plot projected DOS:
python3 dos.py (v) package atoms orbitals (E1) (E2)
Support format: QE (qeproj)
QE inputs: *.dos *.xml *.pdos_atm#*(*)_wfc#*(*)
Script: toten_fit.py
This script prints the total energy vs. distortion coordinate.
Inputs: POSCAR_i, pos_*/OSZICAR, pos_*/POSCAR, (pos_*/EIGENVAL)
Script: phproj.py
This script calculates distortion projection onto phonon modes and uses it as the weight to average the frequency.
Inputs: qpoints.yaml, POSCAR_i, POSCAR_f
Script: wavecar.py
This script reads the KS orbitals from the WAVECAR, and writes into separate files for the VESTA plot:
python3 wavecar.py ik ib ispin
Input: WAVECAR, POSCAR
Scripts: silicon.py, sidef.py
silicon.py creates the atomic structure of silicon nanocrystals, given the radius in angstrom:
python3 silicon.py radius
sidef.py prints information of atoms in a silicon nanocrystal:
python3 sidef.py filename
Script: hbndef.py
This script generates h-BN monolayer or flake structures with or without a defect. To create a 2D h-BN structure, use the following command:
python3 hbndef.py N (defect)
For an h-BN flake, use:
python3 hbndef.py flake r (defect)
N
is the supercell size.r
is the radius of the h-BN flake.defect
specifies the defect, such as CBVN. Ensure atomic symbols are correctly capitalized.
Scripts: afm.py, afm.sh, afmplot.py
afm.py and afm.sh prepare the files and job directories for the AFM simulation. The Python code can be used to prepare the structure files by
python3 afm.py (vasp)
Inputs: afm.in, tip.xyz, sample.parsec_st.dat, (*_POTRE.DAT)
Outputs: parsec_st_*_*.dat, (parsec_st_spot.dat,) manual_*_*.dat, steps.dat
An example of afm.in can be found in the data/inputs directory. If fdet
is set in afm.in, parsec_st_spot.dat will be generated, and the pseudopotential files *_POTRE.DAT will be read to calculate Nb. Add spin
in afm.in to enable spin polarization in the simulations. Add vasp
at the command line to write an example structure (tip + sample) in VASP format.
The Bash script can be used to create directories and prepare files by
afm.sh seq
Inputs: afm.in, job.sh, parsec.in.head, parsec_st_*_*.dat, (parsec_st_spot.dat,) manual_*_*.dat, steps.dat
Outputs: seq_*_*, (spot,) */parsec.in, */job.sh, sbatch.log
If the fdet
option is set, enter the spot directory and submit the job manually before iteratively submitting all other jobs. If fdet
is not set, use the following command to submit the jobs:
afm.sh sbatch
After all the calculations are done, use the Python script afmplot.py to make the plots:
python3 afmplot.py (iz) (atom) (tilt) (bohr) (verbose) (toten)
Inputs: afm.in, steps.dat, (toten.dat or seq_*_*/parsec.out)
Outputs: afm_*.png, (toten.dat)
In the first round, this code reads the total energies from seq_*_*/parsec.out files and writes to toten.dat. After that, the toten.dat will be read.
iz
represents the index of layers to be calculated. For the simple scenario of computing 3 z values for the tip, iz
should be set to 2 as default. Add the atom
option to display the atom positions. Only the top layer within 1 Å is plotted. Add the tilt
option to use the tilt correction. Add the bohr
option to use the Bohr as the length unit.
An iterative tilt correction method is used in this code, which solves the lateral shift by niter
and the damping factor alpha
in the input file afm.in
. The conventional method uses a single-shot approximation niter 1
and alpha 1
in the input.