1D-3D MHD with adaptive meshes

by Doris Folini and Rolf Walder

Page contents

Integrators spacer Adaptive Mesh spacer Graphics and Visualization
Implemented Problems
History spacer Access spacer References and Links


AMRCART is part of the A-MAZE code package which provides codes for astrophysical simulations.

AMRCART solves in 1D, 2D, or 3D the ideal, compressible, hydrodynamical or magnetohydrodynamical equations with arbitrary source terms. We use fractional step methods to solve the inhomogeneous equations. Different high-resolution finite volume integrators are implemented to solve the MHD equations. High-order ODE-solvers are used for the integration of the source terms. AMRCART uses Cartesian meshes (CART) and fully adaptive mesh refinement (AMR) for solving unsteady problems. More information on the codes you find in this brief documentation of AMRCART.

AMRCART has been widely used by the Zürich group for different astrophysical flow problems, for example Symbiotic binaries, WR+O binaries, Shock bound slabs, and Molecular clouds. Several relevant astrophysical problems are implemented in the code. A new problem is easily implemented, as only three subroutines, describing the source terms, the initial, and the boundary conditions, have to be adapted.


AMRCART uses high resolution finite volume methods to integrate the homogeneous HD and MHD equations. The user can choose between two truly multidimensional integrators, one by Colella (1990) the other by LeVeque (1997), and the modified Lax-Friedrichs method proposed by Barmin et al. (1996).
AMRCART provides several explicit or implicit ODE-integrators for integration of the source terms.
It uses a fractional step method to solve the inhomogeneous flow equations.

Adaptive Mesh Refinemen

The Adaptive Mesh Refinement algorithm of Marsha Berger is implemented in the code. In the simulation, this allows to resolve the many different spatial and temporal scales often appearing in astrophysical fluid flows.
In AMRCART, the mesh on which the numerical solution is computed is organized in the form of hierarchically nested levels. Higher levels in the hierarchy have smaller mesh cells than levels lower in the hierarchy. Each level of refinement is composed of one or several regular quadri-lateral blocks (see the examples below). Each individual block comprises a number of cells, each of which corresponds to one discretized data point. Within an individual block the size of the cells is fixed. The extention of a cell in each direction is constant, the cells are square shaped or cubic. A mesh remains fixed for a few time steps only before it is again adapted to the new, unsteady flow structure.

Refinement on the basis of truncation errors
In a first step, the local truncation error is estimated by comparing for each cell the solution on the actual mesh with the solution on a coarsened mesh. Cells having a larger local truncation error than a chosen threshold are flagged to be refined. In a subsequent step, quadri-lateral blocks embedding all flagged cells are constructed. The mesh is then refined in these blocks. Example 1 and 2 illustrate this case.

Refinement on the basis of geometry
Alternatively, the blocks containing small mesh cells can be constructed on the basis of geometrical considerations or special flow features. Example 3 illustrates this case.

Example 1: 2D time-dependent mesh-structure of a magnetic jet simulation
We show the time-dependent construction of a hierarchical mesh with a total of 5 levels at the example of a 2D simulation of the interaction of a molecular, magnetic jet from a proto-star with the magnetic protostellar cloud.

The computational box of the simulation is 5 x 10^(17) cm by 10^(18) cm. Fig. 1 shows density, logarithmically colored, as well as the hierarchical structure of the mesh. The coarsest cells measure 2.5 x 10^(16) cm squared. The mesh then carries 4 refined levels, each consisting of several quadri-lateral blocks. Blocks of the first refinement level, cell size (6.25 x 10^(15) cm)^2, are colored in red, blocks of the second refinement level, cell size (1.56 x 10^(15) cm)^2, are colored in purple, blocks of the third refinement level, cell size (3.9 x 10^(14) cm)^2, are colored in white, blocks of the fourth refinement level, cell size (9.8 x 10^(13) cm)^2, are colored in black. The maximum number of blocks in this example is 648, the complete mesh consists of approximately 10 million cells. Approximately 10^(11) cells have been integrated during the entire simulation.
At the beginning, levels with small mesh cells (high levels in the hierarchy) are constructed only in the neighborhood of the protostellar core (Fig. 1, left). In the final constellation (29378 y), the fine mesh is covering the turbulent zone of the unstable jet as well as the bow shock formed where the jet interacts with the protostellar cloud (Fig. 1, right).

Click to see the full size figure. Click to see the full size figure.
2d jet 2d jet
Fig. 1, left. Initial mesh structure (zoom). Fig. 1, right. Final mesh structure (zoom).

This animation (mpeg, 1.1 MB) shows the time-dependent adaptation of the mesh.

Example 2: 3D mesh of a magnetic jet simulation
As an example in 3D we again take the interaction of a molecular, magnetic jet from a proto-star with the magnetic protostellar cloud.

