WorksPhysics and Astronomy
Chana: A GPU-Accelerated Adaptive-Mesh Code for General Relativistic Magnetohydrodynamics with Multigroup M1 Neutrino Transport
Abstract
This paper presents Chana, a GPU-accelerated, block-structured adaptive-mesh code for general relativistic magnetohydrodynamics, multigroup M1 neutrino transport, and dynamical spacetime evolution using the Z4c formulation. Each physical module uses independently selected spatial discretizations and ghost-zone widths to balance accuracy and computational cost. Stiff radiation-matter interactions are treated implicitly, with Jacobians calculated analytically from the chain-rules. The code is written in C++20 and it uses MPI and Kokkos 5 for distributed-memory and performance-portable parallelism. The code is validated through a number of GRMHD, radiation transport, and dynamic spacetime tests. For a representative core-collapse supernova configuration with three neutrino species and 12 energy groups per species, the code achieves approximately cell updates per GPU second on NVIDIA A100 GPUs using four-stage RK4 integration. Weak-scaling efficiency remains above 85% up to 256 GPUs on Perlmutter.
Introduction
Core-collapse supernovae (CCSNe) and binary neutron-star (BNS) mergers are among the most energetic transient phenomena in the universe. In such systems, the coupled evolution of multiple physical processes jointly determines the final outcomes. General relativity (GR) governs the spacetime in which all other physical processes happen. Hydrodynamic instabilities such as convection and turbulence can aid the explosions and change the evolution of both compact objects and ejecta. Strong magnetic fields either inherited from progenitors or amplified by dynamos redistribute energy and angular momentum and may launch relativistic outflows. Neutrinos carry a major fraction of released energy, while neutrino-matter interactions exchange energy with the fluid and determine its electron fraction, with direct consequences on the dynamics and nucleosynthesis of the ejecta. Predictive numerical simulations of such systems must therefore combine GR, magnetohydrodynamics (MHD), and radiation transport in a single framework. In addition, these systems naturally span a large range of spatial scales. The compact central objects, shocks, and (magneto)hydrodynamic instability structures all require high spatial resolution, while the computational domain must extend far enough to follow the expanding ejecta. Mesh refinement concentrates resolution where it is needed and is therefore essential for extending multi-physics calculations to spatial scales and evolution times relevant for astrophysical phenomena. Adaptive refinement allows the mesh to follow evolving structures as compact objects move, shocks propagate, and ejecta expand. The computational cost of these coupled calculations also motivates implementations that exploit GPU-based supercomputers.
Significant efforts have been made along such paths. General-relativistic MHD codes have reached high levels of robustness and parallel scalability and some have developed mature GPU-accelerated AMR implementations ([24, 40, 18, 41, 15, 32]). Multi-group radiation-hydrodynamics codes with approximate GR treatments, frequently equipped with static mesh refinement (SMR), have been well established and proven successful in CCSN simulations, yet
Corresponding author: Tianshu Wang
[email protected] only a small number of them have been ported to GPUs ([30, 17, 37, 5, 26, 11]). When combined with fully relativistic dynamical spacetime, more approximate radiation transport schemes such as grey M1 and multi-group M0 methods are commonly used ([12, 34, 2, 33]). A smaller number of CPU codes that evolve general-relativistic radiation-hydrodynamics with multi-group M1 radiation transport have also been developed in the past years ([35, 22, 1]), but the high computational cost of the scheme remains a bottleneck. Very recently, Kuroda & Shibata [21] presented ANRe-M1, a GPU-accelerated code coupling dynamical spacetime evolution to multi-group M1 neutrino radiation hydrodynamics on a fixed mesh-refinement hierarchy, which is a performance-portable upgrade of the Kuroda et al. [22] code.
This paper presents CHANA (刹那, “in an instant”), a GPU-accelerated adaptive mesh refinement code that evolves general relativistic magnetohydrodynamics, multi-group M1 neutrino transport, and dynamical spacetime using the Z4c formulation within a coupled numerical framework. The physics modules may be evolved jointly, or separately with the remaining sectors disabled or held fixed. The code allows each physical module to select its own spatial order and ghost widths, allowing computational cost and accuracy to be balanced separately for each module. The code is written in C++20. MPI provides distributed-memory parallelism, while Kokkos 5 (Trott et al. [44]) provides on-node execution on CPUs and GPUs. When available, GPU-aware MPI can be utilized.
The paper is arranged as follows. § 2 gives the physical equations solved by the code. § 3 describes the numerical implementation, and § 4 presents the verification tests and performance measurements. Finally, § 5 summarizes the results.
Equations
We summarize here the physical equations for the coupled system.
Conventions and units
The equations below are written in geometrized units, , with metric signature . Greek indices run over spacetime and Latin indices run over space.
The spacetime is decomposed as
with being the normal observer. Here , , and are the lapse, shift, and spatial metric, respectively. We write , and denote by the covariant derivative compatible with , so that for a spatial vector , . The extrinsic curvature of the slice is
General-relativistic magnetohydrodynamics
The fluid is described by its fluid-frame density , pressure , specific internal energy , electron fraction , spatial coordinate components of the fluid four-velocity, and magnetic four-vector measured in the fluid frame . The total fluid-magnetic stress-energy tensor and the dual electromagnetic field tensor are then written as:
The coupled GRMHD equations are:
where is the dual electromagnetic tensor, is the radiation four-force on the matter, and converts the exchanged neutrino energy into electron lepton number. The sign of is positive for , negative for , and zero for heavy-lepton neutrinos. Accurate lepton-number conservation without separately evolving neutrino number requires a compatible discretization, which is described in § 3.7. The subscript runs over the different radiation species and is the fluid-frame photon/neutrino energy. The equation of state closes the fluid system through .
Let
be the fluid three-velocity measured by the Eulerian observer, its Lorentz factor, and the coordinate transport velocity, and let be the magnetic field measured by that observer (the factor is absorbed into the field’s normalization). The above GRMHD equations can be put into a more useful form:
where
General-relativistic M1 neutrino transport
For each species and fluid-frame energy where is the photon/neutrino four-momentum, the radiation stress-energy tensor is decomposed with respect to the Eulerian observer as
where , , and are the Eulerian radiation energy density, flux, and pressure tensor per unit energy. The zeroth and first angular moments obey
in which the energy derivative involves the third-rank moment .
Writing the equations in a similar conservative form as Eq. (6) (suppressing the and subscripts), one gets
Dynamical spacetime
The code evolves Einstein’s equations in the Z4c formulation of Bernuzzi & Hilditch [3]. The implementation closely follows the equations and gauge choices in Daszuta et al. [10] and Zhu et al. [49], which are briefly listed below:
Write for the Ricci tensor of and for its trace, and define the matter projections
in which the energy-momentum-stress tensor contains both GRMHD and radiation contributions, and introduce
with , and the spatial components of the auxiliary dynamical vector field in the Z4 formulation, the Z4c equations are then written as
where TF denotes the trace-free part with respect to the conformal metric. The following 1 + log lapse variant of the puncture gauge is used:
The intrinsic curvature is decomposed as , where
with compatible with .
Numerical Implementation
Mesh
The coordinate system in Chana is logically Cartesian and is tiled by uniform mesh blocks. Each block contains active cells, where the even block size is selected at compile time. Adaptive refinement uses
an octree: a refined block is replaced by eight children with half the cell spacing in each direction, and neighboring leaf blocks are kept within one refinement level. Each block stores its face-, edge-, and corner-neighbor relations, including periodic images and coarse-fine interfaces. Therefore, a block may have up to 56 neighbors that it needs to communicate with. Chana supports up to four independent refine/coarsen indicators at once. The currently implemented estimators include Löhner [25]-type normalized second-difference indicators on any selected cell-centered variables, indicators based on fractional change across cells of any selected cell-centered variables, an indicator based on pressure-scale-height, an indicator based on Mach number change, a Z4c indicator, and a min indicator. Blocks are padded by ghost zones filled by direct exchange at equal resolution and by restriction or prolongation across refinement boundaries, or by physical boundary conditions at the edge of the domain. The size of ghost regions is chosen to be module-dependent because different reconstruction methods can be used by different physical modules (MHD, radiation, and Z4c) at the same time, which will be discussed with more details next.
Discretization, Reconstruction, Restriction, and Prolongation
The code currently supports the following reconstruction methods for cell-centered variables: piecewise constant; piecewise linear, with either the minmod or the monotonized central (MC) limiter (Mignone [27]); and weighted essentially non-oscillatory (WENO) schemes including 3rd-order WENO3 (Jiang & Shu [16]), 5th-order WENO-Z (Borges et al. [4]), and 7th-order WENO7 (Gerolymos et al. [14]). The code allows different variables to use different discretization/reconstruction methods and ghost widths. This flexibility allows the cheaper piecewise linear reconstruction methods to be used for the expensive radiation sector, while maintaining a higher spatial order for the Z4c sector. By default, the spatial differencing in the Z4c module uses sixth-order centered stencils on four ghost layers.
Prolongation and restriction are done in a similar flexible way. Following Zhu et al. [49], the Z4c variables are prolongated and restricted by Lagrange polynomials over stencils that fully utilize the available ghost layers (order for ghost layers, so 5th order at coarse-fine interface when 6th order differencing is used). The restriction of hydrodynamic and radiation conservative variables uses volume averaging, while their prolongation is done using the piecewise linear method with the minmod limiter by default. This choice limits the spatial order of the radiation-magnetohydrodynamics to second order at coarse-fine interfaces, but is more stable as minmod creates unphysical structures around the interfaces much less frequently than sharper methods ([40]). The restriction of face-centered magnetic fields is done via a face-average, while the prolongation uses the method of Tóth & Roe [43]. The cell-centered magnetic fields of the prolongated/restricted cells are then derived from the face-centered variables.
Time integration
The default integrator is the ten-stage, fourth-order explicit strong-stability-preserving (SSP) Runge-Kutta (RK) method eSSPRK(10, 4) of Ketcheson [19]. Although this method needs more stages per step than the standard RK4, its larger stability region allows larger time step choices, which makes the actual cost per unit simulation time comparable while keeping the SSP property. In terms of memory cost, this method has a low-storage form which needs only two saved state vectors beyond the current solution vector. The standard RK4 integrator is also supported. The per-step computation cost of each time integrator is roughly proportional to the number of stages per step.
Riemann solver
At each face, an orthonormal frame adapted to the face normal is constructed following Kiuchi et al. [20]. The Riemann problem is solved in that frame and the resulting flux is transformed back and densitized. The code supports relativistic HLLE/HLLC/HLLD solvers. The relativistic HLLC/HLLD solvers are implemented closely following Kiuchi et al. [20]. These advanced Riemann solvers involve a nonlinear root finding which may not converge, and if that happens the Riemann solver falls back to the more stable HLLE case. The HLLC/HLLD solvers can develop instabilities near strong grid-aligned shocks. In non-relativistic HLLD solvers, Minoshima & Miyoshi [29] stabilizes the solver by introducing a shock-detection factor, whose generalization to relativistic cases needs further study. Currently, whenever a shock is detected, the code switches to HLLE in a buffer region covering the shock. The size of the buffer region depends on the size of ghost halos.
Constrained Transport
The MHD discretization carries three staggered magnetic quantities: edge-centered EMF , face-centered primary magnetic field , and cell-centered derived magnetic field . At each stage of the time integrator, the face-centered magnetic field is updated by the EMFs on the four edges of the face, which are constructed with the upwind CT prescription of Gardiner & Stone [13]. This keeps the magnetic field divergence unchanged to round-off. After the face field is advanced, is derived from the adjacent face values and then coupled to the cell-centered fluid state. At a refinement boundary the coarse edge EMF value is overwritten by the average of the fine sub-edges that lie on it. Similarly, the coarse face fluxes are overwritten by the area average of fine faces’ fluxes.
In addition to the ideal-MHD EMFs, the code supports resistivity and -dynamo terms. An arbitrary edge- or cell-centered function of the primitive state can be defined and added to the ideal-MHD EMFs. For cell-centered functions, the edge will get the average over its four incident cells.
M1 Closure
To close the M1 radiation transport equations, a closure relation that calculates and from and is needed. This is typically done by interpolating between the optically thin and thick limits using the Eddington factor (e.g., [36]). Importantly, to reproduce the correct diffusion limit, this Eddington factor generally needs to be evaluated in the fluid frame, while the Eulerian to fluid frame transformation depends on the closure itself. This leads to a non-linear root-finding problem whenever a frame transformation is needed, which complicates the calculation especially when it’s involved in the implicit radiation-matter coupling and results in a nested nonlinear root-finding problem.
This issue can be partly solved if the closure itself is Lorentz covariant and can be evaluated in the Eulerian frame to avoid the root finding. One example of Lorentz covariant closures is the Levermore closure (Levermore 1984), because the assumption it’s derived from, that there exists a unique frame (the radiation rest frame) in which the radiation field is isotropic, is Lorentz covariant. At diffusion limit, the Levermore closure automatically gives the correct behavior because the fluid frame itself becomes the radiation rest frame, even if the closure is evaluated in the Eulerian frame. In addition to this physical argument, a numerical test of diffusion-limit on a moving medium is presented in § 4.4. Because of its Lorentz covariance, the Levermore closure is the default choice in CHANA, while the standard nonlinear root-finding for a general closure choice is also implemented following Radice et al. [34]. Although there are a number of other closure choices in the literature ([31]), [47] found that closure choices produced comparatively small changes in the CCSN simulations. The importance of closure choices in other astrophysical settings remains uncertain.
When the Levermore closure is used, the pressure tensor is closed algebraically in the Eulerian frame, where flux factor and Eddington factor are calculated as
and the pressure tensor is expressed as
The third moment needed by the energy-space source is constructed from the same stress tensor in the fluid frame (Shibata et al. [36]). The fluid-frame zeroth (), first (), and second moments () are written as:
The fluid-frame flux factor used by the third-moment closure is
where is the spatial projector orthogonal to . Note that the expressions of and are not directly derived from the radiation-rest frame assumption of the Levermore closure and don’t automatically give the correct fluid-frame diffusion-limit. This is why the flux factor has to be evaluated in the fluid frame. In principle, these coefficients can be derived self-consistently from the Lorentz covariant Levermore closure (Vaytet et al. [46]), but for simplicity we choose this approximate expression. The third angular moment is then
Radiation fluxes
The default method to calculate the spatial numerical flux at a face is the second-order method in Radice et al. [34]:
where coefficient is the larger of the light-cone speeds in the two cells sharing the face,
the optical-depth factor is
with and being the absorption and scattering opacities, and the flux limiter is computed via
When the above fluxes are used, the radiation module doesn’t require any reconstruction onto cell faces and is cheaper and more diffusive than the HLL fluxes calculated from face states reconstructed by the PLM method which is also second order. Stronger diffusion is a double-edged sword: it makes the simulation significantly more stable, but it’s also less accurate. Importantly, the flux formula of Eq. (20) is intrinsically second-order and cannot benefit from higher-order reconstruction methods. Therefore, the HLL fluxes are also implemented for completeness, which can be coupled to an arbitrary order of reconstruction method. However, the fluxes of Eq. (20) are still the default choice because of their performance advantages.
The frequency-space drift is advanced separately as a conservative flux on the internal energy-group edges, following the method of Kuroda et al. [22]. With the group center and the moment per unit energy (representing the fluid-frame moments ), the face value is
where the weights are
with and the group-integrated energy density.
The drift constructed from the moments at group faces is:
Since is linear in the moments at fixed and the weights are scalars shared by all moments, this is equivalent to applying the weights of Eq. (24) to and directly, which is how it is evaluated in the code.
The energy-space derivative is discretized as
Substituting Eq. (24) turns it into a difference of edge fluxes in which each side is weighted by the center energy of the opposite group,
These fluxes are then multiplied by when applied to the conserved radiation state. The above implementation maintains energy, momentum, and number conservation to good accuracy [22].
Radiation-matter coupling
The interaction terms are expressed using the fluid-frame moments and , whose calculation can be found in Equation (17). For each species and energy group, the four-force is
where , , and are the emissivity, absorption opacity, and scattering opacity supplied by the opacity interface. Such four-force terms are solved implicitly in each RK stage. The unknowns are the six fluid variables together with Eulerian-frame for every species and group, so the system has components. Note that the set of unknowns is different from either the primitive or conservative variables. This is to reduce the amount of work in the implicit solve, since the EOS and opacity tables in the code are usually tabulated in space. The convergence criterion is based on the maximum relative residual in the Eulerian frame ( by default).
Although the Jacobian can be computed from numerical differencing, it is not the preferred method because the expensive residual function will be called a lot of times per iteration. Whenever possible, the code tries to (semi-)analytically calculate the Jacobian. This benefits from the fact that all the table interpolations (EOS, opacity, and when applicable, the closure) are made to return not only the variable values but also the derivatives. As a result, the Jacobian is derived using the chain-rule and additional residual evaluations required by finite differencing are avoided.
In most cases, the Jacobian matrix has a particular structure: each group’s block is independent of every other group, and groups communicate only through the six fluid columns. The solve therefore factors each block, eliminates it, and reduces to a Schur complement in the fluid variables, at a cost linear in the number of groups rather than cubic. But this faster solver will no longer work if energy groups are coupled together via processes like inelastic scattering.
Before doing the full Newton-Raphson solve, cheaper candidate steps using approximate residual functions are attempted first if the cell meets certain criteria. Candidates are accepted only when they satisfy the same exact-residual tolerance as the full nonlinear solve. Two candidate estimators have been implemented. The first one focuses on the low-velocity limit, and the second assumes the Eddington factor is unchanged during the radiation-matter interaction process. These candidate steps cost little extra time compared to the exact solver, but they will save a significant amount of time if candidates are accepted. Therefore, the actual performance depends on the acceptance rates of such candidates, and strongly coupled regions in general cost more than optically-thin regions. To avoid imbalanced workload distribution, a timer module which measures the actual computational cost of each MPI rank is implemented, whose results are fed to the workload balance module.
Optimization
The performance-critical loops in CHANA are written with Kokkos [44], with the local physics routines marked as device-callable so that the same source is compiled for host and accelerator backends. MPI distributes mesh blocks among ranks, while Kokkos parallelizes the blocks owned by each rank. Volume kernels use a single flattened iteration space over blocks and cells (and, where appropriate, variable components), rather than a separate launch for each block. This exposes enough parallelism even when is small.
Variables use a component-major structure-of-arrays layout, with the cells of one component contiguous in memory. Neighboring threads therefore access neighboring cells of the same variable, giving coalesced accesses on GPUs. Several bandwidth-bound operations are fused: in particular, reconstruction, the Riemann solve, and flux divergence can be evaluated in one cell kernel, and each Runge–Kutta update combines all required stage vectors with the right-hand side in one pass. Temporary device buffers are retained and reused across stages, avoiding allocations and their associated synchronization inside the step loop.
The packing and unpacking of each block’s ghost halo are also Kokkos kernels. A team handles one halo segment and vectorizes its contiguous inner direction. Same-rank traffic avoids an additional copy between send and receive buffers, while inter-rank transfers use device buffers with GPU-aware MPI when available and pinned-host staging otherwise. Time-step constraints, error checks, and similar global diagnostics are formed with device reductions, so only their small scalar results are returned to the host.
Test Problems
This section presents several standard tests of the Chana code, covering the relativistic MHD, the radiation transport, and the dynamic spacetime modules.
Linear Wave Tests
The first test checks the spatial operators’ accuracy on smooth linear waves. The relativistic MHD wave tests include the fast, slow, Alfvén, and entropy modes. The background has , a sound speed , and a gamma-law equation of state with . The background magnetic field is and the perturbation amplitude is or . The entropy mode has zero background advection velocity , while the other modes are initialized at rest. The domain is , with waves moving along the direction. For these tests, we use the piecewise-linear reconstruction method with the MC limiter on a uniform mesh, with resolution ladder spans 16, 32, 64, 128, and 256 cells per wavelength. We evolve the waves for one cycle of propagation and then measure the L1 error compared to the initial state. The top panel of Figure 1 shows the error of these MHD waves against a second-order reference slope. All four modes decrease at approximately the expected rate over the plotted range.

