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.1.tar.gz (68.8 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.1-py3-none-any.whl (75.5 kB view details)

Uploaded Python 3

File details

Details for the file pymhd-0.1.1.tar.gz.

File metadata

  • Download URL: pymhd-0.1.1.tar.gz
  • Upload date:
  • Size: 68.8 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.1.tar.gz
Algorithm Hash digest
SHA256 4cc16f75e475046af7831354303b3fe54f63f78a83c88a9edec99e4120842987
MD5 a899e4edd6dd6399907b84a961f15b5f
BLAKE2b-256 738db3fd1b3b4836de49382b63974093e46f4f2eeb36798c373e784c9e84b8c4

See more details on using hashes here.

File details

Details for the file pymhd-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pymhd-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 75.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6a2b36844978373c3b09f163cbc967020293a7e5909961796d8d391c3d762c66
MD5 fd9f5cc8bbe2708feb7cd9a21b4ab7ed
BLAKE2b-256 aead38898f72b81c561734be90ac103266f40033bbee28a0c20dfad9e6154a85

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