From ESL
Jump to navigation Jump to search

{{#if: Luis Agapito

esl-entry = Luis Agapito |

Source authors:
Luis Agapito
esl-entry = Luis Agapito

}}{{#if: LGPL |

License: LGPL

}}{{#if: PyTB v0.1 ,PyTB v2.0beta |

Download: PyTB v0.1 ,PyTB v2.0beta

}}{{#if: |

Documentation: {{{documentation}}}

}}{{#if: |

Links to other ESL entries

| {{#if: |

Links to other ESL entries

| {{#if: |

Links to other ESL entries

| {{#if: |

Links to other ESL entries

|{{#if: |

Links to other ESL entries

| {{#if: |

Links to other ESL entries

|}}}}}}}}}}}}{{#if: |



}}{{#if: |



}}{{#if: |

Generic interfaces:

    {{{generic interfaces}}}

}}{{#if: |



}}{{#if: |

Data standards:

    {{{data standards}}}

}}{{#if: |




PyTB: Ab-initio Tight-Binding Hamiltonians

A collection of Python routines to build accurate tight-binding Hamiltonians from ab-initio plane-wave DFT calculations. It currently supports Quantum Espresso.

  • Builds the Hamiltonian and Overlap matrix in reciprocal space (per k-point)
  • Builds the real-space Hamiltonian and Overlap matrices (per lattice vector, New v2.0beta )
  • Postprocessing options
    • Interpolated bandstructures ( New v2.0beta )
    • Electron transport (interfaces to the ASE package, in progress)


PyTB implements the construction of tight-binding Hamiltonians following each Bloch wave method described here [1].

Software description for version 0.1


  • Quantum Espresso
  • Python
  • Numpy
  • Scipy (optional)
  • matplotlib (optional)

Usage: test1

1. Run the DFT calculations.

  • A self-consistent ( run.
  • A non-selfconsistent ( run at the desired kpoints.
  • The input files are in ./PyTB/docs/test1/
cd ./PyTB/docs/test1/

#Download the required pseudopotential file

#Run the following sequence
echo Running the DFT scf calculation ...
mpirun -np 4 $QE/bin/pw.x < > scf.out
echo Running the DFT non-scf calculation ...
mpirun -np 4 $QE/bin/pw.x < > bands.out
echo Projecting the wavefunctions onto atomic orbitals ...
mpirun -np 4 $QE/bin/projwfc.x < > proj.out
  • projwfc.x generates the projection data in xml format in the directory (./PyTB/docs/test1/{atomic_proj.xml,data-file.xml}). Next, those files are parsed by PyTB.

2. Build the ab-initio Hamiltonian and Overlap matrices

from __future__ import print_function
from scipy import linalg
import numpy as np
import sys
import re
import PyTB_lib as hmat

Ry2eV      = 13.60569193

fpath      = './PyTB/docs/test1/'
read_S     = False #no need to read the Overlap for this example
nbnds_norm = 8
shift_type = 1
shift      = 10 #eV
bnd        = 8

U, my_eigsmat, alat, a_vectors, \
nkpnts, nspin, kpnts, kpnts_wght, \
nbnds, Efermi, nawf =  hmat.read_QE_output_xml(fpath,read_S)

# Building the TB Hamiltonian in orthonormal basis
Hks_ortho = hmat.build_Hks(nawf,bnd,nbnds,nbnds_norm,nkpnts,nspin,shift,my_eigsmat,shift_type,U)

# Plot the TB and DFT eigevalues. Writes to comparison.pdf

3. Compare the eigenvalues from the plane-wave calculation and the TB Hamiltonian



  1. Luis A. Agapito, Andrea Ferretti, Arrigo Calzolari, Stefano Curtarolo, and Marco Buongiorno Nardelli, Effective and accurate representation of extended Bloch states on finite Hilbert spaces, Phys. Rev. B 88, 16512 (2013). DOI: 10.1103/PhysRevX.5.011006