Figure 1. Code’s convergence behavior on linear waves. The top panel shows the L1 errors for the fast, slow, Alfvén, and entropy linear MHD waves at different resolutions, while the bottom panel shows that for gravitational waves. In both panels, the code converges at the expected spatial order.
The corresponding Z4c linear wave test evolves a smooth gravitational wave on both a uniform mesh and a mesh with a refined corner octant, following Zhu et al. [49]. The initial data are a transverse-traceless plane wave with amplitude and three wavelengths across the unit cube, propagating along . We use the 6th order spatial differencing scheme, with the fifth order prolongation/restriction scheme. The L1 errors are measured after one wave propagation cycle. Both uniform and refined sequences follow the sixth-order reference trend in the bottom panel of Figure 1. At higher resolution, the corner-refined sequence gradually switches to a fifth order slope, which means that
the prolongation/restriction error starts to dominate. This is consistent to that found in Zhu et al. [49] and at typical resolution of production runs, the prolongation/restriction error is significantly lower than spatial differencing errors.
Relativistic Kelvin-Helmholtz Instability
The Kelvin-Helmholtz instability (KHI) is a standard test for (relativistic) hydrodynamic codes (e.g., [28, 40]). The relativistic KHI in Chana is setup as a two-dimensional SRMHD problem with a domain, resolved by root cells and two refinement levels. The effective resolution is thus cells. The medium is initially set to have , , and , with a uniform field . The shear is and the seed perturbation is . The piecewise linear method with the MC limiter is used, together with both the HLLE and HLLD Riemann solvers.
Figure 2 shows the results at for both Riemann solvers. The relativistic Kelvin–Helmholtz calculation has developed the expected pair of rolled-up shear layers and a central vortex in both cases. The HLLE case reproduces a structure very similar to that presented in Mignone et al. [28], even if the meshes are quite different. This is possibly because the numerical diffusion suppresses the finer structures introduced by the coarse-fine interfaces. The HLLD case with the same spatial resolution shows much finer structures, which is expected because the HLLD solver is less diffusive.

