1 Introduction

The equations of magnetohydrodynamics (MHD) describe electrically conducting fluids in the presence of a magnetic field. They can be used to model a wide range of physical phenomena, including astrophysical systems such as stars and galaxies, plasma physics, and fusion reactors. Their simplest form is given by the ideal MHD equations, in which the influence of fluid viscosity is neglected. This model consists of a system of nonlinear hyperbolic partial differential equations (PDEs) that involve the conservation of mass, momentum, and total energy, along with Faraday’s law for the magnetic field.

In certain applications, such as flows in the deep convective layers of stars, the acoustic Mach number, which is the ratio of the fluid speed to the speed of sound, can become very small. Small Mach numbers pose a challenge for explicit finite volume methods, which are typically used to simulate compressible flows, since in this case the flow approaches the incompressible regime and the acoustic waves propagate much faster than the fluid motion. This gives rise to the following problems for standard finite volume methods: the numerical dissipation increases significantly and the time step condition becomes more restrictive. Basically, there are two strategies in the literature to tackle these challenges.

  1. (1)

    One approach is to rescale the dissipation term in the numerical flux to make it independent of the Mach number and combine this with a fully implicit time integration to circumvent the restrictive time step condition [27, 37]. The drawback of this strategy is that solving large nonlinear systems of equations is required due to the fully implicit method, which can be computationally expensive.

  2. (2)

    Another approach is to split the PDE system into a convective part that is solved explicitly and an acoustic part that is solved implicitly [8, 14, 17]. This makes the CFL condition only coupled to the convective sub-system and therefore independent of the Mach number. At the same time, the implicit part becomes smaller and easier to invert, making it less computationally expensive to solve. Furthermore, no numerical dissipation is embedded in the implicit solver.

For our scheme, we pursue the latter approach and treat all terms associated with the acoustic pressure implicitly. All remaining terms are part of the explicit sub-system. For this purpose, a time integration inspired by the class of implicit-explicit (IMEX) schemes is used [5, 8]. Concerning the development of semi-implicit numerical schemes applied to compressible magnetized plasma flows governed by the ideal MHD equations, only very little work has been done so far. Indeed, semi-implicit schemes for MHD flows have been firstly designed in [1, 23, 28], however they are concerned with the incompressible case. In [32] the anelastic case of the MHD equations is discussed, while in [17] a semi-implicit finite difference scheme is proposed, inspired by the flux splitting approach originally forwarded for compressible gas dynamics [18]. An implicit treatment of the magnetic field has been recently devised in [19], and in [14] a semi-implicit IMEX numerical method for the ideal MHD has been proposed with a finite difference spatial discretization. Our work is strictly related to what presented in [14], however there are some important differences: (i) we use a finite volume discretization for the convective terms; (ii) no numerical dissipation is added in the implicit part even in the case of shock waves; (iii) we also include gravitational source terms.

Regarding the discretisation in the case of low Mach numbers, this has no effect and the source terms can easily be assigned to the explicit part. More challenging is its impact on magnetohydrostatic solutions. These are stationary solutions, where the velocity of the fluid is zero and the magnetic field and pressure are in balance with the gravitational force. If one wants to resolve small perturbations of this equilibrium on a coarse grid, the method should be able to maintain the equilibrium exactly. Usually, this is prevented by different discretizations of the flux and the source term. Numerical schemes that are still able to maintain this balance are called well-balanced. There are different strategies in the literature to construct well-balanced schemes, e.g. hydrostatic reconstructions [24, 25, 36], path conservative methods [12, 29] or special approximate Riemann solvers based on relaxation systems [4, 16, 34]. In this work, we combine the semi-implicit scheme with the method of deviation well-balancing [3]. Instead of evolving the actual solution, the deviation from an a priori known equilibrium solution is evolved. Through special discretization, the numerical fluxes and source terms cancel out in the case of equilibrium, so that the discrete solution is preserved up to rounding errors. A similar approach has been recently forwarded in [21] in the context of general relativity.

In simulations of the MHD equations, it is important to consider the solenoidal constraint, which states that the magnetic field is divergence-free. Numerically, we achieve this structure preserving property by incorporating a constrained transport (CT) method [22] into the semi-implicit scheme. The CT method corrects the magnetic field directly after the explicit step, as the induction equations are entirely assigned to the explicit sub-system of the splitting. By correcting the magnetic field, a specific discrete definition of divergence is kept within machine precision, thereby increasing the stability of the overall scheme.

The paper is structured as follows. In Sect. 2, we provide an overview of the MHD equations and their associated properties and propose a splitting into convective and pressure sub-systems. On the basis of this splitting, we develop in Sect. 3 a second order accurate semi-implicit and well-balanced numerical scheme. The numerical results of this scheme for different test problems are presented in Sect. 4, and finally, Sect. 5 concludes the article providing an outlook to future developments.

2 Governing Equations

Let us consider a three-dimensional computational domain \(\Omega (x,y,z) \in \mathbb {R}^3\) and let the time coordinate be denoted with \(t \in \mathbb {R}_0^+\). The ideal MHD equations with a gravitational source term constitute a system of balance laws of the form

$$\begin{aligned} \frac{\partial }{\partial t} \left( \begin{array}{c} \rho \\ \rho \textbf{v}\\ \rho E \\ \textbf{B}\end{array} \right) + \nabla \cdot \left( \begin{array}{c} \rho \textbf{v}\\ \rho \textbf{v}\otimes \textbf{v}+ (p+\frac{1}{{8\pi }}\vert \textbf{B}\vert ^2) \textbf{I} - {\frac{1}{4\pi }}\textbf{B}\otimes \textbf{B}\\ ( \rho E + p + \frac{1}{{8\pi }}\vert \textbf{B}\vert ^2 ) \textbf{v}- {\frac{1}{4\pi }} \textbf{B}\left( \textbf{B}\cdot \textbf{v}\right) \\ \textbf{v}\otimes \textbf{B}- \textbf{B}\otimes \textbf{v}\end{array} \right) = \left( \begin{array}{c} 0 \\ \rho \textbf{g}\\ \rho \textbf{v}\cdot \textbf{g}\\ \textbf{0} \end{array} \right) . \end{aligned}$$
(1)

In this system, \(\rho \) denotes the density, \(\textbf{v}=(u,v,w)\) the velocity field, p the pressure and \(\textbf{B}=(B_x, B_y,B_z)\) the magnetic field. The total energy \(\rho E\) is defined as the sum of internal (\(\rho e\)), kinetic (\(\rho k\)) and magnetic energy (m), i.e.

$$\begin{aligned} \rho E = \rho e + \rho k + m, \qquad \rho e = \frac{p}{\gamma -1}, \quad \rho k = \frac{1}{2}\rho \textbf{v}^2, \quad m = \frac{1}{8\pi } \textbf{B}^2. \end{aligned}$$
(2)

The internal energy \(\rho e\) is computed from the ideal gas equation of state (EOS) with the ratio of specific heats given by \(\gamma \). The flux in the energy equation is reformulated in terms of the specific enthalpy \(h=e+p/\rho \) by

$$\begin{aligned} \left( \rho E + p + \frac{1}{8\pi }\vert \textbf{B}\vert ^2 \right) \textbf{v}- \frac{1}{4\pi } \textbf{B}\left( \textbf{B}\cdot \textbf{v}\right) = \textbf{v}(\rho k + \rho h + 2m) - \frac{1}{4\pi } \textbf{B}(\textbf{B}\cdot \textbf{v}). \end{aligned}$$
(3)

The vector \(\textbf{g}= (g_x,g_y,g_z)\) in the source term on the right hand side of (1) denotes the time-independent gravitational acceleration. Using these defintions we can write the MHD equations in the equivalent form

$$\begin{aligned} \frac{\partial \textbf{q}}{\partial t} + \frac{\partial \textbf{F}(\textbf{q})}{\partial x} + \frac{\partial \textbf{G}(\textbf{q})}{\partial y} + \frac{\partial \textbf{H}(\textbf{q})}{\partial z} = \textbf{S}(\textbf{q}), \end{aligned}$$
(4)

with the state vector \(\textbf{q}\), the flux in x-direction \(\textbf{F}(\textbf{q})\) and the source \(\textbf{S}(\textbf{q})\) that explicitly write

$$\begin{aligned} \textbf{q}= \left( \begin{array}{c} \rho \\ \rho u \\ \rho v \\ \rho w \\ \rho E \\ B_x \\ B_y \\ B_z \end{array} \right) , \qquad \textbf{F}(\textbf{q}) = \left( \begin{array}{c} \rho u \\ \rho u^2 + p + \frac{1}{8\pi } \textbf{B}^2 - \frac{1}{4\pi } B_x^2 \\ \rho uv - \frac{1}{4\pi } B_x B_y \\ \rho uw - \frac{1}{4\pi } B_x B_z \\ {u(\rho k + \rho h + 2m)} - \frac{1}{4\pi } B_x (\textbf{v}\cdot \textbf{B}) \\ 0 \\ u B_y - v B_x \\ u B_z - w B_x \end{array} \right) , \qquad \textbf{S}(\textbf{q}) = \left( \begin{array}{c} 0 \\ \rho g_x \\ \rho g_y \\ \rho g_z \\ \rho \textbf{v}\cdot \textbf{g}\\ 0 \\ 0 \\ 0 \end{array} \right) .\nonumber \\ \end{aligned}$$
(5)

The fluxes \(\textbf{G}(\textbf{q})\) and \(\textbf{H}(\textbf{q})\) can be expressed in similar forms.

2.1 Eigenstructure of the MHD System

