Python Tight Binding (PythTB)#
PythTB is a pure-Python toolbox for building and analyzing tight-binding models. With a few lines of code, you can define lattices, assign hopping parameters, diagonalize the Hamiltonians on custom meshes, plot band structures, and evaluate quantum-geometry objects such as Berry phases, curvatures, and Chern numbers. The package also reads Wannier90 output so you can work directly with Wannierized models coming from first-principles calculations.
Quick Links
Installation - install instructions and dependencies
API - detailed API reference
Tutorials - Jupyter notebooks demonstrating key features
Development - contributing guidelines and developer docs
Release Notes - detailed version history
Changelog - summary of changes by version
Formalism - theoretical background
Citation - how to cite PythTB in publications
Core functionality#
Define and manipulate tight-binding Hamiltonians using TBModel.
Specify on-site terms, hoppings, spin structure, and
parameter-dependent contributions.
Build structured k-space and parameter meshes with Mesh.
Sample Hamiltonians and store resulting states defined on the Mesh
in WFArray for further analysis.
Compute Berry phases, connections, and curvature; Chern numbers;
the axion angle; local Chern markers; hybrid Wannier
functions; and other quantum-geometric observables using
WFArray and TBModel methods.
Import Wannier90 tight-binding Hamiltonians via W90
for post-processing and topological/quantum-geometric analysis.
Construct maximally localized Wannier functions with Wannier
from a WFArray. Perform projections, disentanglement,
evaluate spreads, and analyze centers and localization properties.
Plot band structures, density of states, lattice geometries, hopping graphs, and interactive 3D models with built-in visualization utilities.
Get started with PythTB#
This is a simple example showing how to define graphene tight-binding model with first neighbour hopping only. Below is the source code and plot of the resulting band structure. Here you can find more examples.
from pythtb.models import graphene
import matplotlib.pyplot as plt
# Create graphene TB model and visualize
model = graphene(delta=0, t=-1)
fig, ax = model.visualize()
plt.show()
# Plot band structure along high-symmetry points
nodes = [[0, 0], [2 / 3, 1 / 3], [1 / 2, 1 / 2], [0, 0]]
label = (r"$\Gamma $", r"$K$", r"$M$", r"$\Gamma $")
fig, ax = model.plot_bands(k_nodes=nodes, k_node_labels=label, nk=200)
plt.show()
Feedback#
Please send comments or suggestions for improvement to these email addresses. If you find bugs, please report them on the GitHub Issues page.