gbspy.grid module

Module to generate a flux-aligned grid

gbspy.grid.build_grid(s, rmin, rmax, Nchi=200)

Returns the variables Xpsi, Ypsi that contain the flux-aligned grid

Parameters
  • s (gbspy.pp.Sim) – Simulation object

  • rmin (float) – Initial normalized radius of the grid

  • rmax (float) – Final normalized radius of the grid

  • Nchi (int, optional) – Number of points along chi

Returns

  • Xpsi (np.ndarray) – X-coordinate of the new grid as a 2D array

  • Ypsi (np.ndarray) – Y-coordinate of the new grif as a 2D array

  • rpsi (np.ndarray) – Radial position of the flux surfaces as a 1D array

  • chi (np.ndarray) – Coordinate along a flux surface as a 2D array

Examples

Interpolate the density defined on the meshgrid X, Y into a new grid Xnew, Ynew generated by build_grid:

>>> import numpy as np
>>> from scipy.interpolate import griddata
>>> import gbspy as g
>>> s = g.Sim()
>>> n = s.get_field('n')
>>> Xnew, Ynew, _, _ = g.build_grid(s, 0.4, 1)
>>> X, Y = np.meshgrid(s.x, s.y)
>>> nnew = griddata((X.ravel(), Y.ravel()),
...                 n[:,:,0,0].ravel(), (Xnew, Ynew))