Skip to content

struphy-hub/struphy

Repository files navigation


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.

Particles in a Tokamak
(model "Vlasov")
Toroidal Alfvén eigenmode
(model "LinearMHDDriftKineticCC")
Strong Landau damping
(model "VlasovAmpereOneSpecies")
Anisotropic diffusion
(propagator "ImplicitDiffusion")

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

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 --status
struphy compile

In case you face troubles with install/compile:

  1. check the prerequisites
  2. visit trouble shooting

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.

Documentation

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

Get in touch

Citing Struphy

About

A Python package for plasma physics PDEs.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 17