Pyrokinetics - A Python library to standardise gyrokinetic analysis

Pyrokinetics - A Python library to standardise gyrokinetic analysis - Published in JOSS (2024)

https://github.com/pyro-kinetics/pyrokinetics

Science Score: 100.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 4 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org
  • Committers with academic emails
    8 of 27 committers (29.6%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Scientific Fields

Mathematics Computer Science - 84% confidence
Last synced: 6 months ago · JSON representation ·

Repository

Python library to run and analyse gyrokinetics simulations

Basic Info
Statistics
  • Stars: 38
  • Watchers: 8
  • Forks: 7
  • Open Issues: 43
  • Releases: 9
Created almost 5 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog License Citation

README.md

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:

bash $ pip install --upgrade pip

To install the latest release:

bash $ pip install pyrokinetics

Otherwise, to install from source:

bash $ 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:

bash $ pip install -e .[docs,tests]

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

Testing

To run the tests:

bash $ 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:

```python

from pyrokinetics import Pyro pyro = Pyro(gkfile="mygs2file.in") # file type is automatically inferred pyro.writegkfile("input.cgyro", gkcode="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:

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

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

bash $ 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:

bash $ 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:

bash $ docker build . -t pyrokinetics

It can then be run using:

bash $ 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 * GEQDSK * TRANSP * GACODE * IMAS * ELITEINP

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} = Te$ Electron temperature at flux surface - $n{ref} = ne$ Electron density at flux surface - $m{ref} = mD$ Deuterium mass - $v{ref} = cs = \sqrt{Te/mD}$ Ion sound speed at flux surface - $B{ref} = B0$ Toroidal field at centre of the flux surface - $L{ref} = a$ Minor radius of the last closed flux surface - $t{ref} = a/cs$ Ion sound time at flux surface - $\rho{ref} = \frac{cs}{eB0/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.

Owner

  • Name: pyro-kinetics
  • Login: pyro-kinetics
  • Kind: organization
  • Email: Python library for gyrokinetic simulations

JOSS Publication

Pyrokinetics - A Python library to standardise gyrokinetic analysis
Published
March 06, 2024
Volume 9, Issue 95, Page 5866
Authors
Bhavin S. Patel ORCID
Culham Centre for Fusion Energy, Abingdon OX14 3DB, UK
Peter Hill ORCID
University of York, Heslington, Y010 5DD, UK
Liam Pattinson ORCID
University of York, Heslington, Y010 5DD, UK
Maurizio Giacomin ORCID
University of York, Heslington, Y010 5DD, UK, University of Padua, Padua, 35122, Italy
Arkaprava Bokshi ORCID
University of York, Heslington, Y010 5DD, UK
Daniel Kennedy ORCID
Culham Centre for Fusion Energy, Abingdon OX14 3DB, UK
Harry G. Dudding ORCID
Culham Centre for Fusion Energy, Abingdon OX14 3DB, UK
Jason. F. Parisi ORCID
Princeton Plasma Physics Laboratory, Princeton, NJ 08536, USA
Tom F. Neiser ORCID
General Atomics, San Diego, CA 92121, USA
Ajay C. Jayalekshmi ORCID
University of Warwick, Warwick, CV4 7AL, UK
David Dickinson ORCID
University of York, Heslington, Y010 5DD, UK
Juan Ruiz Ruiz ORCID
University of Oxford, Oxford OX1 3PU, UK
Editor
Kelly Rowland ORCID
Tags
gyrokinetics turbulence plasma tokamak fusion magnetic confinement

Citation (CITATION.cff)

cff-version: "1.2.0"
authors:
- family-names: Patel
  given-names: Bhavin S.
  orcid: "https://orcid.org/0000-0003-0121-1187"
- family-names: Hill
  given-names: Peter
  orcid: "https://orcid.org/0000-0003-3092-1858"
- family-names: Pattinson
  given-names: Liam
  orcid: "https://orcid.org/0000-0001-8604-6904"
- family-names: Giacomin
  given-names: Maurizio
  orcid: "https://orcid.org/0000-0003-2821-2008"
- family-names: Bokshi
  given-names: Arkaprava
  orcid: "https://orcid.org/0000-0001-7095-7172"
- family-names: Kennedy
  given-names: Daniel
  orcid: "https://orcid.org/0000-0001-7666-782X"
- family-names: Dudding
  given-names: Harry G.
  orcid: "https://orcid.org/0000-0002-3413-0861"
- family-names: Parisi
  given-names: Jason. F.
  orcid: "https://orcid.org/0000-0003-1328-7154"
- family-names: Neiser
  given-names: Tom F.
  orcid: "https://orcid.org/0000-0002-8763-3016"
- family-names: Jayalekshmi
  given-names: Ajay C.
  orcid: "https://orcid.org/0000-0002-6447-581X"
- family-names: Dickinson
  given-names: David
  orcid: "https://orcid.org/0000-0002-0868-211X"
- family-names: Ruiz
  given-names: Juan Ruiz
  orcid: "https://orcid.org/0000-0003-4258-5273"
contact:
- family-names: Patel
  given-names: Bhavin S.
  orcid: "https://orcid.org/0000-0003-0121-1187"
doi: 10.5281/zenodo.10472477
message: If you use this software, please cite our article in the
  Journal of Open Source Software.
preferred-citation:
  authors:
  - family-names: Patel
    given-names: Bhavin S.
    orcid: "https://orcid.org/0000-0003-0121-1187"
  - family-names: Hill
    given-names: Peter
    orcid: "https://orcid.org/0000-0003-3092-1858"
  - family-names: Pattinson
    given-names: Liam
    orcid: "https://orcid.org/0000-0001-8604-6904"
  - family-names: Giacomin
    given-names: Maurizio
    orcid: "https://orcid.org/0000-0003-2821-2008"
  - family-names: Bokshi
    given-names: Arkaprava
    orcid: "https://orcid.org/0000-0001-7095-7172"
  - family-names: Kennedy
    given-names: Daniel
    orcid: "https://orcid.org/0000-0001-7666-782X"
  - family-names: Dudding
    given-names: Harry G.
    orcid: "https://orcid.org/0000-0002-3413-0861"
  - family-names: Parisi
    given-names: Jason. F.
    orcid: "https://orcid.org/0000-0003-1328-7154"
  - family-names: Neiser
    given-names: Tom F.
    orcid: "https://orcid.org/0000-0002-8763-3016"
  - family-names: Jayalekshmi
    given-names: Ajay C.
    orcid: "https://orcid.org/0000-0002-6447-581X"
  - family-names: Dickinson
    given-names: David
    orcid: "https://orcid.org/0000-0002-0868-211X"
  - family-names: Ruiz
    given-names: Juan Ruiz
    orcid: "https://orcid.org/0000-0003-4258-5273"
  date-published: 2024-03-06
  doi: 10.21105/joss.05866
  issn: 2475-9066
  issue: 95
  journal: Journal of Open Source Software
  publisher:
    name: Open Journals
  start: 5866
  title: Pyrokinetics - A Python library to standardise gyrokinetic
    analysis
  type: article
  url: "https://joss.theoj.org/papers/10.21105/joss.05866"
  volume: 9
title: Pyrokinetics - A Python library to standardise gyrokinetic
  analysis

GitHub Events

Total
  • Fork event: 1
  • Create event: 51
  • Commit comment event: 6
  • Release event: 1
  • Issues event: 38
  • Watch event: 11
  • Delete event: 45
  • Member event: 3
  • Issue comment event: 137
  • Push event: 256
  • Pull request review event: 111
  • Pull request review comment event: 72
  • Pull request event: 84
Last Year
  • Fork event: 1
  • Create event: 51
  • Commit comment event: 6
  • Release event: 1
  • Issues event: 38
  • Watch event: 11
  • Delete event: 45
  • Member event: 3
  • Issue comment event: 137
  • Push event: 256
  • Pull request review event: 111
  • Pull request review comment event: 72
  • Pull request event: 84

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 2,234
  • Total Committers: 27
  • Avg Commits per committer: 82.741
  • Development Distribution Score (DDS): 0.392
Past Year
  • Commits: 334
  • Committers: 11
  • Avg Commits per committer: 30.364
  • Development Distribution Score (DDS): 0.329
Top Committers
Name Email Commits
Bhavin Patel 1****7 1,359
Liam Pattinson l****n@g****m 264
Peter Hill p****l@y****k 206
Arkaprava Bokshi a****i@y****k 71
Maurizio Giacomin m****n@y****k 59
physycola t****1@g****m 57
Daniel Kennedy d****y@u****k 38
David Dickinson d****9 36
Harry Dudding h****1@y****k 24
mgiacomin m****n 20
Michael Hardman m****n@p****k 17
jfparisi j****i@p****v 14
David Dickinson d****n@y****k 12
juanruiz 1****z 11
Michael Hardman m****n@t****k 9
Francis Casson f****n@u****k 8
Ajay Chandrarajan Jayalekshmi p****b@k****k 8
Bhavin Patel b****l@u****k 7
Tom Neiser n****t@f****m 5
Bhavin Patel b****0@r****t 2
whornsby82 w****2 1
Bhavin Patel b****l@y****k 1
Juan Ruiz Ruiz j****u@f****l 1
William Hornsby i****2@l****r 1
Riju Dutta r****1@g****m 1
Lexi Masters 1****I 1
Bhavin2107 1****7 1

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 123
  • Total pull requests: 344
  • Average time to close issues: 4 months
  • Average time to close pull requests: 16 days
  • Total issue authors: 26
  • Total pull request authors: 17
  • Average comments per issue: 2.43
  • Average comments per pull request: 2.78
  • Merged pull requests: 295
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 26
  • Pull requests: 112
  • Average time to close issues: 19 days
  • Average time to close pull requests: 9 days
  • Issue authors: 11
  • Pull request authors: 8
  • Average comments per issue: 1.85
  • Average comments per pull request: 1.66
  • Merged pull requests: 91
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • bpatel2107 (32)
  • d7919 (17)
  • LiamPattinson (9)
  • ZedThree (7)
  • juanruizruiz (7)
  • arkabokshi (7)
  • whornsby82 (5)
  • physycola (5)
  • jmcclena (4)
  • mrhardman (4)
  • venkiteshayyar (3)
  • jfparisi (3)
  • mgiacomin (3)
  • mehfoos (3)
  • theo-brown (2)
Pull Request Authors
  • bpatel2107 (194)
  • LiamPattinson (41)
  • physycola (21)
  • d7919 (20)
  • arkabokshi (19)
  • ZedThree (15)
  • mgiacomin (10)
  • fcasson (5)
  • juanruizruiz (4)
  • dake0795 (3)
  • mrhardman (2)
  • hgd511 (2)
  • whornsby82 (2)
  • tomneiser (2)
  • rijudutta (2)
Top Labels
Issue Labels
enhancement (17) bug (6) documentation (2) release (2) help wanted (1) good first issue (1)
Pull Request Labels
enhancement (8) work in progress (4) bug (3) documentation (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 1,879 last-month
  • Total dependent packages: 1
  • Total dependent repositories: 1
  • Total versions: 11
  • Total maintainers: 1
pypi.org: pyrokinetics

Python package for running and analysing gyrokinetic simulations

  • Documentation: https://pyrokinetics.readthedocs.io/en/latest/
  • License: GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
  • Latest release: 0.8.0
    published 8 months ago
  • Versions: 11
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 1,879 Last month
Rankings
Dependent packages count: 7.4%
Forks count: 13.4%
Stargazers count: 13.4%
Average: 14.8%
Downloads: 17.8%
Dependent repos count: 22.2%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/black.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • stefanzweifel/git-auto-commit-action v4 composite
.github/workflows/flake8.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • suo/flake8-github-action releases/v1 composite
.github/workflows/python_publish.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/tests.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
pyproject.toml pypi
  • cleverdict >= 1.9.1
  • contourpy ~= 1.0
  • f90nml >= 1.4.2
  • freeqdsk == 0.1.*
  • h5py >= 2.10
  • matplotlib >= 3.6
  • netCDF4 >= 1.5.6
  • numpy >= 1.20.3
  • path >= 15.1.2
  • pint ~= 0.20.1
  • pint-xarray ~= 0.3
  • scipy >= 1.9.3
  • wheel >= 0.36
  • xarray >= 0.10
.github/workflows/docker_publish.yml actions
  • actions/checkout v4 composite
  • docker/build-push-action v4 composite
  • docker/login-action v2 composite
  • docker/metadata-action v4 composite
Dockerfile docker
  • python 3.11 build
.github/workflows/draft-pdf.yml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v1 composite
  • openjournals/openjournals-draft-action master composite