betaFeedback

WorksPhysics and Astronomy

A Co-Scaling Grid for Athena++

Abstract

We present a co-scaling grid formalism and its implementation in the magnetohydrodynamics code Athena++. The formalism relies on flow symmetries in astrophysical problems involving expansion, contraction, and center-of-mass motion. The grid is evolved at the same time order as the fluid variables. The user specifies grid evolution laws, which can be independent of the fluid motion. Applying our implementation to standard hydrodynamic test cases leads to improved results and higher efficiency, compared to the fixed-grid solutions.

Introduction

Many astrophysical phenomena involve evolution in length scale over orders of magnitude. Supernova and kilonova ejecta expand from stellar radii to parsecs before fully mixing with the interstellar gas [19, 17, 15]. Ionization and stellar-wind driven supershells expand from the scales of a small stellar association to 10s of parsecs [14], impacting the ambient gas and possibly triggering star formation [4]. Protostellar collapse occurs from parsec-scales to a few astronomical units.

Numerical modeling of phenomena evolving over a large range of scales requires methods capable of adapting the scale of the spatial discretization. Lagrangian methods such as smoothed particle hydrodynamics [16] achieve this by following fluid elements defined by a fixed mass rather than a fixed volume. Eulerian methods - the choice for many applications because conservation laws are more easily realized - require adaptive mesh algorithms to cover similar scale ranges as smoothed particle hydrodynamics [11, 10]. Lagrangian remapping combines elements of Lagrangian methods with those of Eulerian ones, evolving fluid elements in a Lagrangian frame, but continually re-mapping the motion on to an Eulerian grid [13]. A more recent development are moving-mesh codes, solving flux-conservative problems on meshes that move with the fluid in a Lagrangian fashion [8, 22], preserving the strength of finite volume methods over smoothed particle hydrodynamics for some applications [7].

A conceptually simpler alternative to moving-mesh codes exploits possible symmetries in an astrophysical problem. The relativistic hydrodynamic codes JET and DISCO have shown the effectiveness of limiting mesh movement to a particular direction in cylindrical coordinates [3, 2]. While symmetries appear during spherical and cylindrical expansion and contraction, they also appear as ‘co-moving’ motion in a single Cartesian direction. For problems involving a drastic change in spatial scale, a co-scaling grid can be more efficient than adaptive mesh-refinement techniques [20]. If uniformity of dissipative properties is relevant, such as for problems involving turbulent transport, a co-expanding grid may be preferable over adaptive mesh refinement. To make use of these advantages for co-scaling grids, we implemented the method in the Eulerian grid code Athena++ [25]. 1

The grid can be co-moving or rescaled, in both cases retaining the initial cell aspect ratio. The grid evolution is integrated at the same time order as the fluid variables. The motion of cell-walls necessitates additional wall flux terms when updating the fluid variables. The time dependence of the grid scaling is defined by a userspecified function. The co-scaling grid can be combined with the adaptive mesh capabilities of Athena++.

The method improves results of standard test cases. Here, we include the Sod shock tube test and a spherical blast-wave test. The sphericity of multi-dimensional blast-waves is preserved on Cartesian grids by a factor of 3 better than for fixed-grid simulations. While the implementation is a factor ∼1.1\sim1.1 slower across resolutions and processor number than the stock version of Athena++ for standard hydrodynamics, the advantage of the co-scaling grid lies in its ability to cover spatial (and thus dynamical) ranges over orders of magnitude, resulting in a net efficiency gain.

Formalism

Eulerian, ideal magnetohydrodynamics solve the conservation laws

∂UT(x⃗,t)∂t=−∇⃗T⋅Γˉ(x⃗,t).(1)\frac{\partial\mathbf{U}^{T}(\vec{x},t)}{\partial t}=-\vec{\nabla}^{T}\cdot\bar{\mathbf{\Gamma}}(\vec{x},t). \tag*{(1)}

The row vector UT\mathbf{U}^{T} contains the conservative variables. The matrix Γˉ\bar{\mathbf{\Gamma}} has columns with the flux of each conservative quantity. These fluxes have rows corresponding to the various coordinate directions (x^1\hat{x}_{1}, x^2\hat{x}_{2}, and x^3\hat{x}_{3}) (Stone et al. [24]). The length of UT\mathbf{U}^{T} depends on the physics of the problem. For ideal MHD, UT\mathbf{U}^{T} has 8 components and the matrix Γˉ\bar{\mathbf{\Gamma}} has 3 rows and 8 columns. Altogether, the right hand side is the flux divergence. For a Cartesian grid, the matrix Γˉ\bar{\mathbf{\Gamma}} has the form

Γˉ=FTx^+GTy^+HTz^(2)\bar{\mathbf{\Gamma}}=\mathbf{F}^{T}\hat{x}+\mathbf{G}^{T}\hat{y}+\mathbf{H}^{T}\hat{z} \tag*{(2)}

where each boldfaced vector of conservative variables is the flux of those quantities in the given direction.

By integrating Eqn. (1) over a discrete volume ΔV\Delta V, the differential equation becomes an integro-differential equation. For static grids, this equation can be rewritten as an ordinary differential equation for the conservative variables U\mathbf{U} of each cell, indexed by (i,j,k)(i,j,k):