In order to analyze the eigenstructure of the MHD system, we consider its one-dimensional homogeneous version. The resulting system is hyperbolic since the eigenvalues \(\lambda ^{MHD}_{i=\{1,\ldots ,8\}}\) of the associated Jacobian matrix \(\textbf{A}=\partial \textbf{F}/\partial \textbf{q}\) with \(B_x=const\) are

$$\begin{aligned} \lambda ^{MHD}_{1,8} = u \pm c_f, \quad \lambda ^{MHD}_{2,7} = u \pm c_a, \quad \lambda ^{MHD}_{3,6} = u \pm c_s, \quad \lambda ^{MHD}_4=u, \quad \lambda ^{MHD}_5 = 0. \end{aligned}$$
(6)

The Alfvén wave speed (\(c_a\)) and the slow (\(c_s\)) and fast (\(c_f\)) magnetosonic wave speeds herein are defined by

$$\begin{aligned} c_a= & {} \frac{B_x}{\sqrt{4\pi \rho }}, \nonumber \\ c_s^2= & {} \frac{1}{2} \left( b^2+c^2-\sqrt{(b+c)^2-4 c_a^2 c^2}\right) , \nonumber \\ c_f^2= & {} \frac{1}{2} \left( b^2+c^2+\sqrt{(b+c)^2-4 c_a^2 c^2}\right) , \end{aligned}$$
(7)

where the adiabatic sound speed \(c= \sqrt{\gamma p / \rho }\) is computed from the ideal gas equation of state. Furthermore, we use the abbreviation \(b^2=\textbf{B}^2/(4\pi \rho )\).

2.2 Low Mach Number Regime

The hydrodynamic behavior of the fluid can be studied by considering the Mach number \(\mathcal {M}=\vert \textbf{v}\vert /c\). In the low Mach number limit, the sound speed becomes very high compared to the fluid velocity, hence the terms related to the pressure are dominant. Consequently, large values of the fast and slow magnetosonic wave speeds are retrieved, and fully explicit numerical methods suffer from both an excessive amount of numerical viscosity, which is proportional to the eigenvalues, and a drastic reduction of the admissible time step \({\Delta t}\) to ensure stability under a classical CFL condition of the type

$$\begin{aligned} {\Delta t}\le \text {CFL} \min _{\Omega } \frac{\min ({\Delta x},{\Delta y},{\Delta z})}{\max |\lambda ^{MHD}|}, \end{aligned}$$
(8)

with \(({\Delta x},{\Delta y},{\Delta z})\) denoting the characteristic mesh spacings in the three spatial directions and the \(\text {CFL}\le 1\) being the CFL number. Therefore, we propose to discretize the pressure gradient in the momentum equation and the enthalpy term in the energy equation implicitly, while keeping an explicit discretization for the nonlinear convective fluxes and the terms related to the magnetic field. To that aim, let the fluxes in x-direction be split into a convective-type flux \(\textbf{F}^c(\textbf{q})\) and a pressure-type flux \(\textbf{F}^p(\textbf{q})\), that is

$$\begin{aligned} \textbf{F}^c(\textbf{q}) = \left( \begin{array}{c} \rho u \\ \rho u^2 + m - \frac{1}{4\pi } B_x^2 \\ \rho uv - \frac{1}{4\pi } B_x B_y \\ \rho uw - \frac{1}{4\pi } B_x B_z \\ u(\rho k + {2}m) - \frac{1}{4\pi } B_x (\textbf{v}\cdot \textbf{B}) \\ 0 \\ u B_y - v B_x \\ u B_z - w B_x \end{array} \right) , \qquad \textbf{F}^p(\textbf{q}) = \left( \begin{array}{c} 0 \\ p \\ 0 \\ 0 \\ h \rho u \\ 0 \\ 0 \\ 0 \end{array} \right) . \end{aligned}$$
(9)

We obtain two sub-systems with the following eigenvalues.

  • Convective sub-system

    $$\begin{aligned}&\frac{\partial \textbf{q}}{\partial t} + \frac{\partial \textbf{F}^c}{\partial x} = \textbf{S}, \end{aligned}$$
    (10a)
    $$\begin{aligned}&\quad \lambda ^c_{1,8} = u \pm \sqrt{\frac{\textbf{B}^2}{4\pi {\rho }}}, \quad \lambda ^c_{2,7} = u \pm \frac{B_x}{\sqrt{4\pi {\rho }}}, \quad \lambda ^c_{3,4{,5,6}} = 0. \end{aligned}$$
    (10b)
  • Pressure sub-system

    $$\begin{aligned}&\frac{\partial \textbf{q}}{\partial t} + \frac{\partial \textbf{F}^p}{\partial x} = \textbf{0}, \end{aligned}$$
    (11a)
    $$\begin{aligned}&\quad \lambda ^p_{1} = \frac{1}{2} \left( u - \sqrt{u^2+4c^2} \right) , \quad \lambda ^p_{2,3,4,5,6,7}=0, \quad \lambda ^p_8=\frac{1}{2} \left( u + \sqrt{u^2+4c^2} \right) \!. \end{aligned}$$
    (11b)

The fluxes \(\textbf{G}\) and \(\textbf{H}\) can be split in a similar way with analogous sub-systems and eigenvalues. In the above splitting we have added the source term to the convective sub-system, since this has no effect on the eigenvalues and thus it does not pose a numerical problem in the low Mach limit. It is clear that, by taking the pressure sub-system implicitly, the maximum admissible time step of the scheme becomes

$$\begin{aligned} {\Delta t}\le \text {CFL} \min _{\Omega } \frac{\max |\lambda ^{c}|}{\min ({\Delta x},{\Delta y},{\Delta z})}, \end{aligned}$$
(12)

hence making the scheme particularly well suited for low Mach number flows (\(\mathcal {M} \ll 1\)) where the pressure terms are dominant. On the other hand, for strongly convected flows with shocks, the convective eigenvalues lead the computation of the time step granting stability.

2.3 Divergence Constraint

The induction equations, which describe the evolution of the magnetic field in (1), can be rewritten in the equivalent form

$$\begin{aligned} \frac{\partial }{\partial t} \textbf{B}+ \nabla \times \textbf{E}= 0, \end{aligned}$$
(13)

where \(\textbf{E}= - \textbf{v}\times \textbf{B}\) denotes the electric field. Applying the divergence operator to (13) yields

$$\begin{aligned} \frac{\partial }{\partial t} \left( \nabla \cdot \textbf{B}\right) = 0. \end{aligned}$$
(14)

This implies that the divergence of the magnetic field is always equal to zero if it is zero for the initial data. Therefore, the MHD equations in multiple spatial dimensions naturally contain the condition

$$\begin{aligned} \nabla \cdot \textbf{B}= 0, \end{aligned}$$
(15)

which is a physically meaningful condition, as it expresses that there should be no magnetic monopoles.

At the discrete level, on the other hand, the divergence of the numerically computed magnetic field can increase in time. This can lead to severe stability problems [11]. Therefore, particular care must be taken in the discretisation to ensure that the divergence in the numerical solution remains sufficiently small [2, 7]. In this work, we rely on a constrained transport method that keeps the divergence at the level of machine accuracy [22]. Section 3.5 explains how this method works and how it is incorporated into the overall method.

2.4 Magnetohydrostatic Solutions

When considering the MHD equations with gravitational source term, magnetohydrostatic solutions can play an important role. These solutions fulfil the following two conditions

$$\begin{aligned} \textbf{v}&= 0, \end{aligned}$$
(16a)
$$\begin{aligned} \nabla \cdot \left( p+\frac{1}{8\pi } \vert \textbf{B}\vert ^2 - \frac{1}{4\pi } \textbf{B}\otimes \textbf{B}\right)&= \rho \textbf{g}. \end{aligned}$$
(16b)

As a consequence, for magnetohydrostatic solutions all fluxes except the momentum flux drop out. The momentum flux, however, fulfils an equilibrium with the source term, so that magnetohydrostatic solutions are stationary.

Different ways of discretising the hyperbolic flux and the gravitational source term prevent in general the exact conservation of discrete stationary magnetohydrostatic solutions of the form (16). In order to ensure that the numerical method described in this work is nevertheless exact (up to machine precision) on this type of stationary solutions, we resort to the idea of deviation well-balancing [3]. The key idea of this approach is to evolve the deviation from an a priori known equilibrium solution \(\tilde{\textbf{q}}\) instead of the actual solution \(\textbf{q}\). Therefore, we do not directly discretize equation (4), but the following equation for the deviation \(\Delta \textbf{q}= \textbf{q}- \tilde{\textbf{q}}\):

$$\begin{aligned} \begin{aligned}&\frac{\partial \Delta {\textbf {q}}}{\partial t} + \frac{\partial {\textbf {F}}(\Delta {\textbf {q}}+ \tilde{{\textbf {q}}})}{\partial x} - \frac{\partial {\textbf {F}}(\tilde{{\textbf {q}}})}{\partial x} + \frac{\partial {\textbf {G}}(\Delta {\textbf {q}}+ \tilde{{\textbf {q}}})}{\partial y} - \frac{\partial {\textbf {G}}(\tilde{{\textbf {q}}})}{\partial y} + \frac{\partial {\textbf {H}}(\Delta {\textbf {q}}+ \tilde{{\textbf {q}}})}{\partial z} - \frac{\partial {\textbf {H}}(\tilde{{\textbf {q}}})}{\partial z} \\ {}&\quad = {\textbf {S}}(\Delta {\textbf {q}}+ \tilde{{\textbf {q}}}) - {\textbf {S}}(\tilde{{\textbf {q}}}). \end{aligned} \end{aligned}$$
(17)

In the equilibrium case (\(\textbf{q}=\tilde{\textbf{q}}\)), the spatial discretizations of (17) cancel so that the equation reduces to \(\frac{\partial \Delta \textbf{q}}{\partial t}=\textbf{0}\) and the solution remains stationary.

