Search arXiv⌕ Search

arXiv · 2605.06634

libwignernj: a reusable C/C++/Fortran/Python library for exact Wigner symbols and related coefficients

Abstract

We describe libwignernj, a freely available, BSD-licensed library that evaluates Wigner 3j, 6j, and 9j symbols, Clebsch--Gordan, Racah $W$, and Fano $X$ coefficients, and Gaunt coefficients over both complex and real spherical harmonics in standards-compliant C99. libwignernj represents factorials by the vector of their signed prime-exponent decomposition - a prime-factorization technique introduced for the angular-momentum coefficients by Dodds and Wiechers (Comput. Phys. Commun. 4, 268 (1972)) and refined in a long line of subsequent work - and combines that representation with the multiword-integer Racah sum of Johansson and Forssén (SIAM J. Sci. Comput. 38, A376 (2016)), under which every intermediate quantity is an exact rational and all rounding is confined to the final floating-point conversion. Single-, double-, and long-double-precision results are correct to the last representable bit, and IEEE 754 binary128 evaluation through libquadmath and arbitrary-precision evaluation through the GNU Multiple-Precision Floating-Point Reliable (MPFR) library are optionally exposed. libwignernj has no mandatory runtime dependencies and no caller-side initialization step, making it easy to embed across the atomic, molecular, nuclear, and electromagnetic-scattering applications in which these coefficients arise. C++, CPython, and Fortran 90 bindings ship alongside the C library. Half-integer angular momenta are encoded exactly via integer $2j$ arguments throughout the application programming interface (API). CMake-package and pkg-config files ship for drop-in integration into downstream projects, and a continuous-integration (CI) pipeline runs the full test suite on Linux (shared and static), macOS, and Windows on every push.

Explore related subjects

Keep this discovery

Explore connections, maps & timelines

BibTeXRIS

Susi Lehtola. 2026-07-02. libwignernj: a reusable C/C++/Fortran/Python library for exact Wigner symbols and related coefficients. https://doi.org/10.1016/j.cpc.2026.110342

Cite the original work for its findings. Save a collection to share your selection of sources.

KEEP EXPLORING

Related papers

A Physics-Driven Framework for Parametric Periodic-Flow Modeling and Finite-Amplitude Aeroelastic Response Analysis

Periodic unsteady flows are common in forced-motion and fluid-structure interaction problems. Their parametric analysis typically requires repeated high-fidelity simulations, whereas existing reduced-order and surrogate models generally rely on pre-generated flow-field or aerodynamic data. This study proposes a purely physics-driven framework for solving parametric periodic flows and finite-amplitude aeroelastic responses. First, a Periodic Physics-Informed Neural Network (P-PINN) is developed to directly solve periodic flows by imposing temporal periodicity over a single motion cycle, thereby avoiding the need to resolve the long transient evolution preceding the establishment of the periodic state. The flow conditions and motion parameters are further incorporated as network inputs to construct continuous parametric representations of the periodic flow field and aerodynamic forces. On this basis, the parametric aerodynamic model is coupled with the structural dynamic equation through first-order harmonic balance to solve the response amplitude and frequency of a single-degree-of-freedom aeroelastic system. This framework is validated using forced-motion cases of a circular cylinder and an airfoil, demonstrating accurate reproduction of periodic aerodynamic forces, surface load distributions, and instantaneous flow fields under different flow and motion parameters compared with time-marching results. Furthermore, aeroelastic analysis is conducted for an elastically mounted circular cylinder at subcritical Reynolds numbers, and the resulting aeroelastic response agrees well with fully coupled CFD/CSD results. Once trained offline, the parametric model can be repeatedly evaluated for different structural parameter states, enabling the complete aeroelastic response curve to be obtained online within seconds, without repeated long-time fluid-structure interaction time marching.

physics.comp-ph↗

Monte Carlo sampling of first-order QED processes in laser and pulsar plasmas

Monte Carlo sampling of strong-field quantum electrodynamics processes underpins simulations of high-intensity laser experiments and of astrophysical compact-object magnetospheres. Sampling an event requires the total rate of the process together with the cumulative probability that determines how energy is partitioned between the produced particles. Simulations typically tabulate both in advance and invert the tabulated probability numerically. Here we replace this procedure with elementary-function approximations for synchrotron radiation and the nonlinear Breit--Wheeler process. For each process, we approximate the auxiliary function that sets the total rate, as well as the cumulative probability, with Padé approximants chosen so that the inversion reduces to a quartic equation. This yields the sampled quantum parameter---electron $χ_e$ or photon $χ_γ$---in closed form. The approximations and the particle spectra sampled from them agree with the exact results to within $1\%$. The procedure requires no lookup tables, no interpolation, and no numerical root finding, and can be inserted directly into radiative particle-in-cell codes.

physics.comp-ph↗

Optimal Bias Potentials via Ergodic Optimal Control and Generator Learning

We investigate the computation of optimal bias potentials for accelerating transitions between metastable states and for computation of equilibrium properties in molecular dynamics simulations. We formulate optimal biasing as an ergodic optimal control problem (OCP), which can be recast as a linear eigenvalue problem for the infinitesimal generator of the unbiased dynamics. We demonstrate that data-driven learning methods for the generator enable reliable solution of the OCP, computation of biasing potentials, extraction of equilibrium properties, and acceleration of state transitions. We also explore the relation of the control problem to coarse grained representations and learning of coarse grained dynamics.

physics.comp-ph↗