NuMagSANS: a GPU-accelerated open-source software package for the generic computation of nuclear and magnetic small-angle neutron scattering observables of complex systems
We present NuMagSANS, a GPU-accelerated software package for calculating nuclear and magnetic small-angle neutron scattering (SANS) cross sections and correlation functions. The program allows users to import position-dependent nuclear density and magnetization data, providing a large flexibility for analyzing the scattering signatures of complex systems, particularly magnetic materials. Full rotational control of the sample is supported, allowing a comprehensive exploration of angular-dependent scattering features. NuMagSANS includes a versatile library of approximately 100 response functions that encompass two-dimensional SANS cross sections, correlation functions, and azimuthally averaged quantities. These capabilities allow users to gain detailed insight into the structural and magnetic characteristics of their samples. GPU acceleration ensures rapid computations, even for large data sets, making NuMagSANS a powerful and efficient tool for advanced SANS analysis.
💡 Research Summary
The paper introduces NuMagSANS, an open‑source, GPU‑accelerated software package designed to compute nuclear and magnetic small‑angle neutron scattering (SANS) observables for structurally and magnetically complex systems. By accepting real‑space maps of nuclear scattering‑length density N(r) and magnetization vector M(r) as input, NuMagSANS evaluates the corresponding Fourier transforms on a discrete grid and constructs a comprehensive set of scattering cross‑sections, including pure nuclear, pure magnetic, nuclear‑magnetic interference, and polarized (POLARIS, SANSPOL) contributions. Approximately one hundred pre‑implemented response functions cover unpolarized, spin‑flip, non‑spin‑flip, chiral, and azimuthally averaged quantities, allowing users to select the appropriate formulation with a single command.
The core of the package is written in C++ and CUDA. Parallelization exploits the massive thread count of modern NVIDIA GPUs: the discrete Fourier sums are performed in block‑wise kernels, shared memory is used to reduce global memory traffic, and the computation scales linearly with the number of q‑points. Benchmarks reported in the manuscript show speed‑ups of one to two orders of magnitude compared with traditional CPU‑only codes, enabling the analysis of large three‑dimensional data sets (e.g., 512³ voxels) within minutes. The software requires only the NVIDIA compiler (nvcc) and runs on Linux, macOS, and Windows without external dependencies.
A key feature is full rotational control of the sample. Users specify the guide‑field direction via a unit vector (\hat{P}) and can apply arbitrary Euler rotations, which are automatically incorporated into the scattering geometry. The program assumes the incident neutron beam along the x‑axis and the detector in the y‑z plane, so that, under the small‑angle approximation, the scattering vector has only y and z components. This geometry simplifies the expressions for the Halpern‑Johnson vector (\mathbf{e}_Q) and allows analytic forms for the various polarized cross‑sections (Eqs. 9‑22 in the manuscript). The software also implements the projection term (d\Sigma_P/d\Omega) as a modular building block, facilitating the construction of all experimentally accessible cross‑sections.
NuMagSANS integrates seamlessly with micromagnetic simulation tools such as MuMax3. Spin configurations generated by MuMax3 can be exported directly as magnetization grids and fed into NuMagSANS, eliminating the need for intermediate data processing. This capability is demonstrated on several case studies: Néel surface‑anisotropy nanoparticles, randomly oriented Stoner‑Wohlfarth particles, defect‑laden magnetic nanoparticles, vortex‑type spin textures, and Dzyaloshinskii‑Moriya‑induced spin‑flip scattering. In each example the software reproduces known angular anisotropies (e.g., (\sin2\theta\cos2\theta) patterns) and isolates form‑factor versus structure‑factor contributions, thereby providing insight into inter‑particle correlations and magnetic interactions.
The package includes advanced analysis tools beyond simple azimuthal averaging. Two‑dimensional scattering patterns can be decomposed into sine and cosine harmonics up to a user‑defined order (k_{\max}), yielding modal intensities (I_c^k(q)) and (I_s^k(q)). These modal amplitudes quantify the degree of anisotropy and can be used to detect subtle chiral contributions, which otherwise average to zero in the conventional azimuthal integral. Numerical integration employs the trapezoidal rule, and the code outputs both the full 2D maps and the 1D radially averaged intensity (I(q)).
All benchmark data sets (four in total) are deposited on Zenodo, providing reproducible inputs, NuMagSANS configuration files, and visualization scripts. The source code is hosted on GitHub under the permissive MIT license, encouraging community contributions and extensions. Current limitations include the omission of nuclear spin‑dependent scattering and the need for external spin‑leakage correction tools (e.g., Pol‑Corr, GRASP) for polarized measurements. Future development plans mentioned by the authors involve adding nuclear spin terms, multi‑GPU scaling, and a graphical user interface for real‑time experimental feedback.
In summary, NuMagSANS offers a powerful, flexible, and high‑performance platform for the quantitative analysis of nuclear and magnetic SANS data from complex materials. By combining GPU acceleration, a rich library of analytical response functions, full rotational control, and direct coupling to micromagnetic simulations, it substantially lowers the computational barrier for researchers investigating advanced magnetic nanostructures, skyrmion lattices, and hybrid nuclear‑magnetic systems.
Comments & Academic Discussion
Loading comments...
Leave a Comment