3 Numerical Scheme

For reasons of clarity and comprehensibility we restrict ourselves in the following to one spatial dimension before returning to three spatial dimensions in Sect. 3.4. The computational domain \(\Omega = [x_L;x_R]\) is discretized using a total number of \(N_x\) equidistant cells of volume \({\Delta x}=(x_R-x_L)/N_x\). The cell centers are indicated with \(x_i\) and the cell interfaces are referred to with \(x_{i+1/2}\). The time coordinate is bounded in the interval \(t\in [0;t_f]\), and the final time \(t_f\) is reached performing a sequence of time steps \({\Delta t}=t^{n+1}-t^n\) that are computed according to the one-dimensional version of the CFL stability condition (12).

3.1 First Order semi-Discrete Scheme in Time

The method constructed in this paper should be able to preserve magnetohydrostatic solutions of the form (16). Therefore, we assume to know an equilibrium solution \(\tilde{\textbf{q}}\) a priori and discretize equation (17). The splitting (9) is therefore applied to equation (17). To simplify the notation, we write \(\bar{q}^n = \Delta q^n + \tilde{q}\). For the convective sub-system, which is treated explicitly, we then get:

$$\begin{aligned} \Delta \textbf{q}^* = \Delta \textbf{q}^n - {\Delta t}\frac{\partial }{\partial x} \textbf{F}^c(\bar{\textbf{q}}) + {\Delta t}\frac{\partial }{\partial x} \textbf{F}^c(\tilde{\textbf{q}}) + {\Delta t}\textbf{S}(\bar{\textbf{q}}) - {\Delta t}\textbf{S}(\tilde{\textbf{q}}). \end{aligned}$$
(18)

Written out for the single components, this results in

$$\begin{aligned} \Delta \rho ^{*} =&\Delta \rho ^{n} - {\Delta t}\frac{\partial }{\partial x}\left( \bar{\rho }\bar{u}\right) ^n + {\Delta t}\frac{\partial }{\partial x} (\tilde{\rho }\tilde{u}), \end{aligned}$$
(19a)
$$\begin{aligned} (\Delta \rho u)^{*} =&(\Delta \rho u)^{n} - {\Delta t}\frac{\partial }{\partial x} \left( \bar{\rho }\bar{u}^2 + \bar{m}- \frac{1}{4\pi } \bar{B}_x^2 \right) ^n + {\Delta t}\frac{\partial }{\partial x} \left( \tilde{\rho }\tilde{u}^2 + \tilde{m}- \frac{1}{4\pi } \tilde{B}_x^2 \right) \nonumber \\&+ {\Delta t}\left( \bar{\rho }g_x \right) ^{{n}} - {\Delta t}\left( \tilde{\rho }g_x \right) , \end{aligned}$$
(19b)
$$\begin{aligned} (\Delta \rho v)^{*}=&(\Delta \rho v)^{n} - {\Delta t}\frac{\partial }{\partial x} \left( \bar{\rho }\bar{u}\bar{v}- \frac{1}{4\pi } \bar{B}_x \bar{B}_y \right) ^n \nonumber \\&+ {\Delta t}\frac{\partial }{\partial x} \left( \tilde{\rho }\tilde{u}\tilde{v}- \frac{1}{4\pi } \tilde{B}_x \tilde{B}_y \right) , \end{aligned}$$
(19c)
$$\begin{aligned} (\Delta \rho w)^{*}=&(\Delta \rho w)^{n} - {\Delta t}\frac{\partial }{\partial x} \left( \bar{\rho }\bar{u}\bar{w}- \frac{1}{4\pi } \bar{B}_x \bar{B}_z \right) ^n + {\Delta t}\frac{\partial }{\partial x} \left( \tilde{\rho }\tilde{u}\tilde{w}- \frac{1}{4\pi } \tilde{B}_x \tilde{B}_z \right) , \end{aligned}$$
(19d)
$$\begin{aligned} (\Delta \rho E)^{*} =&(\Delta \rho E)^{n} - {\Delta t}\frac{\partial }{\partial x} \left( \bar{u}(\bar{\rho }\bar{k}+{2} \bar{m}) - \frac{1}{4\pi } \bar{B}_x (\bar{\textbf{v}} \cdot \bar{\textbf{B}}) \right) ^n \nonumber \\&+ {\Delta t}\frac{\partial }{\partial x} \left( \tilde{u}(\tilde{\rho }\tilde{k}+ {2}\tilde{m}) - \frac{1}{4\pi } \tilde{B}_x (\tilde{\textbf{v}} \cdot \tilde{\textbf{B}}) \right) \nonumber \\&+ {\Delta t}\left( \bar{\rho }\bar{u}g_x \right) ^{{n}} - {\Delta t}\left( \tilde{\rho }\tilde{u}g_x \right) , \end{aligned}$$
(19e)
$$\begin{aligned} \Delta B_x^{*} =&0, \end{aligned}$$
(19f)
$$\begin{aligned} \Delta B_y^{*} =&\Delta B_y^{n} - {\Delta t}\frac{\partial }{\partial x} \left( \bar{u}\bar{B}_y - \bar{v}\bar{B}_x \right) ^n + {\Delta t}\frac{\partial }{\partial x} \left( \tilde{u}\tilde{B}_y - \tilde{v}\tilde{B}_x \right) , \end{aligned}$$
(19g)
$$\begin{aligned} \Delta B_z^{*} =&\Delta B_z^{n} - {\Delta t}\frac{\partial }{\partial x} \left( \bar{u}\bar{B}_z - \bar{w}\bar{B}_x \right) ^n + {\Delta t}\frac{\partial }{\partial x} \left( \tilde{u}\tilde{B}_z - \tilde{w}\tilde{B}_x \right) . \end{aligned}$$
(19h)

In the above equations, we have included terms containing \(\tilde{u}\), \(\tilde{v}\) or \(\tilde{w}\). In the following, however, we will omit these terms, since the equilibrium velocities are always zero.

The above definitions are then employed to obtain a first order semi-implicit time discretization [5, 8, 10] of the MHD equations (4), which writes

$$\begin{aligned} \Delta \rho ^{n+1}&= \Delta \rho ^{*}, \end{aligned}$$
(20a)
$$\begin{aligned} (\Delta \rho u)^{n+1}&=(\Delta \rho u)^{*} - {\Delta t}\frac{\partial }{\partial x}\left( p^{n+1} - \tilde{p}\right) , \end{aligned}$$
(20b)
$$\begin{aligned} (\Delta \rho v)^{n+1}&=(\Delta \rho v)^{*}, \end{aligned}$$
(20c)
$$\begin{aligned} (\Delta \rho w)^{n+1}&=(\Delta \rho w)^{*}, \end{aligned}$$
(20d)
$$\begin{aligned} (\Delta \rho E)^{n+1}&=(\Delta \rho E)^{*} - {\Delta t}\frac{\partial }{\partial x} \left( h^n (\rho u)^{n+1} \right) , \end{aligned}$$
(20e)
$$\begin{aligned} \Delta B_x^{n+1}&=\Delta B_x^{*}, \end{aligned}$$
(20f)
$$\begin{aligned} \Delta B_y^{n+1}&=\Delta B_y^{*}, \end{aligned}$$
(20g)
$$\begin{aligned} \Delta B_z^{n+1}&=\Delta B_z^{*}. \end{aligned}$$
(20h)

Here, we use the known enthalpy \(h^n\) at time level n in the energy equation to avoid nonlinear terms in the implicit part, differently from the schemes proposed in [17, 19]. Additionally, we have made use of the fact that in the implicit fluxes we only work with point values at the cell centers, i.e. we use an implicit finite difference discretization, thus we can write

$$\begin{aligned} \left( \Delta \textbf{q}+ \tilde{\textbf{q}} \right) _i = \textbf{q}_i - \tilde{\textbf{q}}_i + \tilde{\textbf{q}}_i = \textbf{q}_i. \end{aligned}$$
(21)

Therefore, the implicit fluxes are simplified by

$$\begin{aligned}&\frac{\partial }{\partial x}\left( \Delta p^{n+1} + \tilde{p}\right) - {\Delta t}\frac{\partial }{\partial x} \tilde{p}= \frac{\partial }{\partial x}\left( p^{n+1} - \tilde{p}\right) , \\&\quad \frac{\partial }{\partial x} \left( \left( \Delta h^n+\tilde{h} \right) \left( (\Delta \rho u)^{n+1} + \tilde{\rho }\tilde{u}\right) \right) = \frac{\partial }{\partial x} \left( h^n (\rho u)^{n+1} \right) . \end{aligned}$$

According to the definition given in the energy equation (2), we split the deviation of the total energy at the new time level as follows

$$\begin{aligned} (\Delta \rho E)^{n+1} = (\Delta \rho e)^{n+1} + (\Delta m)^{n+1} + (\Delta \rho k)^{n+1}. \end{aligned}$$
(22)

The deviation of the kinetic energy therein is set to

$$\begin{aligned} (\Delta \rho k)^{n+1} = (\rho k)^{n+1} - (\tilde{\rho }\tilde{k}) = \frac{1}{2} \frac{(\rho u)^{n}}{\rho ^{n+1}} (\rho u)^{n+1} - \frac{1}{2} \tilde{\rho }\tilde{u}^2, \end{aligned}$$
(23)

where a semi-implicit strategy is adopted for the term \((\rho k)^{n+1}\). Indeed, the split of the momentum contribution into an explicit and an implicit part is again done in order to avoid nonlinear implicit terms. The density \(\rho ^{n+1}\) and the deviation in the magnetic energy \(\Delta m^{n+1}\) are known because both continuity and induction equations are fully explicit. With the help of the ideal gas law, the deviation in the internal energy can be expressed in terms of the pressure

