# The GS2 Algorithm

**GS2 was the first nonlinear gyrokinetic code for plasma turbulence that could handle fully electromagnetic fluctuations with fully kinetic electrons in general non-circular tokamak geometry using an efficient local flux-tube simulation domain**, and has a comprehensive treatment of all of the effects thought to be most important for turbulence in the main core region of tokamaks, including multiple species, collisions, and sheared flows.

**GS2 uses continuum or Eulerian algorithms** (a combination of spectral methods and grids in the 5-D phase space of gyrokinetics) and so is different from PIC codes (which are a kind of Lagrangian / Monte-Carlo approach). It uses a fully implicit treatment for all of the linear terms, a pseudo-spectral method for evaluation of nonlinear terms, and efficient field-line-following coordinates in a local flux-tube simulation domain (or equivalently, an annular, toroidal wedge).

**The key implicit algorithm** is described in Mike Kotschenreuther's paper "Comparison of Initial Value and Eigenvalue Codes for Kinetic Toroidal Plasma Instabilities," M. Kotschenreuther, G. Rewoldt, and W.M. Tang, Comp. Phys. Comm. 88, 128 (1995). See also an errata. There is a more pedagogical explanation of some of the key ideas and tricks in this implicit algorithm in Emily Belli's 2006 Princeton Ph.D. Dissertation "Studies of Numerical Algorithms for Gyrokinetics and the Effects of Shaping on Plasma Turbulence". Kotschenreuther also introduced the usage of Gaussian integration techniques,
in which an n-point velocity-space integral is done with $ {O}(\Delta v)^{2N} $ $ \sim $ $ {O}(1/N^N) $ super-exponential accuracy (asymptotically for adequately-resolved smooth solutions). Bill Dorland worked on the nonlinear extension of the initial linear code, using pseudo-spectral methods similar to those used in earlier gyrofluid turbulence simulations by Dorland, Mike Beer, and Greg Hammett.

Notes on Kotschenreuther's trick that speeds up the implicit inversion by a factor of $ \sim 10^4 $, and other scattered notes on the algorithms and some input parameters.

A nice and comprehensive description of the algorithms used in AstroGK is given in this paper by R. Numata *et al.*. The algorithms for AstroGK will be mostly identical to those found in GS2, with the exception of the lambda (or pitch-angle) grid. AstroGK does not treat situations with trapped particles, so it has no need to split the lambda grid into 'trapped' and 'untrapped' regions, as GS2 does (see M. Kotschenreuther's CPC paper linked above for a description of how GS2 handles trapped particles).

**A full description of the GS2 equations, normalisations and algorithms** is given in Chapters 3 and 4 of this thesis.

To Do:

Other notes from http://w3.pppl.gov/~hammett/work/gs2 could be transferred to somewhere on this wiki.

Could add a page on aspects of the treatment of trapped particles.