eqtools: Modular, extensible, open-source, cross-machine Python tools for working with magnetic equilibria

Abstract As plasma physics research for fusion energy transitions to an increasing emphasis on cross-machine collaboration and numerical simulation, it becomes increasingly important that portable tools be developed to enable data from diverse sources to be analyzed in a consistent manner. This paper presents eqtools , a modular, extensible, open-source toolkit implemented in the Python programming language for handling magnetic equilibria and associated data from tokamaks. eqtools provides a single interface for working with magnetic equilibrium data, both for handling derived quantities and mapping between coordinate systems, extensible to function with data from different experiments, data formats, and magnetic reconstruction codes, replacing the diverse, non-portable solutions currently in use. Moreover, while the open-source Python programming language offers a number of advantages as a scripting language for research purposes, the lack of basic tokamak-specific functionality has impeded the adoption of the language for regular use. Implementing equilibrium-mapping tools in Python removes a substantial barrier to new development in and porting legacy code into Python. In this paper, we introduce the design of the eqtools package and detail the workflow for usage and expansion to additional devices. The implementation of a novel three-dimensional spline solution (in two spatial dimensions and in time) is also detailed. Finally, verification and benchmarking for accuracy and speed against existing tools are detailed. Wider deployment of these tools will enable efficient sharing of data and software between institutions and machines as well as self-consistent analysis of the shared data. Program summary Program title: eqtools Catalogue identifier: AFBK_v1_0 Program summary URL: http://cpc.cs.qub.ac.uk/summaries/AFBK_v1_0.html Program obtainable from: CPC Program Library, Queen’s University, Belfast, N. Ireland Licensing provisions: GNU GPL v3 No. of lines in distributed program, including test data, etc.: 27204 No. of bytes in distributed program, including test data, etc.: 1217844 Distribution format: tar.gz Programming language: Python, C. Computer: PCs. Operating system: Linux, Macintosh OS X, Microsoft Windows. RAM: Several megabytes, depends on resolution of data Classification: 19.4. External routines: F2PY [1], matplotlib [2], MDSplus [3], NumPy [4], SciPy [5] Nature of problem: Access to results from magnetic equilibrium reconstruction code, conversion between various coordinate systems tied to the magnetic equilibrium. Solution method: Data are stored in an object-oriented data structure with human-readable getter methods. Coordinates are converted using bivariate or trivariate splines. Running time: Coordinate transformations on a 66x66 point spatial grid take between 1 and 5 ms per time slice, depending on the transformation used and how many intermediate results have been stored. References: [1] P. Peterson, F2PY: a tool for connecting Fortran and Python programs, International Journal of Computational Science and Engineering 4 (4) (2009) 296–305. [2] J. D. Hunter, Matplotlib: A 2D graphics environment, Computing in Science and Engineering, 9 (3) (2007) 90–95. [3] J. A. Stillerman, T. W. Fredian, K. A. Klare, G. Manduchi, MDSplus data acquisition system, Review of Scientific Instruments 68 (1) (1997) 939–942. [4] S. van der Walt, S. C. Colbert and G. Varoquaux, The NumPy array: a structure for efficient numerical computation, Computing in Science and Engineering 13 (2) (2011) 22–30. [5] E. Jones, T. Oliphant, P Peterson, et al., SciPy: Open source scientific tools for Python (2001-).