# PAMHD

**CCMC Services available for PAMHD**

Request a Run See how to request a run.

View Request Results See how to visualize PAMHD results.

Download Source Code See how to contribute to PAMHD.

**Model Developer(s)**

Ilja Honkonen

NASA GSFC

**Model Description**

PAMHD solves equations of ideal magnetohydrodynamics in a uniform cartesian grid in one to three dimensions.

Customizable initial and boundary conditions are supported.

Divergence of magnetic field is cleaned using the method of Brackbill and Barnes 1980.

**Model Input**

Input consists of general parameters, grid parameters, and magnetohydrodynamic variables described by initial conditions, copy boundaries and time-dependent value boundaries.

General parameters specify starting time of simulation, duration of simulation, intervals for saving results and removing divergence of magnetic field, the values of adiabatic index, vacuum permeability and proton mass, and the length of simulation time steps with respect to the CFL condition.

Proton mass is used to convert number densities to mass density.

Grid parameters specify the number of simulation cells, simulation geometry and whether the grid is periodic.

Initial condition and value boundaries consist of mathematical expressions for plasma number density, velocity, thermal pressure and magnetic field.

The simulation is initialized by obtaining a value from above initial condition expressions for plasma parameters in each simulation cell.
Expressions can refer to the cell's center coordinates with r[0], r[1] and r[2].
Basic mathematical functions are supported but for security reasons parentheses must be replaced with brackets (e.g. sin[2*pi*r[0]] instead of sin(2*pi*r[0])).

See the links section for pointers to additional documentation regarding supported mathematical expressions.

In value boundaries the plasma parameters are set after each time step and the mathematical expressions can also refer to current simulation time with t.

Initial condition and value boundaries allow further customization with boxes and spheres inside of which separate mathematical expressions can be used for plasma parameters.

Boxes also require the start and end coordinates of their volume to be given while spheres require the center coordinates and radius.

These are evaluated in a pseudorandom order so overlapping regions with different parameter values should be avoided.

Copy boundaries consist of boxes and spheres inside of which plasma parameters are set to the average value of non-boundary nearest neighbor cells.

Cells inside of a copy boundary that only have boundary cells as neighbors are not updated.

**Model Output**

Output consists of mass density, momentum density, total energy density and magnetic field in the simulated volume as well as derived parameters supported by CCMC.

**Limitations and Caveats**

PAMHD solves ideal magnetohydrodynamic equations and is not suitable for problems where e.g. kinetic effects are important.

Ledvina et al. 2008 has a discussion on the applicability of ideal magnetohydrodynamics.

**References and relevant publications**

- Brackbill, J.U., Barnes, D.C. (1980), The effect of nonzero ∇ ⋅ B on the numerical solution of the magnetohydrodynamic equations, Journal of Computational Physics, 35, 3, 426-430, doi: 10.1016/0021-9991(80)90079-0
- Honkonen, I. (2015), A generic simulation cell method for developing extensible, efficient and readable parallel computational models, Geoscientific Model Development, 8, 3, 473-483, doi: 10.5194/gmd-8-473-2015
- Honkonen, I., von Alfthan, S., Sandroos, A., Janhunen, P., Palmroth, M. (2013), Parallel grid library for rapid and flexible simulation development, Computer Physics Communications, 184, 4, 1297-1309, doi: 10.1016/j.cpc.2012.12.017
- Ledvina, S.A., Ma, Y.-J., Kallio, E. (2008), Modeling and Simulating Flowing Plasmas and Related Phenomena, Space Science Reviews, 139, 1-4, 143-189, doi: 10.1007/s11214-008-9384-6
- Stone, J.M., Gardiner, T.A., Teuben, P., Hawley, J.F., Simon, J.B. (2008), Athena: A New Code for Astrophysical MHD, The Astrophysical Journal Supplement Series, 178, 1, 137, doi: 10.1086/588755

**Relevant links**

The source code of PAMHD is available at https://github.com/iljah/pamhd for anyone to download, use, study, modify and redistribute.

The program available through CCMC is the MHD test program in tests/mhd/test.cpp in the above repository.

Various libraries are used in order to reduce development time:

- Solvers for ideal magnetohydrodynamics have been borrowed from Athena, available at https://trac.princeton.edu/Athena/ (Stone et al. 2008).
- Various boost libraries are used for parsing command line and cofiguration files, converting numbers between text and binary representation, string algorithms, etc., available at http://www.boost.org
- Mathematical expressions are parsed by muParserX, available at https://github.com/beltoforion/muparserx. Documentation on supported expressions is at http://articles.beltoforion.de/article.php?a=muparserx
- Eigen is used for linear algebra and is available at http://eigen.tuxfamily.org
- DCCRG is used for parallelization of the model on distributed memory computers via the Message Passing Interface standard, available at https://github.com/fmihpc/dccrg (Honkonen et al. 2013).
- Simulation variables are stored in a generic simulation cell (Honkonen 2015) to simplify parallelization and addition of new simulation variables.
- Rapidjson is used for parsing simulation parameters, available at ihttps://github.com/miloyip/rapidjson

**Source Code Available at:**

https://github.com/iljah/pamhd

**CCMC Contact(s)**

301-286-9571

**Developer Contact(s)**