Skip to main content

LSDensities: Lattice Spectral Densities

lsdensities is a Python library for the calculation of smeared spectral densities from lattice correlators.

Solutions can be obtained with the Hansen Lupo Tantalo method and Bayesian inference with Gaussian Processes, or combinations of the two.

This library is based on mpmath for performing the high-precision arithmetic operations that are necessary for the solution of the inverse problem.

Authors

Niccolò Forzano, Alessandro Lupo.

Installation

One can download, build and install the package

pip install https://github.com/LupoA/lsdensities

Usage

Preliminary tests can be found in the tests folder, and tested using the pytest command.

Usage examples can be found in the examples folder.

The most basic workflow is illustrated in examples/runExact.py, which generates a high-precision correlator, and computes the corresponding spectral density smeared with one of the available kernels.

A realistic example is shown in examples/runInverseProblem.py, where input data for the correlator needs to be provided.

The most complete class is src/lsdensities/InverseProblemWrapper.py, which provides utilities for estimating errors and treating the bias both in the HLT and in the Bayesian framework.

Function call example:

from lsdensities.utils.rhoUtils import (init_precision, Inputs)
from mpmath import mp, mpf
from lsdensities.core import Smatrix_mp
from lsdensities.transform import h_Et_mp_Eslice, y_combine_central_Eslice_mp
from lsdensities.utils.rhoMath import gauss_fp

# compute the smeared spectral density at some energy,
# from a lattice correlator

init_precision(128)
parameters = Inputs()
parameters.time_extent = 32
parameters.kerneltype = 'FULLNORMGAUSS'  # Kernel smearing spectral density
parameters.periodicity = 'EXP'  # EXP / COSH for open / periodic boundary conditions
parameters.sigma = 0.25  # smearing radius in given energy units
peak = 1    #   energy level in the correlator
energy = 0.5     # energy at which the smeared spectral density
                 # is evaluated in given energy units
parameters.assign_values()  # assigns internal variables
                            # based on given inputs
                            # such as tmax = number of data points,
                            # which is inferred from time_extent and periodicity,
                            # if not specified

lattice_correlator = mp.matrix(parameters.tmax, 1)  #  vector; fill with lattice data
lattice_covariance = mp.matrix(parameters.tmax)     #  matrix; fill with data covariance

for t in range(parameters.tmax):    # mock data
    lattice_correlator[t] = mp.exp(-mpf(t + 1) * mpf(str(peak)))
    lattice_covariance[t,t] = lattice_correlator[t] * 0.02


regularising_parameter = mpf(str(1e-6))   # regularising parameters; must be tuned.
                                          # Automatic tuning is provided in InverseProblemWrapper.py
                                          # this example has exact data, so the parameters
                                          # can be made as small as zero,
                                          # in which case the result will be exact in
                                          # the limit of infinite tmax

regularised_matrix = Smatrix_mp(parameters.tmax, alpha_=0) + (regularising_parameter * lattice_covariance)
matrix_inverse = regularised_matrix**(-1)

coeff = h_Et_mp_Eslice(matrix_inverse,   # linear coefficients
                       parameters,
                       energy,
                       alpha_=0)

result = y_combine_central_Eslice_mp(coeff,     # linear combination of data
                                     lattice_correlator,
                                     parameters)

true_value = gauss_fp(peak, energy, parameters.sigma, norm="full")

print("Result: ", float(result))   # reconstructed smeared spectral density at E = energy
print("Exact results :", true_value)  # exact smeared spectral density at E = energy

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Development requirements can be installed by using pip install -r requirements.txt, and they are listed in requirements.txt.

References

For the mean ideas: https://arxiv.org/pdf/1903.06476.pdf

For the Bayesian setup and the general treatment of the bias: https://arxiv.org/pdf/2311.18125.pdf

License

GPL

Metadata

Release files for lsdensities 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lsdensities 0.0.3
File Size Uploaded
lsdensities-0.0.3.tar.gz 58.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lsdensities 0.0.3
File Interpreter ABI Platform
lsdensities-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 119.8 kB

Release files / lsdensities-0.0.3.tar.gz

Download URL lsdensities-0.0.3.tar.gz
Size 58.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7a9d4972d055f2c2d9a10741d796cf75ee54a8f1900b91879f347937e9f24dbd
BLAKE2b-256 checksum
How to use checksums
7d35c508a114118a6ce9badd51032bb97d60dc507f0e55406aa71be135036330
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.7

Release files / lsdensities-0.0.3-py3-none-any.whl

Download URL lsdensities-0.0.3-py3-none-any.whl
Size 61.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2737852075300e4aff9c137696793ddce893d29b0db12d788b32068babd425c6
BLAKE2b-256 checksum
How to use checksums
e30fcabd27b92172909479dbf4a714cdc68ffa89c72043f516d6349b0be27625
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page