ddtUi,j,k=−1Δxi(Fi+12,j,k−Fi−12,j,k)−1Δyj(Gi,j+12,k−Gi,j−12,k)−1Δzk(Hi,j,k+12−Hi,j,k−12)(3)\begin{aligned} \frac{d}{dt}\mathbf{U}_{i,j,k}={}&-\frac{1}{\Delta x_i}\left(\mathbf{F}_{i+\frac{1}{2},j,k}-\mathbf{F}_{i-\frac{1}{2},j,k}\right)\\ &-\frac{1}{\Delta y_j}\left(\mathbf{G}_{i,j+\frac{1}{2},k}-\mathbf{G}_{i,j-\frac{1}{2},k}\right)\\ &-\frac{1}{\Delta z_k}\left(\mathbf{H}_{i,j,k+\frac{1}{2}}-\mathbf{H}_{i,j,k-\frac{1}{2}}\right) \tag*{(3)} \end{aligned}

where the conservative variables U\mathbf{U} are averaged over the cell volume and the flux vectors F\mathbf{F}, G\mathbf{G}, H\mathbf{H} are averaged over a cell wall (see Stone et al. [25]; Felker & Stone [5]). In Eqn. (3), we have removed the row and column vector notation since there are no vector operations left. Therefore, either case (row or column vectors) would satisfy the equation as it is shown. We show a more detailed derivation of Eqn. (3) in Appendix A.

A critical part of the discrete averaging leading to Eqn. (3) is moving the time derivative out of the volume integral on the left hand side of Eqn. (1) (see Appendix A). The justification for that step is the Reynolds Transport Theorem for a quantity ff over a volume VV and boundary BB,

ddt∫VdV f=∫VdV ∂f∂t+∫BdA (w⃗⋅n^)f.(4)\frac{d}{dt}\int_V dV\,f=\int_V dV\,\frac{\partial f}{\partial t}+\int_B dA\,(\vec{w}\cdot\hat{n})f. \tag*{(4)}

For a static grid, the velocity w⃗\vec{w} of the boundary is 0, so Eqn. (4) reduces to

ddt∫VdV f=∫VdV ∂f∂t,(5)\frac{d}{dt}\int_V dV\,f=\int_V dV\,\frac{\partial f}{\partial t}, \tag*{(5)}

allowing the time derivative to be moved in and out of any volume integral.

A co-scaling grid will lead to additional fluxes due to moving cell walls, rendering the surface integral in Eqn. (4) non-zero ([23]). The differential equation now reads (see App. A for details)

ddtUi,j,k=−1Δxi(Fi+12,j,k−Fi−12,j,k−Wi+12,j,k+Wi−12,j,k)−1Δyj(Gi,j+12,k−Gi,j−12,k−Vi,j+12,k+Vi,j−12,k)−1Δzk(Hi,j,k+12−Hi,j,k−12−Si,j,k+12+Si,j,k−12)(6)\begin{aligned} \frac{d}{dt}\mathbf{U}_{i,j,k}={}&-\frac{1}{\Delta x_i}\left(\mathbf{F}_{i+\frac{1}{2},j,k}-\mathbf{F}_{i-\frac{1}{2},j,k}-\mathbf{W}_{i+\frac{1}{2},j,k}+\mathbf{W}_{i-\frac{1}{2},j,k}\right)\\ &-\frac{1}{\Delta y_j}\left(\mathbf{G}_{i,j+\frac{1}{2},k}-\mathbf{G}_{i,j-\frac{1}{2},k}-\mathbf{V}_{i,j+\frac{1}{2},k}+\mathbf{V}_{i,j-\frac{1}{2},k}\right)\\ &-\frac{1}{\Delta z_k}\left(\mathbf{H}_{i,j,k+\frac{1}{2}}-\mathbf{H}_{i,j,k-\frac{1}{2}}-\mathbf{S}_{i,j,k+\frac{1}{2}}+\mathbf{S}_{i,j,k-\frac{1}{2}}\right) \tag*{(6)} \end{aligned}

where W\mathbf{W}, V\mathbf{V}, S\mathbf{S} are the volume-averaged wall fluxes in the various Cartesian coordinate directions. For example, the average wall flux in the x^\hat{x} direction is given by the integral

Wi+12,j,k=1ΔyjΔzk∬dydz[wx(xi+12,t)U(xi+12,y,z,t)].(7)\mathbf{W}_{i+\frac{1}{2},j,k}=\frac{1}{\Delta y_j\Delta z_k}\iint dydz\left[w_x(x_{i+\frac{1}{2}},t)\mathbf{U}(x_{i+\frac{1}{2}},y,z,t)\right]. \tag*{(7)}

While implementing the above correction is an important step, there is another correction hidden in Eqn. (6). The code will use a time integrator to solve the differential equation. Regardless of the particular integrator, the time integration reads

Ui,j,k(tn+1)=Ui,j,k(tn)+1tn+1−tn∫tntn+1dt[ddtUi,j,k].(8)\mathbf{U}_{i,j,k}(t^{n+1})=\mathbf{U}_{i,j,k}(t^n)+\frac{1}{t^{n+1}-t^n}\int_{t^n}^{t^{n+1}}dt\left[\frac{d}{dt}\mathbf{U}_{i,j,k}\right]. \tag*{(8)}

This assumes a static grid. The assumption is hidden in the notation: for a static grid, the volume averages of U\mathbf{U} are taken over the same volume. To correct for this in the time dependent grid case, we need to change Eqn. (8) to

