Abstract
We propose a simple ansatz for estimating the value of the numerical resistivity and the numerical viscosity of any Eulerian MHD code. We test this ansatz with the help of simulations of the propagation of (magneto)sonic waves, Alfvén waves, and the tearing mode (TM) instability using the MHD code Aenus. By comparing the simulation results with analytical solutions of the resistive-viscous MHD equations and an empirical ansatz for the growth rate of TMs, we measure the numerical viscosity and resistivity of Aenus. The comparison shows that the fast magnetosonic speed and wavelength are the characteristic velocity and length, respectively, of the aforementioned (relatively simple) systems. We also determine the dependence of the numerical viscosity and resistivity on the time integration method, the spatial reconstruction scheme and (to a lesser extent) the Riemann solver employed in the simulations. From the measured results, we infer the numerical resolution (as a function of the spatial reconstruction method) required to properly resolve the growth and saturation level of the magnetic field amplified by the magnetorotational instability in the post-collapsed core of massive stars. Our results show that it is most advantageous to resort to ultra-high-order methods (e.g., the ninth-order monotonicity-preserving method) to tackle this problem properly, in particular, in three-dimensional simulations.
Export citation and abstract BibTeX RIS
1. Introduction
Every Eulerian MHD code introduces numerical errors during the integration of an MHD flow because of unavoidable errors resulting from the spatial and time discretization of the problem. These errors can manifest themselves in two ways. They can either smear out the solution (numerical dissipation) or introduce phase errors (numerical dispersion). Because the mode of action of numerical dissipation resembles that of physical viscosity and, for magnetized flows, also of resistivity, they are commonly referred to as numerical viscosity and numerical resistivity, respectively (see, e.g., Laney 1998, Chap.14, and Bodenheimer et al. 2006, Chap. 8.3).
A necessary condition for a physically reliable simulation is that the amount of numerical viscosity and resistivity be sufficiently small. If this requirement is violated, numerical errors can change the solution not only quantitatively, but even qualitatively. For example, Obergaulinger et al. (2009) found that the tearing mode (TM) instability (Furth et al. 1963; FKR63 hereafter) developed in their 2D ideal MHD simulations of the magnetorotational instability (MRI; Balbus & Hawley 1991) in core-collapse although the TM instability supernovae. However, TM instabilities should only grow in resistive MHD. Thus, it must have developed due to numerical resistivity (as pointed out by the authors).
This problem becomes even more exacerbated in relativistic (magneto)-hydrodynamics, since the jumps of physical variables across strong shocks are no longer limited in magnitude, and both linearly degenerate and nonlinear eigenfields degenerate when the flow velocities approach the speed of light (Mimica et al. 2009).
The collapsed core of a massive star is yet another physical application where viscous and resistive effects can definitively shape the outcome after core collapse, i.e., whether a failed or successful supernova explosion results. Abdikamalov et al. (2015) estimate that the Reynolds number in the gain layer (where neutrino heating is stronger than neutrino cooling) can be huge (), resulting in a fully turbulent flow in that region. This turbulence may generate anisotropic stresses on the flow that definitely help in the supernova shock revival (Murphy et al. 2013; Couch & Ott 2015). In this context, convection (Burrows et al. 1995; Herant 1995; Janka & Müller 1996; Foglizzo et al. 2006), the growth of the magnetic field induced by the MRI (Akiyama et al. 2003; Obergaulinger et al. 2006; Cerdá-Durán et al. 2007; Sawai et al. 2013; Mösta et al. 2015; Rembiasz et al. 2016b, 2016a; Sawai & Yamada 2016), and its interplay with buoyancy (Obergaulinger et al. 2009, 2014; Guilet & Müller 2015) are (magneto-)hydrodynamic instabilities whose numerical treatment crucially depends on the amount of numerical viscosity and resistivity of the algorithms employed.
As the magnitude of numerical viscosity and resistivity is a priori unknown in a given simulation, one has to perform convergence tests to determine upper limits for these quantities. However, convergence tests are not always performed in the case of 3D simulations because of a high computational cost. Therefore, it would be valuable to have some way of assessing the importance of numerical viscosity and resistivity for a given system. One would also like to know whether the dominant source of the numerical dissipation are spatial discretization errors or time integration errors.
In this paper, we propose a simple ansatz and a corresponding calibration method to estimate the numerical resistivity and viscosity of any Eulerian MHD code by investigating the dependence of the numerical resistivity and viscosity on both the numerical (i.e., grid resolution, Riemann solver, reconstruction scheme, time integrator) and physical setup of a simulation. To this end, we performed simulations of the propagation of (magneto)sonic waves and Alfvén waves, and of the TM instability. By comparing the results of our simulations with analytical solutions of these resistive-viscous MHD flow problems and an empirical ansatz for the TM growth rate, we are able to quantify the magnitude of the numerical resistivity and viscosity.
We do not consider the effects of numerical dispersion (see, however, Peterson & Hammett 2013), because this would be beyond the scope of this work. Hence, our study should be considered as a first step to better understand the mode of action of numerical viscosity and resistivity in MHD simulations, and provide a quantitative measure of the magnitude of the corresponding errors.
In Section 2, we present the key idea of our ansatz to quantify the numerical viscosity and resistivity of an MHD code, and we describe the code Aenus, used for our simulations in Section 3. Although we calibrate the numerical viscosity and resistivity for a specific code only, the method is general and independent of Aenus. As a service to the community, we provide the data from our tests online3 to facilitate comparisons with other codes. In Section 4, we present a methodology to compute numerical viscosity and resistivity based on the results of numerical simulations of several MHD flows encompassing the propagation of fast magnetosonic waves, Alfvén waves, sound waves, and of the TM instability. In Section 5, we present an example of the application of our methodology. Finally, in Section 6, we summarize and discuss our results.
2. Numerical Resistivity and Viscosity
2.1. Numerical Integration of the MHD Equations
The equations of resistive-viscous (non-ideal) magnetohydrodynamics (MHD) can be written as
where , ρ, η, and are the fluid velocity, the density, a uniform resistivity, and the magnetic field, respectively, expressed in Heaviside–Lorentz units. The total energy density, e⋆, is composed of fluid and magnetic contributions, , where ε and are the internal energy density and the gas pressure, respectively. The stress tensor is given by
where is the unit tensor, and ν and ξ are the kinematic shear and bulk viscosity, respectively.
The system of partial differential equations (PDEs) given by Equations (1)–(3) is expressed in conservation form
where is the vector of conservative variables and is the matrix of the fluxes associated with those variables. For simplicity, we do not consider in this work source terms in the equations.
There exist powerful techniques to integrate numerically hyperbolic systems of conservation laws including a correct treatment of flow discontinuities (e.g., LeVeque 1992; Toro 1997; Laney 1998; LeVeque 2002). Among the most popular techniques are Eulerian methods, which rely on a numerical discretization of the solution (typically in finite volumes) on a fixed, i.e., Eulerian grid. The numerical solution of the discretized system of PDEs differs from its exact solution by an amount that we call the numerical error of the solution. This numerical error can be interpreted as the sum of numerical dissipation and numerical dispersion, which are not present in the original system of hyperbolic equations. The purpose of this work is to characterize this numerical dissipation and to assess whether it can be interpreted as numerical viscosity or as numerical resistivity for magnetized flows.
2.2. A Simple Example
To illustrate the concept of numerical viscosity and resistivity, we present an example of a one-dimensional conservation law for a scalar quantity without external sources
where is the conserved variable and is the flux. Given its value at t = 0, , this equation can be integrated to obtain its solution at any later time.
The numerical solution of Equation (8) can be obtained discretizing the time and spatial derivatives. Hence, the numerical version of Equation (8) reads
where the subscript "num" means that a given derivative is determined numerically, and is a function approximating the solution.
Let us consider a spatial and time discretization of the orders r and q, respectively. Hence, the numerical approximations of the spatial and time derivatives differ from the analytical ones by terms of the order and or higher, respectively. In this case, Equation (9) reads
where ar and bq are coefficients that depend on the spatial and time discretization, and , whose analytic expression is not necessarily known. This equation for u* differs from Equation (8) in terms that are proportional to powers of and . Hence, in the limit and , u* and u coincide. However, at finite resolution, the additional terms arising from the discretization may change the character of the equation, which, in certain regimes, may change the hyperbolic system into a parabolic one. To show the consequences more explicitly, we consider two examples.
In the first example, we examine a method with r = 1 (e.g., using piecewise constant reconstruction, as in Godunov's method) and a time integrator with . In this case,
where all third- or higher-order terms are grouped into . The terms proportional to and are usually referred to as numerical dissipation and numerical dispersion, respectively. For wave-like solutions of the form , the dispersion relation reads
where and are the real and imaginary parts of ω, respectively. The dissipative and dispersive character can be explicitly seen by computing the dissipation rate and the phase velocity of the wave. These quantities are obtained by identifying the two terms in Equation (12) with the respective spatial derivate of u* in Equation (11):
In the second example, we consider an explicit time integration method with q = 1 (e.g., the forward Euler method) and . In this case, keeping only first order terms for simplicity,
where we used to eliminate second-order time derivatives. As in the previous example, we consider wave-like solutions, keeping only terms linear in the amplitude of the perturbations, which results in the following dispersion relation:
The resulting error also acts as numerical dissipation (proportional to k2).
In this work, we focus on the measurement of numerical dissipation in single-scale problems, where the distinction between dissipation and hyperdissipation is of minor importance. However, one should bear in mind that this distinction is important if the estimates presented in this work are applied to multi-scale problems.
2.3. An Ansatz for Numerical Viscosity and Resistivity
Following the reasoning of the previous section, one can try to estimate the importance of the additional terms arising from the numerical discretization of the MHD equations. The additional terms in (2)–(4) are commonly called numerical viscosity and numerical resistivity, since these terms modify the dynamics of the system in a similar way as physical viscosity and resistivity. This is especially valid for flux-conservative methods, in which numerical discretization does not introduce non-conservative terms in the equations (i.e., sources) and similarities with physical viscosity and resistivity are accentuated.
A detailed analysis of the numerical errors is, in general, a challenging task. Here, we will perform an error analysis in a simplified manner. We will not discriminate between numerical dissipation and dispersion, but simply assume that all spatial discretization errors and time integration errors only contribute to numerical dissipation, i.e., to numerical viscosity and resistivity.
Based on the discussion above and the simple tests of the previous section, we propose an ansatz for the numerical viscosity and resistivity of an MHD code that depends on the discretization scheme and the grid resolution used in a simulation.
In the CGS units, both resistivity and kinematic viscosity have the dimension of , hence their numerical counterparts must have the same dimension. The most natural ansatz for, say, the numerical shear viscosity then has the form , where and are the characteristic velocity and length of a simulated system, respectively. The determination of and is not an easy task in general, since it is problem dependent, as we will show in the subsequent sections.
Let us consider a one-dimensional (1D) MHD simulation. Because numerical errors arise from the spatial () and temporal discretization (), these terms should be proportional to and , where r and q depend on the order of the numerical schemes. Since has the dimension , should be multiplied by . The resulting term has a simple interpretation: the more zones used to resolve the characteristic length, the lower the numerical viscosity. The same argumentation holds for time integration errors, which should enter the ansatz in the form of . Therefore, the ansatz for the numerical shear viscosity should read
where , , r, and q are constants for a given numerical scheme.
Using the CFL factor definition for an equidistant grid, Equation (17) can be rewritten as
where is the maximum velocity of the system limiting the time step. If , Equation (18) simplifies to
Note that time and spatial discretization contribute to different derivatives, provided .
The same ansatz should hold for the numerical bulk viscosity and the resistivity , with the coefficients , , and , , respectively:
where we assume that r and q have the same values as in Equations (17)–(19). Once the unknown coefficients , r, and q are determined, the above ansatz can be used to estimate the numerical resistivity and viscosity in any simulation performed with the same code. Throughout this paper, we will differentiate between the measured order of a numerical scheme, r and q, and its theoretically expected value, i.e., and . For example, for a fifth-order accurate reconstruction scheme , and for a third-order accurate time integrator . However, when fitting simulation data, r and q are always assumed to be fit parameters and not a priori known constants (see Table 1).
Table 1. Wave Damping Simulations I
Series | Wave | Reco | Riemann | Time | CFL | Resolution | r | q | ||
---|---|---|---|---|---|---|---|---|---|---|
#S1 | sound | PL | HLL | RK4 | 0.01 | 64...1028 | 14.3 ± 0.7 | 3.049 ± 0.009 | ⋯ | ⋯ |
#S2 | sound | MP5 | LF | RK4 | 0.01 | 8...256 | 42.9 ± 2.3 | 4.957 ± 0.013 | ⋯ | ⋯ |
#S3 | sound | MP5 | HLL | RK4 | 0.01 | 8...256 | 43.4 ± 2.5 | 4.961 ± 0.014 | ⋯ | ⋯ |
#S4 | sound | MP5 | HLLD | RK4 | 0.01 | 8...256 | 42.7 ± 2.2 | 4.956 ± 0.013 | ⋯ | ⋯ |
#S5 | sound | MP7 | HLL | RK4 | 0.01 | 8...64 | 302 ± 20 | 6.897 ± 0.021 | ⋯ | ⋯ |
#S6 | sound | MP9 | HLL | RK4 | 0.01 | 8...32 | 830 ± 340 | 8.42 ± 0.15 | ⋯ | ⋯ |
#S7 | sound | MP9 | HLL | RK3 | 0.5 | 8...256 | ⋯ | ⋯ | 1.492 ± 0.013 | 2.985 ± 0.002 |
#S8 | sound | MP9 | HLL | RK3 | 0.1...0.9 | 64 | ⋯ | ⋯ | 2.45 ± 0.17 | 2.95 ± 0.01 |
#S9 | sound | MP9 | HLL | RK4 | 0.5 | 8...32 | ⋯ | ⋯ | 71 ± 32 | 5.5 ± 0.2 |
#A1 | Alfvén | MP5 | LF | RK4 | 0.01 | 8...256 | 42 ± 3 | 4.95 ± 0.02 | ⋯ | ⋯ |
#A2 | Alfvén | MP5 | HLL | RK4 | 0.01 | 8...256 | 42.6 ± 2.1 | 4.96 ± 0.01 | ⋯ | ⋯ |
#A3 | Alfvén | MP5 | HLLD | RK4 | 0.01 | 8...256 | 42 ± 3 | 4.95 ± 0.02 | ⋯ | ⋯ |
#A4 | Alfvén | MP7 | HLL | RK4 | 0.01 | 8 ...128 | 44 ± 53 | 6.19 ± 0.03 | ⋯ | ⋯ |
#A5 | Alfvén | MP9 | HLL | RK4 | 0.01 | 8...64 | 1190 ± 190 | 8.57 ± 0.06 | ⋯ | ⋯ |
#A6 | Alfvén | MP9 | HLL | RK3 | 0.8 | 16...128 | ⋯ | ⋯ | 0.86 ± 0.08 | 2.949 ± 0.022 |
#A7 | Alfvén | MP9 | HLL | RK4 | 0.8 | 8...64 | ⋯ | ⋯ | 7.6 ± 2.5 | 5.18 ± 0.10 |
#A8 | Alfvén | MP5 | HLL | RK3 | 0.5 | 5...1024 | ⋯ | ⋯ | ⋯ | ⋯ |
#MS1 | magnetosonic | MP5 | HLL | RK4 | 0.01 | 8...128 | 40 ± 3 | 4.95 ± 0.02 | ⋯ | ⋯ |
#MS2 | magnetosonic | MP7 | HLL | RK4 | 0.01 | 8...64 | 288 ± 20 | 6.903 ± 0.023 | ⋯ | ⋯ |
#MS3 | magnetosonic | MP9 | HLL | RK4 | 0.01 | 8...32 | 1970 ± 160 | 8.82 ± 0.03 | ⋯ | ⋯ |
#MS4 | magnetosonic | MP9 | HLL | RK3 | 0.1...0.9 | 64 | ⋯ | ⋯ | 1.77 ± 0.06 | 2.977 ± 0.007 |
#MS5 | magnetosonic | MP9 | HLL | RK4 | 0.2...0.9 | 64 | ⋯ | ⋯ | 4.3 ± 0.8 | 4.834 ± 0.013 |
Note. The columns give (from left to right) the series identifier, the wave type, the reconstruction scheme, the Riemann solver, the time integrator, the CFL factor, and the grid resolution. The estimators for , r, , and q (see Equations (17), (20), and (21)) are obtained from linear fits to the simulation results. For sound waves, Alfvén, waves, and magnetosonic waves , , and , respectively. The estimators are defined analogously.
Download table as: ASCIITypeset image
In the multidimensional (multi-D) case, the ansatz given by Equations (17), (20), and (21) can be generalized. Inspecting Equation (10), one realizes that in the multi-D case, similar terms appear for the spatial derivatives in each of the directions and for all possible cross-derivatives. However, the contribution from the time derivative remains the same. A detailed analysis of the form of these numerical dissipative and dispersive terms is beyond the scope of this work. Instead, we propose a simple ansatz containing the main features of numerical dissipation in multiple directions. The first fact to realize is that different characteristic length scales apply to the different directions. For example, in 2D, using coordinates (x, y), the relevant quantities are and , where and are characteristic lengths in the respective direction. Similarly there is a characteristic velocity, and , in each direction. As a consequence, dissipation acts differently for each direction of the grid and it becomes anisotropic. The diffusion coefficients, ν, ξ, and η, appearing in Equations (2)–(4) rely on the assumption of an isotropic fluid (see, e.g., Landau & Lifshitz 1982), therefore numerical dissipation cannot be modeled using these scalar coefficients in the multi-D case. However, it is relatively easy to find a prescription for a non-isotropic dissipation generalizing the scalar character of the dissipation coefficients to two-tensors. In this way, the generalization of the scalar kinematic viscosity to a tensor (whose components are ) would imply substitutions in the MHD equations of the kind
and similarly for and , with components and . Explicit expressions for the case of viscosity can be obtained using a rank four dynamic viscosity tensor of the form
and following the procedure laid out in chapter 5 of Landau & Lifshitz (1970).
We propose an ansatz for these tensorial coefficients, in which we neglect terms coming from cross-derivatives for simplicity, keeping only the contribution to the numerical discretization error in each direction separately. For the 2D case, which can be trivially generalized to 3D, our ansatz reads
where
and similarly for and . Note that the temporal contribution to the dissipation coefficients is isotropic and depends on the characteristic length and time of the solution ( and ) instead of on the characteristic scales along each direction. In this ansatz, we assume that the same algorithm is used to compute the derivatives in all spatial directions, and hence the coefficient is the same in all components .
One also needs to correctly identify the characteristic velocity, , and length, , of the system (or the corresponding quantities in the multi-D case), which may require a good understanding of the problem (see 2D simulations of sound waves and TMs in Sections 4.2 and 4.3, respectively).
To test the robustness of the above ansatz and to determine the unknown coefficients, we considered four test problems in resistive-viscous MHD that have analytically known solutions: the damping of sound waves, Alfvén waves, and fast magnetosonic waves, and the TM instability. Because slow magnetosonic waves will not be discussed in the remaining part of this paper, we will simply write magnetosonic waves to denote fast magnetosonic waves.
3. The Code
We used the three-dimensional Eulerian MHD code Aenus (Obergaulinger 2008) to solve the MHD Equations (1)–(5). The code is based on a flux-conservative, finite volume formulation of the MHD equations and the constrained-transport scheme to maintain a divergence-free magnetic field (Evans & Hawley 1988). Based on high-resolution shock-capturing methods (e.g., LeVeque 1992), the code employs various optional high-order reconstruction algorithms including a total-variation-diminishing (TVD) piecewise-linear (PL) reconstruction of second-order accuracy, a third-, fifth-, seventh-, and ninth-order monotonicity-preserving (MP3, MP5, MP7, and MP9, respectively) scheme (Suresh & Huynh 1997), a fourth-order, weighted, essentially non-oscillatory (WENO4) scheme (Levy et al. 2002), and approximate Riemann solvers based on the multi-stage (MUSTA) method (Toro & Titarev 2006) and the HLLD Riemann solver (Harten 1983; Miyoshi & Kusano 2005).
We add terms including viscosity and resistivity to the flux terms in the Euler equations and to the electric field in the MHD induction equation. We treat these terms similarly to the fluxes and electric fields of ideal MHD, except for using an arithmetic average instead of an approximate Riemann solver to compute the interface fluxes. The explicit time integration can be performed with Runge–Kutta schemes of first-, second-, third-, and fourth-order accuracy (RK1, RK2, RK3, and RK4), respectively.
4. Numerical Tests
4.1. Wave Damping Tests in 1D
To determine the numerical dissipation of the Aenus code and to test the ansatz (17), (20), and (21), we perform a series of numerical tests involving the propagation of waves in a homogeneous medium. Three kinds of waves are studied, sound waves, Alfvén waves, and fast magnetosonic waves. We align the propagation direction of the wave with one of the grid coordinate directions, making the problem one-dimensional. We determine the damping rates of the wave amplitudes, which depend only on the dissipative terms in the discretized MHD equations, in our case, owing to only numerical dissipation.
To measure the damping rate, we performed numerical simulations letting the wave cross the simulation box, which has periodic boundaries, at least 10 times. The energy of the wave, computed as an integral of the kinetic energy density over the box, decreases exponentially with time. We fit a linear function to the logarithm of this quantity to obtain a measure of the energy damping rate, which is equivalent to twice the amplitude damping rate (see below). To estimate the different dissipation coefficients of our ansatz, we exploit the fact that the damping rate of the different kinds of waves depends differently on numerical viscosity and resistivity.
If not otherwise stated, the simulation box length and the wavevector are set to L = 1 and , respectively. An ideal-gas equation of state (EOS) with an adiabatic index is used.
4.1.1. Sound Waves
We measured the numerical shear and bulk viscosity of the Aenus code using sound waves. We set the background density and pressure to , and imposed a perturbation of the form
where is the sound speed. The amplitude of the velocity perturbation is set to , which is small enough to prevent wave steepening (see Shore 2007) within the time of our simulations.
In the presence of (numerical) viscosity, the wave is damped with time. For a plane wave , one finds from the dispersion relation
In the weak damping approximation, i.e., if
the phase velocity remains constant and the solution can be written as
where the sound damping coefficient is defined as
The sound wave propagates with a constant speed and its amplitude decreases with time. Performing simulations with different values of the physical shear and bulk viscosity, we found an excellent agreement between the analytical (Equation (33)) and the numerical solution (see Rembiasz 2013, for details).
With simulation series #S1, #S3, #S5, and #S6 (Table 1; upper left panel of Figure 1), we investigated the influence of the reconstruction scheme on the numerical dissipation. To keep the contribution of the time integration errors as small as possible, we set . For every simulation, we measure the damping rate from the decay of the kinetic energy, from which we compute the numerical dissipation of the code according to Equation (34) as
where the right-hand side is given by the simulation results. Thus, in the case of sound waves, one cannot determine and separately from the value of , but only a linear combination of both quantities. For every simulation series (i.e., reconstruction scheme), we fit the function
where r is the measured order of convergence of the scheme. From the fit parameter
we can compute if both the characteristic speed and the length of the system are known. As we will show below, for this test ( being the wavelength) and . The results presented in Table 1 and the upper right panel of Figure 1 show that all schemes have an exponent r close to the theoretical order of the method.
The results of the simulation series #S2–#S4 (Table 1) show that the LF, HLL, and HLLD Riemann solvers damp sound waves very similarly.
With the simulation series #S7–#S9, we determine the contribution of the RK3 (#S7 and #S8) and RK4 (#S9) time integrators to the numerical dissipation. To keep the contribution of the spatial discretization errors as low as possible, we use the MP9 reconstruction. We vary the time step either by varying the grid resolution (keeping series #S7 and #S9) or by varying the CFL factor (series #S8). According to Equation (19), both approaches should be equivalent. In both cases, the RK3 scheme performs very close to third-order accuracy, whereas the order of the RK4 integrator is higher than expected. We attribute the overperformance of RK4 in this test to the fact that it is not a TVD scheme since we have not computed the time-reversed operator as suggested in the Shu & Osher (1988) and in Suresh & Huynh (1997) for time integration schemes with orders of larger than three. However, the overperformance of RK4 in this test is very likely a fortunate coincidence (see Section 4.1.3, where it is not the case). The estimators are obtained by employing a fitting procedure analogous to the one for (see Table 1 and the upper right panel of Figure 1).
The natural characteristic speed of this flow problem should be the sound speed (). To test this hypothesis, we performed simulations varying the background pressure (series #cS1) or the density (#cS2) within the range given in Table 2. The results were fitted with the function
From the fit, we obtain the value of α, expecting , and from the offset d, we determine (Table 2). The table and the lower left panel of Figure 1 clearly show that the sound speed is indeed the characteristic speed of the system.
Table 2. Wave Damping Simulations II
Series | Wave | p0 | b0 | λ | α | ||
---|---|---|---|---|---|---|---|
#cS1 | sound | 1 | 0 | 1 | 46.2 ± 2.3 | 0.993 ± 0.003 | |
#cS2 | sound | 1 | 0 | 1 | 46.2 ± 2.3 | 0.993 ± 0.003 | |
#cS3 | sound | 1 | 1 | 0 | 46.2 ± 2.4 | 0.9899 ± 0.0024 | |
#cA1 | Alfvén | 10−1 | 1 | 1 | 34.8 ± 2.4 | 0.945 ± 0.015 | |
#cA2 | Alfvén | 1 | 1 | 1 | 34.8 ± 2.4 | 0.945 ± 0.015 | |
#cA3 | Alfvén | 1 | 1 | 34.8 ± 2.4 | 0.945 ± 0.015 | ||
#cA4 | Alfvén | 1 | 1 | 44 ± 2 | −1.0003 ± 0.0003 | ||
#cMS1 | magnetosonic | 1 | 1 | 1 | 40 ± 3 | 0.997 ± 0.006 | |
#cMS2 | magnetosonic | 1 | 1 | 1 | 40 ± 3 | 0.997 ± 0.006 | |
#cMS3 | magnetosonic | 1 | 1 | 1 | 40 ± 3 | 0.997 ± 0.006 |
Note. Simulations performed with the MP5 reconstruction scheme, the HLL Riemann solver, and the RK3 time integrator to identify the characteristic velocity and length of the system. The CFL factor was set to 0.01 to guarantee negligible time integration errors. The columns give (from left to right) the series identifier, the wave type, the initial pressure, density and magnetic field, and the wavelength λ. is defined as in Table 1 for the corresponding wave type. The exponent α is obtained for each simulation series by means of the fitting functions given by Equations (38), (39), (46), (49), and (61), respectively.
Download table as: ASCIITypeset image
To determine the characteristic length of the system (the natural candidate being the wavelength λ), we performed the simulation series #cS3 varying the wavelength λ (and the size of the simulation domain accordingly, i.e., ). The results were fitted with the function
expecting again . Table 2 and the lower right panel of Figure 1 confirm our hypothesis. The figure shows that the numerical viscosity term is proportional to , i.e., (see Equation (34)).
4.1.2. Alfvén Waves
With the help of Alfvén wave simulations, we determine a linear combination of the numerical shear viscosity and resistivity of the code. We set the background magnetic field and density to , the pressure to , and the transversal velocity to . We imposed a perturbation of the form
In ideal MHD, an Alfvén wave propagates with a constant amplitude at the Alfvén speed . In the presence of viscosity and resistivity, the wave amplitude decreases with time. In the weak damping approximation, i.e., for , the velocity evolution reads (for the derivation, see Campos 1999)
where the Alfvén damping rate is defined as
We verified Equation (43) with the help of numerical simulations, and also checked that the bulk viscosity does not influence the damping coefficient (see Rembiasz 2013, for details).
In the simulation series #A2, #A4, and #A5 (see Table 1), we compared the influence of the MP5, MP7, and MP9 reconstruction schemes on the numerical shear viscosity and resistivity . For every simulation, we measured the decrease of the kinetic energy, from which we determined a linear combination of the numerical shear viscosity and resistivity
The simulation results are fitted with the function
where r is the numerically measured order of accuracy of the reconstruction scheme. From the fit parameter d and Equations (17), (21), and (44), we determined .4 Table 1 and the upper left panel of Figure 2 show that all methods have an order of convergence close to the theoretical expectation.
Download figure:
Standard image High-resolution imageAccording to the results of the simulation series #A1, #A2, and #A3 (Table 1), the numerical dissipation of the LF, HLL, and HLLD Riemann solvers are also very similar for Alfvén waves.
With the simulation series #A6 and #A7 (upper right panel of Figure 2), we assessed the contribution to the numerical dissipation of the RK3 and RK4 time integrators, respectively. We set and changed the time step by varying the grid resolution. The results presented in Table 1 and the upper right panel of Figure 2 show that the RK3 time integrator performs at its theoretical order, whereas the order of the RK4 integrator is once again (like in the sound wave tests) higher than expected.
The characteristic velocity for the Alfvén wave test problem can be inferred from simulation series #cA1, #cA2, and #cA3, in which we varied the magnetic field, pressure, and density, respectively. We find that the logarithm of the numerical dissipation determined from these simulation data can be fitted (see the lower left panel of Figure 2) by the function
where α and d are fitting parameters, and is the fast magnetosonic speed, which is defined as
where θ is the angle between the perturbation wavevector and the background magnetic field. For a wavevector parallel to the background field (),
The values of the fitting parameter α, which are given in Table 2, confirm that the characteristic velocity is the fast magnetosonic speed (not the Alfvén speed, as one could have presumed), both in the flow regime, where is dominated by the Alfvén speed and the sound speed.
The simulation series #cA4 (Table 2) shows that the characteristic length of the Alfvén wave simulations is, as for the sound wave test, the wavelength, and that the numerical dissipation can be fitted by (see Table 2 and the lower right panel of Figure 2)
Finally, to investigate whether the errors resulting from spatial discretization and time integration are additive, we performed simulations #A8, in which both types of errors should contribute non-negligibly to the numerical dissipation. Figure 3 shows the simulation results together with the expected numerical dissipation of the RK3 integrator (green), the MP5 scheme (blue), and the sum of both contributions (red). As the figure shows, the errors add linearly.
Download figure:
Standard image High-resolution image4.1.3. Magnetosonic Waves
From the simulations of magnetosonic waves, we determine the numerical resistivity and viscosity of the Aenus code. If not otherwise stated, the background pressure, density, and magnetic field strength are set to and , respectively. We perturb the background by a magnetosonic wave of the form
where e1 is the total specific energy of the wave. The velocity amplitude , and the wave's angular frequency ω is given by
For (a value chosen in almost all simulations), the magnetosonic speed reads (see Equation (47))
In the presence of viscosity or resistivity, the wave will be damped with time, i.e., the x component of the wave velocity will decrease as
where the damping coefficient for a fast magnetosonic wave propagating in the direction perpendicular to the background magnetic field is (for the derivation, see Campos 1999)
We verified this equation numerically (see Rembiasz 2013 for details).
We also performed simulations #MS1, #MS2, and #MS3 (Table 1) to investigate the influence of the MP5, MP7, and MP9 reconstruction schemes. From the measured kinetic energy damping, we determined a linear combination of the numerical resistivity, shear viscosity, and bulk viscosity, i.e.,
We fitted the simulation results with the function
where the fit parameter r is the numerically measured order of the reconstruction scheme. From the fit parameter d, and with Equations (17), (20), (21), and (59), we determined the combination of coefficients (see Table 1 and the left panel of Figure 4).
Download figure:
Standard image High-resolution imageUsing simulation series #MS4 and #MS5, we studied the contribution of the RK3 and RK4 time integrators to the numerical dissipation (see Table 1 and middle panel of Figure 4). We find that the RK4 integrator performs at a higher order than theoretically expected. Again, we point out that probably due to the non-TVD preserving property of our implementation of RK4, it overperformes in this test (see Section 4.1.2).
To determine the characteristic speed, we performed simulation series #cMS1, #cMS2, and #cMS3, varying background magnetic field strength, pressure, and density, respectively (Table 2). It is not surprising that the characteristic speed is the fast magnetosonic speed (see the bottom panel of Figure 4), which is confirmed quantitatively with the help of the fit function
As expected, the fit (see Table 2) is consistent with within the measurement errors. The value of d can be used to estimate . In the asymptotic regime , the numerical damping is independent of the magnetic field strength, while it is proportional to the field strength for .
4.1.4. Estimation of Numerical Resistivity and Viscosity
So far, we measured the numerical damping for three wave types separately. For each type of a wave, the damping coefficient depends on a linear combination of the resistivity, shear viscosity, and bulk viscosity (see Equations (34), (43), and (58)). This gives a system of three linearly independent equations with three unknowns, which has a unique solution.
If we consider a series of simulations in which time discretization errors are negligible (such as those in the upper left panels of Figures 1, 2, and 4), at a fixed grid resolution and for a given numerical method, the numerical viscosity and resistivity should be the same according to our ansatz (Equations (17), (20), and (21)). Therefore, the damping rates of the three propagating waves can (in principle) be used to compute the numerical viscosity and resistivity.
In Figure 5, we present the resistivity, shear viscosity, and bulk viscosity for three different reconstruction schemes (MP5, MP7, and MP9) as a function of grid resolution. In all simulations, we used the HLL Riemann solver, an RK4 time integrator, and . Fitting a power law to the data allows us to compute the coefficients entering in the ansatz given by Equations (17), (20), and (21). From the fit parameters, which can be found in Table 3, we compute the exponent r appearing in the ansatz independently for resistivity and viscosity. For all three reconstruction schemes (1) the values of r are close to the expected order of convergence, , except for a small deviation in the case of MP9, and (2) the value of the numerical viscosity is significantly larger than the absolute value of the numerical resistivity.
Download figure:
Standard image High-resolution imageTable 3. Values of the Parameters in Our Ansatz for the Spatial Dependence of the Numerical Viscosity (Equations (17) and (20)) and Numerical Resistivity (Equation (21)), Based on a Fit of the Results Shown in Figure 5
Reconstruction | rη | rν | rξ | |||
---|---|---|---|---|---|---|
MP5 | −7.0 ± 0.5 | 4.94 ± 0.02 | 49 ± 3 | 4.95 ± 0.02 | 51 ± 4 | 4.95 ± 0.02 |
MP7 | −41 ± 3 | 6.81 ± 0.03 | 270 ± 50 | 6.80 ± 0.06 | 354 ± 18 | 6.881 ± 0.017 |
MP9 | −3 ± 6 | 6.8 ± 0.6 | 300 ± 200 | 7.9 ± 0.3 | 200 ± 200 | 7.7 ± 0.3 |
Note. We obtain three different estimates of the exponent r from fits of resistivity (rη), shear viscosity (rν), and bulk viscosity (rξ).
Download table as: ASCIITypeset image
Our most striking result is that the value of the numerical resistivity is negative, its absolute value being about one order of magnitude smaller (and even two orders for MP9) than the value of the numerical viscosity (see Table 3). The value of the resistivity coefficient obtained with MP9 (providing the most accurate result) is compatible with a non-negative (very small) numerical resistivity, while the values of the numerical shear viscosity and bulk viscosity are positive and very similar. The resulting damping rate, which is a combination of resistivity and viscosity, prevented an amplification of the wave amplitude in all three systems studied. Taken together, these facts suggest that the numerical viscosity must be considerably larger than the numerical resistivity of the code. Hence, we conjecture that there are large systematic uncertainties that prevent us from properly measuring the numerical resistivity of the code in all three wave propagation tests.
Given that the dissipation is dominated by viscosity rather than resistivity, we had to turn to a completely different system in order to study whether our ansatz for numerical resistivity is a valid one, and if true, whether the results are consistent with a positive value of the resistivity (see Section 4.3).
4.1.5. Waves with a Background Velocity
So far, in the wave damping simulations, we have set the background velocity to zero. To test whether a background velocity affects the numerical damping (i.e., by modifying the characteristic speed of the flow), we repeated the damping test for the sound waves, Alfvén, waves, and magnetosonic waves with a non-zero background velocity. All simulations were performed with the MP5 reconstruction scheme and the RK3 time integrator (with ). For all three Riemann solvers and all types of waves, we observed the same behavior, i.e., the component of the background flow velocity that is perpendicular to the propagation of the wave () does not affect the numerical dissipation, whereas the parallel component () does. Figure 6 shows the numerical dissipation for some exemplary simulations of the sound wave damping test done with the HLL Riemann solver. Based on these simulations, we conclude that the characteristic speed of the flow is given by the sum of (the parallel component of) the flow velocity and the fast magnetosonic speed or, in other words, by the fast magnetosonic eigenvalue of the ideal MHD equations.
Download figure:
Standard image High-resolution image4.2. Sound Waves in 2D
So far, we have studied wave propagation problems in 1D. However, it is well known that unless a genuinely multi-D reconstruction algorithm is used (as proposed by, e.g., Colella et al. 2011; McCorquodale & Colella 2011; Zhang et al. 2011; Buchmüller & Helzel 2014), the order of a reconstruction scheme can be reduced in simulations involving more than one spatial dimension. Our code Aenus employs several independent one-dimensional reconstruction steps (one per dimension). Thus, the convergence rate may be degraded to second order in multi-D simulations, i.e., well below that of 1D applications.
We studied this aspect with the help of 2D simulations (Table 4) of sound wave propagation in a box of size with periodic boundary conditions in both directions. We set the background density and pressure to , and imposed a perturbation of the form
where , , θ is an angle between the x-axis and the wavevector, where
The wavelength is given by
Table 4. Sound Wave Damping in 2D Simulations (Series #LS)
Series | Ly | Reco | Riemann | Time | CFL | r | q | ||
---|---|---|---|---|---|---|---|---|---|
#LS1 | 1 | MP5 | HLL | RK3 | 0.01 | 37.1 ± 2.6 | 4.90 ± 0.02 | ⋯ | ⋯ |
#LS2 | 1 | MP7 | HLL | RK3 | 0.01 | 273 ± 21 | 6.86 ± 0.03 | ⋯ | ⋯ |
#LS3 | 1 | MP9 | HLL | RK3 | 0.01 | 440 ± 300 | 8.2 ± 0.2 | ⋯ | ⋯ |
#LS4 | 1.125 | MP5 | HLL | RK3 | 0.01 | 33.7 ± 4.4 | 4.86 ± 0.02 | ⋯ | ⋯ |
#LS5 | 1.25 | MP5 | HLL | RK3 | 0.01 | 37 ± 7 | 4.90 ± 0.04 | ⋯ | ⋯ |
#LS6 | 2 | MP5 | HLL | RK3 | 0.01 | 37.2 ± 2.7 | 4.90 ± 0.02 | ⋯ | ⋯ |
#LS7 | 2 | MP7 | HLL | RK3 | 0.01 | 276 ± 24 | 6.86 ± 0.03 | ⋯ | ⋯ |
#LS8 | 2 | MP9 | HLL | RK3 | 0.01 | 570 ± 370 | 8.3 ± 0.2 | ⋯ | ⋯ |
#LS9 | 3 | MP5 | HLL | RK3 | 0.01 | 37.1 ± 2.5 | 4.90 ± 0.02 | ⋯ | ⋯ |
#LS10 | 3 | MP7 | HLL | RK3 | 0.01 | 277 ± 24 | 6.86 ± 0.03 | ⋯ | ⋯ |
#LS11 | 3 | MP9 | HLL | RK3 | 0.01 | 680 ± 360 | 8.35 ± 0.18 | ⋯ | ⋯ |
#S3 | ⋯ | MP5 | HLL | RK4 | 0.01 | 43.4 ± 2.5 | 4.962 ± 0.0141 | ⋯ | ⋯ |
#S5 | ⋯ | MP7 | HLL | RK4 | 0.01 | 302 ± 20 | 6.897 ± 0.021 | ⋯ | ⋯ |
#S6 | ⋯ | MP9 | HLL | RK4 | 0.01 | 830 ± 340 | 8.42 ± 0.15 | ⋯ | ⋯ |
#LS12 | 1 | MP9 | HLL | RK3 | 0.5 | ⋯ | ⋯ | 1.28 ± 0.04 | 2.94 ± 0.01 |
#LS13 | 1 | MP9 | HLL | RK4 | 0.5 | ⋯ | ⋯ | 17 ± 3 | 5.14 ± 0.05 |
#LS14 | 2 | MP9 | HLL | RK3 | 0.5 | ⋯ | ⋯ | 1.4 ± 0.2 | 2.970 ± 0.005 |
#LS15 | 2 | MP9 | HLL | RK4 | 0.5 | ⋯ | ⋯ | 31 ± 9 | 5.3 ± 0.1 |
#LS16 | 3 | MP9 | HLL | RK3 | 0.5 | ⋯ | ⋯ | 1.56 ± 0.01 | 2.978 ± 0.002 |
#LS17 | 3 | MP9 | HLL | RK4 | 0.5 | ⋯ | ⋯ | 46 ± 17 | 5.38 ± 0.13 |
#S7 | ⋯ | MP9 | HLL | RK3 | 0.5 | ⋯ | ⋯ | 1.492 ± 0.013 | 2.985 ± 0.002 |
#S9 | ⋯ | MP9 | HLL | RK4 | 0.5 | ⋯ | ⋯ | 71 ± 32 | 5.5 ± 0.2 |
Note. Additionally, for the Reader's Convenience, we repeat some 1D simulations (Series #S) from Table 1. The columns give (from left to right) the series identifier, the Ly box length (Lx = 1), the reconstruction scheme, the Riemann Solver, the time integrator, and the CFL factor. In all 2D simulations, a uniform grid is used (i.e., ) and the number of grid zones Nx per Lx is in the range from 8 to 32. The estimator for , r, , and q (see Equations (17) and (20)) is obtained from linear fits to the simulation results. For sound waves, and .
Download table as: ASCIITypeset image
In all 2D simulations, we set Lx = 1, like in all 1D sound wave simulations (but series #cS3) and use a uniform grid, i.e., . Note that the 1D expressions are recovered in the limit . We determine numerical damping from the kinetic energy of sound waves whose time evolution is
in an analogous manner as described in Section 4.1.1. In the case of scalar constant bulk and shear viscosities, the damping rate is given by (analogically to the 1D case, Equation (34))
However, as already mentioned in Section 2.3 (see Equation (24)), numerical viscosities have a tensorial character in a multi-D simulation, hence the damping rate is given by
To be able to determine (linear combinations of) and (defined in Equations (17) and (20)), i.e., and (Table 4), we first need to identify the characteristic velocities , and , and lengths , and of the system. From our studies in 1D, we infer that the former must be the sound speed, which is homogenous and isotropic in the whole system and, thereby, . Moreover, we postulate that and , since, for the reconstruction scheme in each dimensional sweep, this 2D sound wave problem reduces to a 1D wave propagation (e.g., Equation (62) reduces to Equation (50) for ). The characteristic (physical) timescale of the system is . Furthermore, since the time integration errors must be proportional to , we conclude that .
Therefore, for our system, ansatzes for and (see Equations (25) and (27)) read
The ansatzes for the other components of numerical viscosities have an analogous form. Finally, the damping rate for 2D wave simulations is
which for an equidistant grid, i.e., , and Lx = 1, further simplifies to
According to the above equation, for simulations in which numerical dissipation is dominated either by spatial reconstruction errors (series #LS1–#LS11 from Table 4) or by time integration errors (series #LS12–#LS17), the dissipation rate should, respectively, be and times larger than in the corresponding 1D simulations (with the same . Note that this difference between 1D and 2D simulations is due to the small change in the value of λ. Deviations from this expected value would be indicative of differences in the dissipation coefficients between 1D and 2D simulations. For the MP5 reconstruction scheme, assuming r = 5, and boxes with , and 1.25, the dissipation should be respectively , and 1.26 times larger than in the 1D case, whereas in boxes with Ly = 2 and 3, the numerical dissipation rate should be basically equal to the 1D case (i.e., merely greater by a factor of 1.016 and 1.001, respectively). The upper panel of Figure 7 depicts (in red) the damping rates in simulation series #LS1, #LS4, #LS5, #LS6, and #LS9 (Table 4) performed with the MP5 reconstruction scheme in 2D boxes of those sizes. The ratios of these damping rates to the damping rates in 1D (simulation series #S3 from Tables 1 and 4, marked with asterisks in the figure) are in very good agreement with the above estimates. Similarly, we expect twice higher dissipation rates in simulations done with MP7 (series #LS2) and MP9 (series #LS3) reconstruction schemes in boxes with Ly = 1 than in their 1D counterparts (simulation series #S5 and #S6, respectively), and basically equal (to the 1D case) dissipation rates in simulations with Ly = 2 and Ly = 3 (simulation series #LS7, #LS8, #LS10, and #LS11). Indeed, dissipation rates presented in the upper panel of Figure 7 exhibit this behavior.
In the above analysis, we implicitly assumed that , etc., are equal in 1D and 2D simulations, so the previous analysis only provides a consistency check. However, these coefficients can actually be measured in 2D simulations and can be compared with the coefficients obtained for the 1D case. In Table 4, we present estimators for these quantities determined in the 2D simulations from dissipation rates with the help of Equation (75) in an analogous way as described in Section 4.1.1. The estimators are indeed equal within the measurement errors for each reconstruction scheme, i.e., MP5, MP7, and MP9, in 1D and in 2D simulations. This signifies that our ansatzes (24)–(27) are correct at least for 2D wave simulations for the spatial reconstruction errors.
The bottom panel of Figure 7 depicts dissipation rates in simulation series #LS12–#LS17 (Table 4) performed with the MP9 reconstruction scheme (so that spatial discretization errors are negligible), , and RK3 (red) or RK4 (blue) time integrators in 2D boxes with Ly = 1, 2, and 3 as well as in 1D (series #S7 and #S9). The estimators for q and determined from these data are presented in Table 4. The RK3 time integration scheme once again (like in 1D) has its theoretical order, i.e., , whereas the RK4 time integrator once again overperforms by one unit the expected order, i.e., . The estimators for and q for the RK3 scheme are very similar in 1D and 2D simulations, whereas, for the RK4 scheme, there is a discrepancy that cannot be explained by the measurement errors (i.e., ranges from 17 ± 3 to 71 ± 32, and q from 5.14 ± 0.05 to 5.5 ± 0.2). Note, however, that this discrepancy is insignificant in the considered range of because there is a clear correlation between q and , i.e., the larger q, the larger , leading to very similar predictions for the dissipation rate as we show in the next paragraph. Therefore, we conclude that our ansatzes (24)–(27) are valid for time integration errors in 2D and that both RK3 and RK4 time integration schemes perform (basically) identically in 1D and 2D simulations (with various box sizes).
Download figure:
Standard image High-resolution imageBased on Equation (75), we can make the following estimates for simulations where time integrator errors are dominant. For simulations done with RK3, assuming q = 3 (and equal ), in a box with , and 3 (series #LS12, #LS14, and #LS16, respectively) numerical dissipation should be, respectively, , and 1.23 times greater than in 1D simulations (series #S7). For analogous simulations done with RK4 (series #LS13, #LS15, and #LS17, respectively), assuming q = 5 (and equal ), the dissipation rates should respectively be greater than in the 1D case (series #S9). As can be seen in the bottom panel of Figure 7, these predictions agree very well with our simulation results.
4.3. TM Tests
The TM instability is a resistive MHD instability that can develop in current sheets, where, as a direct consequence of Ampère's law, the magnetic field changes direction. TMs dissipate magnetic energy into kinetic energy and subsequently into thermal energy, disconnect and rejoin magnetic field lines, thereby changing the topology of the magnetic field. The linear theory of TM was extensively studied, in the context of plasma fusion physics, in a seminal paper by FKR63. TMs are of great relevance in astrophysics, (e.g., in the magnetopause or magnetotail of the solar wind, in flares or coronal loops of the Sun, and in the flares of the Crab pulsar (see Priest & Forbes 2007; Pucci & Velli 2014). They have also been suggested to be a terminating agent of the MRI (Balbus & Hawley 1991; Latter et al. 2009; Pessah 2010, but see Rembiasz et al. 2016b who observed an MRI termination by the Kelvin–Helmholtz instability in their 3D MRI simulations).
In this section, we present a test involving TMs for which we know how the reconnection rate depends on the relevant parameters (resistivity, viscosity, etc.). By performing numerical simulations of viscous, but non-resistive, MHD flows at different grid resolutions with various numerical methods, we developed a method to measure the numerical resistivity of MHD codes.
4.3.1. Theory
In this section, we sketch how to analytically obtain a growth rate and an instability criterion of the TM instability, leaving out all technical details that can be found in Appendix
Consider a two-dimensional flow in the x–y plane of constant background density threaded by a magnetic field
where b0 is the magnetic field strength and a defines the shear length (see Figure 8). This magnetic field configuration gives rise to a current sheet at . To balance the resulting magnetic pressure gradient, one can introduce either a gas pressure gradient, so that (pressure equilibrium configuration), or an additional magnetic field component, so that (force-free configuration). Both equilibrium configurations are stable in ideal MHD, but are TM unstable in resistive MHD.
Download figure:
Standard image High-resolution imageFKR63 derived the instability criterion and the growth rate using the linearized resistive-viscous MHD equations in the incompressible limit, which read
where , , and we denote background and perturbed quantities with subscripts "0" and "1" respectively. In the incompressible limit, holds, which was used to obtain the linearized equations. To simplify the notation, we omit hereafter the subscript "1" for the velocity perturbations, because the background flow is assumed to be at rest.
FKR63 solved the above equations using a WKB ansatz, i.e.,
where k is the wavevector in the x direction, and γ is the growth rate of the TM instability. This ansatz is justified only if the time dependence of the background magnetic field can be neglected. This is the case when the diffusion timescale is much larger than the instability timescale, i.e., . The Alfvén crossing time must be sufficiently short too, i.e., , which is equivalent to considering instantaneous propagation of Alfvén waves through the system. Combining both conditions, we have
Among other cases, FKR63 also considered perturbations whose wavelengths in the x direction are comparable to (but smaller than) the shear width, i.e.,
For such perturbations, the wavevectors may differ from that of the fastest growing mode appreciably, and it is possible to set up a numerical test in which, for a given grid resolution, both the magnetic shear layer and the TM are well resolved.
FKR63 solved the TM problem in the limit (84) with a so-called boundary layer analysis (BLA; for details, see Appendix
In the BLA, the inner solution of the resistive MHD equations in a linearized background, i.e.,
(which holds for blue dashed line in Figure 8), is matched with the ideal MHD solution in the outer region at some matching point . The coordinate has to fulfill the condition (or ), which implies that these transition regions can exist only if
In the inviscid limit, analytic TM solutions of the resistive MHD equations can be obtained. For the background magnetic field given by Equation (76), TM will grow if
In this case, the growth rate of the TM is
and the width of the resistive layer is according to our definition
(see Equations (147) and (148), respectively).
The growth rate given by Equation (88) is of little value for our purpose, since it is obtained in the inviscid limit. However, as we have argued in Section 2, both numerical viscosity and resistivity are an unavoidable result of the discretization of the equations. Hence, if we want to use TMs to measure numerical resistivity, we have to use an approach that takes into account numerical viscosity as well. FKR63 also considered the resistive-viscous case for Prandtl numbers
in the limit . Based on their approach, we obtained the TM growth rate for wavenumbers (see Equation (153))
and the width of the resistive-viscous layer
These expressions should be useful to set up a test to measure numerical resistivity. However, as we will show in the next sections, it is difficult to find a region in the numerical parameter space, where Equation (91) holds, i.e., where Equations (83), (84), (86), and (90) are fulfilled.
4.3.2. Numerical Simulations of Physical TM
To demonstrate the possibility of using a TM simulation to measure numerical resistivity, we first set up the test using physical resistivity. This allows us to estimate the reconnection rate as a function of physical resistivity and viscosity.
Our numerical experiment is based on Landi et al. (2008), who were mainly interested in the nonlinear phase of TM, i.e., the formation of magnetic islands and the onset of turbulence. Since we want to study the exponential growth of a single TM in detail, we modified their setup for our purposes. We used a computational box of size , where , with periodic and open boundary conditions in x and y directions, respectively. We set the density and pressure to , and used an ideal-gas EOS with . In the expression for the background field, Equation (76), we set and a = 0.1.
We tested both the pressure equilibrium and force-free configurations and found that only the latter is suitable for our numerical experiments (see Rembiasz 2013 for details). To obtain the force-free configuration, we set
We note that our initial perturbations differ from those of Landi et al. (2008). Because those authors only perturbed the velocity, the TM instability is triggered promptly for high resistivities only (). Instead, we perturb both the velocity and the magnetic field based on an analytic solution of the TM:
The function is given by Equations (132) and (145) for and , respectively, where is the matching point (typically ). Landi et al. (2015) used similar perturbations, i.e., eigenfunctions of the TM, in their studies of what they called "an ideal TM." This ideal case is a solution of the TM problem in a regime first studied by FKR63, but different from the one we consider here.
The function in Equation (95) is given by Equation (131) for , and it is constant for , i.e., according to the "constant ψ approximation" (see Appendix
To compare the results of our TM simulations with the analytical predictions of Equations (91) and (92) for the TM growth rate and the width of the resistive-viscous layer, respectively, we must ensure that we are in the regime of applicability of these analytical predictions, i.e., Equations (83),(84), (86), and (90) should be fulfilled. The first condition (Equation (84)) is ensured by our choice of k and a. The other conditions can be written as
We plot iso-contours of these four quantities in the η-ν plane (see Figure 9) to locate the region where the analytical expressions are valid.
Download figure:
Standard image High-resolution imageWe first discuss the results of a simulation with and , which we call the reference model (#Rf) and which is marked by an asterisk in Figure 9. The first condition (Equation (96)) is only marginally satisfied for the reference model (). To improve the situation, one should decrease the resistivity and viscosity, i.e., one should increase the grid resolution. This would place the model toward the lower left corner of Figure 9, where all the conditions are better satisfied. Therefore, we are limited here by the numerical resolution that we can afford. In the following, we present simulations with numerical resistivities and viscosities as low as 10−7, corresponding to values of in the range of , which are marginally consistent with Equation (96). As a result, the diffusion timescale is only about 10 times larger than the TM e-folding time, i.e., we observe diffusion of the background solution within the duration of the simulation. We circumvent this problem by solving, instead of the proper induction Equation (4), a modified (physically incorrect) version for a constant resistivity, η:
Thereby, the background magnetic field, , does not suffer from diffusion by resistivity.
The second condition (Equation (97)) yields for the reference model, i.e., the Alfvén crossing time is sufficiently small compared to the growth timescale of the TM instability.
The third condition (Equation (98)) is for the reference model, i.e., it is only roughly fulfilled. This condition is the most challenging one to be met in numerical simulations, because the size of the resistive-viscous layer has to be much smaller than the width a of the magnetic shear layer. This can be achieved again by decreasing viscosity and resistivity, but since (Equation (92)) it is necessary to decrease by six orders of magnitude to decrease by a factor of 10. Thus, if we aim for , we need grid points for each box dimension to resolve the resistive-viscous layer with ∼10 grid points.
The fourth condition (Equation (99)) is satisfactorily fulfilled, since .
The reference simulation #Rf was performed with the HLL Riemann solver, an MP9 reconstruction scheme, and with a grid of 2048 × 2048 zones (Figure 10). We find that the initially imposed magnetic field and velocity perturbations do not evolve much with time, except for a growth of their amplitudes. This indicates that our initial perturbations, which are based on the TM solution in resistive-non-viscous MHD (in the constant ψ approximation), are very similar to the eigenfunctions of resistive-viscous TM.
The upper right panel of Figure 10 shows profiles in the y direction of the initial (black) and the evolved (at t = 40; green) magnetic field perturbations at , the latter being normalized to the ratio . The corresponding velocity perturbation at x = 0 (bottom panels) exhibit two pronounced extrema surrounding the magnetic shear layer (marked by the two vertical green lines in the lower right panel, which is a zoom of the lower left panel), which are characteristic of TMs.
To measure the TM growth rate, we compute the evolution with time of the quantity
where the integration is performed only up to to reduce a potential influence of boundary conditions. After an initial transient lasting up to 20 time units during which the initial perturbation adjusts to the analytic solution, grows exponentially at a constant rate. Since ,
where the constant depends on the initial perturbation amplitude and the box size. Using the above equation, we compute the instability growth rate by means of a simple linear regression. The black line in the upper left panel of Figure 10 shows the time evolution of , while the green dashed line is the linear fit according to Equation (102). Note that both lines are almost indistinguishable after the initial transient time.
Download figure:
Standard image High-resolution imageTo obtain the width of the resistive-viscous layer, we plot for every simulation at t = 30 and measure the locations and of the two velocity extrema (see vertical green lines in the bottom right panel of Figure 10). To attribute a measurement error, we note that the extremum can be located anywhere inside of the corresponding computational zone of vertical size . Thus, the actual location of the extremum is uncertain up to an error , i.e., the layer width is
The methodology explained above to measure the growth rate γ and the width of the resistive-viscous layer was applied to all TM simulations discussed below. To understand the dependence of these quantities on the different relevant parameters and to compare with the analytic results, we performed several series of simulations exploring the parameter space in the neighborhood of the reference model, by varying η, ν, b0, and k. Details of these simulations can be found in Appendix
The main result extracted from this set of (numerically converged) simulations is the disagreement between the numerically obtained growth rates and the analytic ones given by Equation (91). The most likely explanation for the discrepancy is that the parameters of our TM simulations are outside of the regime of validity of the analytic results, particularly because of the difficulty to guarantee . Unfortunately, this means that the analytic expressions (91) and (92) cannot be used to measure numerical resistivity. Thus, we decided to use an empirical approach to the problem.
Using the insight gained from the theoretical work of FKR63, we postulate an ansatz for the dependence of both the TM growth rate and the width of the resistive-viscous layer on the physical parameters, which we then calibrate using the series of numerical simulations mentioned above. The whole procedure is described in detail in Appendix
Figure 11 shows the TM growth rates (upper panel) and the width of the resistive-viscous layer (lower panel) measured from two series of simulations done with a viscosity (blue diamonds) and (red asterisks) for different values of the resistivity. Solid lines represent the empirical expressions given by Equations (104) and (105), while the analytic results given by Equation (91) are plotted with dashed lines in the upper panel of Figure 11. The discrepancy in the growth rate between analytic and numerical results is obvious, whereas our empirical expression (105) for the width of the resistive-viscous layer is compatible with the analytical one (Equation (92)).
Download figure:
Standard image High-resolution image4.3.3. Numerical TM
With the knowledge acquired from the resistive-viscous simulations of the previous section, we can tackle the problem of estimating the numerical resistivity of the code. If we perform a simulation with , the development of TM signals the presence of a non-zero numerical resistivity , because TM are not present in ideal MHD.
For the numerical setup presented in the previous section and for a viscosity , the TM growth rate should be well described by Equation (104), if . In this case, we can determine using the expression
where we need to measure only the growth rate of the instability, γ, for a simulation with k = 3 and a = 0.1.
Alternatively, one could measure the resistive-viscous layer width (Equation (105)) to obtain from the expression
This method is much less accurate, however, because measuring from a simulation is prone to rather large relative errors (of the order of 0.1), and because .
To compute the numerical resistivity from Equation (106), we need to know the value of the viscosity ν. However, for a coarse numerical resolution, the value of the numerical viscosity can be of the same order. Therefore, we should require . Expecting that the numerical resistivity and viscosity are of the same order, we had to choose a value of ν that is larger than the typical values of both numerical resistivity and numerical viscosity. On the other hand, ν must not be too large because the growth rate of the instability decreases with increasing ν, i.e., more expensive simulations are required. The size of the resistive-viscous layer also grows with ν and may become comparable to a, thus violating the condition , i.e., Equation (104) no longer holds. As a compromise, we chose a value of and performed all simulations with sufficiently high resolution to ensure that .
Equation (104) was obtained from numerical simulations in which we removed the background field from the resistive term of the MHD equations (see Equation (100)) to prevent diffusion of the background field. The simulations to be discussed in the remainder of this section did not require this measure, because they were performed without physical resistivity. In spite of this difference, we can still apply the calibration obtained in the former series of simulations, because we find that the results of both series of simulations are consistent (TM develop in both cases, but the background magnetic field does not diffuse). Hence, numerical resistivity seems to act independently on large scales (diffusion of the background field across the box) and small scales (development of TM). This finding confirms our ansatz, which postulates that the value of numerical resistivity differs for phenomena occurring at different length scales, because depends on the typical length () and velocity () of the flow.
To determine the dependence of the numerical resistivity on the three Riemann solvers (LF, HLL, HLLD), we performed simulations with the MP5 reconstruction scheme, the RK3 time integrator, a CFL factor of 0.7, and grids of 128 × 128 to 1024 × 1024 zones. The default physical parameters were a = 0.1, k = 3, , , and .
We find that TM are instigated by numerical resistivity for the LF solver. In the simulations performed with the HLL and HLLD Riemann solvers, no TM are observed, i.e., the numerical resistivity resulting from these solvers, though undetermined, must be much less than that of the LF solver. For the latter solver, as expected, the higher the grid resolution the smaller the instability growth rate, i.e., the lower the numerical resistivity (see Figure 12), since (Equation (104)). Coarsening the grid resolution, the numerical resistivity eventually becomes so high that the width of the resistive-viscous layer is so large that Equation (104) is invalid, and we can no longer precisely measure the magnitude of the numerical resistivity. The resolution limit depends on the order of the reconstruction scheme, being 320, 256, and 224 zones per dimension for the MP5, MP7, and MP9 scheme, respectively.
Download figure:
Standard image High-resolution imageThe results of an exemplary simulation (#Ex) without resistivity obtained with MP5 reconstruction scheme on a grid of 384 × 384 zones are shown in Figure 10. Like in the reference model #Rf (with black dashed–dotted line in upper left panel), a TM grows exponentially with time in model #Ex (red dashed–dotted line in the panel), this time being driven by numerical resistivity (in this simulation marked with the third rightmost asterisk in Figure 12). The TM induced growth of the magnetic field (upper right panel of Figure 10) and velocity (bottom left panel) perturbations in model #Ex (without resistivity; red lines) are similar to those in model #Rf (with resistivity; green lines). This comparison clearly demonstrates that the behavior of the numerical resistivity closely resembles that of (real) physical resistivity.
We anticipate that the main contribution to the numerical resistivity comes from the y-direction. All variables exhibit a much stronger variation in the y-direction than in the x-direction. Hence, the characteristic length scales in our multi-D ansatz for the numerical resistivity (analogous one to ansatz (24) for numerical shear viscosity), are much larger in the x-direction than in the y-direction, . More specifically, we can preliminarily estimate that and . Consequently, the total numerical errors coming from the x-direction will be negligible compared to the ones due to the discretization in y, allowing us to use the simpler one-dimensional ansatz in the following. Therefore, in the further discussion of TMs, we will refer to the 1D ansatz for numerical resistivity (Equation (21)) for the sake of simplicity. Furthermore, we will use instead of , since they are equal in our simulations, having in mind, however, that the main contribution comes form errors proportional to . A similar situation occurred in the 2D simulation of sound waves (series #LS6–#LS11 from Table 4) in which and therefore the contribution of the y sweep to the numerical dissipation was negligible and one could equally well use 1D ansatzes for numerical dissipation.
The dependence of the numerical resistivity (which is determined from the measured growth rate of the instability using Equation (106)) on the grid resolution is shown in Figure 12. The results are fitted with the functions
where and ci are the coefficients of the MP reconstruction scheme of the ith order. Their values are (for a CFL factor in the range of 0.1–0.7)
If the numerical resistivity scales as as in Equation (21), one would naively expect that the growth rate scales as , i.e., the expected theoretical values should be , , and , which do not agree with our results. As we explain below, this argumentation is wrong, however, because it fails to account for an (implicit) dependence of the quantities and on .
To explain the apparent considerable reduction of the convergence order r of the MP reconstruction schemes in (109), we need to have a careful look at the ansatz (21) for the numerical resistivity (neglecting the contribution of time integration errors)
where and are the system's characteristic speed and length, respectively.
If we were to assume (which is constant), we would obtain . The conceptual mistake we have made here is that a is the correct choice for the characteristic length of the background magnetic field diffusion problem, but not for a TM whose length scale is much smaller than the shear width. It turns out (as we demonstrate below) that the characteristic length of the system is proportional to the width of the resistive-viscous layer, i.e., . This seems logical because the current sheet can be described very well neglecting Ohmic dissipation everywhere outside the narrow resistive-viscous layer whose width is rather than a.
The value of is somewhat arbitrary, because the boundary of the resistive-viscous layer is (physically) not sharp. We defined its width to be set by the characteristic velocity peaks (see Figure 8), which is a useful convention for our purpose. In fact, there exists a transition region (marked in shaded yellow in the figure), where the ideal MHD equations can still approximately be applied, though one is already in the non-ideal regime.
For our applications, we found a useful definition based on the fact that resistive and viscous effects are largest in the vicinity of steep gradients of the MHD variables. The (in relative terms) most important gradient is that of the y-component of the velocity, which is very large between the two extrema close to the current sheet (see bottom left panel of Figure 10). Taking into account that is the half distance between the two extrema, which approximately corresponds to one-fourth of a wavelength of a sine function, we propose to use as the proper length scale
This choice is consistent with identifying with the wavelength in the wave damping tests. It further suggests that a similar reasoning based on local extrema may lead to the appropriate value in other systems as well. Combining Equations (111) and (110), we obtain
On the other hand, from Equation (105), we have
Note the explicit dependence of Equation (112) on and of Equation (113) on . This dependence can be easily removed obtaining the expressions
which are valid only for a = 0.1 and k = 3, and give the true dependence of and on the grid resolution. Consequently, the TM growth rate is expected to depend on with an exponent , which allows us to compute the order of convergence from the numerical values as
Similarly, Equation (114) can be used to compute , resorting to the coefficient ci from the fit to the growth rate and identifying as the magnetosonic speed, i.e., in this case ( in Equation (47)).
In Table 5, we list the values of and r computed with the procedure outlined above. The MP5 and MP7 schemes are almost fifth and seventh order accurate, whereas the MP9 scheme performs below the theoretical expectation. In other words, the higher the order of the reconstruction scheme, the higher the reduction of the convergence order. A possible explanation of this fact is the following. The function is proportional to for , i.e., outside of the resistive-viscous layer (see the discussion in Appendix
Table 5. Resistivity Coefficient (for the Definition, See Equation (21)) and Reconstruction Scheme Order r (Equation (116)) Determined from TM Simulations Performed with the LF Riemann Solver (see also Figure 15)
Reconstruction | r | |
---|---|---|
MP5 | 16 ± 5 | 4.81 ± 0.09 |
MP7 | 142 ± 33 | 6.65 ± 0.08 |
MP9 | 170 ± 220 | 7.6 ± 0.6 |
Download table as: ASCIITypeset image
According to Figure 13, the values of measured directly from the numerical simulations (see the previous section) agree well with those computed with Equation (115), where the values of r and needed in this equation are extracted from the growth rate using Equations (109) and (116). This result shows that our assumptions are correct, which is far from being obvious, because we assumed that (1) numerical errors can be called "numerical resistivity," (2) this numerical resistivity can be treated as normal physical resistivity, and (iii) the same equations can be used to determine its magnitude or predict its influence on the system. Moreover, we also had to make use of ansatz (21) for the numerical resistivity.
Download figure:
Standard image High-resolution imageTo test whether the magnetosonic speed is indeed the characteristic velocity of our TM setup, as expected from the arguments given in the discussion of the wave damping simulations, we ran several simulations with the same setup, but varying the fast magnetosonic speed from to . This was achieved by changing the background pressure from 0.01 to 900, keeping . The upper panel of Figure 14 shows that the numerical resistivity increases with .
Download figure:
Standard image High-resolution imageDifferent from the wave damping tests, it is not straightforward, however, to compute the fast magnetosonic speed, because in TM simulations the perturbed fluid makes a "U-turn" in the vicinity of the magnetic shear layer (i.e., for ). Therefore, determining the "correct" values of θ (which changes from 0 to ) and the background magnetic field strength (which changes from 1 for to 0 for ) is very error-prone. That is why we introduced ansatzes (17), (20), and (21) to have a simple way of estimating the code's numerical dissipation. Consequently, we took the maximum possible magnetosonic speed (obtained for Equation (47)) in our previous analysis, i.e.,
and put , which is well motivated by practical purposes (i.e., to keep the ansatzes as simple as possible). However, in the current analysis (simulations presented in Figure 14), we obtained a better fit with respect to with , which corresponds to the Alfvén speed at a distance of y = a, i.e.,
We note that the precise choice of is irrelevant in the high plasma β regime, while it only slightly affects the quality of the fits in the low plasma β regime (where the parameter ).
From the measured growth rates γ, we determined the numerical resistivity in each simulation (), and fitted the results with
obtaining
From Equation (114) and Equation (104), we find that
and putting in Equation (121), we finally obtain
For MP5 reconstruction (), the expected value is s = 0.6, which is close to the measured one. Using s from Equation (120), we determine the reconstruction scheme order to be , which is neither equal to 5 within the errors nor consistent with the value of from Table 5. This discrepancy should not concern us, however, because we included only statistical errors in the measurement errors from the linear fit neglecting other errors, e.g., those originating from estimating the fast magnetosonic speed (which changes from zone to zone in the simulation). This implies that this way of determining the order of the reconstruction scheme is much less reliable than from the resolution studies.
In the bottom panel of Figure 14, we show the measured width of the resistive-viscous layer and its value (red curve) predicted from the fit Equation (119). Using the values of s and d in Equation (120), we determined r and , which we then inserted into Equation (115). This methodology demonstrates that our model is self-consistent, since the width of the resistive-viscous layer does depend on as expected.
At the beginning of this section, we made the assumption that the numerical resistivity is not changing the background magnetic profile, but affects only the flow in the resistive-viscous layer, where the TM grows. All consistency checks performed in this section seem to indicate that our assumption is correct. As a confirmation, we checked that there has not been a significant modification of the background profile in any of the simulations. This finding differs from the one obtained in the simulations with physical resistivity but without removing the background field from the induction equation (100). In those simulations, the background field started to diffuse during the simulations (which was the reason why we modified the induction equation (Equation (100)) in the first place).
Finally, in Figure 15, we present a comparison of the expected numerical dissipation in simulations of TM and magnetosonic wave damping based on our ansatz (see Equations (17), (20), and (21)) and the estimators from Tables 1 and 5. For the simulations, we set the characteristic velocities and lengths equal to one, i.e., . The box length is set to 1 too, hence "resolution" in the abscissa of Figure 15 refers to the number of zones per characteristic length. As we can see, the expected numerical dissipation based on calibration with the help of both types of simulations (MS waves and TM) is similar. This is an indication that our approach is presumably universal, and it makes us confident that it can be used to estimate dissipation coefficients for other flows.
Download figure:
Standard image High-resolution image5. Case Study: MRI
In the previous section, we present a methodology that allows us to estimate the numerical viscosity (bulk and shear) and resistivity of a code. It also serves to determine the characteristic velocity, , relevant for the numerical dissipation coefficients. We applied this methodology to the AENUS code for different numerical schemes. Using the ansatzes Equations (17), (20), and (21) and the numerical dissipation coefficients given by Tables 3 (for shear and bulk viscosity coefficients) and 5 (for resistivity coefficients), it is possible to determine the numerical resolution, , needed to perform a numerical simulation with a numerical viscosity and resistivity lower than a given threshold. This allows us to estimate the computational resources needed for a particular application and helps us to choose the numerical scheme that minimizes the computational cost. To show the feasibility and the usefulness of this analysis, we present here the estimates for a particular application of AENUS to simulations of the MRI.
The MRI (Velikhov 1959; Chandrasekhar 1960) is an instability that can develop in a differentially rotating fluid in the presence of a magnetic field. In the case of an homogeneous vertical magnetic field, the MRI develops nonlinear channel flows, which are then disrupted by parasitic instabilities (Goodman & Xu 1994; Pessah & Goodman 2009) into a turbulent flow. The instability has been proposed as the main driver of accretion in accretion disks (Balbus & Hawley 1991) and may play an important role in the amplification of magnetic field during the collapse of stellar cores (Akiyama et al. 2003). There are a number of MHD simulations devoted to the study of the MRI in local box simulations (see, e.g., Obergaulinger et al. 2009; Rembiasz et al. 2016b, 2016a) in which we can aim to resolve numerically the magnetized flow with minimal numerical viscosity and resistivity. The main difficulty of those simulations is that the characteristic length scale relevant for the growth of the MRI channel modes and its termination due to parasitic instabilities (Kelvin–Helmholtz vortices) is very small ( m) compared to the size of the system (∼10 km) when realistic conditions are considered (see Obergaulinger et al. 2009, for a discusion). Here we show, as an example, how one can estimate the resolution requirement and computational cost for the numerical simulations presented in Rembiasz et al. (2016b).
In the typical setup of Rembiasz et al. (2016b), the box size is or (radial, azimuthal, and vertical extension) and channel modes develop with a size of km in the vertical direction (one or three channel modes fit in the vertical direction, depending on the box size). The characteristic length is set by the width of the channel mode, i.e., . The characteristic speed may be chosen among the fast magnetosonic speed ( cm s−1), the Alfvén speed, ( cm s−1), or the flow velocity ( cm s−1). To make a conservative estimate, we take the largest of the three, i.e., cm s−1. The goal of Rembiasz et al. (2016b) was to run the simulations with numerical viscosities and resistivities below a value of cm2 s−1 (according to estimates of Guilet et al. 2015, (physical) viscosity due to neutrinos can vary from cm2 s−1 inside of a proto-neutron star). They estimated that in that regime the Reynolds numbers are above ∼100, which would be sufficient to have convergent results for the growth of the channel flows up to the termination due to parasitic instabilities. The post-termination evolution of the generated turbulent flow would have probably required more stringent resolutions, but this was not the aim of Rembiasz et al. (2016b).
Figure 16 shows the estimated numerical viscosities and resistivities of the AENUS code according to the measurements of the present work rescaled to the simulations of Rembiasz et al. (2016b) for an HLLD solver and three different reconstruction schemes (MP5, MP7, and MP9). According to the figure, it is sufficient to perform simulations with 10, 14, and 28 zones per to reach the accuracy goal for MP9, MP7, and MP5, respectively. This result demonstrates the advantage of using ultra-high-order schemes (MP9) in simulations of smooth flows.
Download figure:
Standard image High-resolution imageOnce the numerical resolution is known, it is possible to estimate the computational cost of a given simulation. As an example, we consider our smallest simulation box (), a typical simulation period of 12 ms duration, and a CFL factor of 0.7. AENUS performs on the SuperMUC supercomputer (www.lrz.de) typically at 0.15 ms/iteration/zone. The upper abscissa of Figure 16 shows the resulting total CPU time for this setup. To reach the accuracy goal, we estimate that we need at least 15, 60, and 842 CPU hrs for MP9, MP7, and MP5, respectively. Even if MP9 suffers a slight computational overhead in comparison to MP7 and MP5, due to the larger size of the numerical stencil, our analysis shows that it pays off to perform simulations with MP9. Indeed, Rembiasz et al. (2016b) performed their simulations with resolutions ranging from 20 to 134 zones per and showed convergence of the results.
6. Summary and Conclusions
We have presented a reliable methodology to measure the numerical shear and bulk viscosity, and the resistivity of Eulerian finite volume MHD codes by means of a simple ansatz for each of these numerical effects, which are inevitably present in any such code. We have postulated that the amount of numerical dissipation depends on the characteristic length and velocity of the system under consideration, the numerical resolution, and some free parameters that have to be calibrated depending on the numerical scheme in use. Hence, our ansatz for each of the three numerical effects consists of two additive terms describing the contribution of spatial and temporal discretization errors, which both depend on the characteristic length and velocity of the system, and on the grid resolution and the size of the time step, respectively.
We performed the parameter calibration by means of a set of test simulations using the Aenus code. However, because the procedure is not restricted to this code, we provide potential users of our methodology with the detailed results of our test suite at http://www.uv.es/camap/tmweb/Web_tm.html. These data should help to measure the dissipation coefficients of other Eulerian finite volume MHD codes.
First, we have considered three wave damping tests from which one can directly extract a linear combination of the numerical resistivity, and the numerical shear and bulk viscosities. These simulations allowed us to estimate the latter two quantities accurately. However, we failed to obtain a physically sound value of the numerical resistivity, because it is much smaller than that of the numerical viscosity of Aenus, i.e., our estimate of the numerical resistivity is dominated by systematic errors.
Nevertheless, the wave damping simulations confirm the appropriateness of our ansatz for the numerical shear and bulk viscosity, and the resistivity. In almost all simulations performed by us, the spatial reconstruction schemes and the RK time integrators have the theoretically expected order of accuracy. We also find that in simulations of sound waves, Alfvén waves, and fast magnetosonic waves, the characteristic length and velocity of the system are always the wavelength of the wave and the fast magnetosonic speed (which reduces to the sound speed in the case of sound waves), respectively. Because the value of the numerical resistivity is substantially lower than that of the numerical viscosity in the wave damping tests (see above), the numerical magnetic Prandtl number is not close to 1, as is commonly suspected among practitioners in the field.
Second, we have performed TM simulations since the wave damping ones were hardly useful to asses the value of the numerical resistivity. By measuring the growth rate of the TM instability and fixing the value of the physical viscosity, we have been able to estimate the numerical resistivity of Aenus. Moreover, from the estimated value of the numerical resistivity, we could correctly predict the expected width of the resistive-viscous layer. This indicates that our method is (self-)consistent. A cautionary note must be added here. In order to obtain reliable estimates of the numerical resistivity in TM simulations, it is necessary to employ spatial reconstruction schemes of the order of . Extensive numerical experience (Rembiasz 2013) shows that the TM setup employed here becomes numerically unstable for lower-order reconstruction schemes in the resolution range considered by us, i.e., it was difficult to maintain a magnetohydrodynamical equilibrium of the background flow for tests in which less than a fifth-order spatial reconstruction scheme was employed.
Comparing the expected numerical dissipation in simulations of magnetosonic wave damping and TM, we find that the expected numerical dissipation based on a calibration with the help of both types of simulations is similar. This indicates that our approach is supposedly universal, which gives us confidence that it is also applicable to estimate the dissipation coefficients for different flow regimes and numerical setups. To illustrate our approach in an astrophysical context, we have estimated in Section 5 the numerical viscosities and resistivity for the MRI models of Rembiasz et al. (2016b), which in turn have allowed us to obtain a reliable estimate of the computational needs in terms of numerical resolution and computational time for these particular simulations.
We have found that the high orders of convergence of the MP reconstruction schemes obtained in the wave damping tests are retained in the 2D simulations of sound waves and TMs. This is a remarkable result, because our approach is based on several (one per dimension) independent one-dimensional reconstruction steps instead of a genuinely multi-D reconstruction algorithm as proposed by, e.g., Colella et al. (2011), McCorquodale & Colella (2011), Zhang et al. (2011), and Buchmüller & Helzel (2014). In general, such a simplification may introduce additional numerical errors, thus degrading the order of accuracy of multi-D simulations to second order, i.e., well below that of 1D ones.
However, our 2D simulations do not suffer from this degradation. This may be the result of our somewhat simple tests, i.e., in the TM case, the derivatives in the y-direction dominate over the ones in the x-direction, and in 2D simulations of sound waves, we consider small sinusoidal perturbations of the background. One should not expect this behavior to hold in a general case of a nonlinear multi-D problem. However, exploring this topic is beyond the scope of this work.
It is important to note that, in our ansatz, there is a single length scale for which the dissipation coefficients are estimated. If applied to systems in which dissipation occurs at multiple length scales (e.g., turbulence), then the interpretation of our ansatz is a measurement of the dissipation coefficients at each length scale, which may give rise to different values of these coefficients. Indeed, we observe this effect in our TM simulations, if the background magnetic field is not eliminated from the induction equation. If not eliminated, we have dissipation occurring both in the resistive-viscous layer (of size ) and within the background shear profile (of size ) at the same time. This scale-dependent definition of the dissipation coefficients is similar to that used in large eddy simulations of anisotropic weakly compressible turbulence (see, e.g., Fureby & Grinstein 1999; Zhou et al. 2014; Radice et al. 2015). Alternatively, we could have formulated our ansatz equivalently in terms of scale-independent hyperviscosity and hyperresistivity coefficients. This formulation has the disadvantage of not having physical counterparts for the purely numerical hyperdissipation coefficients but, on the other hand, it allows us to interpret the high-order derivative terms appearing in the Taylor expansion of the space and time derivatives (see Equation (10)).
Using our ansatz may not always be straightforward, since it requires identifying the relevant characteristic velocity and length , of the system. As for the former, we have shown that in all our tests (wave damping and TM) without background flow, the characteristic velocity is equal to the fast magnetosonic speed. In the wave damping tests with a non-zero background velocity (see Section 4.1.5), we have found that the characteristic velocity depends on the direction of the wave propagation relative to the direction of the background flow. However, one can easily obtain an estimate for the upper limit of the characteristic velocity, i.e., for the sum of the moduli of the background velocity and the fast magnetosonic speed. The determination of the characteristic length, , of the system can be tricky and requires a good understanding of the simulated system. For example, in the case of the TM simulations, the first "natural candidate" for seems to be the width of the magnetic shear layer, a, (Equation (76)), but it turns out to be the width of the resistive-viscous layer, (Equation (105)).
Even though all of our tests were performed in boxes with uniform grid resolutions, our results can be translated to adaptive mesh refinements (AMR) codes that refine the grid where the flow develops small-scale structures. A natural way of using our ansatzes in AMR simulations would be to apply it at each refinement level separately, i.e., to compute the numerical dissipation coefficients (21) based on the refined grid width. Numerical viscosity and resistivity then quite obviously are position-dependent. This is, however, not a unique feature of AMR simulations because, in general, numerical viscosity and resistivity are local quantities because they depend on the characteristic velocity and length scale that may vary strongly throughout the simulation domain.
Finally, we note that in the (astro-)physics literature hydrodynamic and magnetohydrodynamic simulations are often categorized by the numerical Reynolds numbers
where L and V are the typical length and typical velocity of the system, respectively. However, often both quantities are subjectively chosen. In other words, the assumed typical length and velocity of the system are not the values obtained after a thorough calibration analysis, as we have conducted here. Indeed, in general, and , i.e., the typical values (chosen by the respective author), are not equal to the characteristic values, which are uniquely set by the physics and numerics of a given simulation. Hence, the Reynolds numbers commonly estimated can vary by a few orders of magnitude for the same physical system and numerical setup across the literature. For this reason, the typical values of the numerical Reynolds number seldomly are a useful quantity to cross-compare different numerical models. However, once the numerical viscosity and resistivity are measured (as we propose in this paper), one can easily express simulation results in terms of numerical hydrodynamic and magnetohydrodynamic Reynolds numbers, in as much as the proper characteristic length and velocity of the system have been identified. Because this is not a common practice in the community, we conclude that the use of numerical Reynolds numbers more often obscures than reveals the true nature of numerical viscosity and resistivity.
T.R. acknowledges support from The International Max Planck Research School on Astrophysics at the Ludwig Maximilians University Munich. E.M. and T.R. acknowledge support from the Max-Planck-Princeton Center for Plasma Physics as well as from the Deutsche Forschungsgemeinschaft through the grant EXC 153 "Origin and Structure of the Universe." M.A., M.O., P.C.D., and T.R. acknowledge support from the European Research Council (grant CAMAP-259276). We also acknowledge support from grants AYA2015-66899-C2-1-P, AYA2013-40979-P, and PROMETEOII/2014-069. The computations were performed at the Max Planck Computing and Data Facility (MPCDF) and at the Servei d'Informàtica of the University of Valencia. We thank J. Guilet for his useful comments on the manuscript. We also thank the anonymous referee whose valuable comments and suggestions allowed us to improve the quality of this manuscript.
Software: Aenus (Obergaulinger 2008).
Appendix A: TM Growth Rate
In Appedix A.1, we present an analytical derivation of the TM growth rate in resistive MHD, and we briefly discuss a generalization of these results to resistive-viscous MHD, which was already done by FKR63.
In Appendix A.2, we postulate empirical equations for the TM growth rate in resistive-viscous MHD and calibrate these rates with the help of numerical simulations.
A.1. Analytical Approach
In their analytical study of the TM instability, FKR63 considered the effects of various physical factors, like a position-dependent background density, temperature, and resistivity. We will restrict ourselves to a much simpler system, yet demonstrating the key features of the TM instability. Our presentation is greatly inspired by the excellent discussion of this topic in Goedbloed et al. (2010). We also recommend Schnack (2009) for a concise introduction to the TM instability.
A.1.1. General Case
We consider perturbations of the system described in Section 4.3.1 whose wavelength in x direction is comparable to the shear width, i.e., (Equation (84)). Note that one only needs to solve Equations (77) and (78) for and b1y, respectively, while the other perturbation components can be easily determined from conditions (79) and (80). For the WKB ansatz (Equations (81) and (82)) to be justified, condition (83) must be satisfied.
Inserting the WKB ansatz into Equations (77) and (78) and taking the curl of the latter equation to eliminate the pressure, the y component of the induction equation and the derivative of the z component of the equation of motion read
After some algebra, we arrive at
Because this system cannot be integrated analytically, FKR63 used the BLA method (see Section 4.3.1). They divided the domain into two regions, an outer one ( and , where is a small positive constant such that ) in which dissipative effects can be neglected, and an inner layer () in which resistivity (and viscosity) are important (see Figure 8). The complete solution is determined by an interplay between both regions: resistivity acts in the inner region, but the rate at which magnetic field lines are reconnected also depends on the rate at which the field can be advected into and out of the inner region. Hence, the growth rate can be quite different for field profiles that are the same close to y = 0, but differ elsewhere.
Outer Layer—Condition (83) implies that there are negligible field gradients in the outer regions (), i.e., resistive processes are slow there compared to the growth of TMs. On the other hand, (the second relation follows from assumption 84). Hence, to solve Equations (126) and (127) in the outer region the resistivity term in the induction Equation (126) can be neglected, i.e.,
Furthermore, from the second part of condition (83), we have . This inequality together with Equation (128) implies that terms proportional to velocity (gradients) in Equation (127) are negligible, i.e., . Hence, TMs evolve so slowly that the plasma inertia (terms containing in Equation (127)) can be neglected on the ideal MHD timescale, and Equations (126) and (127) simplify to
in the outer layers. So far, we have not yet made any assumption concerning the background magnetic field. For , the solution of Equation (130) reads
where b1 is a constant (initial perturbation amplitude) and Γ denotes the Euler gamma function. The velocity perturbations can be easily determined combining Equations (129) and (131):
Note that Equation (129) has a singularity for , i.e., for , which is removed (i.e., smearded out) by resistivity in the inner region.
Inner Layer—Resistive (and viscous) terms can no longer be neglected in the inner layer (), and we have to solve Equations (126) and (127) simultaneously. Because in the inner region , we can approximate the background magnetic field (Equation (76)) as (Equation (85)). In the inner region, perturbations in both velocity and magnetic field vary more strongly in the y direction than in the x direction, i.e., and .5 Therefore, we can neglect the terms proportional to k2 in Equations (126) and (127), and we obtain
where we used also Equation (85). Combining both equations into a single one by eliminating terms that contain b1y, we arrive at a sixth-order ordinary differential equation (ODE) for that reads
where and . This equation cannot be integrated analytically, i.e., some further approximations are necessary.
In the inner layer, but sufficiently far away from y = 0, velocity perturbations will have a solution of type , i.e., the terms with the highest order derivatives of dominate the solution of (135). Thus, we proceed neglecting lower-order derivatives in (135). Because the two terms with the highest order derivatives ( and ) depend on viscosity, we consider Equation (135) for two limiting cases, namely in the viscous and the inviscid regime.
A.1.2. Inviscid Case
In the inviscid case (), Equation (135) reduces to a fourth-order differential equation that is still too complicated to be solved analytically. Therefore, we follow FKR63 and use their "constant ψ approximation".6
FKR63 noted that the function becomes singular in ideal MHD because for (see Equation (129)), i.e., varies strongly in the limit of small resistivity. Resistivity regularizes this ill-behaved solution. The function b1y varies less for and can be approximated by a constant . With this approximation, Equations (133) and (134) reduce to
We solve this system of equations by first integrating Equation (136) to obtain , which we insert into Equation (137) to get b1y.
To express Equations (136) and (137) in dimensionless form, we introduce the dimensionless variables
with the length scale
The physical interpretation of is that resistive effects are important in the center (y = 0) up to . In these new variables, Equations (136) and (137) read
The solution of Equation (143) can be written as an integral over an auxiliary variable u (Goedbloed et al. 2010):
The function Φ (black line in Figure 17) is positive for , and has a global maximum at . Moreover, for , and for .
Download figure:
Standard image High-resolution imageTo obtain the final form of the velocity perturbations, , in the inner layer (given by Equations (139) and 145), we need to determine the TM growth rate γ. It can be calculated by matching the inner and outer solutions of (the former given by Equation (132)) at a certain point in the region (marked in yellow in Figure 8), where both solutions are valid and overlap, i.e., where they give the same predictions for both the velocity and the magnetic field perturbations. The value of ym must be large enough, so that can be approximated as , i.e., , yet small enough that the outer ideal MHD solution behaves like (for ). Moreover, the inner resistive solution was found for such small values of y that can be approximated by Equation (85). Hence, must hold. Recalling that s = 1 for , we can combine the above conditions into
The remaining part of the matching procedure is conceptually rather straightforward. Comparing Equations (145) and (132) at , we can determine the TM growth rate γ. We omit the details of these calculations7 and only give here the final expression for the TM growth rate in resistive (-inviscid) MHD:
For , the growth rate is complex (because of the last factor), i.e., the system is TM unstable only for perturbations with wavevectors . On the other hand, for , the growth rate given by Equation (147) diverges, but in this regime the "constant ψ approximation" becomes invalid and Equation (147) no longer holds.
We note that the width of the resistive layer is somewhat arbitrary. Some authors (see Schnack 2009; Goedbloed et al. 2010) define that the layer extends to , whereas we define its boundary to be located at
which corresponds to the maximum of (Figure 17). This is a convenient definition because corresponds to the peaks of , which can be determined from simulations rather easily (compare Figure 17 with the bottom panels of Figure 10).
Equations (132) and (145) for the velocity perturbation , and Equation (131) for the magnetic field perturbation b1y (supplemented by Equation (147) and the transformations (138) and (139) constitute a complete solution of the TM problem in resistive MHD. In the inner layer, the magnetic field perturbation b1y is approximately constant, i.e., , and the perturbations and b1x can be determined from conditions (79) and (80), respectively.
As a next step, we will generalize the above results to resistive-viscous MHD, because Equation (147) does not take into account (numerical) viscosity, which might be comparable to (or even larger than) numerical resistivity.
A.1.3. Viscous Case
The derivation of the TM solution in resistive-viscous MHD by FKR63 is very similar to that of the non-viscous case. Therefore, we will only sketch their procedure (for more details, see FKR63). One integrates Equations (126) and (127) again separately in the outer and inner region. In the outer region, one can neglect dissipative terms and plasma inertia as in the inviscid case, i.e., the magnetic field perturbation b1y and the velocity perturbation are still given by Equations (131) and (132), respectively. In the inner region, FKR63 simplified the sixth-order ODE (135) for using again the "constant ψ approximation" to a fourth-order ODE, but now including viscous terms. They further simplified the ODE by neglecting terms with lower-order derivatives, which is an acceptable approximation for magnetic Prandtl numbers . Next, FKR63 introduced the dimensionless variables
(where we used the tilde symbol to explicitly stress that functions 145 and 150 differ) with the length scale
The latter expression shows that both resistivity and viscosity affect the size of the region, where dissipative effects are important. We call this region the resistive-viscous layer. The width of this layer is proportional to , and hence differs from the width of the resistive (inviscid) layer, which is proportional to (Equation (142)).
In the resistive-viscous case, matching condition (146) has to be replaced by
and from matching of with Equation (132), we obtain the TM growth rate in resistive-viscous MHD:
The above expression differs from the result of FKR63 (see their Equation (H.8)) because these authors derived their equation in the limit (in our units), whereas we did not neglect terms proportional to . For the background magnetic field , we calculated the growth rate more accurately. Note that Equation (153) is only an approximation, because FKR63 only approximately solved ODE (135). Therefore, the above equation could be off by a small constant numerical factor.
Our numerical results differ from the analytic growth rates derived above. Restrictions of grid resolution and computing time prevented us from reaching the parameter regime where the derivation of the analytic growth rates holds. Therefore, in the following subsection, we present an "empirical" ansatz for the TM growth rate, which gives much better predictions for our simulation results presented in Section 4.3.
A.2. Empirical Approach
In the analytically derived Equations (147) and (153), the TM growth rate is proportional to a product of different powers of resistivity, viscosity, Alfvén speed, , and . Based on this observation, we postulate an ansatz:
where N0 is a (real) constant and are fractional constants, which shall be determined by numerical simulations. The dimension of the growth rate is , which we abbreviate as . It has to be "constructed" from the other physical quantities. Since , , , and , dimensional analysis provides the following conditions:
Similarly, the width of the resistive-viscous layer should be equal to
where M0 is a (real positive) constant and are fractional numbers to be determined by simulations. From the dimensional analysis follows
To determine n1 and m1, we performed the simulations series #TMa (the setup is described in Table 6 and the results are given in Figure 11, where the solid lines are the theoretical predictions according to Equations (171) and (172)) keeping all parameters constant but the resistivity. To the measured TM growth rates and widths of the resistive-viscous layer (as described in Section 4.3.2), we fit functions
where according to ansatzes (154) and (157) N1 and M1 should be constant for the models of series #TMa, i.e.,
From the obtained estimators (and their small errors; see Table 6) and (the upper index "a" denotes the simulation series, i.e., #TMa), we conclude that our ansatzes hold (at least for resistivity) and that and .
Table 6. 2D Simulations Performed to Test and Calibrate Ansatz (154) and (157)
Series | a | b0 | ν | η | ni | Ni | mi | Mi |
---|---|---|---|---|---|---|---|---|
#TMa | 0.1 | 1 | 10−4 | 0.7994 ± 0.0012 | 5.377 ± 0.015 | 0.160 ± 0.003 | −2.08 ± 0.04 | |
#TMar | 0.1 | 1 | 10−4 | 4/5 | 5.385 ± 0.001 | 1/6 | −1.992 ± 0.004 | |
#TMb | 0.1 | 1 | 10−5 | 0.801 ± 0.004 | 5.84 ± 0.05 | 0.159 ± 0.007 | −2.393 ± 0.006 | |
#TMbr | 0.1 | 1 | 10−5 | 4/5 | 5.826 ± 0.003 | 1/6 | −2.393 ± 0.006 | |
#TMc | 0.1 | 10−4 | 0.391 ± 0.004 | −4.377 ± 0.006 | −0.364 ± 0.017 | −4.021 ± 0.015 | ||
#TMcr | 0.1 | 10−4 | 2/5 | −4.385 ± 0.006 | −1/3 | −4.03 ± 0.02 | ||
#TMd | 0.05 | 10−5 | 10−6 | 0.411 ± 0.008 | −4.058 ± 0.005 | −0.329 ± 0.017 | −5.17 ± 0.01 | |
#TMdr | 0.05 | 10−5 | 10−6 | 2/5 | −4.055 ± 0.005 | −1/3 | −5.17 ± 0.01 |
Note. The columns give the series identifier, shear parameter a, initial magnetic field strength b0, viscosity ν, and resistivity η. In all simulations the background density is set to , and an equidistant grid spacing of is used. The box length is and the TM wavevector . The estimators ni, Ni, mi, and Mi are given by fits according to Equations (160), (161), (165), and (166), respectively. In #TMa, the estimators n1, , m1, and are determined, whereas in #TMar the estimators n1 and m1 are set to fractional values and and are determined. For series #TMb, #TMc, and #TMd, we proceeded analogously.
Download table as: ASCIITypeset image
In the simulation series #TMb (Figure 11), we set the value of the viscosity to , keeping the other parameters as in #TMa, and also vary the value of the resistivity. The fits done according to Equations (160) and (161) (see Table 6) confirm that and .
We determine the dependence of the TM growth rate and of the width of the resistive-viscous layer on viscosity in the following somewhat indirect way. To the results of simulations #TMa, we refit functions (160) and (161), but this time with and , to obtain and , respectively (Table 6; note that we denote this series as #TMar, where "r" stands for "refitted"). In an analogous way, we obtain and . According to ansatz (154), the difference between and should be
From the obtained estimators (Table 6), we have , from which we can infer . Analogously, from , we infer that (theoretically this value should be ).
In two further sets of simulations (#TMc and #TMd), we determined the dependence of the TM growth rate and of the width of the resistive-viscous layer on the strength of the background magnetic field. To the simulation results (Figure 18), we fit functions
where N3 and M3 should be constant for a given simulation series.
Download figure:
Standard image High-resolution imageFrom the obtained estimators (Table 6), we infer that and . Note that these results are consistent with our ansatzes, as from condition (155), by putting and , we find , and analogously from condition (158), we have , as .
With the results of simulation series #TMc and #TMd, one more aspect of Equations (154) and (157) can be tested. Even though we have not determined and , we expect from dimensional analysis that and (Equations (156) and (159), respectively). Therefore, doubling and k (from a = 0.1, k = 3 to a = 0.05, k = 6) should increase the instability growth rate by a factor of and decrease the width of the resistive-viscous layer by a factor of (because for a constant a to k ratio, the term in Equation (154) does not change). To the results of simulations #TMc and #TMd, we refitted functions (165) and (166), but this time with and , obtaining (Table 6) and . Taking into account the different values of resistivity and viscosity in these two series of simulations, we theoretically expect and . Hence, the difference between theory and simulation is
Hence, the predictions for the resistive-viscous layer agree within the measurement error. Moreover, we tested that, as theoretically expected, in the parameter range explored by us (incompressible limit), the growth rate of the TM neither depends on the background pressure p0 nor on the bulk viscosity (see Rembiasz 2013, for details).
So far, we have confirmed that our ansatzes for the TM growth rate (Equation (154)) and the width of the resistive-viscous layer (Equation (157)) hold and are given by
where N0 and M0 are (real) constants, and and are fractions. Moreover, from conditions (156) and (159) we have and , respectively. This allows us to calibrate these equations with the help of estimators and (Table 6) for k = 3 and a = 0.1 obtaining8
Footnotes
- 3
- 4
The characteristic velocity and length of the system was set to and , respectively. See the extended discussion that appears later in this subsection.
- 5
As an example, we consider velocity perturbations. Assuming that b1y is constant and using approximation (85), Equation (129) implies . Because in the inner layer, we have from Equation (84) , and hence . Although Equation (129) holds only in the outer layer, it should still be roughly applicable near the edge of the inner region. Note that was only assumed to simplify the calculations, i.e., relaxing this assumption does not change the estimate.
- 6
- 7
- 8
In these two equations we decided not to include the measurement errors, because for the applications discussed in Section 4.3.3 they would be negligible anyway.