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 and visualization 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: 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 with:
pip install pymhd
This command installs PyMHD and its required dependencies, including:
- NumPy for core computations
- 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:
git clone https://github.com/PlasmaHua/PyMHD.git
Alternatively, download the source code from the GitHub releases page. Then navigate to the ./examples subdirectory with cd PyMHD/examples, where two AthenaK simulation examples are provided.
Each directory in PyMHD/examples contains a Python script, quick.py, that demonstrates basic usage of PyMHD, including:
- Extracting a PyMHD
Turbulenceobject from output files with thepymhd.output2turbulencefunction - Calculating turbulent energy spectra with the PyMHD
EnergySpectraclass - Estimating numerical dissipation a posteriori with the PyMHD
NumericalDissipationclass - Visualizing turbulent spectra and numerical dissipation with the
pymhd.plotmodule
Analyze Your Own Athena Simulations
PyMHD natively supports simulations from Athena++, AthenaK, and AthenaPK. Following the examples in PyMHD/examples, 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, please consider citing the package using the following BibTeX entry:
@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}
}
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.2.tar.gz.
File metadata
- Download URL: pymhd-0.1.2.tar.gz
- Upload date:
- Size: 69.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ec9649931a2d3c7424b97b6122f59423bfff75da7ecf1d169c8791c497afbd5
|
|
| MD5 |
e55b68b398a4b1524823b50a50e071f9
|
|
| BLAKE2b-256 |
8f6d95f8eb983fa8418eadaf3ee5843488d46eadbc379675f6b72c4997e698c8
|
File details
Details for the file pymhd-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pymhd-0.1.2-py3-none-any.whl
- Upload date:
- Size: 75.9 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 |
6137d92dd76f0b92ac71a1d429cff1e85872200b7b1a63e02b2c9cec8197fc4d
|
|
| MD5 |
4334436c945156a32fd2eb71531daa01
|
|
| BLAKE2b-256 |
e85c1314e4876c9cd85121ab7f82686941181c07b80c8f752ede5a586b763f70
|