Ui,j,k(tn+1)=Vi,j,k(tn)Vi,j,k(tn+1)[Ui,j,k(tn)+1tn+1−tn∫tntn+1dt[ddtUi,j,k]].(9)U_{i,j,k}(t^{n+1})=\frac{V_{i,j,k}(t^n)}{V_{i,j,k}(t^{n+1})}\left[U_{i,j,k}(t^n)+\frac{1}{t^{n+1}-t^n}\int_{t^n}^{t^{n+1}}\mathrm{d}t\left[\frac{\mathrm{d}}{\mathrm{d}t}U_{i,j,k}\right]\right]. \tag*{(9)}

Here, Vi,j,k(t)V_{i,j,k}(t) is the volume of the (i,j,k)(i,j,k) cell at time tt.

Thus, a co-moving, co-scaling, or generically time-dependent grid requires two corrections. The first is to include cell wall movement by using the true flux (Eqn. (6)). The second is to include the change in cell volume, scaling the conserved quantities (Eqn. (9)).

Implementation

Athena++ solves Eqn. (1) over a static grid ([24, 25]). A co-scaling grid requires the integration of the grid’s motion over time, in addition to the integration of the physical variables. After this grid integration, we add corrections to the physical variables in the form of wall fluxes and volume scaling (§ 3.1; derived in § 2). Finally, all coordinate variables need to be updated throughout the full mesh hierarchy, including derived quantities such as cell volumes and areas, and reconstruction coefficients. This requires changes to the task list implemented in Athena++ (§ 3.2).

Wall Flux and Volume Change Corrections

To include the corrections to the update equation (Eqn. (6)), we need to approximate the wall flux integral (Eqn. (7)). Assuming the cell wall’s velocity and the conservative quantity are constant on the cell wall, Eqn. (7) reads

Wi+12,j,k=wx(xi+12,t)U(xi+12,t),(10)W_{i+\frac{1}{2},j,k}=w_x(x_{i+\frac{1}{2}},t)U(x_{i+\frac{1}{2}},t), \tag*{(10)}

providing a simple definition for the wall flux. To add these fluxes, we introduce an ‘expansion’ source function. Here, we add the wall fluxes to the conservative variables in the same manner used in the base Athena++ code to add the hydrodynamic fluxes (except we need to consider the difference in sign, see Eqn. (6)). Then, we multiply all conservative variables by the volume expansion factor Vi,j,k(tn)(Vi,j,k(tn+1))−1V_{i,j,k}(t^n)\left(V_{i,j,k}(t^{n+1})\right)^{-1} (see Eqn. (9)). With this last step, the conservative variables are fully updated. These steps are shown as a part of Figure 1.

Image not extracted

Figure 1. Changes to the task list in Athena++ for the co-scaling grid module. The orange shaded boxes (with black borders) show the normal progression through the task list during a given sub step of a time integrator. The green boxes (with no borders) and dashed arrows are the detours necessary for a co-scaling grid. For simplicity, we only show base Athena++ tasks affected by the co-scaling grid. For more detailed flow charts of Athena++ task lists, see Stone et al. [24]; Stone et al. [25].

Task List Changes

Athena++ uses a task list to control and optimize the sequence of operations necessary to solve Eqn. (1) ([24, 25]). For any time integrator, the code completes the task list for every time sub-step. For example, when Athena++ runs with a 4th order time integrator, the task list completes 4 times during a time step, once for each sub-step. Each loop through the list is slightly different, because Athena++ uses minimum-register time integrator methods ([9]). By incorporating the co-scaling grid integration into this task list, the implementation works for any time integrator available in Athena++.

The co-scaling grid requires additional tasks during a sub-step. The first is an evaluation of the user-prescribed velocity function for every cell wall of the grid. The second task takes those stored velocities and integrates the grid, over time, to determine where each cell wall will be at the end of the sub-step. The third edits the stored coordinates to reflect the change in location of each cell wall. The other detour boxes in Figure 1 regarding wall flux calculation and correcting the conservative variables are implemented within other tasks in the task list.

The first two new tasks are executed before any hydrodynamic or magnetic field calculations, since the wall velocity function only uses information from the previous time sub-step (see Figure 1).

We update the coordinate grid after the conservative and primitive variables have been fully updated, and before boundary values are calculated for the next time sub-step. As a result, all variables (grid and physical) are fully updated and available for output or the next integration step.

Tests

We assess accuracy and stability of the co-scaling grid implementation with the 1D Sod shock tube ([21, 24]), and with the 2D cylindrical blast wave. For the latter, we compare the accuracy and computational cost of our implementation to the equivalent static grid simulation. To highlight the applicability of the co-scaling grid to astrophysical problems, we finish with the evolution of a blast waves from free expansion to the Sedov-Taylor phase.

Each test uses a gas with a specific heat capacity ratio γ=53\gamma= \frac{5}{3}.

Sod Shock Test

The Sod shock tube is a popular test of a numerical code’s accuracy and stability ([21, 24]) by comparing the numerical solution to the corresponding Riemann problem (e.g. Toro [27]). The initial conditions of the test are a density and pressure discontinuity at the origin with 0 velocity throughout the simulation. The test uses Cartesian coordinates in one dimension.

The left side of the initial discontinuity has density ρl=1\rho_l = 1 and pressure Pl=1.0P_l = 1.0, whereas the right side has density ρr=0.125\rho_r = 0.125 and pressure Pr=0.1P_r = 0.1 ([21]).

Figure 2 compares a co-scaling grid simulation (64e5) with a static grid at the same number of grid points (64s). We also show a higher resolution static grid simulation (2048s) as an approximation of the analytic solution.

Image not extracted

