Skip to main content

A Python package for post-processing MHD turbulence simulations

Project description

PyMHD

DOI License: MIT

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++ .athdf files, AthenaK .bin files, and AthenaPK .phdf files;
  • Matplotlib for plotting functionality in the pymhd.plot modules;
  • KDEpy for plotting smoothed histograms of numerical dissipation data in the pymhd.plot.nd module.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymhd-0.1.0.tar.gz (68.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymhd-0.1.0-py3-none-any.whl (75.4 kB view details)

Uploaded Python 3

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

Hashes for pymhd-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4efbc386f490b8713c38525fbe2e14c77ca9ee252961832e3105c0d17dd1e6cb
MD5 35c847cd2fef0dedc9a672e6df953f90
BLAKE2b-256 324d9b01a00acc913dc794372bebef51d167882a5fd98f42f7ad3bd9ea0abd5b

See more details on using hashes here.

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

Hashes for pymhd-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92f37c60e3e67c3cba31b482899ec99a4f732b68aa53d32d0969e2377a064d5b
MD5 fd3ba00b6f0686f59dfce036b3156785
BLAKE2b-256 a4275789b7091ae42d7e414beb25c52c673c84a454d1b06b7b940a3950669dcb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page