Skip to main content

Documentation Status Tests Available on pypi Formatted with black Code coverage DOI

Pyrokinetics

This project aims to standardise gyrokinetic analysis.

A general pyro object can be loaded either from simulation/experimental data or from an existing gyrokinetics file.

In general pyrokinetics can do the following

  • Read data in from:
    • Gyrokinetic input files
    • Simulations outputs
  • Write input files for various GK codes
  • Generate N-D pyro object for scans
  • Read in gyrokinetic outputs
  • Standardise analysis of gk outputs

At a minimum pyrokinetics needs the local geometry and species data. Example scripts can be found in the examples folder

Documentation

Documentation can be found at readthedocs.

Installation

Pyrokinetics requires a minimum Python version of 3.9. It may be necessary to upgrade pip to install:

$ pip install --upgrade pip

To install the latest release:

$ pip install pyrokinetics

Otherwise, to install from source:

$ git clone https://github.com/pyro-kinetics/pyrokinetics.git
$ cd pyrokinetics
$ pip install .

If you are planning on developing pyrokinetics use the following instead to install:

$ pip install -e .[docs,tests]

Note that currently the installation of pyrokinetics requires an available Fortran compiler

Testing

To run the tests:

$ pip install -e .[tests]
$ pytest --cov .

Basic Usage

The simplest action in Pyrokinetics is to convert a gyrokinetics input file for code 'X' into an equivalent input file for code 'Y'. The easiest way to achieve this is to use a Pyro object, which manages the various other classes in the API. For example, to convert a GS2 input file to a CGYRO input file:

>>> from pyrokinetics import Pyro
>>> pyro = Pyro(gk_file="my_gs2_file.in") # file type is automatically inferred
>>> pyro.write_gk_file("input.cgyro", gk_code="CGYRO")

There are many other features in Pyrokinetics, such as methods for building gyrokinetics input files using global plasma equilibria and/or kinetics profiles. There are also methods for analysing and comparing the results from gyrokinetics code runs. Please read the docs for more information.

Command Line Interface

After installing, simple pyrokinetics operations can be performed on the command line using either of the following methods:

$ python3 -m pyrokinetics {args...}
$ pyro {args...}

For example, to convert a GS2 input file to CGYRO:

$ pyro convert CGYRO "my_gs2_file.in" -o "input.cgyro"

You can get help on how to use the command line interface or any of its subcommands by providing -h or --help:

$ pyro --help
$ pyro convert --help

Docker

Pyrokinetics provides a Dockerfile from which you can build and run Docker containers. To do so, you must have Docker installed on your system. To build a local container:

$ docker build . -t pyrokinetics

It can then be run using:

$ docker run -it --rm -v ./path/to/local:/mymount pyrokinetics

where:

  • -it runs an interactive shell.
  • --rm deletes the Docker instance after use.
  • -v ./path/to/local:/mymount mounts the local directory ./path/to/local to the directory /mymount within the Docker container.

The container runs an IPython interpreter, with Pyrokinetics already installed. Note that you will need to import Pyrokinetics before it can be used.

Code structure

Pyro object comprised of

  • Equilibrium
    • LocalGeometry
      • Miller
      • Fourier (to be added)
  • Kinetics
    • LocalSpecies
  • Numerics
  • GKCodes
  • GKOutput
    • For nonlinear simulations
      • Fields (field, kx, ky, theta, time)
      • Fluxes (field, species, moment, ky, theta, time)
    • For linear simulations
      • Fields (field, kx, ky, theta, time)
      • Fluxes (field, species, moment, ky, theta, time)
      • Eigenfunctions (field, ky, theta, time)
      • Eigenvalues - growth rate and mode freq (ky, time)

There also exists the PyroScan object which allows you to make a N-D parameter scan of Pyro objects

Supports sources of Equilibrium data

pyrokinetics currently supports

Future formats to be added are

  • CHEASE

Supported sources of Kinetic data

Sources of kinetic profile data currently supported are

  • SCENE
  • JETTO
  • TRANSP
  • GACODE
  • PFILE
  • IMAS
  • ELITEINP

Future codes to be add

  • SimDB
  • OMFIT

Supported GK codes

The following gk codes are supported in pyrokinetics

  • CGYRO
  • GS2
  • GENE
  • TGLF
  • GKW
  • STELLA
  • GX

Note on units

The pyro object uses standardised reference values to normalise the results. It will automatically handle converting to a GK codes standard units.

Note any scans/parameter changes made will be in standard pyro units so please account for this.

Reference values

  • $T_{ref} = T_e$ Electron temperature at flux surface
  • $n_{ref} = n_e$ Electron density at flux surface
  • $m_{ref} = m_D$ Deuterium mass
  • $v_{ref} = c_s = \sqrt{T_e/m_D}$ Ion sound speed at flux surface
  • $B_{ref} = B_0$ Toroidal field at centre of the flux surface
  • $L_{ref} = a$ Minor radius of the last closed flux surface
  • $t_{ref} = a/c_s$ Ion sound time at flux surface
  • $\rho_{ref} = \frac{c_s}{eB_0/m_D}$ Ion Larmor radius at flux surface

It is possible to change the reference units but proceed with caution

Used By

This project is used by the following institutions

  • UKAEA
  • University of York

Copyright owned by UKAEA. Pyrokinetics is licensed under LGPL-3.0, and is free to use, modify, and distribute.

Metadata

Release files for pyrokinetics 0.9.1

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

Source distribution (sdist)

Source distribution for pyrokinetics 0.9.1
File Size Uploaded
pyrokinetics-0.9.1.tar.gz 17.6 MB Details

Built distribution (wheel)

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

Total release size: 30.5 MB

Release files / pyrokinetics-0.9.1.tar.gz

Download URL pyrokinetics-0.9.1.tar.gz
Size 17.6 MB
Tags Source
SHA-256 checksum
How to use checksums
745280799c6032c5c564d217d7df303071ef464bbeeb2e3b375757c3d1f77d37
BLAKE2b-256 checksum
How to use checksums
657d333c73f8f72cb51e78f44e3062e1610b2f382317c3cd8dc873928088ba79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 13, 2026.

Transparency log

Release files / pyrokinetics-0.9.1-py3-none-any.whl

Download URL pyrokinetics-0.9.1-py3-none-any.whl
Size 12.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
131b2b142fe63153345fcb3921f59e80fa6d09f20f670cd7f93fb2e177638996
BLAKE2b-256 checksum
How to use checksums
97f9b77310eb3b83af6106af79fe3b12c5cf27229a1971fd2236063615e6b997
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.9.1 This release

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.0.1

2 release files

0.0.0

2 release files

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