Figure 2. The primitive variables at for the Sod shock tube at t=0.25t = 0.25. The line corresponds to a resolution of N=2048N = 2048 on a static grid, and the green circles represent a static grid model at N=64N = 64 cells. The corresponding co-scaling grid model at N=64N = 64 is indicated by the brown plus markers. The latter starts out with a domain [−0.1,0.1][-0.1, 0.1] and expands to the domain shown, by a factor of 5.

For the co-scaling grid, the domain initially extends over −0.1≤x≤0.1-0.1 \le x \le0.1 and expands by a factor of 5, reaching the static grid domain size of −0.5≤x≤0.5-0.5 \le x \le0.5 at t=0.25t = 0.25. Thus, the final output of the simulations can be directly compared (see Figure 3). The expanding grid keeps the cell size uniform.

Image not extracted

Figure 3. Time evolution of the Sod shock tube. The top row shows the density profile for the three models 64e5, 64s, and 2048s, the bottom row the normalized residuals with respect to the 2048s model. Large errors at the discontinuities arise because the discontinuities cannot be resolved physically. For smooth flow regions, the co-scaling grid solution approximates the 2048s simulation more closely.

In terms of code validation, the solution for the co-scaling grid is consistent with the analytic solution (Figure 2). Specifically for x≤0x \le0, the co-scaling grid approximates the analytic solution more closely than the static grid. Large differences are expected at the discon-

tinuities (see also Figure 3), since the discontinuities cannot be resolved – slopes just get steeper with increasing resolution. Generally, slopes are slightly steeper for the co-scaling grid, suggesting that tracking the three waves with the co-scaling grid improves the accuracy of the solution. Figure 3 indicates the co-scaling grid is more accurate over the evolution of the test, with steeper discontinuities and more accurate shock location.

The expanding and static simulations used a Piecewise-Linear Reconstruction (PLM) method. The Piecewise-Parabolic Reconstruction (PPM) method is known to cause oscillations in the velocity [12]. The PPM method combined with the co-scaling grid results in higher oscillations than when using the static grid. Since the co-scaling grid requires more time steps and thus more reconstructions, oscillations can reach higher amplitudes.

1D Blast Wave Test

Our second test is the one-dimensional blast wave in spherical coordinates. This allows us to check the volume expansion correction in other coordinate systems. The initial condition consists of an inner region with r<1.0r < 1.0, which is over-pressured by a factor of 10410^{4} and over-dense by a factor of 10310^{3} with respect to the ambient medium (ρamb=0.1\rho_{\mathrm{amb}} = 0.1, Pamb=1.0P_{\mathrm{amb}} = 1.0).

As for the Sod shock tube, we compare three models, one at high resolution (1000 grid points), and the fixed and expanding grid models at 100 grid points each. Figure 4 summarizes the results, showing the density profile and normalized residuals for two time instances. While discontinuities introduce large residuals, the shock position is more accurately traced by the co-scaling grid model – for the fixed-grid model, the shock position leads compared to the high-resolution model.

Image not extracted

Figure 4. Density and normalized residual profiles at two times for the spherical 1D blast wave at a resolution of 100 cells. Residuals are calculated with respect to the static high resolution simulation at 1000 grid points (blue solid line). Discontinuities introduce large residuals. The expanding grid initially matches the resolution of high resolution profile, leading to more accurate shock locations.

Early in the expanding simulation, the peaks are significantly more resolved than in the static grid simulation. The sharpness of discontinuities plays an important role in radiative losses. Therefore, simulations with radiative losses will be more accurate if they use a co-scaling grid.

2D Blast Wave Test

We test the multi-dimensional performance of the co-scaling grid via the 2D blast wave, both for cylindrical and Cartesian coordinates. Cartesian coordinates introduce directionally dependent numerical diffusion, since the resolution is effectively lower along the diagonals by a factor of 2\sqrt{2}.

Figure 5 compares four 2D blast wave models. Cylindrical models on a grid with resolution (nr,nθ)=(512,64)(n_r, n_\theta) = (512, 64) are shown on the left, Cartesian ones at linear resolution of 512 on the right, while the top row shows static grid models, and the bottom row co-scaling grid ones. We track the shell to determine the grid expansion rate required to keep the blast wave within the simulation domain.

Image not extracted

Figure 5. Density maps of four two-dimensional cylindrical blast wave models. For reference, a red circle is plotted at r=22.5r = 22.5 in all the maps. This is the radial coordinate of the peak in density for the cylindrical simulations. Models on cylindrical grids (left, nr=512n_r = 512) are nearly indistinguishable. The strength of the co-scaling grid (bottom row) becomes clear when comparing Cartesian grid models (right column, nx=ny=512n_x = n_y = 512). Rayleigh-Taylor fingers triggered by the discretization are nearly uniformly distributed for the co-scaling grid.

The cylindrical models are essentially indistinguishable, as expected. Using cylindrical (instead of spherical) coordinates allows us to more easily compare to the 2D Cartesian case.

Both Cartesian cases suffer from directionally dependent numerical diffusion, yet, the co-scaling grid achieves a more spherical solution. We expect Rayleigh-Taylor fingers to be triggered at the grid scale. Since the expanding grid starts with a smaller scale, the instabilities are seeded at a smaller scale, leading to a more uniform distribution of Rayleigh-Taylor fingers and a more circular appearance of the blast wave.

Figure 6 provides a more detailed view of the deviation from sphericity. The vertical axis measures the difference between the largest outer and smallest inner radius of the shell Δr\Delta r for the Cartesian grid, normalized by the same quantity for the cylindrical grid. An effective shell

Image not extracted

