Skip to main content

Multi-model plasma physics package

Project description

STRUPHY Header

Release License badge Ubuntu latest MacOS latest isort and 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)
  • 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.

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

Tutorials

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

Quick install

Quick install on your computer (using a virtual environment):

python -m venv struphy_env
source struphy_env/bin/activate
pip install -U pip
pip install -U struphy
struphy compile

In case you face troubles with install/compile:

  1. check the prerequisites
  2. visit trouble shooting

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.

Quick run

As an example, let’s say we want to solve Maxwell’s equations. We can use the CLI and generate a default launch file via

struphy params Maxwell

Hit yes when prompted - this will create the file params_Maxwell.py in your current working directory (cwd). You can open the file and - if you feel like it already - change some parameters, then run

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.

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.

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

Documentation

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

Get in touch

Citing Struphy

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

struphy-3.1.0.tar.gz (3.9 MB view details)

Uploaded Source

Built Distribution

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

struphy-3.1.0-py3-none-any.whl (4.1 MB view details)

Uploaded Python 3

File details

Details for the file struphy-3.1.0.tar.gz.

File metadata

  • Download URL: struphy-3.1.0.tar.gz
  • Upload date:
  • Size: 3.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for struphy-3.1.0.tar.gz
Algorithm Hash digest
SHA256 4f84b4d674ee80346db0f3674e1dbf892ec2796617ecb31e3c8d05d871e0956b
MD5 c843223fee8eb4921200014a76688e7d
BLAKE2b-256 a0dd249e2fbff2c55cb07be80e60cd8f3b788dc4eb7274a44f4c6a6961784d9a

See more details on using hashes here.

Provenance

The following attestation bundles were made for struphy-3.1.0.tar.gz:

Publisher: pypi-release.yml on struphy-hub/struphy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file struphy-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: struphy-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for struphy-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e83bd396e62506a0cb11e3ed494642790687fb5d2945b987eb2d1c0c1963fb2
MD5 8d671997fa3383be5c4787fe29715902
BLAKE2b-256 519aa02ce85feef7efd037472105548f57b43fe30aaca000db6766395d9bf22e

See more details on using hashes here.

Provenance

The following attestation bundles were made for struphy-3.1.0-py3-none-any.whl:

Publisher: pypi-release.yml on struphy-hub/struphy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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