We present for astrophysical use a multidimensional numerical code to solve the equations for ideal magnetohydrodynamics (MHD). It is based on an explicit finite-difference method on an Eulerian grid, called the total variation diminishing (TVD) scheme, which is a second-order-accurate extension of the Roe-type upwind scheme. Multiple spatial dimensions are treated through a Strang-type operator splitting. The constraint of a divergence-free field is enforced exactly by calculating a correction via a gauge transformation in each time step. Results from two-dimensional shock-tube tests show that the code captures correctly discontinuities in all three MHD wave families as well as contact discontinuities. The numerical viscosities and resistivity in the code, which are useful in order to understand simulations involving turbulent flows, are estimated through the decay of two-dimensional linear waves. Finally, the robustness of the code in two dimensions is demonstrated through calculations of the Kelvin-Helmholtz instability and the Orszag-Tang vortex.
- Methods: numerical
- Shock waves