Figure 6. Deviation from circular shape (eqn. 11), against time, for the blast wave on a Cartesian grid. The dashed lines are static grid simulations and the solid lines are expanding grid simulations. At the same resolution the co-scaling grid simulations produce shells which are more uniformly circular.

thickness ratio of

R≡ΔrcartΔrcyl=1(11)\mathcal{R} \equiv\frac{\Delta r_{\mathrm{cart}}}{\Delta r_{\mathrm{cyl}}} = 1 \tag*{(11)}

indicates a perfectly circular ring. The less circular the shell, the larger Δrcart\Delta r_{\mathrm{cart}} will become, and thus R>1\mathcal{R} > 1. Results for the co-scaling grid (solid lines) improve with higher resolution. With time, deviations from circularity grow because the discretization leads to Rayleigh-Taylor instabilities (see Figure 5). The effective shell thickness ratios R\mathcal{R} for the static grid (dashed lines) are at least a factor of 2 larger than for the co-scaling grid and vary substantially with time right from the start of the shell expansion.

Performance

To compare the performance of the stock version of Athena++ with the co-scaling grid implementation (Figure 7), we ran the blast wave test in three dimensions in Cartesian coordinates at a resolution of 2563256^3 and 5123512^3. We use basic hydrodynamics, i.e. no magnetic fields or other additional physics, except for the co-scaling grid. The co-scaling grid implementation tracks the stock version closely, running at 90% of the base speed for small processor numbers, and without perceptible loss for large processor numbers. This behavior extends to the 5123512^3 resolution, and thus seems resolution-independent, demonstrating that our modification to Athena++ is “minimally invasive”. While the additional steps clearly slow the code down, the speed decrease is offset with increased accuracy of the co-scaling implementation (§ 4.3).

Image not extracted

Figure 7. (a) Speed of the fixed grid (circles) and co-scaling grid (triangles) against processor number, as a strong scaling measure. (b) Efficiency of the fixed and co-scaling grids measured with respect to base efficiency of the fixed grid using 1 processor. The co-scaling grid tracks the stock version of Athena++, running at ∼90%\sim90\% of the base speed for small processor numbers, and without perceptible loss for large numbers.

Long-Term Blast Wave Evolution

As a final demonstration of the code’s capabilities, we follow the evolution of a point explosion from free-expansion to the Sedov-Taylor phase as in a supernova or kilonova remnant ([19, 17]). During free expansion, the velocity is constant and the radius scales as rs∝tr_s \propto t. When the ejecta mass reaches the mass of the swept-up ambient gas, the blast wave enters the energy-conserving Sedov-Taylor phase with rs∝t2/5r_s \propto t^{2/5}. Once radiative losses become dominant, the snow-plow (momentum-conserving) phase is reached. Here, we only consider the first two phases, leaving the implementation of radiative losses for a later contribution. The explosion is initialized with a total energy of E=108E = 10^8, with kinetic energy Ekin=0.99EE_{\mathrm{kin}} = 0.99E. The ejecta density is set to ρe=104\rho_e = 10^4 within a radius of rs(0)=1.2r_s(0) = 1.2. The ambient density and pressure are ρa=10−2\rho_a = 10^{-2} and Pa=10−7P_a = 10^{-7}. These values result in a transition radius between free expansion and Sedov-Taylor phase of

rST=rs(0)(ρeρa)1/3=120.(12)r_{\mathrm{ST}} = r_s(0) \left(\frac{\rho_e}{\rho_a}\right)^{1/3} = 120. \tag*{(12)}

We implemented the test for the expanding grid at 128 grid points and for the fixed grid at an approximate equivalent of 8192 points (Figure 8). Results agree with the analytical estimate for both implementations. The advantage of the expanding grid is obvious – it can follow the evolution to arbitrary time values. A more sophisticated implementation would include radiative losses to allow the blast wave to enter the snow-plow phase.

Image not extracted

Figure 8. (a) Blast wave radius against time for the fixed grid (8192f) and the expanding grid (128e) model. Grey solid lines indicate the transition radius (eq. 12) and time. (b) Logarithmic slope of r(t)r(t), indicating the transition from the free expansion to the Sedov-Taylor phase (d(ln⁡r)/d(ln⁡t)=0.4d(\ln r)/d(\ln t) = 0.4).

Discussion

The co-scaling grid implementation provides a generalization of the co-expanding grid formalism of (Röpke [20]), applicable to expanding, contracting, or comoving frames. Its closest relative is Lagrangian remapping (Lufkin & Hawley [13]), where the fluid equations are solved in a Lagrangian frame to reduce advection errors, but the solution is interpolated (remapped) back onto an Eulerian grid. The underlying grid in our method is not strictly Eulerian any more, requiring additional fluxes due to cell-wall motion. Therefore, the effect of the grid motion can be integrated at the same time order as the fluid equations. The grid shape cannot change, which renders the method less flexible than moving-mesh codes [8, 22]. While dissipative properties can vary with time due to expansion or contraction of the underlying grid, they stay constant across the grid, in difference to adaptive mesh refinement techniques [6, 26, 18, 1, 25]. The closest implementations to ours are JET and DISCO, two moving mesh codes which restrict to singular dimensions [3, 2].

Summary

We present an implementation of a co-scaling (expanding, contracting, or co-moving) grid for the magnetohydrodynamics code Athena++ [25]. The method can be used to follow the evolution of a system over orders of magnitude in scale, as long as the underlying assumption of an existing flow symmetry persists. The scaling prescription ensures the preservation of cell aspect ratios. The method’s main strength lies in covering orders of magnitude in spatial scales for isotropically expanding or contracting systems, or for comoving systems, while keeping dissipative properties constant across the grid. It provides less flexibility than moving mesh codes, but it can be combined with Athena++’s native adaptive mesh refinement.