Figure 2. Rest-mass density in the relativistic Kelvin–Helmholtz test at using HLLE and HLLD Riemann solvers. The expected pair of rolled-up shear layers and a central vortex are developed in both cases, while the HLLD solver is significantly less diffusive than the HLLE solver.
Relativistic Magnetized Blast Wave
The evolution of a magnetized blast wave moving at relativistic speeds provides a further test of the relativistic MHD module in the code. A two-dimensional case is considered: inside the density and pressure are , outside they are , and both quantities vary linearly across . The equation of state has and the uniform field is . The uniform run covers with in-plane cells. The AMR run uses the same domain and the block size is chosen to be 8 to build a more flexible AMR hierarchy.
It starts with a root mesh and adds four refinement levels above with a Löhner density indicator (refine/coarsen thresholds 0.02/0.005), reaching the same finest spacing. Both calculations evolved to with a CFL number of 0.3.
Figure 3 shows the results at the end of the simulations. The magnetized blast produces an expanding and strongly anisotropic pressure shell, which is recovered by both the uniform and AMR runs. The maximum fractional difference between uniform and AMR cases is below 2% throughout the domain at , and the RMS fractional difference is .

Figure 3. Pressure in the relativistic magnetized blast wave. The top panel shows the results on a uniform mesh and the middle panel shows the corresponding AMR results at the same finest spacing, together with the AMR hierarchy. The bottom panel shows the fractional differences between the uniform and AMR tests. The maximum fractional difference between uniform and AMR cases is always below two percents, and the RMS fractional error is .
Diffusion Limit in a Moving Medium
The first test on the radiation transport module focuses on the diffusion limit. Since Chana by default uses the Lorentz covariant Levermore closure in the lab-frame instead of the fluid-frame, it’s important to test if it can reproduce the correct diffusion limit in a relativistically moving medium.
This test uses one grey group, a uniform medium moving at 0.5 the speed of light, and pure scattering with . The initial radiation energy is a Gaussian , with its flux set to the fully trapped comoving value so that the pulse translates with the fluid from the beginning [34]. The spatial resolution is set to be .
Figure 4 shows the test results at and . At both times, the numerical energy-density profile lies on the analytic translated and diffused solution over the entire domain. This means that the flux treatment described in § 3.7 together with the Levermore closure evaluated in the Eulerian frame is able to give the correct diffusion-limit behavior in this case. Radice et al. [34] has also discussed that the full radiation-matter coupling treatment is required to capture the behavior of the trapped radiation, while approximate solvers may give wrong advection speeds or rates of diffusion. Therefore, this test also partly validates Chana’s radiation-matter coupling implementation. Although candidate solutions are proposed by approximate solvers, they are accepted only if the convergence criterion based on the exact residual function is satisfied.

