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

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.