Acknowledgments

We thank the University of North Carolina at Chapel Hill’s Information Technology Services for providing the computational resources.

We also thank Dr. Ellen Zweibel for her help in editing this paper and for encouraging the completion of this project. This work was aided by Dr. Zweibel’s NSF grant AST-2007323. We thank the anonymous referee for a very constructive report, and especially for pointing out an inconsistency in an earlier version of our grid implementation.

Update Equation Derivation

We show the derivation for both time independent and time dependent grids (including our co-scaling example) to highlight their differences, using a Cartesian grid as an example.

Fixed Eulerian Grid Method

For a static, time independent grid, the integration of the left hand side (LHS) of Eqn. (1) over space gives

∫VdV[∂U(x⃗,t)∂t]=ddt∫VdV [U(x^,t)].(13)\int_V dV \left[\frac{\partial\mathbf{U}(\vec{x},t)}{\partial t}\right] = \frac{d}{dt}\int_V dV\,[\mathbf{U}(\hat{x},t)]. \tag*{(13)}

Because the volume is independent of time, we can move the time derivative outside of the volume integral (See Eqn. (5)).

We then apply the same integration to the right hand side (RHS) of Eqn. (1). Considering a Cartesian coordinate system with unit vectors x^\hat{x}, y^\hat{y}, z^\hat{z}, the matrix of fluxes can be split into the directional quantities (F, G, H). This means the RHS is

−∫VdV[∇⃗T⋅(FTx^+GTy^+HTz^)].(14)-\int_V dV\left[\vec{\nabla}^{T}\cdot\left(\mathbf{F}^{T}\hat{x}+\mathbf{G}^{T}\hat{y}+\mathbf{H}^{T}\hat{z}\right)\right]. \tag*{(14)}

By splitting the above volume integral into its constituent directions, the gradients in each direction can be removed. The integral of the flux divergence in the x^\hat{x} direction is

∫VdV[∂F∂x]=∬dydz [F(xb,t)−F(xa,t)],(15)\int_V dV\left[\frac{\partial\mathbf{F}}{\partial x}\right]=\iint dydz\,[\mathbf{F}(x_b,t)-\mathbf{F}(x_a,t)], \tag*{(15)}

where xbx_b and xax_a are the upper and lower bounds, respectively, of the volume VV in the x^\hat{x} direction. Using notation from Stone et al. [24] and Stone et al. [25], the LHS and RHS can be written in a computationally usable form. The first step in using this notation is to consider solving the equation on a computational grid or mesh, where each direction (x,y,z)(x,y,z) is indexed by an integer (i,j,k)(i,j,k) and each cell in the grid has a unique tuple of these integers. Each cell has a volume which we define as Vi,j,kV_{i,j,k}. With these assumptions, the volume average of the conservative values U at time tt is

Ui,j,k=1Vi,j,k∫Vi,j,k[U(xi1,xj2,xk3,t)] dV.(16)\mathbf{U}_{i,j,k}=\frac{1}{V_{i,j,k}}\int_{V_{i,j,k}}[\mathbf{U}(x_i^1,x_j^2,x_k^3,t)]\,dV. \tag*{(16)}

Written with this notation, the LHS (Eqn. (13)) becomes

Vi,j,kdUi,j,kdt.(17)V_{i,j,k}\frac{d\mathbf{U}_{i,j,k}}{dt}. \tag*{(17)}

Time-Dependent Eulerian Grid Method

We also need to define the integral over the divergence of the fluxes. To discretize Eqn. (15), we can use the term

Fi+12,j,k=1ΔyjΔzk∬dydz[F(xi+12,y,z,t)],(18)\mathbf{F}_{i+\frac{1}{2},j,k}=\frac{1}{\Delta y_j\Delta z_k}\iint dydz\left[\mathbf{F}(x_{i+\frac{1}{2}},y,z,t)\right], \tag*{(18)}

where xi+12x_{i+\frac{1}{2}} is the upper bound of the cell centered (with respect to the x^\hat{x} coordinate) on xix_i. The Δyj\Delta y_j and Δzk\Delta z_k are the width of the cell in the y^\hat{y} and z^\hat{z} directions respectively. Eqn. (18) is the value of the flux of each conservative variable at the given wall of the cell. This notation can be used not only for F, but also for G and H. Altogether, the RHS (Eqn. (14)) can be written as

−[ΔyjΔzk(Fi+12,j,k−Fi−12,j,k)+ΔxiΔzk(Gi,j+12,k−Gi,j−12,k)+ΔxiΔyj(Hi,j,k+12−Hi,j,k−12)].(19)-\left[\Delta y_j\Delta z_k\left(\mathbf{F}_{i+\frac{1}{2},j,k}-\mathbf{F}_{i-\frac{1}{2},j,k}\right)+\Delta x_i\Delta z_k\left(\mathbf{G}_{i,j+\frac{1}{2},k}-\mathbf{G}_{i,j-\frac{1}{2},k}\right)+\Delta x_i\Delta y_j\left(\mathbf{H}_{i,j,k+\frac{1}{2}}-\mathbf{H}_{i,j,k-\frac{1}{2}}\right)\right]. \tag*{(19)}

