LibSparseIR.jl
SpM-lab / LibSparseIR.jl
Julia wrapper for libsparseir, a C++ library for the sparse intermediate representation (IR) of correlation functions (under development; SparseIR.jl is recommended for production use)
Overview
Julia Interface for libsparseir
Typical use cases
- Perform sparse sampling in imaginary time and Matsubara frequencies by calling libsparseir from Julia
README
LibSparseIR.jl
Julia wrapper for the libsparseir C++ library, providing high-performance sparse intermediate representation (IR) of correlation functions in many-body physics.
[!WARNING] This Julia wrapper is still under development. For production use, please consider:
- SparseIR.jl - Pure Julia implementation (recommended)
- sparse-ir - Python implementation
- sparse-ir-fortran - Fortran implementation
Overview
LibSparseIR.jl provides Julia bindings to the C++ libsparseir library, offering optimized routines for:
- Basis construction: Finite temperature basis using singular value expansion (SVE)
- Sparse sampling: Efficient sampling in imaginary time and Matsubara frequencies
- DLR transformations: Discrete Lehmann Representation for compact representation
- Augmented basis: Extended basis for vertex functions and multi-point correlations
Features
Implemented Components
- ✅ Statistics: Fermionic and Bosonic
- ✅ Kernels: LogisticKernel, RegularizedBoseKernel
- ✅ Basis Functions: FiniteTempBasis with SVE
- ✅ Sampling: TauSampling, MatsubaraSampling
- ✅ DLR: DiscreteLehmannRepresentation
- ✅ Augmentation: TauConst, TauLinear, MatsubaraConst
- ✅ Basis Sets: FiniteTempBasisSet for multi-Λ calculations
API Example
using LibSparseIR
# Create basis for fermionic system
β = 10.0 # Inverse temperature
ωmax = 1.0 # Frequency cutoff
ε = 1e-10 # Accuracy parameter
basis = FiniteTempBasis(Fermionic(), β, ωmax, ε)
# Sparse sampling in imaginary time
tau_sampling = TauSampling(basis)
tau_points = tau_sampling.sampling_points
# Transform between representations
coeffs = fit(tau_sampling, gtau_values)
gtau_reconstructed = evaluate(tau_sampling, coeffs)
Installation
Prerequisites
- Julia 1.10+
- libsparseir C++ library built with C API support
Setup Instructions
Build libsparseir with C API:
git clone https://github.com/SpM-lab/libsparseir.git cd libsparseir ./build_capi.shClone and install LibSparseIR.jl:
git clone https://github.com/SpM-lab/LibSparseIR.jl.git cd LibSparseIR.jlBuild the Julia package:
julia --project -e 'using Pkg; Pkg.instantiate(); Pkg.build()'This generates
src/C_API.jlby parsing the C headers using Clang.jl.Run tests:
julia --project -e 'using Pkg; Pkg.test()'
Testing
We use ReTestItems.jl for testing with tagged test groups:
- Run all tests:
julia -e 'using Pkg; Pkg.test()' - Run specific test groups:
using Pkg Pkg.test(test_args=["--tags", "julia"]) # Pure Julia tests Pkg.test(test_args=["--tags", "wrapper"]) # C wrapper tests Pkg.test(test_args=["--tags", "cinterface"]) # C interface tests
Tutorials
Interactive tutorials are available in the tutorials/ directory:
Pluto notebooks (
tutorials/pluto/):sparse_sampling.jl- Introduction to sparse samplingtransformation_IR.jl- IR basis transformationsdlr.jl- Discrete Lehmann Representationdmft_ipt.jl- DMFT with IPT solverflex.jl- FLEX approximation exampleBgG.jl- Bethe-Goldstone calculations
Jupyter notebooks (
tutorials/jupyter/) - Similar content in Jupyter format
To run Pluto tutorials:
using Pluto
Pluto.run(notebook="tutorials/pluto/sparse_sampling.jl")
Project Structure
LibSparseIR.jl/
├── src/
│ ├── LibSparseIR.jl # Main module
│ ├── C_API.jl # Auto-generated C bindings
│ ├── abstract.jl # Abstract interfaces
│ ├── lib/ # C library wrappers
│ │ ├── basis.jl # Basis functions
│ │ ├── kernel.jl # Kernel implementations
│ │ ├── sampling.jl # Sampling routines
│ │ ├── dlr.jl # DLR transformations
│ │ └── sve.jl # SVE computations
│ └── spir/ # Pure Julia extensions
│ ├── augment.jl # Augmented basis
│ └── basis_set.jl # Multi-Λ basis sets
├── test/ # Test suites
├── tutorials/ # Interactive tutorials
└── builder/ # BinaryBuilder scripts
Source: https://github.com/SpM-lab/LibSparseIR.jl README
Richness
Richness = how many of docs / examples / tests are in place, shown as 0–3 stars (1 star = 1 item; the checklist below is the breakdown). Software listed by hand (without repository data) is not assessed and is left out when filtering by a richness of 1 or more.
- Yes: README
- No: LICENSE
- No: docs
- Yes: examples
- Yes: tests
- No: CITATION
- No: release
Information
- Primary language
- Jupyter Notebook
- Languages
- Jupyter Notebook, Julia
- License
- —
- Provider
- github