qlat.muon_line — Muon-Line Integrals for HLbL Scattering¶
Source: qlat/qlat/muon_line.pyx
Note: Update this document when updating the source file.
Outline¶
Overview¶
muon_line computes the muon-line tensor
that appears in the hadronic light-by-light (HLbL) scattering contribution
to the muon anomalous magnetic moment :math:(g-2)_\mu. The computation
follows the method described in arXiv:2304.04423, Eq.~(9).
The module provides:
Direct numerical integration via
calc_muon_line_m(uses the CUBA multi-dimensional integration library).Pre-computed interpolation tables that can be saved to disk and loaded later, avoiding repeated expensive integrals.
Extra-weighted variants (
get_muon_line_m_extra,get_muon_line_m_extra_lat) that combine multiple interpolation tables with configurable weights for subtracted and unsubtracted contributions.
All core functions return a 4-D NumPy array of shape (3, 4, 4, 4) and
dtype float64, where the indices are [i, rho, sigma, lambda].
The module sets the environment variable CUBACORES=0 on import to
control CUBA’s threading behaviour.
CUBA Integration Library¶
has_cuba() -> bool¶
Return True if the CUBA integration library is available at runtime.
import qlat as q
size_node_list = [[1, 1, 1, 1]]
q.begin_with_mpi(size_node_list)
if q.has_cuba():
print("CUBA is available")
q.end_with_mpi()
test_integration_multi_dimensional()¶
Run a built-in test of the CUBA multi-dimensional integration routines. Useful for verifying that the integration library works correctly.
Interpolation Management¶
Interpolations are pre-computed tables of the muon-line tensor stored on disk. Once loaded they allow fast retrieval of
- math:
\mathcal{M}_{i,\rho,\sigma,\lambda}without re-evaluating the integral.
clear_muon_line_interpolations()¶
Release all loaded interpolation tables from memory.
get_number_of_muon_line_interpolations() -> int¶
Return the number of interpolation tables currently loaded in memory.
compute_save_muonline_interpolation(path, dims, eps) -> int¶
Compute and save a muon-line interpolation table to disk.
Parameter |
Type |
Description |
|---|---|---|
|
|
Directory path where the interpolation is saved |
|
|
Grid resolution in each of the 5 dimensions, e.g. |
|
|
Integration parameters: |
Default integration tolerances: epsabs=1e-8, epsrel=1e-3.
load_multiple_muonline_interpolations(path, idx_list) -> int¶
Load pre-computed interpolation tables from path.
Parameter |
Type |
Description |
|---|---|---|
|
|
Root directory containing interpolation checkpoints |
|
|
Indices to load. If empty, load all available tables |
Tables are expected under path/{idx:010d}/checkpoint. Returns the number
of tables loaded.
Extra Weights¶
Extra weights control how multiple interpolation tables are combined in
get_muon_line_m_extra and get_muon_line_m_extra_lat. The weights are
a list of lists of floats, one inner list per interpolation index.
get_muon_line_m_extra_weights() -> list[list[float]]¶
Return the current extra weights.
set_muon_line_m_extra_weights(weights=None)¶
Set the extra weights. Pass None to restore the default values.
Core Computation Functions¶
All functions below return a NumPy array of shape (3, 4, 4, 4) with
dtype float64.
calc_muon_line_m¶
calc_muon_line_m(x: CoordinateD, y: CoordinateD, eps: tuple) -> numpy.ndarray
Directly compute the muon-line tensor by numerical integration (CUBA).
Parameter |
Type |
Description |
|---|---|---|
|
|
First spacetime coordinate |
|
|
Second spacetime coordinate |
|
|
|
Wraps the C++ function muon_line_sym_py.
get_muon_line_m¶
get_muon_line_m(x: CoordinateD, y: CoordinateD, z: CoordinateD,
idx: int, eps: tuple) -> numpy.ndarray
Return the muon-line tensor
- math:
\mathcal{M}_{i,\rho,\sigma,\lambda}(x,y,z).
Parameter |
Type |
Description |
|---|---|---|
|
|
First spacetime coordinate |
|
|
Second spacetime coordinate |
|
|
Third spacetime coordinate |
|
|
Interpolation index. If |
|
|
|
Wraps the C++ function get_muon_line_m_py.
get_muon_line_m_extra¶
get_muon_line_m_extra(x: CoordinateD, y: CoordinateD, z: CoordinateD,
tag: int) -> numpy.ndarray
Return the muon-line tensor using weighted combinations of loaded interpolations.
Parameter |
Type |
Description |
|---|---|---|
|
|
First spacetime coordinate |
|
|
Second spacetime coordinate |
|
|
Third spacetime coordinate |
|
|
|
The following interpolation tables must be loaded:
Index |
Grid |
Type |
Used by |
|---|---|---|---|
0 |
6^5 |
with-sub |
|
1 |
8^5 |
with-sub |
|
2 |
10^5 |
with-sub |
|
3 |
12^5 |
with-sub |
|
4 |
14^5 |
with-sub |
|
5 |
16^5 |
with-sub |
|
6 |
6^5 |
no-sub |
|
7 |
8^5 |
no-sub |
|
8 |
10^5 |
no-sub |
|
9 |
12^5 |
no-sub |
|
10 |
14^5 |
no-sub |
|
11 |
16^5 |
no-sub |
|
Wraps the C++ function get_muon_line_m_extra_py.
get_muon_line_m_extra_lat¶
get_muon_line_m_extra_lat(x: Coordinate, y: Coordinate, z: Coordinate,
total_site: Coordinate, a: float,
tag: int) -> numpy.ndarray
Lattice-aware version of get_muon_line_m_extra. Coordinates are given
as integer lattice sites and a is the muon mass in lattice units.
Parameter |
Type |
Description |
|---|---|---|
|
|
First lattice site |
|
|
Second lattice site |
|
|
Third lattice site |
|
|
Total lattice dimensions |
|
|
Muon mass in lattice units |
|
|
|
Requires the same set of interpolation tables as get_muon_line_m_extra.
Wraps the C++ function get_muon_line_m_extra_lat_py.
Examples¶
Check CUBA Availability¶
import qlat as q
size_node_list = [[1, 1, 1, 1]]
q.begin_with_mpi(size_node_list)
print("CUBA available:", q.has_cuba())
q.end_with_mpi()
Compute Muon-Line Tensor Directly¶
import qlat as q
size_node_list = [[1, 1, 1, 1]]
q.begin_with_mpi(size_node_list)
x = q.CoordinateD([0.1, 0.2, 0.3, 0.4])
y = q.CoordinateD([0.5, 0.6, 0.7, 0.8])
eps = (1e-8, 1e-3, 0, 0)
m = q.calc_muon_line_m(x, y, eps)
print("Shape:", m.shape) # (3, 4, 4, 4)
print("dtype:", m.dtype) # float64
q.end_with_mpi()
Load Interpolations and Query¶
import qlat as q
size_node_list = [[1, 1, 1, 1]]
q.begin_with_mpi(size_node_list)
# Load pre-computed interpolation tables
path = "/path/to/interpolations"
q.load_multiple_muonline_interpolations(path, [])
print("Loaded:", q.get_number_of_muon_line_interpolations())
# Use a loaded interpolation (idx >= 0)
x = q.CoordinateD([0.1, 0.2, 0.3, 0.4])
y = q.CoordinateD([0.5, 0.6, 0.7, 0.8])
z = q.CoordinateD([0.0, 0.0, 0.0, 0.0])
m = q.get_muon_line_m(x, y, z, idx=1, eps=(0, 0, 0, 0))
print("Shape:", m.shape)
# Clean up
q.clear_muon_line_interpolations()
q.end_with_mpi()
Use Extra-Weighted Muon-Line Tensor (Lattice Version)¶
import qlat as q
size_node_list = [[1, 1, 1, 1]]
q.begin_with_mpi(size_node_list)
# Load all required interpolation tables (indices 0-11)
path = "/path/to/interpolations"
q.load_multiple_muonline_interpolations(path, [])
# Integer lattice coordinates
x = q.Coordinate([1, 0, 0, 0])
y = q.Coordinate([0, 1, 0, 0])
z = q.Coordinate([0, 0, 0, 0])
total_site = q.Coordinate([16, 16, 16, 32])
a = 0.01 # muon mass in lattice units
# Subtracted contribution (tag=0)
m_sub = q.get_muon_line_m_extra_lat(x, y, z, total_site, a, tag=0)
# Unsubtracted contribution (tag=1)
m_nosub = q.get_muon_line_m_extra_lat(x, y, z, total_site, a, tag=1)
print("sub shape:", m_sub.shape) # (3, 4, 4, 4)
print("nosub shape:", m_nosub.shape) # (3, 4, 4, 4)
q.clear_muon_line_interpolations()
q.end_with_mpi()