Changelog#
All notable changes to this project will be documented in this file. The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[Unreleased]#
[2.0.0] - 2025-11-??#
Fixed#
Fixed bug in
TBModel._shift_to_home()where only the last orbital was shifted. This affected theto_homeflag inchange_nonperiodic_vector()andmake_supercell().
Improved#
Vectorized code throughout using NumPy for substantial speed improvements
TBModelinitialization, Hamiltonian construction, and diagonalization orders of magnitude faster for large modelsW90.model()construction from Wannier90 data significantly faster, allowing practical use with large first-principles models
Type hints added throughout the codebase for improved developer experience and IDE support
Modernized Sphinx-based documentation website, copying over the previous tutorials, and adding some new ones to cover new features
TBModel.visualize(): Enhanced 2D Visualization
Changed#
Restructured from single
pythtb.pyfile to organizedpythtb/package with separate purpose-specific modules:tbmodel.py: Tight-binding model class and methodswfarray.py: Wavefunction array class for storing and manipulating quantum statesw90.py: Wannier90 interfaceetc.
Migrated from
setup.pyto modernpyproject.tomlconfiguration as per PEP 518
Breaking Changes
Updated class and method names to follow PEP 8 conventions:
tb_model->TBModelwf_array->WFArrayw90->W90
TBModelInitialization ChangesReplaced
dim_r,dim_k,lat,orb, andperparameters with a singleLatticeinstanceReplaced
nspinparameter withspinfulboolean flag
TBModel.solve_ham()(replacessolve_one()andsolve_all())Changed eigenvalue/eigenvector indexing for vectorized workflows
Eigenvalues: shape
(nk, nstate)(matrix elements last for NumPy compatibility)Eigenvectors for spinless (
nspin=1): shape(nk, nstate, nstate)Eigenvectors for spinful (
nspin=2): shape(nk, nstate, norb, 2)
TBModel.position_expectation()parameter renamingRenamed parameter
evectoevecsfor clarityRenamed parameter
dirtopos_dirto avoid conflict with built-in Python functiondir()
TBModel.position_matrix()parameter renamingRenamed parameter
evectoevecsfor clarityRenamed parameter
dirtopos_dirto avoid conflict with built-in Python functiondir()
TBModel.position_hwf()parameter renamingRenamed parameter
evectoevecsfor clarityRenamed parameter
dirtopos_dirto avoid conflict with built-in Python functiondir()
WFArrayInitialization Changes:Replaced
mesh_arrparameter with aMeshinstanceReplaced
modelparameter with aLatticeinstanceRenamed
nsta_arrparameter to integernstatesfor clarity
WFArray.berry_phase()parameter renamingdirrenamed toaxis_idxto avoid conflict with Python built-indir()occrenamed tostate_idxto emphasize that band indices need not be occupiedRemoved
"all"option; useNone(default) to include all states
WFArray.berry_flux()parameter renamingdirsrenamed toplanenow only accepts 2-element tuples defining planesoccrenamed tostate_idxto emphasize that band indices need not be occupied
WFArray.position_matrix()parameter renamingdirrenamed topos_dirto avoid conflict with built-in Python functiondir()occrenamed tostate_idxto emphasize that states need not be occupiedRemoved
"all"option; useNone(default) to include all states
WFArray.position_expectation()parameter renamingdirrenamed topos_dirto avoid conflict with built-in Python functiondir()occrenamed tostate_idxto emphasize that states need not be occupiedRemoved
"all"option; useNone(default) to include all states
WFArray.position_hwf()parameter renames:dirrenamed topos_dirto avoid conflict with built-in Python functiondir()occrenamed tostate_idxto emphasize that states need not be occupiedRemoved
"all"option; useNone(default) to include all states
WFArray.choose_states()parameter rename:subsetrenamed tostate_idxsfor clarity and consistency
WFArray.empty_like()parameter rename:nsta_arrrenamed tonstatesfor clarity and consistency
W90.w90_bands_consistency()(deprecated and renamed tobands_w90())Returned energy array shape changed from
(band, kpts)to(kpts, band)Now consistent with eigenvalue shape from
TBModel.solve_ham()Aligns with NumPy convention of putting k-points in first axis
Added#
Published
pythtbpackage to conda-forge for easy installation viaconda install -c conda-forge pythtbOptional TensorFlow backend for linear algebra acceleration on compatible hardware (GPUs/TPUs) in
TBModelandWFArrayEnable by passing
use_tensorflow=Trueon some methods
Comprehensive unit tests added using
pytestto cover core functionalityNew examples and tutorials added to documentation website covering new features and workflows
New classes
Latticeclass that handles lattice geometry and reciprocal operations.Encapsulates lattice manipulation methods previously embedded in
TBModelUsed by
TBModelandWFArray
Meshclass that defines structured grids in k-space or parameter space.Supports arbitrary dimensions and mixed \((k, \lambda)\) meshes
Includes
Axishelper class for labeled mesh axesUsed by
WFArrayfor consistent data mapping
Wannierclass for constructing and analyzing Wannier functions fromWFArrayProjection onto trial orbitals
Iterative maximal localization/disentanglement
Visualization of centers, decay profiles, and spreads
New modules
pythtb.models: collection of common tight-binding modelsthat are importable using, e.g.,pythtb.io.w90: Wannier90 file parsing utilitiesread_hr(),read_centres()etc. for standalone Wannier90 file parsingSupports loading a full Wannier90 dataset for downstream
W90->TBModelprocessing
pythtb.io.qe: Quantum ESPRESSO file parsing utilitiesread_bands_qe()for readingprefix_bands.outbands.xoutput files
New features to pre-existing classes
TBModelmethods:TBModel.__str__: Allows printing aTBModelinstance usingprint(TBModel), which printsTBModel.info()TBModel.info(): Replacesdisplay()for printing model summaryTBModel.get_lat_vecs(): Replacesget_lat()for clarityTBModel.get_orb_vecs(): Replacesget_orb()for clarityAdded boolean flag
cartesianto return orbital vectors in Cartesian coordinates (defaultFalse)
TBModel.solve_ham(): Diagonalizes Hamiltonian and returns eigenvalues and optionally eigenvectorsReplaces
solve_one()andsolve_all()with a unified, vectorized diagonalization method
Symbolic
TBModel.set_onsiteandTBModel.set_hop: both accept strings and callables for setting onsite energies and hoppings allowing for parameter-dependent termsTBModel.with_parameters()returns model at specific parameter values for parameterized modelsTBModel.set_parameters()resolves parameterized terms with scalar valuesTBModel.set_shell_hops(): Bulk setting of n’th nearest-neighbor hoppings for faster model constructionTBModel.hamiltonian()constructs Hamiltonians for finite and periodic systemsTBModel.velocity()computes velocity operator \(dH/dk\) in orbital basisTBModel.quantum_geometric_tensor()quantum geometric tensor using Kubo formulaTBModel.quantum_metric()quantum metric tensor from quantum geometric tensorTBModel.berry_curvature()berry curvature from quantum geometric tensorTBModel.chern_number()computes Chern number using Berry curvatureTBModel.axion_angle()computes axion angle using 4-curvature integrationTBModel.local_chern_marker()Bianco-Resta formula for real-space Chern markerTBModel.get_recip_lat()returns reciprocal lattice vectorsTBModel.make_finite(): Convenience function for chainingcut_piece()along different directionsTBModel.plot_bands()built-in band structure plotting utilityTBModel.visualize3d()interactive 3D visualization for 3D models
TBModelattributesTBModel.assume_position_operator_diagonal: attribute setter to control diagonal approximation for position operatorReplaces deprecated
ignore_position_operator_offdiagonal()method
TBModel.lattice: read-only property returning associatedLatticeinstanceTBModel.nspin: read-only property returning spinful/spinless statusTBModel.periodic_dirs: read-only property returning list of periodic directionsTBModel.norb: read-only property returning number of orbitalsTBModel.nstate: read-only property returning number of statesTBModel.dim_r: read-only property returning real-space dimensionTBModel.dim_k: read-only property returning k-space dimensionTBModel.onsite: read-only property returning on-site energies as NumPy arrayTBModel.hoppings: read-only property returning hoppings as list of dictionariesTBModel.spinful: read-only property returning spinful/spinless status
WFArraymethods:WFArray.overlap_matrix(): Computes overlap matrix of the states in theWFArraywith their nearest neighbors on a k-Mesh.WFArray.links(): Computes the unitary part of the overlap between states and their nearest neighbors in each mesh directionWFArray.berry_connection(): Computes Berry connection from the links between nearest neighbor states in the meshWFArray.wilson_loop(): Static method that computes the Wilson loop unitary matrix for a loop of statesWFArray.berry_curvature(): Computes dimensionful Berry curvature by divinding Berry flux by mesh cell area/volumeWFArray.chern_number(): Returns the Chern number for a given plane in the parameter meshWFArray.solve_model(): PopulatesWFArraywith energy eigenstates from a givenTBModelalong theMeshReplaces deprecated
solve_on_grid()andsolve_on_one_point()methods
WFArray.projectors(): Returns band projectors and optionally their complements as NumPy arraysWFArray.states(): Returns states as a NumPy array, optionally the full Bloch states including phase factorsWFArray.get_k_shell(): Generates vectors connecting nearest neighboring k-points in the mesh.WFArray.get_shell_weights(): Returns the finite-difference weights for a given shell of k-neighbors.WFArray.roll_states_with_pbc(): Rolls states along a given mesh axis with periodic boundary conditions.WFArray.copy(): Creates a deep copy of theWFArrayinstanceAdded parameter
non_abeliantoWFArray.berry_flux()to compute non-Abelian Berry flux for a manifold of states
W90methods:W90.bands_w90(): Replacesw90_bands_consistency()for clarityReturns energy array with shape
(kpts, band)consistent withTBModel.solve_ham()
W90.bands_qe(): Reads band structure from Quantum ESPRESSOprefix_bands.outoutput files
Deprecated#
The following methods are deprecated but still functional with backward compatibility wrappers. These will be removed in a future release.
tb_model, andw90class names remain available as aliases for new classesTBModel.display()(deprecated) renamed toTBModel.info()to prevent confusion with visualizationUse
TBModel.info()orprint(my_model)instead
TBModel.get_lat()(deprecated) renamed toTBModel.get_lat_vecs()for clarityTBModel.get_orb()(deprecated) renamed toTBModel.get_orb_vecs()for clarityTBModel.set_onsite()andTBModel.set_hop()modes:resetmode is deprecated; usesetinstead
TBModel.solve_one()(deprecated) replaced byTBModel.solve_ham()TBModel.solve_all()(deprecated) replaced byTBModel.solve_ham()WFArray.impose_pbc()(deprecated). Periodic boundary conditions are handled automatically byMesh. Will raiseNotImplementedErrorif called.WFArray.impose_loop()(deprecated). Periodic boundary conditions are handled automatically byMesh. Will raiseNotImplementedErrorif called.WFArray.solve_on_grid()(deprecated). UseWFArray.solve_model()instead. Will raiseNotImplementedErrorif called.WFArray.solve_on_one_point()(deprecated). UseWFArray.solve_model()instead. Will raiseNotImplementedErrorif called.W90.w90_bands_consistency()(deprecated) renamed toW90.bands_w90()for clarity
Removed#
Following SPEC-0 (Scientific Python Ecosystem Coordination)
Dropped support for Python < 3.12
Dropped support for NumPy < 2.0
Dropped support for Matplotlib < 3.9
Expired deprecations
Removed parameter
to_home_supress_warninginTBModel.change_nonperiodic_vector()andTBModel.make_supercell()(deprecated since v1.8.0). Default behavior is to only shift orbitals along periodic directions, with a warning sent to the logger if an orbital is outside the home unit cell in a non-periodic direction.
The following functionality has been removed. Users should update their code accordingly.
Removed
TBModel.reduce_dim(). This was used fix a particular k-component.TBModelis not intended to handle such constraints directly. This should be handled externally.Removed
TBModel.ignore_position_operator_offdiagonal(). Functionality replaced byTBModel.assume_position_operator_diagonalattribute setter.Removed flag
individual_phasesinWFArray.berry_flux(). The returned Berry fluxes are always computed with individual phases now.
[1.8.0] - 2022-09-20#
Changed#
Updated class
wf_arrayto make it easier to store states which are not Bloch-like eigenstates.Fixed various small issues.
Added#
Added new functionality to
wf_arraysolve_on_one_pointchoose_statesempty_like
Added function change_nonperiodic_vector and changed the way
to_homeparameter works.
Removed#
Removed some functions that were kept for backwards compatibility
berry_curvk_pathtbmodelset_sitesadd_hop.
[1.7.2] - 2017-08-01#
Changed#
Display function now prints hopping distances
Added#
Added support for deleting orbitals
[1.7.1] - 2016-12-22#
Added#
Added support for python 3.x in addition to 2.x
[1.7.0] - 2016-06-07#
Changed#
Cleaned up period boundary condition in the
wf_arrayclass
Fixed#
Fixed bug with reduce_dim. Some hopping terms were not correctly cast as onsite terms.
Fixed bug in
impose_pbcwhendim_kis less thandim_r.
Added#
Added interface with Wannier90 package
Added support for making bandstructure plots along multi-segment paths in the Brillouin zone
Added support for hybrid Wannier functions.
Berry curvature in dimensions higher than 2.
[1.6.2] - 2013-02-25#
Added#
Added support for spinors.
Added make_supercell method with which one can make arbitrary super-cells of the model and also generate slabs with arbitrary orientation.
[1.6.1] - 2012-11-15#
For the most part, the code should be backward-compatible with version 1.5.
Changed#
Renamed the code package (previously PyTB) to avoid confusion with other acronyms.
Streamlined the code to be more consistent in naming conventions.
Made some improvements and extensions to the calculation of Berry phases and curvatures.
Changed the way in which the
impose_pbcfunction is used.tb_mode,set_onsite,set_hopare named differently but have aliases to names from version 1.5
Added#
Built a proper python distribution including documentation and an improved website.
Added a more powerful method of setting onsite and hopping parameters.
Added some additional examples.
Removed#
Removed
add_wffunction fromwf_arrayobject and replaced it with[]operator, and