Figure 4. Moving diffusion test at and . The analytic solution is shown as black dashed lines, while the markers depict the numerical result. At both times, the numerical energy-density profile lies on the analytic translated and diffused solution over the entire domain.
Doppler and Gravitational Shifts
The two cases shown in this subsection test the frequency-space operator with an emitting sphere whose radiation propagates through a transparent medium, following Anninos & Fragile [1]. For a more straightforward comparison to the same test in that paper, units and physical constants are put back in the following description.
The sphere has km and emits a 5 MeV Fermi-Dirac spectrum sampled by 30 logarithmic groups between 1 and 50 MeV. The radial domain is , represented by 400 cells, and the final time is two light-crossing times.
For the Doppler test the metric is flat and the prescribed infall velocity is zero for km, decreases linearly to at km, and follows further out. For the gravitational test the matter is at rest and the metric is generated by a uniform sphere of density . With , the prescribed potential and lapse are
The exact mean energy outside the emitting region follows from conservation of the radiation energy along a stationary characteristic,
where is the discrete mean of the emitted groups. The Doppler test has , while the gravitational test has .
The final profiles in Figure 5 show the simulated group-weighted mean energy against Eq. (30). The Doppler profile follows the prescribed blueshift through the velocity ramp and returns toward the emitted value as the infall speed decreases outside the ramp, while the gravitational profile decreases monotonically with radius. The good agreement between the numerical results and the exact solutions shows that the frequency-space drift treatment described in § 3.7 works accurately.