$$\begin{aligned} (\Delta \rho e)^{n+1} = \frac{p^{n+1}-\tilde{p}}{\gamma -1}. \end{aligned}$$
(24)

In order to derive a preliminary discretization of the total energy equation we transform (20b) into

$$\begin{aligned} (\rho u)^{n+1} = (\Delta \rho u)^{*} + \tilde{\rho }\tilde{u}- {\Delta t}\frac{\partial }{\partial x}\left( p^{n+1} - \tilde{p}\right) , \end{aligned}$$
(25)

and insert the result into the energy equation (20e). This leads to an elliptic equation for the pressure

$$\begin{aligned} \frac{p^{n+1}}{\gamma -1} - {\Delta t}\frac{(\rho u)^{n}}{2 \rho ^{n+1}} \frac{\partial }{\partial x} \left( p^{n+1}-\tilde{p}\right) - {\Delta t}^2 \frac{\partial }{\partial x} \left( h^n \frac{\partial }{\partial x} \left( p^{n+1} - \tilde{p}\right) \right) = b^n, \end{aligned}$$
(26)

with the known right-hand-side given by

$$\begin{aligned} b^n= & {} \frac{\tilde{p}}{\gamma -1} + \frac{1}{2} \tilde{\rho }\tilde{u}^2 + (\Delta \rho E)^{*} \nonumber \\{} & {} - \frac{(\rho u)^{n}}{2 \rho ^{n+1}} \left( (\Delta \rho u)^{*} + \tilde{\rho }\tilde{u}\right) - \Delta m^{n+1} - {\Delta t}\frac{\partial }{\partial x} \left( h^n \left( (\Delta \rho u)^{*} + \tilde{\rho }\tilde{u}\right) \right) . \end{aligned}$$
(27)

The pressure equation (26) constitutes a linear system for the scalar unknown \(p^{n+1}\) that is solved using the iterative GMRES solver [31] up to a prescribed tolerance (we typically set \(\text {tol}=10^{-12}\)). Differently from [17, 19], this approach does not need any fixed point method thanks to the semi-implicit splitting of the enthalpy flux and the kinetic energy in the energy equation. Once the new pressure is known, the deviation in the momentum \((\Delta \rho u)^{n+1}\) is updated with (20b), and then the deviation in the total energy is updated using (20e). Notice that the scheme is written in flux form, therefore it is locally and globally conservative.

3.2 Discrete Spatial Operators

The convective sub-system (18) is discretized by a Godunov-type finite volume method which writes

$$\begin{aligned} \Delta \textbf{q}_{i}^*= & {} \Delta \textbf{q}_{i}^n -\frac{{\Delta t}}{{\Delta x}} (\hat{\textbf{F}}_{i+1/2}^{c} - \hat{\textbf{F}}_{i-1/2}^{c})\nonumber \\{} & {} + \frac{{\Delta t}}{{\Delta x}} (\textbf{F}^c(\tilde{\textbf{q}}_{i+1/2}) - \textbf{F}^c(\tilde{\textbf{q}}_{i-1/2})) + {\Delta t}\hat{\textbf{S}}_i - {\Delta t}\textbf{S}(\tilde{\textbf{q}}_i). \end{aligned}$$
(28)

In this notation, the hat symbol indicates a numerical flux or source term. For the numerical flux, we decide to use a simple and robust Rusanov-type flux of the form

$$\begin{aligned} \hat{\textbf{F}}_{i+1/2}^{c}= & {} \hat{\textbf{F}}^{{c}}(\bar{\textbf{q}}_{i+1/2}^{L},\bar{\textbf{q}}_{i+1/2}^{R})\nonumber \\= & {} \frac{1}{2} \left( \textbf{F}^c(\bar{\textbf{q}}_{i+1/2}^{L})+\textbf{F}^c(\bar{\textbf{q}}_{i+1/2}^{R}) \right) - \frac{1}{2} s_{max} \left( \bar{\textbf{q}}_{i+1/2}^{R} - \bar{\textbf{q}}_{i+1/2}^{L} \right) , \end{aligned}$$
(29)

where the numerical dissipation \(s_{max}=\max \left( \vert (\lambda ^c)_{i+1/2}^L \vert ,\vert (\lambda ^c)_{i+1/2}^R \vert \right) \) only considers the convective eigenvalues and is therefore independent of the Mach number. The numerical flux is computed in the states

$$\begin{aligned} \bar{\textbf{q}}_{i+1/2}^{L,R} = \Delta \textbf{q}_{i+1/2}^{L,R} + \tilde{\textbf{q}}_{i+1/2}, \end{aligned}$$
(30)

where the superscripts LR denote the left and right extrapolated data at the interface. It is essential for the well-balancing that only the deviation \(\Delta \textbf{q}\) is reconstructed, while the equilibrium solution is evaluated at the cell interface.

The third term in the right hand side of (28) simply computes the physical fluxes based on the equilibrium solution at the cell interface, that is \({{\textbf {F}}}^c(\tilde{{\textbf {q}}}_{i+1/2})\). For the source term, we substitute the volume-averaged quantity with its cell centered value, which is accurate up to second order:

$$\begin{aligned} \hat{\textbf{S}}_i = \textbf{S}(\bar{\textbf{q}}_i). \end{aligned}$$
(31)

The implicit terms appearing in the pressure sub-system (11) are approximated by means of finite difference operators with no numerical dissipation [8]:

$$\begin{aligned} \left. \frac{\partial p}{\partial x} \right| _i^{n+1}&= \frac{p_{i+1}^{n+1}-p_{i-1}^{n+1}}{2 \, {\Delta x}} + \mathcal {O}({\Delta x}^2), \end{aligned}$$
(32a)
$$\begin{aligned} \frac{\partial }{\partial x} \left. \left( h \frac{\partial p}{\partial x} \right) \right| _i^{n,n+1}&= \frac{1}{{\Delta x}^2} \left[ h_{i-1}^n \, h_i^n \, h_{i+1}^n \right] \left[ \begin{array}{ccc} 3/4 &{} -1 &{} 1/4 \\ 0 &{} 0 &{} 0 \\ 1/4 &{} -1 &{} 3/4 \end{array} \right] \left[ \begin{array}{c} p_{i-1}^{n+1} \\ p_i^{n+1} \\ p_{i+1}^{n+1} \end{array} \right] + \mathcal {O}({\Delta x}^2). \end{aligned}$$
(32b)

3.3 Second Order Extension in Time and Space

3.3.1 Second Order in Time

The scheme achieves second order of accuracy in time by using the implicit-explicit Runge Kutta method LSDIRK(2,2,2) (L-stable diagonally implicit Runge Kutta method) [30]. The triplet (2,2,2) refers to the number of stages of the implicit part, the number of stages of the explicit part, and the order of the IMEX scheme, respectively. Let us denote the spatial operator in the MHD equations by \(\mathcal {H}(\textbf{q}_E(t),\textbf{q}_I(t))\), where the first argument is discretized explicitly, while the second argument is discretized implicitly. According to the splitting (9), \(\mathcal {H}\) is defined by

$$\begin{aligned} \mathcal {H}(\textbf{q}_E(t),\textbf{q}_I(t)) = \frac{\partial }{\partial x} \textbf{F}^c(\textbf{q}_E) + \frac{\partial }{\partial x} \textbf{F}^p(\textbf{q}_I) + \textbf{S}(\textbf{q}_E). \end{aligned}$$
(33)

At the beginning of each time step we initialize \(\textbf{q}_E^n=\textbf{q}_I^n=\textbf{q}^n\) and then compute for each stage i its stage fluxes \(\textbf{k}_i\) in the following way:

$$\begin{aligned} \textbf{q}_E^{i}&= \textbf{q}_E^n + {\Delta t}\sum _{j=1}^{i-1} \hat{a}_{ij} \textbf{k}_j,&2 \le i \le s, \end{aligned}$$
(34a)
$$\begin{aligned} \textbf{q}_I^{i}&= \textbf{q}_E^n + {\Delta t}\sum _{j=1}^{i-1} a_{ij} \textbf{k}_j,&2 \le i \le s, \end{aligned}$$
(34b)
$$\begin{aligned} \textbf{k}_i&= \mathcal {H} \left( \textbf{q}_E^{i}, \textbf{q}_I^{i} + {\Delta t}a_{ii} \textbf{k}_i \right) ,&1 \le i \le s. \end{aligned}$$
(34c)

Notice that the only implicit evaluation lies in (34c), which indeed corresponds to the solution of the elliptic equation on the pressure (26). Using these stage fluxes, the updated solution at the new time level is computed by

$$\begin{aligned} \textbf{q}^{n+1} = \textbf{q}^n + {\Delta t}\sum _{i=1}^s b_i \textbf{k}_i. \end{aligned}$$
(35)

The coefficients are given by a double Butcher tableau of the form

$$\begin{aligned} \begin{array} {c|c} \hat{c} &{} \hat{A} \\ \hline &{} \hat{b}^\top \\ \end{array} \qquad \begin{array} {c|c} c &{} A \\ \hline &{} b^\top \\ \end{array} \end{aligned}$$
(36)

with matrices \((\hat{A},A) \in \mathbb {R}^{s\times s}\) and vectors \((\hat{c},c,\hat{b},b) \in \mathbb {R}^s\). In this notation, the hat symbol indicates the coefficients for the explicit scheme. The coefficients for LSDIRK2(2,2,2) are listed in Table 1.

Table 1 Butcher tableau for the LSDIRK2(2,2,2) time discretization with \(\gamma = 1-1/\sqrt{2}\), \(\beta =1/(2\gamma )\). Left: explicit tableau. Right: implicit tableau

