Skip to content
Snippets Groups Projects
Forked from kwant / kwant
750 commits behind the upstream repository.
kpm.rst 11.37 KiB

Calculating spectral density with the kernel polynomial method

We have already seen in the ":ref:`closed-systems`" tutorial that we can use Kwant simply to build Hamiltonians, which we can then directly diagonalize using routines from Scipy.

This already allows us to treat systems with a few thousand sites without too many problems. For larger systems one is often not so interested in the exact eigenenergies and eigenstates, but more in the density of states.

The kernel polynomial method (KPM), is an algorithm to obtain a polynomial expansion of the density of states. It can also be used to calculate the spectral density of arbitrary operators. Kwant has an implementation of the KPM method that is based on the algorithms presented in Ref. [1].

Roughly speaking, KPM approximates the density of states (or any other spectral density) by expanding the action of the Hamiltonian (and operator of interest) on a (small) set of random vectors as a sum of Chebyshev polynomials up to some order, and then averaging. The accuracy of the method can be tuned by modifying the order of the Chebyshev expansion and the number of random vectors. See notes on accuracy below for details.

Introduction

Our aim is to use the kernel polynomial method to obtain the spectral density \rho _A(E), as a function of the energy E, of some Hilbert space operator A. We define

\rho _A(E) = \rho (E) A(E),

where A(E) is the expectation value of A for all the eigenstates of the Hamiltonian with energy E, and the density of states is

\rho (E) = \frac{1}{D} \sum_{k=0}^{D-1} \delta (E-E_k),

D being the Hilbert space dimension, and E_k the eigenvalues.

In the special case when A is the identity, then \rho _A(E) is simply \rho (E), the density of states.

Calculating the density of states

In the following example, we will use the KPM implementation in Kwant to obtain the density of states of a graphene disk.

We start by importing kwant and defining our system.

After making a system we can then create a ~kwant.kpm.SpectralDensity object that represents the density of states for this system.

The ~kwant.kpm.SpectralDensity can then be called like a function to obtain a sequence of energies in the spectrum of the Hamiltonian, and the corresponding density of states at these energies.

When called with no arguments, an optimal set of energies is chosen (these are not evenly distributed over the spectrum, see Ref. [1] for details), however it is also possible to provide an explicit sequence of energies at which to evaluate the density of states.

../images/kpm_dos.*

In addition to being called like functions, ~kwant.kpm.SpectralDensity objects also have a method ~kwant.kpm.SpectralDensity.integrate which can be used to integrate the density of states against some distribution function over the whole spectrum. If no distribution function is specified, then the uniform distribution is used:

We see that the integral of the density of states is normalized to 1. If we wish to calculate, say, the number of states populated in equilibrium, then we should integrate with respect to a Fermi-Dirac distribution and multiply by the total number of available states in the system:

Increasing the accuracy of the approximation

~kwant.kpm.SpectralDensity has two methods for increasing the accuracy of the method, each of which offers different levels of control over what exactly is changed.

The simplest way to obtain a more accurate solution is to use the add_moments method:

This will update the number of calculated moments and also the default number of sampling points such that the maximum distance between successive energy points is energy_resolution (see notes on accuracy).

../images/kpm_dos_acc.*

Alternatively, you can directly increase the number of moments with add_moments, or the number of random vectors with add_vectors.

../images/kpm_dos_r.*

Calculating the spectral density of an operator

Above, we saw how to calculate the density of states by creating a ~kwant.kpm.SpectralDensity and passing it a finalized Kwant system. When instantiating a ~kwant.kpm.SpectralDensity we may optionally supply an operator in addition to the system. In this case it is the spectral density of the given operator that is calculated.

~kwant.kpm.SpectralDensity accepts the operators in a few formats:

  • explicit matrices (numpy array of scipy sparse matrices will work)
  • operators from kwant.operator

If an explicit matrix is provided then it must have the same shape as the system Hamiltonian.

Or, to do the same calculation using kwant.operator.Density:

Using operators from kwant.operator allows us to calculate quantities such as the local density of states by telling the operator not to sum over all the sites of the system:

~kwant.kpm.SpectralDensity will properly handle this vector output, which allows us to plot the local density of states at different point in the spectrum:

../images/kpm_ldos.*

This nicely illustrates the edge states of the graphene dot at zero energy, and the bulk states at higher energy.

Advanced topics

Custom distributions for random vectors

By default ~kwant.kpm.SpectralDensity will use random vectors whose components are unit complex numbers with phases drawn from a uniform distribution. There are several reasons why you may wish to make a different choice of distribution for your random vectors, for example to enforce certain symmetries or to only use real-valued vectors.

To change how the random vectors are generated, you need only specify a function that takes the dimension of the Hilbert space as a single parameter, and which returns a vector in that Hilbert space:

Reproducible calculations

Because KPM internally uses random vectors, running the same calculation twice will not give bit-for-bit the same result. However, similarly to the funcions in ~kwant.rmt, the random number generator can be directly manipulated by passing a value to the rng parameter of ~kwant.kpm.SpectralDensity. rng can itself be a random number generator, or it may simply be a seed to pass to the numpy random number generator (that is used internally by default).

Defining operators as sesquilinear maps

Above, we showed how ~kwant.kpm.SpectralDensity can calculate the spectral density of operators, and how we can define operators by using kwant.operator. If you need even more flexibility, ~kwant.kpm.SpectralDensity will also accept a function as its operator parameter. This function must itself take two parameters, (bra, ket) and must return either a scalar or a one-dimensional array. In order to be meaningful the function must be a sesquilinear map, i.e. antilinear in its first argument, and linear in its second argument. Below, we compare two methods for computing the local density of states, one using kwant.operator.Density, and the other using a custom function.

References

[1] (1, 2) Rev. Mod. Phys., Vol. 78, No. 1 (2006).