Figure 5. Mean radiation energy outside the emitting sphere for the Doppler (top) and gravitational-redshift (bottom) tests. The blue points are the numerical group-weighted means and the black dashed curves are the exact stationary-shift laws given by Eq. (30). The good agreement between numerical results and the exact solutions shows that the frequency-space drift treatment described in § 3.7 works accurately.
Cylinder Shadow
The first multi-dimension test on the radiation module is a cylinder shadow test, in which an initially uniform radiation field is attenuated by an absorbing cylinder. This is an one-group M1 calculation on a frozen matter reservoir in flat spacetime. The domain is , resolved by cells. The cylinder has radius one, absorption opacity and zero scattering inside, giving a central optical depth of two. Medium outside the cylinder is set to . Radiation starts at a negligible floor and a unit, forward-peaked beam is injected through the left boundary.
The energy-density map in Figure 6 shows the persistent low-density shadow downstream of the obstacle. On a transverse probe, the numerical profile follows the analytic attenuation closely, while the visible discrepancy is confined to the smoothed shadow edges. This shows that the second-order spatial flux is slightly over-diffusive, but given its stability and simplicity we still use it as the default choice.

Figure 6. Results of the cylindrical shadow test at . The top panel shows the spatial distribution of radiation energy density with the cylinder boundary marked by a circle. The bottom panel compares the numerical energy distribution on a transverse probe (indicated by the black dashed line in the top panel) with the analytical attenuation. The numerical profile follows the analytic solution closely, while some discrepancies can be seen at the smoothed shadow edges. The mismatch is caused by the slightly over-diffusive spatial flux solver.
Radiation Beam Near a Black Hole
The next test focuses on the spacetime curvature terms in Chana. This is a five-group, zero-opacity M1 calculation on a frozen Schwarzschild metric in Kerr-Schild coordinates. The domain is , with in code units, and is resolved by cells (). The initial radiation is a low-amplitude background, while a beam of half-width and unit energy is injected at along through the left boundary. Since the opacity is identically zero and the metric is held fixed, each group follows the same null-geodesic problem, and the reference curves are the corresponding analytic Kerr-Schild characteristics. The test uses a CFL number of 0.3 and is evolved to .
The normalized energy density in Figure 7 remains concentrated between the two reference characteristics as the beam bends toward increasing and decreasing . The front broadens gradually due to the over-diffusive spatial radiation flux, but the trajectory remains aligned with the curved reference paths across the plotted domain. This broadening is due to the more diffusive spatial flux, and the results closely reproduce that in Radice et al. [34] which uses the same method.

Figure 7. Normalized radiation energy density for the beam propagating near a black hole. The green curves mark the reference characteristic paths, and the radiation energy remains concentrated between them. The front broadens gradually due to the over-diffusive spatial radiation flux, but the trajectory remains aligned with the curved reference paths across the plotted domain.
Evolution of Binary Punctures
A binary puncture test is presented to demonstrate Chana’s capability to simulate dynamic spacetimes. We use the total ADM mass as the unit of length and time. The initial data contain two nonspinning punctures with bare masses at , with equal and opposite momenta and . The computational cube is , with seven root blocks per direction and eight refinement levels. Each block has eight cells along each dimension, which is the smallest allowed block size with the 6th order spatial differencing method. This small block size leads to a more flexible AMR hierarchy and thus add extra pressure to the AMR and halo exchange modules. The criterion is used with refine/coarsen thresholds set to 0.03 and 0.005, respectively. A shift damping of and constraint damping are used, with the K.O. dissipation parameter set to be 0.5. The test is evolved to .
Figure 8 shows the lapse and refinement pattern at . The tracked punctures remain resolved by the nested refinement levels. The imbalance between the refine and coarsen criteria leads to the asymmetric block