3.3.2 Second Order in Space

The extension to second order in space in the explicit part is based on a piecewise linear reconstruction of the conservative variables. The values at the cell interface, which serve as initial data for the Riemann problems, are computed by evaluating the function

$$\begin{aligned} \textbf{q}(x) = \textbf{q}_i + \mathbf {\sigma }_i (x-x_i) \end{aligned}$$
(37)

at the cell boundaries \(x_{i-1/2}\) and \(x_{i+1/2}\). The slopes \(\mathbf {\sigma }_i\) are computed by applying a minmod limiter to the left and right slope, i.e.

$$\begin{aligned} \mathbf {\sigma }_i = \text {minmod} \left( \frac{\textbf{q}_i-\textbf{q}_{i-1}}{{\Delta x}}, \frac{\textbf{q}_{i+1}-\textbf{q}_{i}}{{\Delta x}} \right) . \end{aligned}$$
(38)

We compute a separate slope for each of the conservative variables in \(\textbf{q}\). At this point, it should be recalled that the reconstruction is only applied to the deviation \(\Delta \textbf{q}\) in (30), and not to the equilibrium solution \(\tilde{\textbf{q}}\). With this procedure, the spatial discretization of the explicit part becomes of second order. In the implicit part, no further changes are needed, since only point values are used and the operators in (32) are already second order.

3.4 Multi-dimensional Extension

In three spatial dimensions we discretize the domain \(\Omega = [x_L,x_R] \times [y_L,y_R] \times [z_L,z_R]\) by a Cartesian grid with \(N_x \times N_y \times N_z\) cells, which have the uniform cell size \({\Delta x}\times {\Delta y}\times {\Delta z}\).

The discretization of the explicit part is extended to three spatial dimensions by using an unsplit finite volume method according to [35], which writes

$$\begin{aligned} \begin{aligned} \Delta \textbf{q}_{i,j,k}^* = \Delta \textbf{q}_{i,j,k}^n&-\frac{{\Delta t}}{{\Delta x}} \left( \hat{\textbf{F}}_{i+1/2,j,k}^{c} - \hat{\textbf{F}}_{i-1/2,j,k}^{c}\right) + \frac{{\Delta t}}{{\Delta x}} \Bigl ( \textbf{F}^c(\tilde{\textbf{q}}_{i+1/2,j,k}) - \textbf{F}^c(\tilde{\textbf{q}}_{i-1/2,j,k}) \Bigr ) \\&-\frac{{\Delta t}}{{\Delta y}}\left( \hat{\textbf{G}}_{i,j+1/2,k}^{c} - \hat{\textbf{G}}_{i,j-1/2,k}^{c}\right) + \frac{{\Delta t}}{{\Delta y}} \Bigl ( \textbf{G}^c(\tilde{\textbf{q}}_{i,j+1/2,k}) - \textbf{G}^c(\tilde{\textbf{q}}_{i,j-1/2,k})\Bigr ) \\&-\frac{{\Delta t}}{{\Delta z}} \left( \hat{\textbf{H}}_{i,j,k+1/2}^{c} - \hat{\textbf{H}}_{i,j,k-1/2}^{c}\right) + \frac{{\Delta t}}{{\Delta z}} \Bigl (\textbf{H}^c(\tilde{\textbf{q}}_{i,j,k+1/2}) - \textbf{H}^c(\tilde{\textbf{q}}_{i,j,k-1/2})\Bigr ) \\&+ {\Delta t}\hat{\textbf{S}}_{i,j,k} - {\Delta t}\textbf{S}(\tilde{\textbf{q}}_{i,j,k}). \end{aligned} \nonumber \\ \end{aligned}$$
(39)

The numerical fluxes \(\hat{\textbf{F}}^c\), \(\hat{\textbf{G}}^c\) and \(\hat{\textbf{H}}^c\) have the form of the Rusanov flux and are constructed as in (29). For the source term \(\hat{\textbf{S}}\) we again use the cell centered value. The updated density \(\Delta \rho _{i,j,k}^{n+1}\) and magnetic field \(\Delta \textbf{B}_{i,j,k}^{n+1}\) are equal to their explicit update, since in the splitting the complete flux of these components is explicit. The update of the momentum components, on the other hand, contains implicit parts and reads in the fully discrete and three-dimensional form as

$$\begin{aligned} (\Delta \rho u)_{i,j,k}^{n+1}&=(\Delta \rho u)_{i,j,k}^{*} - \frac{{\Delta t}}{2{\Delta x}}\left( p_{i+1,j,k}^{n+1} - \tilde{p}_{i+1,j,k} - p_{i-1,j,k}^{n+1} + \tilde{p}_{i-1,j,k} \right) , \end{aligned}$$
(40a)
$$\begin{aligned} (\Delta \rho v)_{i,j,k}^{n+1}&=(\Delta \rho v)_{i,j,k}^{*} - \frac{{\Delta t}}{2{\Delta y}}\left( p_{i,j+1,k}^{n+1} - \tilde{p}_{i,j+1,k} - p_{i,j-1,k}^{n+1} + \tilde{p}_{i,j-1,k} \right) , \end{aligned}$$
(40b)
$$\begin{aligned} (\Delta \rho w)_{i,j,k}^{n+1}&=(\Delta \rho w)_{i,j,k}^{*} - \frac{{\Delta t}}{2{\Delta z}}\left( p_{i,j,k+1}^{n+1} - \tilde{p}_{i,j,k+1} - p_{i,j,k-1}^{n+1} + \tilde{p}_{i,j,k-1} \right) . \end{aligned}$$
(40c)

Implicit terms also appear in the update of the total energy:

$$\begin{aligned} \begin{aligned} (\Delta \rho E)_{i,j,k}^{n+1} = (\Delta \rho E)_{i,j,k}^*&- \frac{{\Delta t}}{2{\Delta x}} \left( h_{i+1,j,k}^n(\rho u)_{i+1,j,k}^{n+1} - h_{i-1,j,k}^n(\rho u)_{i-1,j,k}^{n+1} \right) \\&- \frac{{\Delta t}}{2{\Delta y}} \left( h_{i,j+1,k}^n(\rho v)_{i,j+1,k}^{n+1} - h_{i,j-1,k}^n(\rho v)_{i,j-1,k}^{n+1} \right) \\&- \frac{{\Delta t}}{2{\Delta z}} \left( h_{i,j,k+1}^n(\rho w)_{i,j,k+1}^{n+1} - h_{i,j,k-1}^n(\rho w)_{i,j,k-1}^{n+1} \right) . \end{aligned} \end{aligned}$$
(41)

The pressure \(p^{n+1}\), which is needed for the updates (40) and (41), can be determined by solving the following elliptic equation:

$$\begin{aligned}&\frac{p_{i,j,k}^{n+1}}{\gamma -1} - \frac{{\Delta t}}{2{\Delta x}} \frac{(\rho u)_{i,j,k}^{n}}{2 \rho _{i,j,k}^{n+1}} \left( p_{i+1,j,k}^{n+1} - \tilde{p}_{i+1,j,k} - p_{i-1,j,k}^{n+1} + \tilde{p}_{i-1,j,k} \right) \nonumber \\&\qquad - \frac{{\Delta t}}{2{\Delta y}} \frac{(\rho v)_{i,j,k}^{n}}{2 \rho _{i,j,k}^{n+1}} \left( p_{i,j+1,k}^{n+1} - \tilde{p}_{i,j+1,k} - p_{i,j-1,k}^{n+1} + \tilde{p}_{i,j-1,k} \right) \nonumber \\&\qquad - \frac{{\Delta t}}{2{\Delta z}} \frac{(\rho w)_{i,j,k}^{n}}{2 \rho _{i,j,k}^{n+1}} \left( p_{i,j,k+1}^{n+1} - \tilde{p}_{i,j,k+1} - p_{i,j,k-1}^{n+1} + \tilde{p}_{i,j,k-1} \right) \nonumber \\&\qquad - \frac{{\Delta t}^2}{{\Delta x}^2} \Bigg [ \left( \frac{3}{4} h_{i-1,j,k}^n + \frac{1}{4} h_{i+1,j,k}^n \right) \left( p_{i-1,j,k}^{n+1}-\tilde{p}_{i-1,j,k}\right) \nonumber \\&\qquad - \left( h_{i-1,j,k}^n+h_{i+1,j,k}^n \right) \left( p_{i,j,k}^{n+1}-\tilde{p}_{i,j,k}\right) + \left( \frac{1}{4} h_{i-1,j,k}^n+\frac{3}{4} h_{i+1,j,k}^n \right) \left( p_{i+1,j,k}^{n+1}-\tilde{p}_{i+1,j,k} \right) \Bigg ]\nonumber \\&\qquad - \frac{{\Delta t}^2}{{\Delta y}^2} \Bigg [ \left( \frac{3}{4} h_{i,j-1,k}^n + \frac{1}{4} h_{i,j+1,k}^n \right) \left( p_{i,j-1,k}^{n+1}-\tilde{p}_{i,j-1,k}\right) \nonumber \\&\qquad - \left( h_{i,j-1,k}^n+h_{i,j+1,k}^n \right) \left( p_{i,j,k}^{n+1}-\tilde{p}_{i,j,k}\right) + \left( \frac{1}{4} h_{i,j-1,k}^n+\frac{3}{4} h_{i,j+1,k}^n \right) \left( p_{i,j+1,k}^{n+1}-\tilde{p}_{i,j+1,k}\right) \Bigg ] \nonumber \\&\qquad - \frac{{\Delta t}^2}{{\Delta z}^2} \Bigg [ \left( \frac{3}{4} h_{i,j,k-1}^n + \frac{1}{4} h_{i,j,k+1}^n \right) \left( p_{i,j,k-1}^{n+1}-\tilde{p}_{i,j,k-1}\right) \nonumber \\&\qquad - \left( h_{i,j,k-1}^n+h_{i,j,k+1}^n \right) \left( p_{i,j,k}^{n+1}-\tilde{p}_{i,j,k}\right) + \left( \frac{1}{4} h_{i,j,k-1}^n+\frac{3}{4} h_{i,j,k+1}^n \right) \left( p_{i,j,k+1}^{n+1}-\tilde{p}_{i,j,k+1}\right) \Bigg ] \nonumber \\&\quad = b_{i,j,k}^n \end{aligned}$$
(42)

