pythtb.TBModel#
- class TBModel(lattice, spinful=False)[source]#
Build, parametrize, and solve tight-binding Hamiltonians.
A tight-binding (TB) model describes single-particle dynamics in a discrete orbital basis (e.g., Wannier functions, atomic-like orbitals) placed on sites of a lattice. The Hamiltonian is specified by on-site and hopping terms between orbitals.
This class supports
Periodic systems (one or more reciprocal-space dimensions),
Finite real-space systems (open boundaries), or
Mixed geometries (some periodic, some open; e.g. ribbons or slabs).
Removed in version 2.0.0: Parameters
dim_randdim_kwere removed. Real- and reciprocal-space dimensions are inferred fromLattice.- Parameters:
- lattice
Lattice Lattice and basis specification. This object defines the lattice vectors, the positions of the localized orbitals (basis functions) within the unit cell, and which lattice directions are treated as periodic. The orbital positions are given in reduced (fractional) coordinates relative to the lattice vectors. The periodic directions are a list of indices into the lattice vectors.
Changed in version 2.0.0: Replaced constructor arguments
dim_k,dim_r,lat,orb, andperwith a singleLatticeargument. Real- and reciprocal-space dimensionalities are inferred from the lattice definition. For example, code that previously usedTBModel(dim_r=2, dim_k=1, lat=..., orb=..., per=[1])should now useTBModel(lattice=Lattice(lat_vecs=..., orb_vecs=..., periodic_dirs=[1])).- spinfulbool, optional
If True, each orbital carries two spin components (spin-1/2), and the Hamiltonian includes a 2x2 matrix structure for each orbital pair. If False, the model is spinless. Default is False.
Changed in version 2.0.0: Renamed from
nspintospinfuland changed type tobool. Instead of specifying the number of spin components (1 or 2), now specify whether the model is spinful (True) or spinless (False).
- lattice
Notes
The lattice geometry (primitive vectors, orbital positions, and periodic directions) is specified through a
Latticeobject. Periodic directions are treated in reciprocal space.Latticealso provides methods for constructing a finite model from a periodic one (e.g. ribbons, slabs, etc.).Both spinless and spinful models are supported; spin-orbit effects may be encoded directly in the hopping matrices.
Beyond constructing and diagonalizing the Hamiltonian, this class provides methods for computing topological and quantum-geometric observables, including:
Quantum geometric tensor (QGT) (in ≥ 2D periodic systems)
Berry curvature and quantum metric (in ≥ 2D periodic systems)
Chern number (in ≥ 2D periodic systems)
Axion angle (in 3D periodic models + 1 varying parameter)
Bianco-Resta local Chern marker (in 2D finite systems)
Hamiltonians may depend on external parameters (e.g. strain, adiabatic parameters), and can be registered by setting onsite or hopping terms with strings or callable functions that take parameter names as keyword arguments. Supply these values as keyword arguments when calling downstream methods and the class will automatically evaluate the Hamiltonian with the specified parameters.
Examples
Create a ribbon-like model: two real-space directions but only one periodic axis. The first lattice vector is
[1, 1/2]and the second is[0, 2]; only the second direction is periodic, so we model a strip that repeats along \(\mathbf{a}_2\). Three orbitals sit at fractional coordinates inside the unit cell.>>> from pythtb import TBModel, Lattice >>> lat = Lattice( ... lat_vecs=[[1, 1/2], [0, 2]], ... orb_vecs=[[0.2, 0.3], [0.1, 0.1], [0.2, 0.2]], ... periodic_dirs=[1], ... ) >>> tb = TBModel(lattice=lat, spinful=False)
Define on-site terms and a few hoppings (home cell hop plus one along the periodic direction):
>>> tb.set_onsite([0.0, 1.0, 0.5]) # onsite energies for all three orbitals >>> tb.set_hop(1.0, 0, 1, [0, 0]) # 0 <-> 1 within home unit cell >>> tb.set_hop(-0.8, 1, 2, [0, 0]) # 1 <-> 2 within home unit cell >>> tb.set_hop(0.3, 2, 0, [0, 1]) # 2 <-> 0 shifted by one cell along periodic axis
Introduce parameters with strings or callables; the parameter names are remembered and must be supplied later:
>>> tb.set_onsite("U", ind_i=0) # onsite energy for orbital 0 is parameter 'U' >>> tb.set_onsite(lambda U: np.cos(U), ind_i=2) # onsite energy for orbital 2 is parameter 'U' >>> tb.set_hop(lambda t: t**2, 1, 2, [0, 0]) # hopping from orbital 1 to 2 is parameter 't'
Evaluate the Bloch Hamiltonian at a range of reduced momenta for specific parameter values:
>>> H = tb.hamiltonian(k_pts=np.linspace(0,1,10), return_eigvecs=True, U=0.4, t=0.7) >>> H.shape (10, 3, 3)
Diagonalize the Bloch Hamiltonian for a range of momenta and parameter values,
>>> U_vals = np.linspace(0, 2*np.pi, 11) >>> t_vals = np.linspace(0, 1, 12) >>> evals, evecs = tb.solve_ham(k_pts=np.linspace(0,1,10), return_eigvecs=True, U=U_vals, t=t_vals) >>> evals.shape (10, 11, 12, 3) >>> evecs.shape (10, 11, 12, 3, 3)
This pattern of setting parameters by name and supplying their values extends to all other methods that depend on the Hamiltonian, such as Berry curvature, quantum metric, etc.
Methods#
Adds a new orbital to the model with the specified coordinates. |
|
Axion angle change via the second Chern form. |
|
Compute the Berry curvature in energy eigenbasis via Kubo formula. |
|
Change non-periodic lattice vector |
|
Compute the Chern number on the specified plane. |
|
Remove all hopping terms from the model. |
|
Reset all on-site energies to zero. |
|
Return a deep copy of the model. |
|
Cut a (d-1)-dimensional piece out of a d-dimensional tight-binding model. |
|
Return lattice vectors in Cartesian coordinates. |
|
Return orbital positions. |
|
Generate the Bloch Hamiltonian of the tight-binding model. |
|
Print or return a textual report describing the model. |
|
Interpolates a path in reciprocal space. |
|
Generate a uniform grid of k-points in reduced (fractional) coordinates. |
|
Bianco-Resta local Chern marker. |
|
Returns a finite model. |
|
Make model on a super-cell. |
|
Enumerate nearest-neighbor shells of the lattice. |
|
Plot the band structure along a specified path in k-space. |
|
Returns diagonal matrix elements of the position operator. |
|
Eigenvalues and eigenvectors of the position operator |
|
Position operator matrix elements |
|
Quantum geometric tensor at a list of k-points via Kubo formula. |
|
Quantum metric in the energy eigenbasis computed via Kubo formula. |
|
Removes specified orbitals from the model. |
|
Define hopping amplitudes between tight-binding orbitals. |
|
Define on-site energies for tight-binding orbitals. |
|
Materialize parameterized on-site and hopping terms at fixed scalar values. |
|
Set hopping amplitudes for entire nearest-neighbor shells. |
|
Diagonalize the tight-binding Hamiltonian. |
|
Generate the velocity operator in the orbital basis. |
|
Visualizes the tight-binding model geometry. |
|
Visualize a 3D tight-binding model using |
|
Create a new TBModel instance with parameter-dependent terms evaluated at the supplied scalar values. |
Attributes#
Whether the position operator is assumed to be diagonal in the orbital basis. |
|
Volume of the real-space unit cell in Cartesian units. |
|
Dimensionality of reciprocal space (number of periodic directions). |
|
Dimensionality of real space. |
|
Whether the model was constructed from |
|
Hopping terms defined in the model. |
|
Lattice vectors in Cartesian coordinates. |
|
The |
|
Number of hoppings defined in the model. |
|
Number of tight-binding orbitals per unit cell. |
|
Number of spin components (1 for spinless, 2 for spinful). |
|
Total number of electronic states ( |
|
On-site energies for each orbital. |
|
Orbital positions in reduced coordinates. |
|
Parameter providers registered on on‑site and hopping terms. |
|
Periodic directions as indices into the lattice vectors. |
|
Reciprocal lattice vectors in inverse Cartesian units. |
|
Volume of the reciprocal unit cell in inverse Cartesian units. |
|
Whether the model includes spin degrees of freedom. |