Japanese | English
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.
The following versions are available in .tar.gz format.
The source code is hosted on GitHub.
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.
Sample IDL and Python/matplotlib routines are provided. For IDL, please run the 'batch' script in the following way.
$ idl IDL> .r batch
For Python 3, please run the 'plot.py' script in the following way.
$ ipython3 --pylab
In [1]: %run plot.py
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
Set the n_start
parameter to non-zero.
The HLLD flux solver. Here is a benchmark.
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
The following problems are pre-configured.