with the right-hand side

$$\begin{aligned} \begin{aligned} b_{i,j,k}^n =&\frac{\tilde{p}_{i,j,k}}{\gamma -1} + (\Delta \rho E)_{i,j,k}^* - \Delta m_{i,j,k}^{n+1} \\&-\frac{(\rho u)_{i,j,k}^n}{2\rho _{i,j,k}^{n+1}} (\Delta \rho u)_{i,j,k}^* -\frac{{\Delta t}}{2{\Delta x}} \left( h_{i+1,j,k}^n (\Delta \rho u)_{i+1,j,k}^* - h_{i-1,j,k}^n (\Delta \rho u)_{i-1,j,k}^* \right) \\&-\frac{(\rho v)_{i,j,k}^n}{2\rho _{i,j,k}^{n+1}} (\Delta \rho v)_{i,j,k}^* -\frac{{\Delta t}}{2{\Delta y}} \left( h_{i,j+1,k}^n (\Delta \rho v)_{i,j+1,k}^* - h_{i,j-1,k}^n (\Delta \rho v)_{i,j-1,k}^* \right) \\&- \frac{(\rho w)_{i,j,k}^n}{2\rho _{i,j,k}^{n+1}} (\Delta \rho w)_{i,j,k}^* -\frac{{\Delta t}}{2{\Delta z}} \left( h_{i,j,k+1}^n (\Delta \rho w)_{i,j,k+1}^* - h_{i,j,k-1}^n (\Delta \rho w)_{i,j,k-1}^* \right) . \end{aligned} \end{aligned}$$
(43)

3.5 Constrained Transport Method

When simulating the ideal MHD equations in multiple space dimensions, the divergence constraint (15) must also be taken into account in order to maintain stability and accuracy. Furthermore, the solenoidal property of the magnetic field represents a physical constraint. The scheme described up to this point does not do this in the sense that the divergence can increase significantly during the simulation. Therefore, an additional correction of the magnetic field is required after each time step. In order to retrieve at the discrete level a solenoidal magnetic field, we rely on a second order accurate CT method [22]. As it is typical in staggered CT methods, this method is based on the integration of the induction equations (13) over the cell boundaries using Stokes theorem. This results in an update formula for the magnetic field at the face centers of the cell based on the electric field at the cell corners. In our case, we update the deviation at the face centers:

$$\begin{aligned} \begin{aligned} \frac{\partial }{\partial t} \Delta B_{x,i+1/2,j,k} =&\frac{1}{{\Delta y}} \left( \Delta \textbf{E}_{z,i+1/2,j+1/2,k} - \Delta \textbf{E}_{{z,}i+1/2,j-1/2,k} \right) \\&- \frac{1}{{\Delta z}} \left( \Delta \textbf{E}_{y,i+1/2,j,k+1/2} - \Delta \textbf{E}_{y,i+1/2,j,k-1/2} \right) . \end{aligned} \end{aligned}$$
(44)

The deviation of the magnetic field at y- and z-faces is updated by similar formulae. The discretizations of the electric field at the cell corners can be taken from [22] and transferred to the deviations without any problems, since the physical fluxes evaluated in the equilibrium solution are omitted due to the zero velocity. The cell averages of the magnetic field are then computed via the arithmetic mean from the values at the faces, which still maintains second order of accuracy:

$$\begin{aligned} \Delta B_{x,i,j,k} = \frac{1}{2} \left( \Delta B_{x,i-1/2,j,k} + \Delta B_{x,i+1/2,j,k} \right) . \end{aligned}$$
(45)

In the semi-implicit scheme, this whole procedure of constrained transport is carried out directly after the explicit update. Thus, for solving the pressure equation (42) we already use the corrected and divergence-free magnetic field. Overall, by incorporating the CT method, the semi-implicit scheme keeps the following discrete definition of the divergence

$$\begin{aligned} (\nabla \cdot \textbf{B})_{i,j,k}= & {} \frac{B_{x,i+1/2,j,k}-B_{x,i-1/2,j,k}}{{\Delta x}} + \frac{B_{y,i,j+1/2,k}-B_{y,i,j-1/2,k}}{{\Delta y}}\nonumber \\{} & {} + \frac{B_{z,i,j,k+1/2}-B_{z,i,j,k-1/2}}{{\Delta z}}, \end{aligned}$$
(46)

within the order of machine accuracy. This is checked and validated at each time step of the computation.

3.6 Well-Balanced Property

The following theorem states that the presented fully discrete scheme preserves magnetohydrostatic equilibria of the form (16) up to rounding errors.

Theorem 1

Let us assume that the numerical solution \(\textbf{q}^n\) is equal to the discrete magnetohydrostatic equilibrium solution \(\tilde{\textbf{q}}\), i.e.

$$\begin{aligned} \textbf{q}_{i,j,k}^n = \tilde{\textbf{q}}_{i,j,k} \qquad \forall (i,j,k) \in \{1,...,N_x\} \times \{1,...,N_y\} \times \{1,...,N_z\}. \end{aligned}$$
(47)

Then the numerical method described in Sect. 3.1-3.5 preserves the solution up to machine precision.

Proof

From the assumption (47) it follows that \(\Delta \textbf{q}= 0\) at every grid point. Thus, the input (30) of the Rusanov fluxes in the convective sub-system is reduced to the equilibrium solution at the interface, i.e.

$$\begin{aligned} \bar{\textbf{q}}_{i+1/2,j,k}^{L}&= \bar{\textbf{q}}_{i+1/2,j,k}^{R} = \tilde{\textbf{q}}_{i+1/2,j,k}, \end{aligned}$$
(48a)
$$\begin{aligned} \bar{\textbf{q}}_{i,j+1/2,k}^{L}&= \bar{\textbf{q}}_{i,j+1/2,k}^{R} = \tilde{\textbf{q}}_{i,j+1/2,k}, \end{aligned}$$
(48b)
$$\begin{aligned} \bar{\textbf{q}}_{i,j,k+1/2}^{L}&= \bar{\textbf{q}}_{i,j,k+1/2}^{R} = \tilde{\textbf{q}}_{i,j,k+1/2}. \end{aligned}$$
(48c)

It follows by the consistency of the Rusanov flux that the numerical fluxes are equal to the physical fluxes and these truncate away with the physical fluxes in (39). Likewise, the source terms are truncated away. Therefore, the contributions from the explicit part (39) are zero:

$$\begin{aligned} \Delta \rho _{i,j,k}^*{} & {} = (\Delta \textbf{v})_{i,j,k}^* = (\Delta \rho E)_{i,j,k}^* = \Delta \textbf{B}_{i,j,k}^* = 0 \nonumber \\{} & {} \qquad \forall (i,j,k) \in \{1,...,N_x\} \times \{1,...,N_y\} \times \{1,...,N_z\}. \end{aligned}$$
(49)

Consequently, also the deviation in the magnetic energy \(\Delta m_{i,j,k}^{n+1}\) is zero. The constrained transport step after the explicit update does not change anything, because the electric field at the corners in the update (44) is equal to zero due to the zero velocity in the equilibrium. Under these conditions, the elliptic equation for the pressure (42) simplifies to

