Source-linked AI summary
Kwant: a software package for quantum transport
Christoph W. Groth, Michael Wimmer, Anton R. Akhmerov, Xavier Waintal
TL;DR
Quantum transport simulations lacked a package combining broad tight-binding applicability with performance, interoperability, flexibility, and ease of use. This paper introduces Kwant, whose algorithms outperform recursive Green’s function methods while providing an expressive Python interface for defining and analyzing quantum-transport systems.
Problem
Existing implementations were restricted to quasi-one-dimensional geometries or particular tight-binding Hamiltonians, while no package emphasized broad quantum-transport applicability alongside usability and performance.
Method
Kwant combines a high-level Python interface for constructing tight-binding Hamiltonians with an efficient low-level representation and numerical algorithms.
Results
Kwant’s algorithms significantly outperform the recursive Green’s function method and avoid instabilities associated with commonly used algorithms.
Takeaways & Limitations
Kwant provides a simple, clear, and powerful interface for defining and working with tight-binding models while supporting high-performance quantum-transport calculations.
Takeaways & Limitations
Kwant version 1.0 remains a work in progress, with additional solvers and broader symmetry support identified as future improvements.
Abstract
from arXiv · showhide
Kwant is a Python package for numerical quantum transport calculations. It aims to be an user-friendly, universal, and high-performance toolbox for the simulation of physical systems of any dimensionality and geometry that can be described by a tight-binding model. Kwant has been designed such that the natural concepts of the theory of quantum transport (lattices, symmetries, electrodes, orbital/spin/electron-hole degrees of freedom) are exposed in a simple and transparent way: Defining a new simulation setup is very close to describing the corresponding mathematical model. Kwant offers direct support for calculations of transport properties (conductance, noise, scattering matrix), dispersion relations, modes, wave functions, various Green's functions, and out-of-equilibrium local quantities. Other computations involving tight-binding Hamiltonians can be implemented easily thanks to its extensible and modular nature. Kwant is free software available at http://kwant-project.org/.
1. INTRODUCTION
Kwant is a publicly available, user-friendly Python package for efficient quantum-transport scattering calculations in broad tight-binding systems. It combines robust algorithms that outperform commonly used recursive Green’s methods with interoperability and expressive system definition.
- 1. INTRODUCTION: Scattering calculations directly yield conductance and other transport properties and can serve as building blocks for more complex phenomena.The scattering problem concerns finite systems coupled, possibly strongly, to infinite leads.
- 1. INTRODUCTION: Kwant is highly interoperable with other packages and algorithms throughout both scattering-problem definition and solution.This reduces the need for specialized packages to reimplement scattering solvers while allowing them to use Kwant’s efficient algorithms.
2. OVERVIEW OF BASIC CONCEPTS OF QUANTUM TRANSPORT
Kwant models quantum-transport systems as tight-binding graphs comprising a finite scattering region connected to semi-infinite periodic electrodes. Its wave-function approach derives scattering states and matrices from lead modes, enabling transport and local-property calculations.
- System geometry: Kwant primarily targets infinite systems with a finite scattering region connected to semi-infinite periodic electrodes that guide plane waves as experimental contacts.Finite systems are also supported, but the main target is the scattering-region-plus-leads geometry of the Landauer–Büttiker formalism.
- Tight-binding representation: Tight-binding Hamiltonians encode lattice sites and internal spin, orbital, or Nambu electron-hole degrees of freedom, arising from atomic models or continuum finite-difference discretizations.Kwant represents these Hamiltonians as annotated infinite graphs: nodes carry onsite matrices, edges represent nonzero hopping matrices, and lead periodicity yields a finite representation.
- Scattering formulation: Kwant focuses on the wave-function scattering formulation because its default solver uses it and it is more stable than the mathematically equivalent non-equilibrium Green’s-function approach.Multiple leads can be treated as a single effective lead with disjoint sections, giving a tridiagonal block structure for the scattering region and periodic lead unit cells.
- Lead modes: Lead wave functions are superpositions of translation-operator modes: |λ_n|<1 modes are evanescent, while λ_n=e^ik_n modes are propagating and current-normalized.Scattering states are obtained by matching the lead modes to the wave function in the scattering region through the tight-binding Schrödinger equations.
- Computed observables: The scattering matrix and scattering-region wave functions are Kwant’s main raw outputs, from which conductance, shot noise, spin currents, thermoelectric coefficients, local density of states, and current density can be computed.Differential conductance is obtained from the scattering matrix through the Landauer formula, while internal properties follow from the scattering-region wave functions.
3. THE DESIGN OF KWANT
Kwant separates intuitive Python-based system construction from low-level numerical solving to combine flexibility, ease of use, performance, and interoperability. Its Builder and universal low-level representations support general tight-binding models and downstream computations.
- Design goals: Kwant’s two-phase design constructs tight-binding Hamiltonians in Python, then solves scattering problems with low-level numerical algorithms and data structures.The construction phase uses physics concepts such as lattices, while the solving phase is suited to more complex numerical algorithms.
- Design goals: Nested dissection in sparse linear-algebra libraries lets Kwant significantly outperform a pure-C reference implementation of the RGF algorithm.The two-phase approach therefore does not cause a significant performance drop.
- Builder objects: Builder represents tight-binding systems as graph mappings from sites and hoppings to Hamiltonian values, using a hash table for incremental geometry edits.Site families and tags represent site types and positions, while regular lattices support sublattices and translation-related hopping operations.
- Builder objects: Kwant extends Hamiltonian elements from constants to matrices for multiple local degrees of freedom and functions of position, while supporting Hermiticity and real-space symmetries.Translationally symmetric Builders can be attached to other Builders to form scattering leads.
- Low-level systems: Finalizing a Builder produces a memory-efficient, language-interoperable low-level system that serves as input to quantum-transport solvers and external computations.Low-level systems can also be defined directly by external packages, and their Hamiltonians can be passed to standard eigenstate routines such as ARPACK.
4. COMPARISON WITH OTHER QUANTUM TRANSPORT PACKAGES
The section situates Kwant among quantum-transport software, contrasting DFT–non-equilibrium-Green’s-function packages for molecular junctions with Kwant’s generality for mesoscopic models and geometries. It also reports that Kwant significantly outperforms comparable scattering packages by using nested dissection rather than RGF.
- Related packages: Quantum transport is addressed by software packages from different domains, including commercial tools for molecular-junction transport.Examples include TranSiesta/Atomistix Toolkit, SMEAGOL, OpenMX, and nanodcal/nanodsim.
- Generality and scope: Kwant targets the broad variety of complex models and geometries encountered in mesoscopic physics, emphasizing generality over narrower application domains.This contrasts with molecular-junction packages such as TranSiesta/Atomistix Toolkit, SMEAGOL, OpenMX, and nanodcal/nanodsim, which combine DFT with non-equilibrium Green’s functions.
- Performance comparison: Kwant significantly outperforms private scattering codes and the publicly available KNIT package by using nested dissection instead of RGF.The comparison is stated relative to packages for solving the scattering problem.
5. ILLUSTRATION OF KWANT USAGE: UNIVERSAL CONDUCTANCE FLUCTUATIONS IN A QUANTUM BILLIARD
Kwant is illustrated through a stadium-billiard scattering problem exhibiting universal conductance fluctuations and chaotic density of states. The example shows that defining the system and computing observables is transparent and requires few steps.
- 5. ILLUSTRATION OF KWANT USAGE: UNIVERSAL CONDUCTANCE FLUCTUATIONS IN A QUANTUM BILLIARD: The scattering region is defined by a stadium-shaped lattice, onsite potential −4t, and nearest-neighbor hopping t = −1.A shape function selects lattice sites inside the stadium, which are then assigned onsite and hopping terms.
- 5. ILLUSTRATION OF KWANT USAGE: UNIVERSAL CONDUCTANCE FLUCTUATIONS IN A QUANTUM BILLIARD: Leads complete the scattering problem through translational symmetry, which automatically applies lead operations to all symmetry-related image sites.The example constructs a lead with symmetry [0, −1], assigns its sites and nearest-neighbor hoppings, and attaches it to the system.
- 5. ILLUSTRATION OF KWANT USAGE: UNIVERSAL CONDUCTANCE FLUCTUATIONS IN A QUANTUM BILLIARD: After transforming the system for efficient numerical calculations, Kwant’s solvers compute conductance from the scattering matrix and local density of states.The scattering matrix gives transmission between leads, while kwant.ldos returns the local density of states in the scattering region.
- 5. ILLUSTRATION OF KWANT USAGE: UNIVERSAL CONDUCTANCE FLUCTUATIONS IN A QUANTUM BILLIARD: The resulting plots show universal conductance fluctuations and an irregular, chaotic density of states in the stadium billiard.Figure 4 displays conductance versus energy and the local density of scattering states, including the first ten lead unit cells.
6. A FULL-SCALE APPLICATION: HANLE EFFECT IN A GRAPHENE-BASED NON-LOCAL SPIN VALVE
Kwant simulates a four-terminal graphene non-local spin valve and reproduces the Hanle effect, including sign reversal of the spin-dependent non-local resistance under increasing magnetic field. The quantum-coherent model extends beyond semiclassical diffusion to study phase coherence and ballistic propagation.
- The four-terminal device measures pure spin transport through non-local resistance R_01,23 = V/I, with current through contacts 0 and 1 and voltage measured between 2 and 3.No electrical current flows through the voltage-measuring electrodes, and the setup was studied experimentally recently.
- The minimal tight-binding model combines graphene and cubic-lattice ferromagnetic leads, spin-dependent interface hopping, static disorder, and an in-plane magnetic field H_x.The interface polarization is controlled by −1 < β < 1, while disorder strength is set by W.
- Kwant naturally represents the four-terminal, multi-lattice, spinful system through distinct site families and matrix Hamiltonians, while Python enables custom coupling and numerical extensions.The graphene–ferromagnet connection is custom-coded using Kwant coordinates and a SciPy kd-tree, and the resistance calculation uses a 3×3 linear equation solved with NumPy.
- The simulation produces a typical Hanle signal: increasing H_x changes the sign of the spin-dependent signal ΔR = R_P − R_AP for parallel and antiparallel magnetizations.Figure 5 uses β = 0.5, t = 0.2, W = 0.4, and a graphene ribbon containing around 7000 carbon atoms.
- Unlike conventional semiclassical diffusion treatments, the full quantum model accounts for quantum coherence and can examine phase-coherent or ballistic transport when W = 0.Additional magnetic disorder could be added to introduce a finite spin-diffusion length.
7. BENCHMARK
The benchmark compares Kwant’s conductance calculation for square tight-binding systems with a C implementation of the RGF algorithm, measuring runtime and memory as system size grows. Kwant’s MUMPS-based solver is faster for large systems but uses more memory, while RGF remains available for larger-scale calculations.
- 7. BENCHMARK: The benchmark measures conductance for an L × L square tight-binding lattice with leads of width L attached to opposite sides at fixed energy.Because the energy is fixed, the number of propagating lead modes is proportional to L.
- 7. BENCHMARK: For large systems, Kwant with the MUMPS-based solver is up to ten times faster than the C RGF code, with crossover around L = 50.Figure 6 compares construction and solving times as functions of the square system side length L.
- 7. BENCHMARK: For large L, construction scales as O(L^2), MUMPS-based solving as O(L^3), RGF solving as O(L^4), MUMPS memory as O(L^2 logL), and RGF memory as O(L^2).These are the theoretically expected asymptotic scalings shown in Figures 6 and 7.
- 7. BENCHMARK: Kwant’s MUMPS-based solver uses more memory than RGF, but can handle systems exceeding 10^6 sites with a few GiB of main memory.RGF was also implemented to handle even larger systems, though it was not yet part of the public release.
8. CONCLUSION · Appendix A: Programming interface of builder objects · A.1. Sites and site families
Kwant combines high-performance quantum-transport algorithms with a clear, powerful Python interface for defining tight-binding models. Its builder interface represents sites through site families and tags, supports arbitrary lattice dimensionality and geometry, and was released as open-source version 1.0 while remaining a work in progress.
- 8. CONCLUSION: Kwant’s double objective is to combine high-performance quantum-transport algorithms with a simple, clear, and powerful interface for tight-binding models, extending Python rather than creating a new language.The design replaces conventional specialized input files with Python-based model descriptions.
- 8. CONCLUSION: Version 1.0 was Kwant’s first public release, but the project remains a work in progress with planned improvements including additional solvers and more general symmetries.The improvement list is maintained with the source code.
- 8. CONCLUSION: Kwant is free open-source software distributed under the simplified BSD license, with its website and mailing list intended to support a community of users and developers.The project welcomes contributions and sharing of related code modules.
- A.1. Sites and site families: Site objects abstract tight-binding sites, each belonging to exactly one site family and distinguished within that family by a tag.For regular lattices, tags are typically integer lattice coordinates; site families commonly represent crystal lattices or sublattices.
- A.1. Sites and site families: Arbitrary crystal lattices with bases can be defined from Bravais-lattice primitive vectors and the coordinates of sites within the unit cell, including graphene’s honeycomb lattice.Each sublattice receives an associated site family.
- A.1. Sites and site families: A site’s lattice position maps uniquely to its family and tag, while site.pos provides access to its real-space position.For example, a site at R = 5u_0 + 8u_1 + v_B is identified as B(5,8).
- A.1. Sites and site families: Kwant includes predefined common lattices and uses a dimensionality-independent graph representation, so it is not restricted to two-dimensional systems.Site families can also represent amorphous materials or character-based labels, although Bravais lattices suffice for most systems.
A.2. Tight-binding systems as Python mappings … B.1. Low-level systems
Kwant models tight-binding systems through Python builders that support sites, hoppings, matrix- or function-valued Hamiltonians, bulk operations, symmetries, and leads. These builders can be finalized into sparse low-level systems that expose Hamiltonians to solvers.
- A.2. Tight-binding systems as Python mappings: Builders represent tight-binding systems as Python mappings from sites and hoppings to Hamiltonian submatrices, while preserving Hermiticity and removing connected hoppings when sites are deleted.Values can be queried, assigned, and deleted using ordinary mapping syntax; hoppings exist only between sites present in the builder.
- A.3. Values of sites and hoppings: Kwant accepts scalar or matrix-valued onsite and hopping terms, and supports delayed value functions whose site- or hopping-dependent evaluations enable parameter variation in one finalized system.Matrix values can use NumPy or tinyarray objects, with tinyarray optimized for better performance on small arrays.
- A.3.1. Example: value functions for hoppings and sites: Value functions model magnetic fields and reproducible disorder by combining Peierls-substituted hoppings with random-access pseudo-random site potentials whose outputs remain stable during a solver invocation.The disorder generator uses the site representation and a salt parameter, which acts similarly to a random seed.
- A.3.2. Example: value functions that return matrices: Matrix-returning value functions define multi-orbital Hamiltonians using compact parameter namespaces, and their outputs may be recalculated per site or hopping without practical inefficiency.Kwant permits value functions to return anything valid as a constant builder value, including matrices.
- A.4. Acting on multiple sites/hoppings at once: Composite builder keys let users add many sites or hoppings at once through iterables, shape-based region selection, HoppingKind, and nearest-neighbor keys, avoiding explicit loops for complex geometries.The shape method finds reachable lattice sites inside a region, while high-level keys can generate nth-nearest-neighbor hoppings on regular lattices.
- A.5. Symmetries: Symmetry-enabled builders represent infinite periodic systems through transformations and a fundamental domain, with translational symmetry supporting lead construction but low-level finalization limited to one-dimensional translation symmetry in Kwant 1.0.Sites and hoppings are internally mapped to representatives in the fundamental domain, so equivalent objects can be manipulated through symmetry-related keys.
- A.6. Leads: Infinite periodic builders attach to finite scattering regions as leads through interfaces, while attach_lead automatically adds compatible sites and hoppings and determines the lead interface.Lead unit-cell geometry is determined by the fundamental domain, which affects required added sites but not the system’s physics.
- B.1. Low-level systems: Low-level systems encode sparse tight-binding Hamiltonians as annotated graphs in compressed sparse row format, providing the common construction-to-solving interface and supporting scalar or block matrix Hamiltonians.They are usually produced by Builder.finalized but can also be implemented directly from FiniteSystem; hamiltonian_submatrix returns dense or sparse Hamiltonian submatrices.
B.2. Quantum transport
Kwant computes quantum transport by solving sparse linear systems with a wave-function approach, using sparse-matrix orderings for efficient scaling. It provides scattering matrices, wave functions, and local densities, enabling transport analyses such as quantum Hall conductance and backscattering.
- Quantum transport: Kwant’s default wave-function algorithm computes transport by setting up and solving a sparse system of linear equations, including noninvertible hopping and numerically stabilized cases.The method is formulated from the Hamiltonian matrices of the system and attached leads, with a connection to Green’s-function methods.
- Quantum transport: Nested-dissection sparse solvers reduce the two-dimensional rectangular tight-binding solve to O(LW^2) time, though pivoting can worsen scaling while ensuring stability.The sparse system includes the scattering-region Hamiltonian plus outgoing and evanescent lead modes; in practice, Kwant has stably solved problems for which RGF failed.
- Quantum transport: The scattering matrix provides lead-to-lead transmission and noise, while optional wave-function calculations expose individual scattering states when memory permits.kwant.smatrix discards scattering wave functions by default because retaining them can require excessive memory for large systems; kwant.wave_function retrieves them when needed.
- Quantum transport: The quantum Hall conductance shows two quantized plateaus, whereas the third near 1/Φ = 40 is absent because a constriction causes edge-state backscattering.The corresponding density visualization shows the quantum Hall edge state partially backscattered at 1/Φ = 40.
- Quantum transport: Kwant can compute site-resolved densities and visualize them with its plotting tools, linking local density patterns to transport features.The density array contains one value per system site and can be color-plotted with kwant.plotter.map.
B.3. Exact diagonalization of a finite system Hamiltonian
Kwant supports user-specified computations beyond its built-in solvers, illustrated by exact diagonalization of a finite tight-binding system using SciPy-accessible ARPACK. The example computes states near the Fermi level in a Majorana wire as a function of magnetic field strength, with output shown in Fig. 15.
- Extensibility: Kwant enables arbitrary computations beyond included solvers, often by implementing a new solver in only a few lines of Python.This extensibility is a design objective of the package.
- Sparse exact diagonalization: ARPACK computes the lowest eigenenergies of a large finite-system Hamiltonian after Kwant exports it in SciPy-compatible sparse format.The calculation uses SciPy’s ARPACK interface through hamiltonian_submatrix(sparse=True).
- Majorana-wire application: The workflow calculates energies of states closest to the Fermi level in a Majorana wire across magnetic-field strengths using value functions and a few additional code lines.The magnetic field is sampled over B_values = numpy.linspace(0, 0.6, 80), and sparse eigensolvers target eigenvalues near zero.
- Majorana-wire application: The resulting energy spectrum is presented in Fig. 15.The figure shows the output of the code-based calculation.
Appendix C: Implementation of Kwant … D.4. System with leads
Kwant combines a predominantly Python implementation with optimized compiled and numerical libraries, preserving usability while concentrating performance effort on computationally dominant components. Its appendices illustrate building finite systems, quantum dots, and lead-connected systems through concise, transparent constructions.
- Appendix C: Implementation of Kwant: Kwant is written primarily in Python, while optimizing asymptotically expensive components and using pragmatic optimization for less critical code.This design prioritizes human-time efficiency where performance penalties are small.
- C.1. Resource usage of quantum transport calculations: Solving dominates quantum-transport runtime, scaling as O(n3−2/d) for the RGF algorithm in d dimensions, whereas initialization and post-processing are generally less expensive.The calculation stages therefore have substantially different scaling with system size.
- C.2. Programming languages used: Kwant combines pure Python, Cython-wrapped libraries, and direct Cython or C/C++ implementations across its implementation.The stated approaches include NumPy/SciPy delegation, wrapping previously unavailable libraries via Cython, and native low-level code.
- C.2. Programming languages used: Its transport solvers use UMFPACK or SuperLU through SciPy, or the separately installed MUMPS library with Metis orderings.Lead modes and self-energies use Python together with LAPACK wrapped through Cython.
- C.2. Programming languages used: More than half of Kwant’s runtime is spent in highly optimized libraries except for small systems, limiting the potential speedup from rewriting all code in C or Fortran.As system size grows, the library fraction of total runtime approaches 100%.
- D.1. Simplest builder usage: The simplest builder example constructs and plots a three-site system by assigning onsite values and hoppings on a lattice.The example is explained in Appendix A.2 and shown in Fig. 8.
- D.2. Circular quantum dot: Kwant examples construct and plot a disk-shaped quantum dot on a square lattice and a bean-shaped quantum dot on a honeycomb lattice.These examples are featured in Appendix A.4 and shown in Figs. 9 and 10.
- D.4. System with leads: A further example creates a ring-shaped finite system with a periodic infinite system attached twice as leads, once outside and once inside, and plots it in Fig. 11.The lead uses translational symmetry and is attached at two positions to the ring.
D.5. Quantum Hall effect · D.6. Majorana Fermion
The examples demonstrate Kwant simulations of quantum Hall transport and Majorana-fermion spectra. They cover conductance plateaus, edge-state densities, and magnetic-field-dependent eigenenergies in explicitly constructed tight-binding systems.
- D.5. Quantum Hall effect: Quantum Hall plateaus break down as magnetic-field strength decreases in a two-lead quantum point contact with perpendicular field and on-site disorder (Fig. 13).
- D.5. Quantum Hall effect: A partially backscattered quantum Hall edge state is visualized for the same two-lead system (Fig. 14).
- D.5. Quantum Hall effect: The quantum Hall model is built as a finite region with disordered onsite potential, magnetic-field-dependent hopping, and two reversed translationally symmetric leads.
- D.5. Quantum Hall effect: The quantum Hall setup computes conductance from scattering-matrix transmission across magnetic-field values and maps lead-resolved wave-function density.
- D.6. Majorana Fermion: The Majorana example constructs a one-dimensional chain whose lowest eigenenergies are plotted as a function of magnetic-field strength (Fig. 15).
- D.6. Majorana Fermion: Its tight-binding Hamiltonian combines chemical potential, hopping, spin-orbit coupling, magnetic field, and superconducting pairing through matrix-valued onsite and hopping terms.