Combining the LHS and RHS, we get the update equation (Eqn. (3)) for a discrete Cartesian grid. This is the final update equation and it is used in Athena++ to evolve the system ([24, 25]). The entire derivation assumes that the grid does not depend on time. The next section outlines how the update equation changes when cell positions and sizes depend on time.

The most important change to the static grid update equation (Eqn. (3)) derivation in the co-scaling grid case comes from the Reynolds Transport Theorem, Eqn. (4). Integrating Eqn. (1) over space to make the LHS into Eqn. (13) is still valid in the moving grid method. However, we cannot simply move the time derivative outside of the volume integral. Instead, the LHS will be

∫VdV[∂U(x⃗,t)∂t]=ddt∫V(t)dV [U(x⃗,t)]−∫BdA(w⃗⋅n^)U.(20)\int_V dV\left[\frac{\partial\mathbf{U}(\vec{x},t)}{\partial t}\right]=\frac{d}{dt}\int_{V(t)}dV\,[\mathbf{U}(\vec{x},t)]-\int_BdA(\vec{w}\cdot\hat{n})\mathbf{U}. \tag*{(20)}

The above expression clearly indicates that there is an additional flux due to grid motion w⃗\vec{w}. This term can be directly incorporated to the RHS expression. Moving the extra term in Eqn. A8 to the RHS, Eqn. A2, the RHS for a Cartesian grid becomes

−[∫VdV[∇⃗⋅(FTx^+GTy^+HTz^)]−∫BdA(w⃗⋅n^)U](21)-\left[\int_V dV\left[\vec{\nabla}\cdot\left(\mathbf{F}^{T}\hat{\mathbf{x}}+\mathbf{G}^{T}\hat{\mathbf{y}}+\mathbf{H}^{T}\hat{\mathbf{z}}\right)\right]-\int_B dA\left(\vec{w}\cdot\hat{n}\right)\mathbf{U}\right] \tag*{(21)}

This is the most general formulation of the so-called ‘true flux’ [23] for a time dependent grid. As seen in the fixed grid derivation, the volume integral of the fluxes becomes an area average over each directional flux, F\mathbf{F}, G\mathbf{G}, and H\mathbf{H}. The RHS will be

−[∫V(t)dV[∂F∂x+∂G∂y+∂H∂z]−∑m=16∫AmdA wmU](22)-\left[\int_{V(t)}dV\left[\frac{\partial\mathbf{F}}{\partial x}+\frac{\partial\mathbf{G}}{\partial y}+\frac{\partial\mathbf{H}}{\partial z}\right]-\sum_{m=1}^{6}\int_{A_m}dA\,w_m\mathbf{U}\right] \tag*{(22)}

where we have split the integration over the boundary BB into a sum of integrals over the 6 walls of the Cartesian volume element. The velocity wm=w⃗m⋅n^mw_m=\vec{w}_m\cdot\hat{n}_m is evaluated on the wall in the direction of the normal vector to AmA_m.

Ignoring the yy and zz directions, the RHS is

−[∫y(t)∫z(t)dydz[F(xi+12)−F(xi−12)−[wx(xi+12)U(xi+12)−wx(xi−12)U(xi−12)]]](23)-\left[\int_{y(t)}\int_{z(t)}dydz\left[\mathbf{F}\left(x_{i+\frac{1}{2}}\right)-\mathbf{F}\left(x_{i-\frac{1}{2}}\right)-\left[w_x\left(x_{i+\frac{1}{2}}\right)\mathbf{U}\left(x_{i+\frac{1}{2}}\right)-w_x\left(x_{i-\frac{1}{2}}\right)\mathbf{U}\left(x_{i-\frac{1}{2}}\right)\right]\right]\right] \tag*{(23)}

The negative sign for the flux at the xi−12x_{i-\frac{1}{2}} wall results from the normal vector n^=−x^\hat{n}=-\hat{x} at that wall. Taking note of this relationship between n^\hat{n} and x^\hat{x} allows us to write the flux using the xx component of w⃗\vec{w} at that wall, which is defined as wx(xi−12)w_x(x_{i-\frac{1}{2}}).

To formulate a new update equation, we need to define a wall flux for the various directions. We use W\mathbf{W}, V\mathbf{V}, and S\mathbf{S} to denote the wall flux in the xx, yy, and zz directions respectively. As a result, the numerical term for the moving wall flux is

Wi+12,j,k=1ΔyjΔzk∬dydz[wx(xi+12(t))U(xi+12(t),t)](24)\mathbf{W}_{i+\frac{1}{2},j,k}=\frac{1}{\Delta y_j\Delta z_k}\iint dydz\left[w_x\left(x_{i+\frac{1}{2}}(t)\right)\mathbf{U}\left(x_{i+\frac{1}{2}}(t),t\right)\right] \tag*{(24)}

Using the notation above, the RHS is

−[ΔyjΔzk(Fi+12,j,k−Fi−12,j,k−Wi+12,j,k+Wi−12,j,k)+ΔxiΔzk(Gi,j+12,k−Gi,j−12,k−Vi,j+12,k+Vi,j−12,k)+ΔxiΔyj(Hi,j,k+12−Hi,j,k−12−Si,j,k+12+Si,j,k−12)].(25)-\left[\Delta y_j\Delta z_k\left(\mathbf{F}_{i+\frac{1}{2},j,k}-\mathbf{F}_{i-\frac{1}{2},j,k}-\mathbf{W}_{i+\frac{1}{2},j,k}+\mathbf{W}_{i-\frac{1}{2},j,k}\right)+\Delta x_i\Delta z_k\left(\mathbf{G}_{i,j+\frac{1}{2},k}-\mathbf{G}_{i,j-\frac{1}{2},k}-\mathbf{V}_{i,j+\frac{1}{2},k}+\mathbf{V}_{i,j-\frac{1}{2},k}\right)+\Delta x_i\Delta y_j\left(\mathbf{H}_{i,j,k+\frac{1}{2}}-\mathbf{H}_{i,j,k-\frac{1}{2}}-\mathbf{S}_{i,j,k+\frac{1}{2}}+\mathbf{S}_{i,j,k-\frac{1}{2}}\right)\right]. \tag*{(25)}

