A Python package for post-processing MHD turbulence simulations
Project description
PyMHD
A Python package for post-processing magnetohydrodynamic (MHD) turbulence simulations.
Features
- High-fidelity a posteriori estimation of numerical dissipation in MHD turbulence simulations;
- Computation and visualization of turbulent energy spectra;
- Visualization of 2D slices of MHD variables;
- Built-in support for simulations from the Athena family, including Athena++, AthenaK, and AthenaPK;
- Support for driven MHD turbulence (e.g., Alfvénic turbulence and small-scale dynamos), driven hydrodynamic turbulence, and MRI-driven turbulence (from shearing-box simulations) with triply periodic boundary conditions;
- Support for adiabatic and isothermal equations of state (EoS); TODO: add support for incompressible EoS;
- TODO: Computation and visualization of correlation functions;
- TODO: Spectral energy transfer analysis following Grete, Philipp, et al. Physics of Plasmas 24.9 (2017).
- TODO: Support JAX acceleration on GPUs and multi-node CPUs (currently, certain algorithms support parallelism on single-node, multi-core CPUs).
Quick Start
Installation
Install PyMHD from PyPI via:
pip install pymhd
This will automatically install PyMHD and its required dependencies, including:
- NumPy for core computation;
- JAX for parallel acceleration on single-node, multi-core CPUs; therefore, the CPU version of JAX is required;
- yt and h5py for extracting data from HDF5 output files, specifically Athena++
.athdffiles, AthenaK.binfiles, and AthenaPK.phdffiles; - Matplotlib for plotting functionality in the
pymhd.plotmodules; - KDEpy for plotting smoothed histograms of numerical dissipation data in the
pymhd.plot.ndmodule.
Built-in Examples
For a quick start, clone the source repository, for example:
git clone https://github.com/PlasmaHua/PyMHD.git
Then navigate to the ./examples subdirectory using cd PyMHD/examples, where two AthenaK simulation examples are provided.
Under construction.
Analyze Your Own Athena Simulations
PyMHD natively supports simulations from Athena++, AthenaK, and AthenaPK. Use the pymhd.output2turbulence function to extract output data and input-file metadata, then construct a PyMHD Turbulence object for further analysis.
API Documentation
Under construction.
Citation
If PyMHD contributes to your work in any way, please consider citing the package via:
@misc{Hua2026,
doi = {10.5281/zenodo.20749062},
url = {https://zenodo.org/doi/10.5281/zenodo.20749062},
author = {Hua, Yuyang},
title = {PyMHD: Python package for post-processing MHD turbulence simulations},
publisher = {Zenodo},
year = {2026},
copyright = {MIT License}
}
If you specifically use the framework for numerical dissipation estimation, please cite our method paper via:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pymhd-0.1.0.tar.gz.
File metadata
- Download URL: pymhd-0.1.0.tar.gz
- Upload date:
- Size: 68.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4efbc386f490b8713c38525fbe2e14c77ca9ee252961832e3105c0d17dd1e6cb
|
|
| MD5 |
35c847cd2fef0dedc9a672e6df953f90
|
|
| BLAKE2b-256 |
324d9b01a00acc913dc794372bebef51d167882a5fd98f42f7ad3bd9ea0abd5b
|
File details
Details for the file pymhd-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pymhd-0.1.0-py3-none-any.whl
- Upload date:
- Size: 75.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92f37c60e3e67c3cba31b482899ec99a4f732b68aa53d32d0969e2377a064d5b
|
|
| MD5 |
fd3ba00b6f0686f59dfce036b3156785
|
|
| BLAKE2b-256 |
a4275789b7091ae42d7e414beb25c52c673c84a454d1b06b7b940a3950669dcb
|