Figure 8. Results of the binary-puncture test at . The color shows the lapse, the black mesh lines show the AMR hierarchy, and the cyan curves show the tracked puncture trajectories. The asymmetric block distribution around the punctures is caused by the imbalance between the refine and coarsen criteria. The puncture trajectories are in good agreement with the results calculated by AthenaK (Zhu et al. [49]).
distribution around the punctures, because the coarsening is delayed compared to refining as the punctures move. The puncture trajectories are in good agreement with the results calculated by AthenaK (Zhu et al. [49]), despite of the very different AMR hierarchy and block sizes1.
Collapse of A Neutron Star
Finally, the code’s dynamic spacetime capability in a non-vacuum spacetime is validated by a neutron star collapse test. The initial data are a , polytrope (in units of ), with a central density of , just below that of the maximum-mass configuration. Solving the TOV equations gives a gravitational mass of , an areal radius of , and a baryonic mass of . Outside the star is an atmosphere of on the same polytrope, and the matter is evolved with a ideal-gas equation of state. The initial spacetime is the TOV metric in isotropic coordinates, i.e., conformally flat with zero shift and zero extrinsic curvature, and the matter is cell-averaged onto the mesh with a Gauss-Legendre quadrature. The collapse is triggered by reducing the pressure and internal energy of the matter by 5% after the hydrostatic initialization solve, which leaves the star with more baryonic mass than any equilibrium of the depleted polytrope can support. The metric is resolved after this reduction using the method described in Cordero-Carrión et al. [9] and total mass-energy of the initial data is then 1.628 .
The computational domain is km, covered by four root blocks per direction, each with cells. Three levels of refinement are placed around the star, so the finest spacing is 0.25 km over km. The indicator with a refine threshold of 0.02 is used. With as the unit, the shift damping is and the constraint damping is with , and the K.O. dissipation parameter is set to be 0.5. The piecewise linear method with the MC limiter and the HLLE Riemann solver are used for the matter, and the Z4c uses the 6th order spatial differencing scheme. The test is evolved with a CFL number of 0.3 to ms .
Figure 9 shows results of this test. The top panel shows the lapse profile along the -axis at different times, while the bottom panel shows a snapshot at ms together with the apparent horizon and AMR hierarchy. The central lapse starts at 0.471, decreases slowly during the first 0.2 ms, drops rapidly between 0.3 and 0.5 ms as the star collapses, and then settles to at the grid point nearest to the center. The lapse profiles after 0.6 ms nearly overlap each other, showing that the 1 + log slicing and the Gamma-driver shift have brought the spacetime to the expected stationary trumpet-like slice of a black hole. The apparent horizon, found as the outermost sphere with zero outgoing null expansion assuming spherical symmetry, first appears at ms. Its coordinate radius drifts slowly from 2.55 to 2.73 km as the gauge evolves, while its areal radius stays at 4.81 km, giving a black hole mass of . By ms all of the matter is inside the horizon and the baryonic mass is conserved to better than . Since a spherical collapse emits no gravitational waves, the black hole should carry the mass-energy of the initial data, in agreement with the measured value to 0.2%.

Figure 9. Results of the neutron star collapse test. The top panel shows the lapse along the axis every 0.1 ms, colored by time. The profiles after 0.6 ms nearly overlap each other, showing that the spacetime has settled into a stationary slice of a black hole. The bottom panel shows the lapse in the plane at ms, with the black mesh lines showing the AMR hierarchy and the black dashed circle marking the apparent horizon, whose areal radius gives a black hole mass of 1.630 .
Performance
The performance of Chana is measured using Nvidia A100 GPUs on the Perlmutter supercomputer of National Energy Research Scientific Computing (NERSC). The setup is a core-collapse supernova case, and the initial condition is set to be an 18 model from Sukhbold et al. [42], evolved to 10 milliseconds post-bounce so that neutrino radiation is strong. The tabulated SFHo equation of state (Steiner et al. [39]) is used, while neutrino-matter interaction rates are taken from Burrows et al. [7], the same as those used in Fornax CCSN simulations (Skinner et al. [37]; Vartanyan et al. [45]; Burrows et al. [6, 8]; Wang & Burrows [48]). There are three neutrino species, each with 12 energy groups. The piecewise-linear method with the MC limiter is used for MHD and radiation variables, while the Z4c uses the 6th order spatial differencing scheme.
The code’s performance with different block sizes is measured. The number of total active cell is chosen to be 524,288=, which is the same order of magnitude of the actual workload of a production simulation. Block sizes of 8, 16, 32, and 64 are tested. The results are 216k, 293k, 334k, and 171k cell-updates per second when the eSSPRK(10, 4) time integrator is used, and with the standard RK4 integrator the numbers become 525k, 714k, 820k, and 421k. The factor of about 2.5 is a direct consequence of the 2.5 times fewer stages per step in the standard RK4 method. The decreasing performance of blocks with 64 cells is because there are only two blocks in the tested domain and block-oriented kernels have very little coarse-grained parallelism. From this test, it can be concluded that a block size of 32 gives the best performance, while a block size of 16 leads to more AMR flexibility but slightly lower computation efficiency. In addition, increasing the number of active cells per GPU improves the GPU performance. Because the size-32 blocks have a lower face-to-bulk ratio and memory cost, each A100 GPU can handle cells (size-8 blocks will lead to out-of-memory), which leads to 445k eSSPRK(10, 4) cell-updates and 1.1M RK4 cell-updates per second. It’s worth mentioning that the code’s performance strongly depends on the acceptance rate of the candidate solutions estimated by the approximate radiation-matter solvers, and the acceptance rate can change significantly in the domain. In the above performance tests, the domain is refined to be the inner 100 km of the CCSN model where neutrinos and matter strongly couples, therefore the acceptance rate is lower. For a more general simulation setup, with many blocks locate at large radii and candidate solutions work well, a higher performance is expected.
The weak-scaling test is done with the block size fixed to 32 and the active cell count per GPU fixed to 1,048,576. The number of blocks in the domain runs from 256 to 8192, while the number of computation nodes are correspondingly increased from 2 to 64. Each node contains four Nvidia A100 GPUs. Figure 10 shows the measured weak-scaling efficiency and number of RK4 cell-updates per second at given node count. The weak-scaling efficiency remains above 85% up to 64 nodes (256 GPUs).

