Kernels
The IR basis is nothing but the singular value expansion of a suitable integral kernel K mediating the change from real frequencies to imaginary times:
where:
is the spectral function and w(ω) is a weight function. The integral is defined on the interval [-ωmax, ωmax], where ωmax(=Λ/β) is a frequency cutoff.
Different kernels yield different IR basis functions. The sparse-ir library defines two kernels:
sparse_ir.LogisticKernel: continuation of fermionic/bosonic spectral functions with w(ω)=1 for fermions and w(ω)=1/tanh(ω/ωmax) for bosons.
sparse_ir.RegularizedBoseKernel: continuation of bosonic spectral functions with w(ω)=1/ω.
By default, sparse_ir.LogisticKernel is used.
Kernels can be fed directly into sparse_ir.FiniteTempBasis to
get the intermediate representation.
Predefined kernels
- class sparse_ir.LogisticKernel(lambda_)
Fermionic/bosonic analytical continuation kernel.
In dimensionless variables
x = 2*τ/β - 1,y = β*ω/Λ, the integral kernel is a function on[-1, 1] x [-1, 1]:\[K(x, y) = \frac{\exp(-\Lambda y(x + 1)/2)}{1 + \exp(-\Lambda y)}\]LogisticKernel is a fermionic analytic continuation kernel. Nevertheless, one can model the τ dependence of a bosonic correlation function as follows:
\[\int \frac{\exp(-\Lambda y(x + 1)/2)}{1 - \exp(-\Lambda y)} \rho(y) dy = \int K(x, y) \frac{\rho'(y)}{\tanh(\Lambda y/2)} dy\]i.e., a rescaling of the spectral function with the weight function:
\[w(y) = \frac1{\tanh(\Lambda y/2)}.\]- Parameters:
lambda (float) – Kernel cutoff Λ = β * ωmax
- property lambda_
Kernel cutoff.
- class sparse_ir.RegularizedBoseKernel(lambda_)
Regularized bosonic analytical continuation kernel.
In dimensionless variables
x = 2*τ/β - 1,y = β*ω/Λ, the fermionic integral kernel is a function on[-1, 1] x [-1, 1]:\[K(x, y) = \frac{y \exp(-\Lambda y(x + 1)/2)}{\exp(-\Lambda y) - 1}\]Care has to be taken in evaluating this expression around
y == 0.- Parameters:
lambda (float) – Kernel cutoff Λ = β * ωmax
- property lambda_
Kernel cutoff.
Custom kernels
Adding kernels to sparse_ir is simple - at the very basic level, the
library expects a kernel K to be able to provide two things:
the values through
K(x, y)a set of SVE discretization hints through
K.hints()
Let us suppose you simply want to include a Gaussian default model on the real
axis instead of the default (flat) one. We create a new kernel by inheriting
from sparse_ir.kernel.AbstractKernel and then simply wrap around a
fermionic kernel, modifying the values as needed:
import sparse_ir
import sparse_ir.kernel
class KernelFGauss(sparse_ir.kernel.AbstractKernel):
def __init__(self, lambda_, std):
self._inner = sparse_ir.LogisticKernel(lambda_)
self.lambda_ = lambda_
self.std = std
def __call__(self, x, y, x_plus=None, x_minus=None):
# First, get value of kernel
val = self._inner(x, y, x_plus, x_minus)
# Then multiply with default model
val *= np.exp(-.5 * (y / self.std)**2)
return val
def hints(self, eps):
return self._inner.hints(eps)
You can feed this kernel now directly to sparse_ir.FiniteTempBasis:
K = GaussFKernel(10., 1.)
basis = sparse_ir.FiniteTempBasis(K, 'F')
print(basis.s)
This should get you started. For a fully-fledged and robust implementation, you should:
Make sure that your kernel does not lose precision in computing
K(x, y), as this directly affects the quality of the basis. This is also where the argumentsx_plusandx_minusmay become useful.Optimize your discretization hints. To do so, it is useful to choose the segments in
xandyclose to the asymptotic distribution of the roots of the respective singular functions. The Gauss order can then be determined from a convergence analysis.Check whether your kernel is centrosymmetric, and if so, override the
is_centrosymmetricproperty. This yields a approximately four-times performance boost. However, check that the symmetrized versions of the kernels do not lose precision.
Base classes
- class sparse_ir.kernel.AbstractKernel
Abstract base class for kernels.
Note
Additional kernel classes are currently being refactored. Please refer to the concrete kernel classes above for the current API.