$$\begin{aligned}{} & {} \frac{p_{i,j,k}^{n+1}}{\gamma -1} \nonumber \\{} & {} \quad - \frac{{\Delta t}^2}{{\Delta x}^2} \left( \left( \frac{3}{4} h_{i-1,j,k}^n + \frac{1}{4} h_{i+1,j,k}^n \right) p_{i-1,j,k}^{n+1} - \left( h_{i-1,j,k}^n+h_{i+1,j,k}^n \right) p_{i,j,k}^{n+1}\right. \nonumber \\{} & {} \quad \left. + \left( \frac{1}{4} h_{i-1,j,k}^n+\frac{3}{4} h_{i+1,j,k}^n \right) p_{i+1,j,k}^{n+1} \right) \nonumber \\{} & {} \quad - \frac{{\Delta t}^2}{{\Delta y}^2} \left( \left( \frac{3}{4} h_{i,j-1,k}^n + \frac{1}{4} h_{i,j+1,k}^n \right) p_{i,j-1,k}^{n+1} \right. \nonumber \\{} & {} \quad \left. - \left( h_{i,j-1,k}^n+h_{i,j+1,k}^n \right) p_{i,j,k}^{n+1} + \left( \frac{1}{4} h_{i,j-1,k}^n+\frac{3}{4} h_{i,j+1,k}^n \right) p_{i,j+1,k}^{n+1} \right) \nonumber \\{} & {} \quad - \frac{{\Delta t}^2}{{\Delta z}^2} \left( \left( \frac{3}{4} h_{i,j,k-1}^n + \frac{1}{4} h_{i,j,k+1}^n \right) p_{i,j,k-1}^{n+1}\right. \nonumber \\{} & {} \quad \left. - \left( h_{i,j,k-1}^n+h_{i,j,k+1}^n \right) p_{i,j,k}^{n+1} + \left( \frac{1}{4} h_{i,j,k-1}^n+\frac{3}{4} h_{i,j,k+1}^n \right) p_{i,j,k+1}^{n+1} \right) \nonumber \\{} & {} \quad = \frac{\tilde{p}_{i,j,k}}{\gamma -1} \nonumber \\{} & {} \quad - \frac{{\Delta t}^2}{{\Delta x}^2} \left( \left( \frac{3}{4} h_{i-1,j,k}^n + \frac{1}{4} h_{i+1,j,k}^n \right) \tilde{p}_{i-1,j,k}\right. \nonumber \\{} & {} \quad \left. - \left( h_{i-1,j,k}^n+h_{i+1,j,k}^n \right) \tilde{p}_{i,j,k} + \left( \frac{1}{4} h_{i-1,j,k}^n+\frac{3}{4} h_{i+1,j,k}^n \right) \tilde{p}_{i+1,j,k} \right) \nonumber \\{} & {} \quad - \frac{{\Delta t}^2}{{\Delta y}^2} \left( \left( \frac{3}{4} h_{i,j-1,k}^n + \frac{1}{4} h_{i,j+1,k}^n \right) \tilde{p}_{i,j-1,k} \right. \nonumber \\{} & {} \quad \left. - \left( h_{i,j-1,k}^n+h_{i,j+1,k}^n \right) \tilde{p}_{i,j,k} + \left( \frac{1}{4} h_{i,j-1,k}^n+\frac{3}{4} h_{i,j+1,k}^n \right) \tilde{p}_{i,j+1,k} \right) \nonumber \\{} & {} \quad - \frac{{\Delta t}^2}{{\Delta z}^2} \left( \left( \frac{3}{4} h_{i,j,k-1}^n + \frac{1}{4} h_{i,j,k+1}^n \right) \tilde{p}_{i,j,k-1} - \left( h_{i,j,k-1}^n+h_{i,j,k+1}^n \right) \tilde{p}_{i,j,k} \right. \nonumber \\{} & {} \quad \left. + \left( \frac{1}{4} h_{i,j,k-1}^n+\frac{3}{4} h_{i,j,k+1}^n \right) \tilde{p}_{i,j,k+1} \right) \end{aligned}$$
(50)

which admits the unique solution

$$\begin{aligned} p_{i,j,k}^{n+1} = \tilde{p}_{i,j,k}. \end{aligned}$$
(51)

This means that the right-hand side of the momentum update (40) becomes zero and consequently the right-hand side of the energy update (41) also becomes zero. Thus, the updated deviations for all components of the state vector remain zero, which means that the solution \(\textbf{q}\) does not change during one time step, i.e.

$$\begin{aligned} \textbf{q}_{i,j,k}^{n+1} = \textbf{q}_{i,j,k}^n = \tilde{\textbf{q}}_{i,j,k} \qquad \forall (i,j,k) \in \{1,...,N_x\} \times \{1,...,N_y\} \times \{1,...,N_z\}. \end{aligned}$$
(52)

\(\square \) \(\square \)

3.7 Summary of the Scheme

Since various methods are combined in our scheme, we provide an overview of the individual steps of the scheme at this point. Let us assume that we know the time-independent equilibrium solution \(\tilde{\textbf{q}}\) at every point in the computational domain \(\Omega \). Then a single time-step in the well-balanced semi-implicit method from time \(t=t^n\) to time \(t=t^{n+1}\) consists of the following sub-steps:

  1. (1)

    Start with the values at the current time level: \(\textbf{q}_{i,j,k}^n\), \(\textbf{B}_{x,i+1/2,j,k}^n\), \(\textbf{B}_{y,i,j+1/2,k}^n\), \(\textbf{B}_{z,i,k,k+1/2}^n\).

  2. (2)

    Compute the deviation: \(\Delta \textbf{q}_{i,j,k}^n = \textbf{q}_{i,j,k}^n-\tilde{\textbf{q}}_{i,j,k}\).

  3. (3)

    Reconstruct the values at the cell interfaces for the deviation: \(\Delta \textbf{q}_{i+1/2,j,k}^{L}\), \(\Delta \textbf{q}_{i+1/2,j,k}^{R}\), \(\Delta \textbf{q}_{i,j+1/2,k}^{L}\), \(\Delta \textbf{q}_{i,j+1/2,k}^{R}\), \(\Delta \textbf{q}_{i,j,k+1/2}^{L}\), \(\Delta \textbf{q}_{i,j,k+1/2}^{R}\).

  4. (4)

    Perform the explicit update (28): \(\Delta \textbf{q}_{i,j,k}^*\).

  5. (5)

    Start the constrained transport routine: update the staggered magnetic field at the face centers and compute the updated cell centered magnetic field: \(\textbf{B}_{x,i+1/2,j,k}^{n+1}\), \(\textbf{B}_{y,i,j+1/2,k}^{n+1}\), \(\textbf{B}_{z,i,k,k+1/2}^{n+1}\), \(\textbf{B}_{i,j,k}^{n+1}\).

  6. (6)

    Use the computed quantities from the explicit part to solve the elliptic equation for the pressure (26) via GMRES: \(p_{i,j,k}^{n+1}\).

  7. (7)

    Compute the updated deviation in the momentum: \((\Delta \rho u)_{i,j,k}^{n+1}\).

  8. (8)

    Compute the updated deviation in the total energy: \((\Delta \rho E)_{i,j,k}^{n+1}\).

  9. (9)

    Recompute the actual solution at the new time level: \(\textbf{q}_{i,j,k}^{n+1}=\Delta \textbf{q}_{i,j,k}^{n+1} + \tilde{\textbf{q}}_{i,j,k}\).

In the case that we do not want to balance a magnetohydrostatic equilibrium, the equilibrium solution \(\tilde{\textbf{q}}\) can be set to zero.

4 Numerical Results

In this section, the second order semi-implicit finite volume well-balanced method (SIFV-WB) is applied to various numerical test problems for the Euler and ideal MHD equations. The time step of the method is calculated in each case based on the CFL condition (12) with \(\text {CFL}=0.9\). Partially, the results are compared with a non-well-balanced method. This is the same semi-implicit scheme, except for the fact that the equilibrium solution \(\tilde{\textbf{q}}\) is set to zero. All tests are performed on an uniform Cartesian grid.

4.1 Shock Tube Under Gravitational Field

The first test case is the standard Sod shock tube for the one-dimensional Euler equations, to which a gravitational source term with constant acceleration \(g_x=-1\) is added [13]. The initial conditions in the domain \(\Omega =[0,1]\) are given by

