## OpenMHD code

Japanese | English

#### Introduction

OpenMHD is a two-dimensional finite-volume code for magnetohydrodynamics (MHD). The code is written in Fortran 90. It is parallelized by using MPI-2 and OpenMP.

OpenMHD was originally developed for my studies on magnetic reconnection [1,2]. In addition, substantial improvements have been made since then. The code has been made publicly available in the hope that others may find it useful.

##### Obtaining the code

The following versions are available in .tar.gz format.

The source code is hosted on GitHub.

##### Basic equations

OpenMHD solves the following equations of magnetohydrodynamics. \begin{align} \frac{\partial \rho}{\partial t} &+ \nabla \cdot ( \rho \vec{v} ) = 0, \\ \frac{\partial \rho \vec{v}}{\partial t} &+ \nabla \cdot ( \rho\vec{v}\vec{v} + p_T\overleftrightarrow{I} - \vec{B}\vec{B} ) = 0, \\ \frac{\partial e}{\partial t} &+ \nabla \cdot \Big( (e+p_T )\vec{v} - (\vec{v}\cdot\vec{B}) \vec{B} + \eta \vec{j} \times \vec{B} \Big) = 0, \\ \frac{\partial \vec{B}}{\partial t} &+ \nabla \cdot ( \vec{v}\vec{B} - \vec{B}\vec{v} ) + \nabla \times (\eta \vec{j}) + \nabla \psi = 0, \\ \frac{\partial \psi}{\partial t} &+ c_h^2 \nabla \cdot \vec{B} = - \Big(\frac{c_h^2}{c_p^2}\Big) \psi, \end{align} where $p_T=p+B^2/2$ is the total pressure, $\overleftrightarrow{I}$ is the unit tensor, $e=p/(\Gamma-1) + \rho v^2/2 + B^2/2$ is the energy density, $\Gamma=5/3$ is the adiabatic index, and $\psi$ is a virtual potential for hyperbolic divergence cleaning [3]. The second-order Runge=Kutta methods and second-order MUSCL scheme are employed. The source term for $\psi$ is handled by the Strang splitting and an analytic solution $\psi = \psi_0 \exp [ - ({c_h^2}/{c_p^2}) t ]$. Other numerical techniques are documented in Ref. [1] and references therein. In addition, the latest version contains the HLLD flux solver [4,2] and other improvements such as the parallel I/O.

#### Q & A

1. How to visualize the data?

Sample Python 3 (matplotlib) and IDL routines are provided. For Python 3, please run the 'plot.py' script in the following way.

$ipython3 --pylab In [1]: %run plot.py  For IDL, please run the 'batch' script in the following way. $ idl
IDL> .r batch

2. How to set up boundary conditions?

The user needs to set up boundary conditions for both conserved variables (U) and MUSCL-interporlated primitive variables (VL and VR). One might want to modify the boundary conditions in the following files:

• [mpi]bc*.f90
• [mpi]bc_vlvr_*.f90

3. How to reload the previous data?

Set the n_start parameter to non-zero.

4. What is the most costly part?

The HLLD flux solver. Here is a benchmark.

5. What is the best URL for a reference?

Please refer a link (http://ascl.net/1604.001) at Astrophysics Source Code Library (ASCL) or the github URL (https://github.com/zenitani/OpenMHD), because this URL (http://th.nao.ac.jp/MEMBER/zenitani/openmhd-e.html) may not be stable.

Here are snippets for your convenience.

S. Zenitani, Phys. Plasmas, 22, 032114 (2015).
S. Zenitani, Astrophysics Source Code Library, record ascl:1604.001 (2016).

Zenitani, S. 2015, Phys. Plasmas, 22, 032114
Zenitani, S. 2016, Astrophysics Source Code Library, record ascl:1604.001


#### Test problems

The following problems are pre-configured.

#### History

2018-03-14
• Better OpenMP performance.
2018-02-14
• Employed non-blocking communication.
• Improved MPI-IO routines.
• Fixed an OpenMP bug in the HLLD solver.
• Other minor improvements.
2017-07-28
• Added a new problem on a relativistic jet.
• Added a relativistic HLL/HLLD solver for transverse propagation.
• Updated Python/IDL routines.
2017-04-28
• Changed the binary file format: We removed the fortran record markers. (Courtesy of Dr. Kondoh, Dr. Hotta, and Prof. Matsumoto)
• Updated Python/IDL routines.
• Temporally removed the Mathematica notebook.
2016-12-26
• Updated Python/IDL routines.
• Added a sample Mathematica notebook.
2016-10-08
• Revised slope limiters with OpenMP directives.
• Revised flux solvers in the X/Y (and Z) directions.
• New resistive-term and GLM-term solvers.
• Improved performance.
• Fixed a bug in the energy state in the HLLC solver in X.
• Changes in initial parameters. (Courtesy of Mr. Hino)
• Added sample Python 3 (matplotlib) codes.
• Changed the directory layout.
2016-08-08
• Fixed initial and boundary conditions in magnetic reconnection. (Courtesy of Dr. Kondoh)
2016-01-17
• Improved the HLLC solver and the Koren limiter.
• Added OpenMP directives to the flux solvers.
2015-08-15
• Parallel I/O.
• Modified resistive terms in the HLL solver.
• Optimized the LLF/HLL/HLLC solvers and the minmod/MC limiters, in particular on SPARC processors.
• Fixed a bug in the energy state in the HLLC solver in X.
2015-03-25
• Updated initial settings of the reconnection problem (ref. [2]).
• Reorganized BC subroutines.
• Improved performance.
2014-09-08
• Added a resistive HLLD solver.
• The code can restart from the output file(s).
• Fixed a NaN issue in the fast-mode speed.
• The code is now hosted on GitHub.
2012-07-05
• Added a test problem on "CIR".