{"title":"A new gradient descent divergence cleaning method with optimized high-order low-dissipation TENO schemes for ideal magnetohydrodynamic simulations","authors":"Zeyu Chen , Kuangxu Chen","doi":"10.1016/j.cpc.2025.109744","DOIUrl":null,"url":null,"abstract":"<div><div>In this study, we present a new Gradient Descent Divergence Cleaning (GDDC) method, integrated with optimized high-order low-dissipation Target Essentially Non-Oscillatory (TENO) schemes, for the simulation of ideal magnetohydrodynamic (MHD) flows while ensuring a robust divergence-free constraint. The GDDC method constructs a loss function that quantifies the total divergence error. By computing the gradient of this loss function with respect to the magnetic field, the method integrates seamlessly into the Runge-Kutta time-stepping scheme to enable divergence cleaning consistent with the spatial discretization in a discrete sense. Unlike traditional divergence cleaning methods that depend on a non-physical variable <em>ψ</em> and associated parameters controlling its transport velocity and decay rate, the GDDC method introduces only a single parameter, <em>η</em>, and preserves the original hyperbolic eigensystem of the ideal MHD equations. Numerical experiments demonstrate that the method is highly insensitive to variations of <em>η</em> across three orders of magnitude. Additionally, we build the GDDC method upon the optimized TENO (TENO-OPT) schemes. Leveraging the TENO schemes' inherent ability to detect discontinuities, dynamic linear weights are used to combine sub-stencils into an optimal large stencil that avoids crossing discontinuities. Extensive numerical tests demonstrate that the GDDC method coupled with the 5th- and 6th-order TENO-OPT schemes effectively captures discontinuities in ideal MHD flows with low dissipation and without spurious oscillations. We developed our code using NVIDIA's CUDA Fortran and evaluated its performance on a single NVIDIA A800 GPU. For an ideal MHD simulation that employs a 5th-order TENO-OPT scheme, each Runge-Kutta time-stepping stage took approximately 1.118 seconds at a grid resolution of 0.268 billion points. Both computational time and GPU memory usage increase linearly with grid size, with roughly 4 million grid points requiring 1 GB of memory. Based on these scaling trends, the enhanced memory capacity of the NVIDIA H200 GPU could theoretically support up to approximately 0.560 billion grid points. The code is available on <span><span>https://github.com/FallenCastle/MHD_GDDC_GPU</span><svg><path></path></svg></span>.</div></div>","PeriodicalId":285,"journal":{"name":"Computer Physics Communications","volume":"315 ","pages":"Article 109744"},"PeriodicalIF":3.4000,"publicationDate":"2025-07-15","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Computer Physics Communications","FirstCategoryId":"101","ListUrlMain":"https://www.sciencedirect.com/science/article/pii/S0010465525002462","RegionNum":2,"RegionCategory":"物理与天体物理","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q1","JCRName":"COMPUTER SCIENCE, INTERDISCIPLINARY APPLICATIONS","Score":null,"Total":0}
引用次数: 0
Abstract
In this study, we present a new Gradient Descent Divergence Cleaning (GDDC) method, integrated with optimized high-order low-dissipation Target Essentially Non-Oscillatory (TENO) schemes, for the simulation of ideal magnetohydrodynamic (MHD) flows while ensuring a robust divergence-free constraint. The GDDC method constructs a loss function that quantifies the total divergence error. By computing the gradient of this loss function with respect to the magnetic field, the method integrates seamlessly into the Runge-Kutta time-stepping scheme to enable divergence cleaning consistent with the spatial discretization in a discrete sense. Unlike traditional divergence cleaning methods that depend on a non-physical variable ψ and associated parameters controlling its transport velocity and decay rate, the GDDC method introduces only a single parameter, η, and preserves the original hyperbolic eigensystem of the ideal MHD equations. Numerical experiments demonstrate that the method is highly insensitive to variations of η across three orders of magnitude. Additionally, we build the GDDC method upon the optimized TENO (TENO-OPT) schemes. Leveraging the TENO schemes' inherent ability to detect discontinuities, dynamic linear weights are used to combine sub-stencils into an optimal large stencil that avoids crossing discontinuities. Extensive numerical tests demonstrate that the GDDC method coupled with the 5th- and 6th-order TENO-OPT schemes effectively captures discontinuities in ideal MHD flows with low dissipation and without spurious oscillations. We developed our code using NVIDIA's CUDA Fortran and evaluated its performance on a single NVIDIA A800 GPU. For an ideal MHD simulation that employs a 5th-order TENO-OPT scheme, each Runge-Kutta time-stepping stage took approximately 1.118 seconds at a grid resolution of 0.268 billion points. Both computational time and GPU memory usage increase linearly with grid size, with roughly 4 million grid points requiring 1 GB of memory. Based on these scaling trends, the enhanced memory capacity of the NVIDIA H200 GPU could theoretically support up to approximately 0.560 billion grid points. The code is available on https://github.com/FallenCastle/MHD_GDDC_GPU.
期刊介绍:
The focus of CPC is on contemporary computational methods and techniques and their implementation, the effectiveness of which will normally be evidenced by the author(s) within the context of a substantive problem in physics. Within this setting CPC publishes two types of paper.
Computer Programs in Physics (CPiP)
These papers describe significant computer programs to be archived in the CPC Program Library which is held in the Mendeley Data repository. The submitted software must be covered by an approved open source licence. Papers and associated computer programs that address a problem of contemporary interest in physics that cannot be solved by current software are particularly encouraged.
Computational Physics Papers (CP)
These are research papers in, but are not limited to, the following themes across computational physics and related disciplines.
mathematical and numerical methods and algorithms;
computational models including those associated with the design, control and analysis of experiments; and
algebraic computation.
Each will normally include software implementation and performance details. The software implementation should, ideally, be available via GitHub, Zenodo or an institutional repository.In addition, research papers on the impact of advanced computer architecture and special purpose computers on computing in the physical sciences and software topics related to, and of importance in, the physical sciences may be considered.