3.5. kwant.solvers – Library of solvers

Overview

Kwant offers several modules for computing the solutions to quantum transport problems, the so-called solvers. Each of these solvers may use different internal algorithms and/or depend on different external libraries. If the libraries needed by one solver are not installed, trying to import it will raise an ImportError exception. The Installation instructions list all the libraries that are required or can be used by Kwant and its solvers.

kwant.solvers.default – The default solver

There is one solver, kwant.solvers.default that is always available. For each Kwant installation it combines the best functionality of the available solvers into a single module. We recommend to use it unless there are specific reasons to use another. The following functions are provided.

smatrix(sys[, energy, args, out_leads, …])

Compute the scattering matrix of a system.

greens_function(sys[, energy, args, …])

Compute the retarded Green’s function of the system between its leads.

wave_function(sys[, energy, args, …])

Return a callable object for the computation of the wave function inside the scattering region.

ldos(sys[, energy, args, check_hermiticity, …])

Calculate the local density of states of a system at a given energy.

smatrix returns an object of the following type:

kwant.solvers.common.SMatrix(data, …[, …])

A scattering matrix.

The analog of smatrix, greens_function accordingly returns:

kwant.solvers.common.GreensFunction(data, …)

Retarded Green’s function.

Being just a thin wrapper around other solvers, the default solver selectively imports their functionality. To find out the origin of any function in this module, use Python’s help. For example

>>> help(kwant.solvers.default.ldos)

Other solver modules

Unlike the default one, other solvers have to be imported manually. They provide, whenever possible, exactly the same interface as the default. Some allow for specific tuning that can improve performance. The differences to the default solver are listed in the documentation of each module.

For Kwant experts: detail of the internal structure of a solver

Each solver module (except the default one) contains a class Solver (e.g. kwant.solvers.sparse.Solver), that actually implements that solver’s functionality. For each module-level function provided by the solver, there is a correspondent method in the Solver class. The module-level functions are simply the methods of a hidden Solver instance that is present in each solver module.

The encapsulation in a class allows different solvers to easily share common code. It also makes it possible to use solvers with different options concurrently. Typically, one does not need this flexibility, and will not want to bother with the Solver class itself. Instead, one will use the module-level functions as explained in the previous sections.