Python Tight Binding (PythTB)#

PythTB is a Python library for constructing and analyzing tight-binding models, built for modern topological band theory applications. It provides a streamlined path from model specification to physical interpretation, making it useful for both learning electronic structure and conducting research-level studies. With only a few lines of code, you can define lattice models, build tight-binding Hamiltonians, and compute electronic properties.

PythTB 2.0.0 Released!

Release Notes
Changelog

Quick Links

  • GitHub - source code and issue tracker

  • Installation - install instructions and dependencies

  • API - detailed API reference

  • Tutorials - Jupyter notebooks demonstrating key features

  • Development - contributing guidelines and developer docs

  • Release Notes - discussion of new features by version

  • Changelog - list of changes by version

  • Formalism - theoretical background

  • Citation - how to cite PythTB in publications

Core functionality#

Model construction

Define and manipulate tight-binding Hamiltonians using TBModel. Specify on-site terms, hoppings, spin structure, and parameter-dependent contributions.

pythtb.TBModel
State sampling

Build structured k-space and parameter meshes with Mesh. Sample Hamiltonians and store resulting states defined on the Mesh in WFArray for further analysis.

pythtb.WFArray
Topology & quantum geometry

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.

PythTB API Reference
Wannier90 Integration

Import Wannier90 tight-binding Hamiltonians via W90 for post-processing and topological/quantum-geometric analysis.

pythtb.W90
Wannier workflows

Construct maximally localized Wannier functions with Wannier from a WFArray. Perform projections, disentanglement, evaluate spreads, and analyze centers and localization properties.

pythtb.Wannier
Visualization

Plot band structures, density of states, lattice geometries, hopping graphs, and interactive 3D models with built-in visualization utilities.

PythTB API Reference

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()
_images/graphene_lattice.png

Graphene lattice#

_images/graphene_bands.png

Graphene band structure#

Feedback#

Please send comments or suggestions for improvement to these email addresses. If you find bugs, please report them on the GitHub Issues page.