Skip to main content

STRUPHY Header

Release License badge Ubuntu latest MacOS latest ruff PyPI PyPI Downloads

Welcome!

This is a Python package for solving partial differential equations (PDEs) mainly - but not exclusively - for plasma physics.

STRUPHY stands for STRUcture-Preserving HYbrid code (or STRUcture-preserving PHYsics code). The package provides off-the-shelf models for plasma physics problems, such as

  • Maxwell’s equations
  • Magneto-hydrodynamics (MHD)
  • Multi-fluid models
  • Vlasov-Poisson and Vlasov-Maxwell kinetic models
  • Drift-kinetic models for strongly magnetized plasma
  • MHD-kinetic hybrid models

All models can be run on multiple cores through MPI (distributed memory) and OpenMP (shared memory). The compute-intensive parts of the code are translated and compiled (“transpiled”) using pyccel, giving you the speed of Fortran or C while working within the familiar Python environment.

Explore Struphy on its website struphy-hub.github.io: the models and their equations, the numerical methods, domains, equilibria and a gallery of examples.

The code is freely available under an MIT license - Copyright (c) 2019-2026, Struphy developers, Max Planck Institute for Plasma Physics.

Max Planck Institute Logo

Quick install

Struphy is available on PyPI, so you can install it with pip:

pip install -U struphy
struphy compile -j 4

-j 4 compiles the kernels in parallel on four cores. In case you face troubles with install/compile:

  1. check the prerequisites
  2. visit trouble shooting

Examples

Ready-to-run simulations, each with a parameter file and a post-processing script, are in the repository struphy-examples, one folder per model and case. Its tags match the Struphy releases, so clone the tag of your installed version (struphy --version), for example

git clone --branch vX.Y.Z https://github.com/struphy-hub/struphy-examples.git
cd struphy-examples/VlasovAmpereOneSpecies/two_stream
python params_two_stream.py
python pproc_two_stream.py

Two-stream instability: phase space of the electrons at t = 0, 25 and 50

Two-stream instability: the electron distribution function f(x, v) at t = 0, 25 and 50, computed with the model VlasovAmpereOneSpecies in a FEEC-PIC discretization (particle-in-cell markers for the electrons, finite element exterior calculus splines for the electric field). Two counter-streaming beams roll up into a phase-space vortex.

To look at finished examples and their results without running anything, browse the examples gallery on the Struphy website.

AI coding agents

Struphy ships a usage guide for AI coding agents (Claude Code, Codex, Copilot, Cursor, ...) that matches your installed version. It explains how to set up, run and post-process simulations. Print it with

struphy agents

To make it available in your own project, run this in the project folder:

struphy agents --install

This copies the Struphy skills (setup-simulation, postprocess-simulation) to .claude/skills/ and adds a short pointer to the guide to AGENTS.md and CLAUDE.md, so your agent finds it automatically. Run it again after upgrading Struphy. Developers changing Struphy itself find the coding guidelines in AGENTS.md.

Available models

Check the list of currently available models. If you want to see a particular model implemented, please let us know via issues.

Documentation

The doc is on Github pages, we recommend in particular to visit:

Example: solve Maxwell’s equations

Use the command line to generate a default launch file:

struphy params Maxwell

This will create params_Maxwell.py in your current working directory (cwd). You can open the file and - if you feel like it already - change some parameters. Start the simulation with

python params_Maxwell.py

The default output is in sim_1/ in your cwd. You can change the output path via the class EnvironmentOptions in the parameter file.

For plots and diagnostics of the output, install plasma-plots with pip install "struphy[pproc]"; Output loads it automatically, adding out.plot, out.analysis and .plasma.plot on every product.

Parallel simulations are run for example with

pip install -U mpi4py
mpirun -n 4 python params_Maxwell.py

You can also put the run command in a batch script.

Python API

Try out the Python API in a Jupyter notebook or any Python environment. For example, you can create a simulation object and show the domain and equilibrium magnetic field of the linear MHD model via

from struphy import (
    Simulation,
    domains,
    equils,
)
from struphy.models import LinearMHD

model = LinearMHD()

domain = domains.DESCunit()
equil = equils.DESCequilibrium(use_nfp=False)

sim = Simulation(
    model=model,
    domain=domain,
    equil=equil,
)

sim.show_domain(scalars="absB0", window_size = (850, 250), zoom_factor=2.0)

This will show the domain and equilibrium magnetic field of the linear MHD model. You can find more examples in the documentation.

Tutorials on Binder

Get familiar with Struphy right away on mybinder - no installation needed.

Docker

If you want to get started right away without installing anything, you can use the Docker image - just pull and run:

docker pull spossann/struphy:main
docker run -it --rm spossann/struphy:main
ls struphy_*

This will show three available Struphy environments, which you can activate for example via

source struphy_fortran_/env_fortran_/bin/activate

There is also a Docker image with just the prerequisites (on Ubuntu), so you can install and compile Struphy on top of it yourself:

docker pull spossann/ubuntu-for-struphy:main
docker run -it --rm spossann/ubuntu-for-struphy:main

Get in touch

Publications

Metadata

Release files for struphy 3.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for struphy 3.5.0
File Size Uploaded Provenance Actions
struphy-3.5.0.tar.gz 4.4 MB With provenance Details for struphy-3.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for struphy 3.5.0
File Interpreter ABI Platform Actions
struphy-3.5.0-py3-none-any.whl Python 3 none any Details for struphy-3.5.0-py3-none-any.whl

Total release size: 9.4 MB

Release files / struphy-3.5.0.tar.gz

Download URL struphy-3.5.0.tar.gz
Size 4.4 MB
Tags Source
SHA-256 checksum
How to use checksums
d83e715621896058bc61594e43047276767200d98cc23a38623985f17e1d2199
BLAKE2b-256 checksum
How to use checksums
b1e122ca0b8d6cc3c0966b15143cbabc23e03bf6b3d4f4b1a9fa5d2a642442c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / struphy-3.5.0-py3-none-any.whl

Download URL struphy-3.5.0-py3-none-any.whl
Size 5.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
d92cd8ba7522dcd67f486b097792f73154e5f478ea50eecf24400b1dc1f0d551
BLAKE2b-256 checksum
How to use checksums
6ba4ae91d9045b15f01950a59afb550e14c522a00fc7a6266152369fdcb33d4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for struphy 3.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for struphy-3.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.5.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page