$$\begin{aligned} (\rho ,\textbf{v},p) = {\left\{ \begin{array}{ll} (1,\textbf{0},1), \quad &{}x< 0.5, \\ (0.125,\textbf{0},0.1), &{}x> 0.5, \end{array}\right. } \end{aligned}$$
(53)

with solid wall boundary conditions. The magnetic field \(\textbf{B}\) is set to zero and the ratio of specific heats is \(\gamma =1.4\). The solution at final time \(t_f=0.2\) is computed by the second order semi-implicit scheme on 100 cells. Since we have no flow around an equilibrium in this test, we set the equilibrium solution \(\tilde{\textbf{q}}\) to zero. The numerical solution is compared to a reference solution, which is computed by a fully explicit second order finite volume method on 20000 cells. The results in Fig. 1 show good agreement with the reference solution and are also consistent with solutions in the literature [13]. This test demonstrates the capability of the semi-implicit scheme to deal with shocks, thus flows which are not in the low Mach regime (\(\mathcal {M}\approx 0.76\)).

Fig. 1
figure 1

Shock tube under gravitational field at time \(t_f=0.2\). Comparison against the reference solution for density (top left), horizontal velocity (top right), pressure (bottom left) and internal energy (bottom right)

4.2 Orszag-Tang Vortex

A well-known test for the two-dimensional homogeneous MHD equations is the Orszag-Tang vortex [15, 17, 33]. Starting with smooth initial data, over time shocks develop along the diagonal direction in combination with a vortex located at the center of the computational domain. The initial conditions for the primitive variables on the spatial domain \(\Omega =[0,1]^2\) are given by

$$\begin{aligned} \begin{aligned}&(\rho , u,v,w, p, B_x, B_y, B_z )\\&\quad = \left( \frac{25}{36 \pi }, \ -\sin (2 \pi y), \ \sin (2 \pi x), \ 0, \ \frac{5}{12 \pi }, \ -\frac{1}{\sqrt{4 \pi }} \sin (2 \pi y), \ \frac{1}{\sqrt{4 \pi }} \sin (4 \pi x),0 \right) . \end{aligned} \end{aligned}$$
(54)

The gravitational acceleration \(\textbf{g}\) and the equilibrium solution \(\tilde{\textbf{q}}\) are set to zero. Periodic boundary conditions are imposed on all sides. We discretize the computational domain by a \(128 \times 128\) control volumes. In Fig. 2 results for the pressure p at different times computed by the second-order semi-implicit method are presented. The numerical method successfully captures the shocks that occur as time evolves and the results align qualitatively with those reported in the literature. [15, 17].

Fig. 2
figure 2

Orszag-Tang vortex. Numerical solution of the pressure at output time \(t_f = 1/12\) (top left), \(t_f = 1/3\) (top right), \(t_f = 0.5\) (bottom left) and \(t_f = 5/6\) (bottom right)

4.3 General Euler Steady State in 1D

The following test investigates the method’s behaviour in the presence of a hydrostatic equilibrium [16]. On the domain \(\Omega =[0,1]\) we define the gravitational acceleration in x-direction by \(g_x = 2 \pi \cos (2\pi x)\) and use the initial values

$$\begin{aligned} (\rho ,\textbf{v},p) = \left( 3+2\sin (2\pi x), \ \textbf{0}, \ 3+3 \sin (2\pi x) - 0.5 \cos (4\pi x) \right) .\nonumber \\ \end{aligned}$$
(55)

The magnetic field \(\textbf{B}\) is set to zero and \(\gamma =1.4\). Periodic boundary conditions are imposed on all sides. It can be easily checked that the values in (55) satisfy the equilibrium (16) and thus should be preserved until any final time \(t_f\). Here, we set \(t_f=1\). In a first step, we perform this test without defining an equilibrium solution \(\tilde{\textbf{q}}\). Table 2 lists the \(L_1\) error as well as the experimental order of convergence (EOC) for different numbers of grid points \(N_x\). Clearly, in this case, the equilibrium is not preserved exactly, but only with a second order of accuracy. In this form, the method is therefore not well-balanced. In a second step we use the initial values as equilibrium solution \(\tilde{\textbf{q}}\). The results in Table 3 show that the equilibrium is now maintained exactly. No iterations are needed to solve the linear system for the pressure and the residual is of the size of the machine accuracy.

Table 2 General Steady State for the non well-balanced scheme.
Table 3 General Steady State for the well-balanced scheme

4.4 Isothermal Atmosphere for Euler in 2D

After performing one-dimensional tests, the well-balanced property is now verified for the two-dimensional scheme. For this purpose we set as initial values an isothermal equilibrium [13] of the form

$$\begin{aligned} (\rho ,\textbf{v},p) = \left( 1.21 e^{-1.21(x+y)}, \textbf{0}, e^{-1.21(x+y)} \right) . \end{aligned}$$
(56)

The magnetic field \(\textbf{B}\) is set to zero and the gravitational acceleration is defined by \(\textbf{g}= (-1,-1,0)\). The ratio of specific heats is \(\gamma =1.4\). Clearly, this initial data satisfies the equilibrium (16). We run this test until a final time \(t_f=1\) on a domain \(\Omega =[0,1]^2\) with different numbers of cells \((N_x,N_y)\). As boundary conditions we enforce the exact solution. The numerical results of this test show that, as for the general steady state before, no iterations are needed to solve the pressure linear system (42) because the right hand side is perfectly balanced by the pressure terms. As a consequence, the residual has the order of the machine accuracy and the solution is preserved exactly throughout the simulation.

4.5 Perturbation of an Isothermal Atmosphere for Euler in 2D

The aim of well-balanced methods is not only to maintain hydrostatic equilibria exactly, but in particular to resolve small perturbations of these equilibria. In this sense we now add a perturbation in the pressure to the equilibrium (56), i.e.

$$\begin{aligned} p = e^{-1.21(x+y)} + \eta e^{-121 \left( (x-0.5)^2+(y-0.5)^2 \right) }. \end{aligned}$$
(57)

The parameter \(\eta \) regulates the size of the perturbation. We perform the test on a \(64\times 64\)-grid with the non-well-balanced method as well as with the well-balanced method. For the well-balanced scheme, the unperturbed initial data (56) is used for \(\tilde{\textbf{q}}\). First, we run the test with a rather large perturbation (\(\eta = 10^{-1}\)). The top row in Fig. 3 shows the perturbation \(\delta p=p(t_f)-\tilde{p}\) at time \(t_f=0.15\). For this perturbation, both methods provide a good resolution and perform qualitatively equally well. In a second simulation, we choose a smaller perturbation (\(\eta = 10^{-10}\)). In this case, the non-well-balanced method is no longer able to resolve the perturbation, while the well-balanced method resolves the small perturbation as good as the large one before. These results are consistent with the results from the literature [4, 13, 26].

Fig. 3
figure 3

Perturbation of an isothermal atmosphere in 2D at time \(t_{{f}}=0.15\). Distribution of the pressure perturbation \(\delta p\) obtained with an initial strength of \(\eta =10^{-1}\) (top row) and \(\eta =10^{-10}\) (bottom row) for the well-balanced (left column) and the non-well-balanced (right column) scheme

4.6 MHD Steady State in 2D

The following test is intended to show that the method can also maintain equilibria exactly, which have a nonzero magnetic field. For this purpose, we modify the equilibrium from Sect. 4.4 by adding a magnetic field. The initial values on the domain \(\Omega = [0,1]^2\) are then given by

$$\begin{aligned} (\rho , \textbf{v}, p, B_x, B_y, B_z ) = \left( 2.21 e^{-(x+y)}, \ \textbf{0}, \ 1.21 e^{-(x+y)}, \ e^{-\frac{1}{2}(x+y)}, \ -e^{-\frac{1}{2}(x+y)}, \ 0 \right) , \end{aligned}$$
(58)

and we set \(\gamma =1.4\). The boundary conditions rely on the exact solution. The \(L_1\)-errors for the well-balanced scheme at time \(t_f=1\) are zero just as for the Euler equilibria before, which shows that the equilibrium is preserved exactly. Consequently, the method is also well-balanced for MHD equilibria as stated in Theorem 1.

4.7 Perturbation of the MHD Steady State in 2D

As already done for the isothermal Euler equilibrium, we also add a perturbation to the MHD equilibrium (58). The initial pressure is then given by

$$\begin{aligned} p = 1.21 e^{-(x+y)} + \eta e^{-100 \left( (x-0.5)^2+(y-0.5)^2 \right) }. \end{aligned}$$
(59)

This test is also carried out with a large (\(\eta =10^{-1}\)) and a small (\(\eta =10^{-10}\)) perturbation. Figure 4 shows the results for the well-balanced and the non-well-balanced method at final time \(t_f=0.15\). The behavior is similar to the one for the Euler equilibrium in Sect. 4.5. The non-well-balanced method can only resolve the large perturbation, whereas the well-balanced method accurately reproduces both perturbations. It should be noted that the altered shape of the Gaussian perturbation in comparison to the one of the Euler equilibrium results from the newly introduced force of the magnetic field.

Fig. 4
figure 4

Perturbation of a MHD equilibrium in 2D at time \(t_{{f}}=0.15\). Distribution of the pressure perturbation \(\delta p\) obtained with an initial strength of \(\eta =10^{-1}\) (top row) and \(\eta =10^{-10}\) (bottom row) for the well-balanced (left column) and the non-well-balanced (right column) scheme

4.8 Euler Vortex in a Gravitational Field

After demonstrating the well-balanced property in the former tests, this section is devoted to show the low Mach property of the scheme. For this purpose, we use a vortex for the Euler equations that is characterised by the balance of the pressure gradient with the centrifugal and the gravitational forces, which makes the vortex axisymmetric, stationary and having zero radial velocity. The vortex is placed on top of a hydrostatic equilibrium solution, which is why \(\tilde{\textbf{q}}\) is set to this equilibrium. The detailed initial data can be found in [34].

Fig. 5
figure 5

Distribution of the local Mach number \(\mathcal {M}\) at \(t_{{f}}=0\) (top left) and after one turn for different maximum Mach numbers \(\mathcal {M}_{max}\)

Fig. 6
figure 6

Time evolution of the total kinetic energy for different maximum Mach numbers \(\mathcal {M}_{max}\) and grid resolutions \(N=N_x=N_y\)

We compute the solution after one full turn of the vortex (\(t_f=1.26\)) for different initial maximum Mach numbers \(\mathcal {M}_{max}\) on a \(40 \times 40\)-grid. Figure 5 shows the distributions of the local Mach number \(\mathcal {M}\) at time \(t_f\) and additionally the initial distribution for \(\mathcal {M}_{max}=10^{-1}\) (top left). It becomes clear that the numerical scheme adds a certain amount of numerical dissipation to the approximate solution in comparison to the initial data, which dampens the local Mach number. The vortex, however, is well resolved in each case and there is no qualitative difference between the solutions for different \(\mathcal {M}_{max}\). This indicates that the numerical dissipation is independent of the Mach number thanks to the implicit discretisation of the acoustic terms in the flux splitting.

This finding is underlined by the time evolution of the total kinetic energy. Since the domain is a closed setup due to the periodic boundary conditions, the total kinetic energy should be conserved over time in the low Mach limit. Therefore, the loss of kinetic energy is a good measure for the amount of numerical dissipation. Figure 6 shows the time evolution of the kinetic energy for different \(\mathcal {M}_{max}\) and grid resolutions \(N=N_x=N_y\). It turns out that the loss of kinetic energy only depends on the grid resolution and not on the Mach number. The results are consistent with those in [34].

5 Conclusions

In this work we have presented a well-balanced semi-implicit scheme for the ideal MHD equations with gravitational source terms. The method is based on splitting the equations into the convective part, which is discretized explicitly in time, and the acoustic part, which is discretized implicitly. An elliptic equation for the pressure is obtained, which is solved in the implicit part without adding any numerical dissipation. This makes the method particularly suitable for problems in the low Mach regime. Numerical results show indeed that the numerical dissipation is independent of the Mach number. At the same time, the explicit finite volume method for the nonlinear convective terms ensures stability in the presence of shocks. A constrained transport method is embedded in the numerical scheme to ensure the solenoidal property of the magnetic field at the discrete level.

In order to maintain magnetohydrostatic equilibria exactly and to handle small perturbations of these equilibria even on coarse grids, the method utilizes the deviation well-balancing technique. The resulting scheme solves the equations for the deviation of the solution from an a priori known equilibrium solution. We have proven that, in the equilibrium, the pressure equation has only one solution, which is the equilibrium pressure itself. As a result, the solution is preserved exactly in the case of a magnetohydrostatic equilibrium. Thus, the scheme is well-balanced. Numerical tests demonstrate that arbitrary equilibria are preserved exactly and even very small perturbations are resolved accurately.

Future developments will concern the extension of the method to unstructured meshes along the lines of [6, 9], in order to address more challenging and physically relevant problems in plasma flows as tokamak simulations [20].