← Back to catalog

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)

Strong correlation/effective modelsJupyter Notebook
1 Open issues / PRsUpdated: 2025-11-24

Overview

Julia Interface for libsparseir

Typical use cases

Quick Start

This software provides a Quickstart / tutorial.

README

LibSparseIR.jl

Ask DeepWiki

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:

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
  1. Julia 1.10+
  2. libsparseir C++ library built with C API support
Setup Instructions
  1. Build libsparseir with C API:

    git clone https://github.com/SpM-lab/libsparseir.git
    cd libsparseir
    ./build_capi.sh
    
  2. Clone and install LibSparseIR.jl:

    git clone https://github.com/SpM-lab/LibSparseIR.jl.git
    cd LibSparseIR.jl
    
  3. Build the Julia package:

    julia --project -e 'using Pkg; Pkg.instantiate(); Pkg.build()'
    

    This generates src/C_API.jl by parsing the C headers using Clang.jl.

  4. 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 sampling
    • transformation_IR.jl - IR basis transformations
    • dlr.jl - Discrete Lehmann Representation
    • dmft_ipt.jl - DMFT with IPT solver
    • flex.jl - FLEX approximation example
    • BgG.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

Moderate · 1 commits/yrLast updated: 2025-11-24 ()

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.

Information

Primary language
Jupyter Notebook
Languages
Jupyter Notebook, Julia
License
—
Provider
github

Contact / Contribution