Figure 10. Measured weak-scaling efficiency and number of RK4 cell-updates per second at given node count on Perlmutter. Each node contains four Nvidia A100 GPUs. The measured weak-scaling efficiency remains above 80% up to 64 nodes (256 GPUs).
Summary
This paper presents Chana, a block-structured adaptive-mesh code which evolves general-relativistic magnetohydrodynamics, multi-group M1 neutrino transport, and a dynamical spacetime in the Z4c formulation as one coupled system. Separate ghost widths and separate reconstruction/prolongation/restriction methods allow each physical module to use the stencil appropriate to its numerical method. The implementation is parallelized with MPI and Kokkos and uses flattened block-cell kernels, coalesced structure-of-arrays storage, kernel fusion, and device-side halo packing for efficient execution on GPUs.
A few design choices of the radiation scheme are worth emphasizing again: (a) The Lorentz-covariant Levermore closure is evaluated algebraically in the Eulerian frame, avoiding an additional nonlinear solve. The analytic expression of the Levermore closure allows one to compute its derivatives very easily, which unlocks the next design choice. (b) The stiff matter-radiation interactions are solved implicitly in each RK stage, and importantly, the Jacobian is derived using the chain rule instead of numerical differencing. This avoids the expensive repeated residual calculations, table readings, and closure evaluations during the Newton-Raphson solve. This choice is in particular helpful for GPU performance, because a large fraction of memory-bandwidth-limited scattered table readings are replaced by computation-heavy chain-rule derivative calculations. (c) The second-order method of Radice et al. [34] is used to compute spatial radiation fluxes because it’s deliberately robust and inexpensive. Although the shadow and curved-beam tests show the corresponding numerical diffusion near sharp radiation features in optically-thin regions, such features are rarely found in astrophysical systems Chana intends to model. The HLL fluxes computed from reconstructed face states are also implemented, which can reproduce sharper features when combined with higher-order reconstruction methods. However, the Radice et al. [34] fluxes are used by default because of their performance advantages. The tests exercise the principal components of the code. Linear MHD and gravitational waves converge at the expected spatial order. The Kelvin-Helmholtz instability and relativistic magnetized blast reproduce their expected structures, and the uniform- and adaptive-mesh blast solutions agree to the accuracy selected by the refinement criterion. The radiation module reproduces the analytic diffusion of a pulse moving at , which verifies both the diffusion-limit behavior of the radiation fluxes and the radiation-matter coupling. The radiation module also reproduces the expected Doppler and gravitational energy shifts, attenuation behind an absorbing cylinder, and the bending of a beam along null characteristics. In addition, the binary-puncture calculation and neutron star collapse tests validate the code’s capability to evolve dynamic spacetimes. Finally, the performance is measured for a representative three-species, 12-group CCSN GRRMHD configuration with Nvidia A100 GPUs on Perlmutter. When size-32 blocks are used, the performance rates are approximately cell updates per GPU second with eSSPRK(10, 4) and with RK4 time integrators. The per-step cost is roughly proportional to the number of RK stages per cell update. The weak-scaling efficiency remains above 85% up to 256 GPUs (64 Perlmutter nodes).
Future development of the code includes (but are not limited to): improving the approximate implicit solver of radiation-matter coupling which provides the candidate solutions, overlapping ghost halo exchange more with kernel work on active cells, and improving GPU utilization of each individual kernel. There might be another factor of 1.5 to 2 speedup by changing the time integration scheme. Kuroda & Shibata [21] evolves the Z4c and radiation-hydrodynamics sectors with different time integrators: Z4c with four Runge-Kutta stages, others with two. This means the per-step cost of the most expensive radiation sector is halved, compared to the standard four-stage RK4 method. However, it is unclear how this scheme may impact the robustness of the simulation when spacetime is evolving rapidly, and further tests are desired.
Code availability: Chana is still being developed actively, the author will only provide the code upon collaboration or requests at this moment. After further testing and debugging and more performance optimizations, the code will become publicly available.
Acknowledgments
The development and optimization of the code involves LLM tools including various versions/models of Codex, Claude Code, Gemini, GLM, and OpenCode. The author thanks the many open source projects (e.g., Athena++, AthenaK, Phoebus, WhiskyTHC, etc) and their contributors. The author (and likely the LLM tools) has learned a lot from such projects. The author would like to thank Daniel Kasen, Adam Burrows, and David Radice for the very helpful discussions. The author acknowledges support by the U. S. Department of Energy under grant DE-SC0004658, support by the Gordon and Betty Moore Foundation through Grant GBMF5076, and support through a Simons Foundation grant (622817DK). The author acknowledges the Savio computational cluster resource provided by the Berkeley Research Computing program at the University of California, Berkeley; computational resources provided by the high-performance computer center at Princeton University, which is jointly supported by the Princeton Institute for Computational Science and Engineering (PICSciE) and the Princeton University Office of Information Technology; and allocation at the National Energy Research Scientific Computing Center (NERSC), which is supported by the Office of Science of the U. S. Department of Energy under contract DE-AC02-76SF00098. The author acknowledges access to the Frontera cluster (under awards AST20020 and AST21003). This research is part of the Frontera computing project at the Texas Advanced Computing Center ([38]). Frontera is made possible by NSF award OAC-1818253. Additionally, a generous award of computer time was provided by the INCITE program, enabling this research to use resources of the Argonne Leadership Computing Facility, a DOE Office of Science User Facility supported under Contract DE-AC02-06CH11357.
References
- [1]Anninos, P., & Fragile, P. C. 2020, ApJ, 900, 71
- [2]Barker, B., Gogilashvili, M., Rodriguez-Bueno, J., et al. 2024, arXiv e-prints, arXiv:2410.09146arxiv.org/abs/2410.09146
- [3]Bernuzzi, S., & Hilditch, D. 2010, PhRvD, 81, 084003
- [4]Borges, R., Carmona, M., Costa, B., & Don, W. S. 2008, Journal of Computational Physics, 227, 3191
- [5]Bruenn, S. W., Blondin, J. M., Hix, W. R., et al. 2020, ApJS, 248, 11
- [6]Burrows, A., Radice, D., Vartanyan, D., et al. 2020, MNRAS, 491, 2715
- [7]Burrows, A., Reddy, S., & Thompson, T. A. 2006, Nuclear Physics A, 777, 356
- [8]Burrows, A., Wang, T., & Vartanyan, D. 2024, ApJL, 964, L16
- [9]Cordero-Carrión, I., Cerdá-Durán, P., Dimmelmeier, H., et al. 2009, PhRvD, 79, 024017
- [10]Daszuta, B., Zappa, F., Cook, W., et al. 2021, ApJS, 257, 25
- [11]Endeve, E., Mewes, V., Harris, J. A., et al. 2026, ApJS, 284, 40
- [12]Foucart, F., O’Connor, E., Roberts, L., et al. 2015, PhRvD, 91, 124021
- [13]Gardiner, T. A., & Stone, J. M. 2005, Journal of Computational Physics, 205, 509
- [14]Gerolymos, G. A., Sénéchal, D., & Vallet, I. 2009, Journal of Computational Physics, 228, 8481
- [15]Han, M.-Z., Kiuchi, K., & Shibata, M. 2026, arXiv e-prints, arXiv:2607.08743arxiv.org/abs/2607.08743
- [16]Jiang, G.-S., & Shu, C.-W. 1996, Journal of Computational Physics, 126, 202
- [17]Just, O., Obergaulinger, M., & Janka, H.-T. 2015, MNRAS, 453, 3386
- [18]Kalinani, J. V., Ji, L., Enn oggi, L., et al. 2025, Classical and Quantum Gravity, 42, 025016
- [19]Ketcheson, D. I. 2008, SIAM Journal on Scientific Computing, 30, 2113
- [20]Kiuchi, K., Held, L. E., Sekiguchi, Y., & Shibata, M. 2022, PhRvD, 106, 124041
- [21]Kuroda, T., & Shibata, M. 2026, arXiv e-prints, arXiv:2608.26681arxiv.org/abs/2608.26681
- [22]Kuroda, T., Takiwaki, T., & Kotake, K. 2016, ApJS, 222, 20
- [24]Liska, M. T. P., Chatterjee, K., Issa, D., et al. 2022, ApJS, 263, 26
- [25]Löhner, R. 1987, Computer Methods in Applied Mechanics and Engineering, 61, 323
- [26]Melson, T., Kresse, D., & Janka, H.-T. 2020, ApJ, 891, 27
- [27]Mignone, A. 2014, Journal of Computational Physics, 270, 784
- [28]Mignone, A., Zanni, C., Tzeferacos, P., et al. 2012, ApJS, 198, 7
- [29]Minoshima, T., & Miyoshi, T. 2021, Journal of Computational Physics, 446, 110639
- [30]Müller, B., Janka, H.-T., & Dimmelmeier, H. 2010, ApJS, 189, 104
- [31]Murchikova, E. M., Abdikamalov, E., & Urbatsch, T. 2017, MNRAS, 469, 1725
- [32]Musolino, C., Ecker, C., Topolski, K., et al. 2026, arXiv e-prints, arXiv:2607.09854arxiv.org/abs/2607.09854
- [33]Palenzuela, C., Bezares, M., Liebling, S., et al. 2025, Classical and Quantum Gravity, 42, 245005
- [34]Radice, D., Bernuzzi, S., Perego, A., & Haas, R. 2022, MNRAS, 512, 1499
- [35]Roberts, L. F., Ott, C. D., Haas, R., et al. 2016, ApJ, 831, 98
- [36]Shibata, M., Kiuchi, K., Sekiguchi, Y., & Suwa, Y. 2011, Progress of Theoretical Physics, 125, 1255
- [37]Skinner, M. A., Dolence, J. C., Burrows, A., Radice, D., & Vartanyan, D. 2019, ApJS, 241, 7
- [38]Stanzione, D., West, J., Evans, R. T., et al. 2020, in PEARC ’20, Practice and Experience in Advanced Research Computing, Portland, OR, 106–111
- [39]Steiner, A. W., Hempel, M., & Fischer, T. 2013, ApJ, 774, 17
- [40]Stone, J. M., Tomida, K., White, C. J., & Felker, K. G. 2020, ApJS, 249, 4
- [41]Stone, J. M., Mullen, P. D., Fielding, D., et al. 2026, ApJS, 283, 27
- [42]Sukhbold, T., Woosley, S. E., & Heger, A. 2018, ApJ, 860, 93
- [43]Tóth, G., & Roe, P. L. 2002, Journal of Computational Physics, 180, 736
- [44]Trott, C. R., Lebrun-Grandié, D., Arndt, D., et al. 2022, IEEE Transactions on Parallel and Distributed Systems, 33, 805
- [45]Vartanyan, D., Burrows, A., Radice, D., Skinner, M. A., & Dolence, J. 2019, MNRAS, 482, 351
- [46]Vaytet, N. M. H., Audit, E., Dubroca, B., & Delahaye, F. 2011, JQSRT, 112, 1323
- [47]Wang, T., & Burrows, A. 2023, ApJ, 943, 78
- [48]— 2024, ApJ, 969, 74
- [49]Zhu, H., Fields, J., Zappa, F., et al. 2025, ApJS, 278, 50