RAMSES-CPP

RAMSES-CPP aims to provide a functional and physically consistent alternative to the original Fortran implementation while maintaining strict bit-perfect parity in data structures and I/O.

View the Project on GitHub SinsuSquid/RAMSES-CPP

Magnetohydrodynamics (MHD) in RAMSES-CPP

Status: The MHD module is fully integrated with the AmrGrid system and is the primary focus of the Phase 2 multi-dimensional expansion. Core physics, Constrained Transport, and adaptive refinement for magnetic gradients are fully operational and verified against standard benchmarks.

The MHD module in RAMSES-CPP provides a robust, divergence-free implementation of ideal magnetohydrodynamics on adaptive grids.

Key Features

Implementation Details

Staggered Grid and Variable Layout

Magnetic fields are stored at the faces of the cells (indices 6-8 for left faces, and $nvar-2$ to $nvar$ for right faces), while hydro variables are stored at cell centers.

EMF and CT Update

The Electromotive Forces (EMFs) are computed at cell edges using electric field components from the Riemann fluxes. The face-centered magnetic fields are then updated using the curl of these EMFs: \(\frac{\partial \mathbf{B}}{\partial t} = -\nabla \times \mathbf{E}\) This staggered update ensures that the divergence $\nabla \cdot B$ remains zero to machine precision throughout the simulation.

Verified Benchmarks

Configuration

To enable MHD, use the following CMake flag:

cmake .. -DRAMSES_USE_MHD=ON

In the namelist, ensure hydro=.true. and appropriate MHD parameters are set in the &HYDRO_PARAMS and &PHYSICS_PARAMS blocks.