Below we show the computational box (in black) of this simulation together with the hierarchical mesh structure (left) and a zoom showing the interaction surface together with the blocks of the finest level of refinement. The size of the computational box is 2.5 x 10^(17) cm by 2.5 x 10^(17) cm by 5 x 10^(17) cm. The mesh is Cartesian with a cell size of 1.25 x 10^(16) cm cubed on the coarsest level. 4 levels of refinement exist, the cells being refined by a factor of 4 between successive levels. The finest blocks (blue in Fig.2) contain cells of 2 x 10^(14) cm cubed, which is more than 3 orders of magnitude smaller than the computational box. In this example, 63 hierarchically nested blocks are used and the total number of mesh cells is again about 10 million.

Click to see the full size figure. Click to see the full size figure.
3d jet 3d jet
Computational box (black), and blocks of the first (green), second (purple), third (red) and fourth (blue) level of refinement. Beam of the jet (black), bow-shock (red), and blocks of the finest level of refinement (blue).

Graphics and Visualization

3D and 2D

We provide visualization tools on the basis of AVS-Express, NCAR-graphics, and AVS 5. In close collaboration with our institute, Dr. J. Favre from CSCS has developed tools on top of AVS-Express for fast visualization of time-dependent, hierarchical, multi-block data.
To allow for a simple but less powerful visualization a fortran code can be supplied which interpolates a regular array of a flow variable from the full adaptive 3D data set dumped by AMRCART. This regular data array can then be visualized with any commercial visualization package, e. g. IDL.


Master1D, a package of macros based on IDL, has been developed. The package allows to simultaneously visualize different flow variables of different data files in different windows.

Implemented problems

At present, the following astrophysical problems are implemented:
  • Supernova Remnant
  • Colliding Winds in Planetary Nebulae and other ring nebulae
  • Wind dynamics in binary systems: wind-wind collision and accretion
  • Interaction of jets with its environment
A new problem can be easily implemented by the user. Only three subroutines specifying the problem set-up, the initial conditions, the boundary conditions and the source terms have to be exchanged. The more complex parts of the code have not to be touched by the user.


  • 1988: AMRCART designed for 2D Euler equations by M. Berger and R. LeVeque.
  • 1990: First use in astrophysics (R. Walder, Institute of Astronomy, ETHZ).
  • 1991: Implementation of different source terms (e.g. gravity, radiative cooling).
  • 1992: Extension to 1D and 3D.
  • 1998: Extension to ideal magneto-hydrodynamics, MHD.


At the moment, the following versions are available:
MHD 3D : beta-version of
MHD 2D : beta-version of
MHD 1D : beta-version of
Hydro 3D : Version 1.0
Hydro 2D : Version 1.0
Hydro 1D : Version 1.0

See here how to access the codes.

Links to further informations


A. A. Barmin, A. G. Kulikovskij, and N. V. Pogorelov
Shock capturing Approach and Nonevolutionary Solutions in Magntodydrodynamics,

Journal of Computational Physics, 126, 77 (1996).

Marsha J. Berger and Randall J. LeVeque,
Adaptive Mesh Refinement using Wave-Propagation Algorithms for Hyperbolic Systems,

SIAM J. Numer. Anal., 35, 2298-2316 (1998).
Available as a 300KB gzipped postscript file.

Marsha J. Berger and Randall J. LeVeque,
Cartesian Meshes and Adaptive Mesh Refinement for Hyperbolic Partial Differential Equations,

Proc. 3rd Int. Conf. Hyperbolic Problems, Uppsala, Sweden 1990.

Marsha J. Berger,
Adaptive mesh refinement for Hyperbolic Equations,

Lectures in Applied Mathematics, 22, 31--40 (1985).

Marsha J. Berger and Phillip Colella,
Local Adaptive Mesh refinement for Shock Hydrodynamics,

Journal of Computational Physics, 82, pages 64--84 (1989).

Phillip Colella
Multidimensional Upwind Methods for Hyperbolic Conservation Laws

Journal of Computational Physics, 87, pages 171 (1990).

Randall J. LeVeque,
Wave propagation algorithms for multi-dimensional hyperbolic systems

Journal of Computational Physics,131, 327-353 (1997).

K. G. Powell, P. L. Roe, and T. J. Linde
A solution adaptive upwind scheme for ideal mhd

Journal of Computational Physics, 154, 284-309, (1999).

S. A.E.G. Falle, S. S. Komissarov, and P. Joarder
A multidimensional upwind scheme for MHD

Monthly notices of the Royal Astronomical Society, 297,265-277, (1998).

Send comments to authors of A-MAZE:
Doris Folini and Rolf Walder
Last Update: October 14, 2002