PythTB API Reference#

Core Classes#

PythTB centers on a small set of core classes for constructing and analyzing tight-binding models. This page highlights what each component is for and links to the API reference in the tables below.

  • pythtb.TBModel Tight-binding Hamiltonians on arbitrary lattices. Use it to set hoppings, sweep parameters, compute spectra, and evaluate derived quantities such as Berry curvature, quantum geometric tensors, axion angles, or local Chern markers.

  • pythtb.WFArray Mesh-aware wavefunction storage. Solve a model across \((k, \lambda)\) grids, then evaluate Wilson loops, Berry phases, Chern numbers, and other objects with consistent periodic boundary conditions.

  • pythtb.W90 Interface with Wannier90 and export a Wannierized tight-binding model in the form of a TBModel.

Added in version 2.0.0: The classes below were introduced in PythTB version 2.0.0.

  • pythtb.Mesh Describes combined crystal momentum and parameter meshes, \((k, \lambda)\). Can construct uniform grids, paths, and meshes defined on a custom set of points. Encodes boundary conditions (loops, endpoints, adiabatic cycles) for WFArray to apply appropriate gauge conditions downstream.

  • pythtb.Lattice Holds real- and reciprocal-space geometry, orbital positions, and nearest-neighbor shells. Every model and wavefunction array references the same lattice instance to ensure consistent coordinates.

  • pythtb.Wannier Build Wannier gauges directly inside PythTB from a WFArray, perform projections, disentanglement and maximal localization, and analyze spreads and centers.

TBModel(lattice[, spinful])

Build, parametrize, and solve tight-binding Hamiltonians.

WFArray(lattice, mesh[, nstates, spinful])

Wavefunction container defined on a sampling mesh.

Lattice(lat_vecs, orb_vecs[, periodic_dirs])

Store lattice and orbital information.

Mesh(axis_types[, axis_names, dim_k])

Store and manage a mesh in \((k, \lambda)\)-space.

W90(path, prefix)

Interface to Wannier90

Wannier(bloch_states)

Construct Wannier functions through the projection method.

Predefined Models#

PythTB also provides a collection of predefined tight-binding models. Import and use these models using the following syntax:

from pythtb.models import haldane, graphene, ssh

models

Collection of tight-binding models.

I/O Utilities#

PythTB ships with lightweight readers for importing data from external software packages such as Wannier90 and Quantum ESPRESSO.

io.w90

IO utilities for Wannier90 output files.

io.qe

IO utilities for Quantum ESPRESSO output files.