Combining the LHS and RHS that we have derived above, we get an update equation (Eqn. (6)) for a simulation with a time dependent grid. Considering the time integration involved in solving the ordinary differential equation Eqn. (6), we also find a necessary volume change correction (see Eqn. (9)).

References

  1. [1]Cunningham, A. J., Frank, A., Varnière, P., Mitran, S., & Jones, T. W. 2009, ApJ Supplement Series, 182, 519, doi: 10.1088/0067-0049/182/2/519DOI
  2. [2]Duffell, P. C. 2016, ApJS, 226, 2, doi: 10.3847/0067-0049/226/1/2DOI
  3. [3]Duffell, P. C., & MacFadyen, A. I. 2013, ApJ, 775, 87, doi: 10.1088/0004-637X/775/2/87DOI
  4. [4]Elmegreen, B. G., & Lada, C. J. 1977, The Astrophysical Journal, 214, 725, doi: 10.1086/155302DOI
  5. [5]Felker, K. G., & Stone, J. M. 2018, Journal of Computational Physics, 375, 1365, doi: 10.1016/j.jcp.2018.08.025DOI
  6. [6]Fryxell, B., Olson, K., Ricker, P., et al. 2000, ApJ Supplement Series, 131, 273, doi: 10.1086/317361DOI
  7. [7]Heitsch, F., Naab, T., & Walch, S. 2011, MNRAS, 415, 271, doi: 10.1111/j.1365-2966.2011.18694.xDOI
  8. [8]Hopkins, P. F. 2015, MNRAS, 450, 53, doi: 10.1093/mnras/stv195DOI
  9. [9]Ketcheson, D. I. 2010, Journal of Computational Physics, 229, 1763, doi: 10.1016/j.jcp.2009.11.006DOI
  10. [10]Klein, R. I. 2017, Memorie della Societa Astronomica Italiana, 88, 642
  11. [11]Krumholz, M. R., Klein, R. I., & McKee, C. F. 2007, The Astrophysical Journal, 656, 959, doi: 10.1086/510664DOI
  12. [12]Lee, D. 2011, in Astronomical Society of the Pacific Conference Series, Vol. 444, 5th International Conference of Numerical Modeling of Space Plasma Flows (ASTRONUM 2010), ed. N. V. Pogorelov, E. Audit, & G. P. Zank, 236
  13. [13]Lufkin, E. A., & Hawley, J. F. 1993, ApJ Supplement Series, 88, 569, doi: 10.1086/191833DOI
  14. [14]McCray, R., & Kafatos, M. 1987, The Astrophysical Journal, 317, 190, doi: 10.1086/165267DOI
  15. [15]Metzger, B. D. 2019, Living Reviews in Relativity, 23, 1, doi: 10.1007/s41114-019-0024-0DOI
  16. [16]Monaghan, J. J. 1992, Annual Rev. Astron. Astrophys, 30, 543, doi: 10.1146/annurev.aa.30.090192.002551DOI
  17. [17]Montes, G., Ramirez-Ruiz, E., Naiman, J., Shen, S., & Lee, W. H. 2016, ApJ, 830, 12, doi: 10.3847/0004-637X/830/1/12DOI
  18. [18]O’Shea, B. W., Bryan, G., Bordner, J., et al. 2004, arXiv e-prints, astro. https://arxiv.org/abs/astro-ph/0403044
  19. [19]Ostriker, J. P., & McKee, C. F. 1988, Reviews of Modern Physics, 60, 1, doi: 10.1103/RevModPhys.60.1DOI
  20. [20]Röpke, F. K. 2005, Astronomy & Astrophysics, 432, 969, doi: 10.1051/0004-6361:20041700DOI
  21. [21]Sod, G. A. 1978, Journal of Computational Physics, 27, 1, doi: 10.1016/0021-9991(78)90023-2DOI
  22. [22]Springel, V. 2010, MNRAS, 401, 791, doi: 10.1111/j.1365-2966.2009.15715.xDOI
  23. [23]Springel, V. 2011. https://arxiv.org/abs/1109.2218
  24. [24]Stone, J. M., Gardiner, T. A., Teuben, P., Hawley, J. F., & Simon, J. B. 2008, ApJ Supplement Series, 178, 137–177, doi: 10.1086/588755DOI
  25. [25]Stone, J. M., Tomida, K., White, C. J., & Felker, K. G. 2020, ApJ Supplement Series, 249, 4, doi: 10.3847/1538-4365/ab929bDOI
  26. [26]Teyssier, R. 2002, Astronomy & Astrophysics, 385, 337, doi: 10.1051/0004-6361:20011817DOI
  27. [27]Toro, E. F. 2019, Shock Waves, 29, 1065, doi: 10.1007/s00193-019-00912-4DOI

Paper details

vlnc:W_kkssybdu
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 10

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Physics and Astronomy

Not recorded for this paper

View statement
Looking for related papers…
Contents