CuPyMag: GPU-accelerated finite-element micromagnetics with magnetostriction

We introduce CuPyMag , an open-source, Python-based framework for large-scale micromagnetic simulations with magnetostriction. CuPyMag solves micromagnetics with finite elements in a GPU-resident workflow in which key operations, such as right-hand-side assembly, spatial derivatives, and volume averages, are tensorized using CuPy’s BLAS-accelerated backend. Benchmark tests show that the GPU solvers in CuPyMag achieve a speedup of up to two orders of magnitude compared to the CPU codes. Its runtime grows linearly/sublinearly with problem size, demonstrating high efficiency. Additionally, CuPyMag uses the Gauss-Seidel projection method for time integration, which not only allows stable time steps (up to 11 ps) but also solves each governing equation with only 1–3 conjugate-gradient iterations without preconditioning. CuPyMag accounts for magnetoelastic coupling and far-field effects arising from the boundary of the magnetic body, both of which play an important role in magnetization reversal in the presence of local defects. CuPyMag solves these computationally-intensive multiphysics simulations with a high-resolution mesh (up to 3M nodes) in under three hours on an NVIDIA H200 GPU. This acceleration enables micromagnetic simulations with non-trivial defect geometries and resolves nanoscale magnetic structures. It expands the scope of micromagnetic simulations towards realistic, large-scale problems that can guide experiments. More broadly, CuPyMag is developed using widely adopted Python libraries, which provide cross-platform compatibility, ease of installation, and accessibility for adaptations to diverse applications. Program Title: CuPyMag CPC Library link to program files: https://doi.org/10.17632/pmkz4vzz7w.1 Developer’s repository link: https://github.com/hongyiguan/CuPyMag OSF repository link: https://osf.io/6nmsv/?view_only=dbd8fa339f8740a6bd009c03499ea23f Licensing provisions: Apache-2.0 Programming language: Python 3 Nature of problem: The program addresses large-scale micromagnetic simulations that are computationally demanding due to the solution of magnetoelastic coupling (mechanical equilibrium with magnetostriction at each time step), far-field demagnetization effects, and arbitrarily shaped inclusion-like defects that require unstructured finite-element meshes. Solution method: CuPyMag implements a GPU-resident, tensorized workflow built on CuPy’s BLAS-accelerated backend. This design exploits highly optimized linear algebra kernels, enabling efficient parallel execution and maintaining high GPU utilization. It uses an ellipsoid theorem to account for far-field demagnetization effects, and the Gauss-Seidel projection method for stable and efficient time integration.

Authors

Institutions

Publication Details

Journal
Computer Physics Communications
Published
2026-02-22
DOI
https://doi.org/10.1016/j.cpc.2026.110093
Primary Topic
Magnetic properties of thin films
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

CuPyMag: GPU-accelerated finite-element micromagnetics with magnetostriction

Hongyi Guan, Ananya Renuka Balakrishna
Computer Physics Communications
Magnetic properties of thin films
article

CuPyMag: GPU-accelerated finite-element micromagnetics with magnetostriction

Hongyi Guan, Ananya Renuka Balakrishna
article en

Abstract

We introduce CuPyMag , an open-source, Python-based framework for large-scale micromagnetic simulations with magnetostriction. CuPyMag solves micromagnetics with finite elements in a GPU-resident workflow in which key operations, such as right-hand-side assembly, spatial derivatives, and volume averages, are tensorized using CuPy’s BLAS-accelerated backend. Benchmark tests show that the GPU solvers in CuPyMag achieve a speedup of up to two orders of magnitude compared to the CPU codes. Its runtime grows linearly/sublinearly with problem size, demonstrating high efficiency. Additionally, CuPyMag uses the Gauss-Seidel projection method for time integration, which not only allows stable time steps (up to 11 ps) but also solves each governing equation with only 1–3 conjugate-gradient iterations without preconditioning. CuPyMag accounts for magnetoelastic coupling and far-field effects arising from the boundary of the magnetic body, both of which play an important role in magnetization reversal in the presence of local defects. CuPyMag solves these computationally-intensive multiphysics simulations with a high-resolution mesh (up to 3M nodes) in under three hours on an NVIDIA H200 GPU. This acceleration enables micromagnetic simulations with non-trivial defect geometries and resolves nanoscale magnetic structures. It expands the scope of micromagnetic simulations towards realistic, large-scale problems that can guide experiments. More broadly, CuPyMag is developed using widely adopted Python libraries, which provide cross-platform compatibility, ease of installation, and accessibility for adaptations to diverse applications. Program Title: CuPyMag CPC Library link to program files: https://doi.org/10.17632/pmkz4vzz7w.1 Developer’s repository link: https://github.com/hongyiguan/CuPyMag OSF repository link: https://osf.io/6nmsv/?view_only=dbd8fa339f8740a6bd009c03499ea23f Licensing provisions: Apache-2.0 Programming language: Python 3 Nature of problem: The program addresses large-scale micromagnetic simulations that are computationally demanding due to the solution of magnetoelastic coupling (mechanical equilibrium with magnetostriction at each time step), far-field demagnetization effects, and arbitrarily shaped inclusion-like defects that require unstructured finite-element meshes. Solution method: CuPyMag implements a GPU-resident, tensorized workflow built on CuPy’s BLAS-accelerated backend. This design exploits highly optimized linear algebra kernels, enabling efficient parallel execution and maintaining high GPU utilization. It uses an ellipsoid theorem to account for far-field demagnetization effects, and the Gauss-Seidel projection method for stable and efficient time integration.

Computer Physics CommunicationsVol. 323
University of California, Santa Barbara (US)
Openalex Percentile: Top 46%
Magnetic properties of thin films
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.