WallGo.grid

Class for computing and storing the coordinates on the grid and other related quantities.

Classes

Grid(M, N, positionFalloff, momentumFalloffT)

Computes the grid on which the Boltzmann equation is solved.

class Grid(M, N, positionFalloff, momentumFalloffT, spacing='Spectral')[source]

Computes the grid on which the Boltzmann equation is solved.

Grid is 3d, and consists of the physical coordinates:

  • \(\xi\), position perpendicular to the wall,

  • \(p_z\), momentum perpendicular to the wall,

  • \(p_\Vert\), momentum magnitude parallel to the wall.

In addition there are the corresponding compactified coordinates on the interval [-1, 1],

\[\chi \equiv \frac{\xi}{\sqrt{\xi^2 + L_{\xi}^2}}, \qquad \rho_{z} \equiv \tanh\left(\frac{p_z}{2 T_0}\right), \qquad \rho_{\Vert} \equiv 1 - 2 e^{-p_\Vert/T_0}.\]

All coordinates are in the wall frame.

chiValues

Grid of the \(\chi\) direction.

Type:

array_like

rzValues

Grid of the \(\rho_z\) direction.

Type:

array_like

rpValues

Grid of the \(\rho_\Vert\) direction.

Type:

array_like

xiValues

Grid of the \(\xi\) direction.

Type:

array_like

pzValues

Grid of the \(p_z\) direction.

Type:

array_like

ppValues

Grid of the \(p_\Vert\) direction.

Type:

array_like

Initialises Grid object.

Compactified coordinates are chosen according to

\[\chi = -\cos\left(\frac{\pi \alpha}{M}\right), \qquad \rho_{z} = -\cos\left(\frac{\pi \beta}{N}\right), \qquad \rho_{\Vert} = -\cos\left(\frac{\pi \gamma}{N-1}\right),\]

with integers \(\alpha, \beta, \gamma\) taken over

\[\alpha = 0, 1, \dots, M, \qquad \beta = 0, 1, \dots, N, \qquad \gamma = 0, 1, \dots, N-1.\]

These are the Gauss-Lobatto collocation points, here with all boundary points included.

The boundary points \(\chi=\pm 1\), \(\rho_z=\pm 1\) and \(\rho_{\Vert}=1\) correspond to points at infinity. The deviation from equilibrium is assumed to equal zero at infinity, so these points are dropped when solving the Boltzmann equations. The resulting grid is

\[\alpha = 1, 2, \dots, M-1, \qquad \beta = 1, 2, \dots, N-1, \qquad \gamma = 0, 1, \dots, N-2.\]
Parameters:
  • M (int) – Number of basis functions in the \(\xi\) (and \(\chi\)) direction.

  • N (int) – Number of basis functions in the \(p_z\) and \(p_\Vert\) (and \(\rho_z\) and \(\rho_\Vert\)) directions.

  • positionFalloff (float) – Length scale determining transform in \(\xi\) direction. Should be expressed in physical units (the units used in EffectivePotential).

  • momentumFalloffT (float) – Temperature scale determining transform in momentum directions. Should be close to the plasma temperature.

  • spacing ({'Spectral', 'Uniform'}) – Choose ‘Spectral’ for the Gauss-Lobatto collocation points, as required for WallGo’s spectral representation, or ‘Uniform’ for a uniform grid. Default is ‘Spectral’.

changeMomentumFalloffScale(newScale)[source]

Change the momentum falloff scale.

Parameters:

newScale (float) – New momentum falloff scale.

Return type:

None

changePositionFalloffScale(newScale)[source]

Change the position falloff scale.

Parameters:

newScale (float) – New position falloff scale.

Return type:

None

compactificationDerivatives(zCompact, pzCompact, ppCompact)[source]

Derivative \(d(X)/d(X_\text{compact})\) of coordinate transforms to [-1, 1] interval.

Parameters:
  • z_compact (array-like) – Compact z coordinate (chi).

  • pz_compact (array-like) – Compact pz coordinate (rho_z).

  • pp_compact (array-like) – Compact p_par coordinate (rho_par).

  • zCompact (ndarray)

  • pzCompact (ndarray)

  • ppCompact (ndarray)

Returns:

  • dzdzCompact (array-like) – Derivative d(z)/d(chi).

  • dpzdpzCompact (array-like) – PDerivative d(p_z)/d(rho_z).

  • dppdppCompact (array-like) – Derivative d(p_par)/d(rho_par).

Return type:

tuple[ndarray, …]

compactify(z, pz, pp)[source]

Transforms coordinates to [-1, 1] interval

Parameters:
  • z (array-like) – Physical z (or xi) coordinate.

  • pz (array-like) – Physical pz coordinate.

  • pp (array-like) – Physical p_par coordinate.

Returns:

  • z_compact (array-like) – Compact z coordinate (chi).

  • pz_compact (array-like) – Compact pz coordinate (rho_z).

  • pp_compact (array-like) – Compact p_par coordinate (rho_par).

Return type:

tuple[ndarray, …]

decompactify(zCompact, pzCompact, ppCompact)[source]

Transforms coordinates to [-1, 1] interval

Parameters:
  • z_compact (array-like) – Compact z coordinate (chi).

  • pz_compact (array-like) – Compact pz coordinate (rho_z).

  • pp_compact (array-like) – Compact p_par coordinate (rho_par).

  • zCompact (ndarray)

  • pzCompact (ndarray)

  • ppCompact (ndarray)

Returns:

  • z (array-like) – Physical z (or xi) coordinate.

  • pz (array-like) – Physical pz coordinate.

  • pp (array-like) – Physical p_par coordinate.

Return type:

tuple[ndarray, …]

getCompactCoordinates(endpoints=False, direction=None)[source]

Return compact coordinates of grid.

Parameters:
  • endpoints (Bool, optional) – If True, include endpoints of grid. Default is False.

  • direction (string or None, optional) – Specifies which coordinates to return. Can either be ‘z’, ‘pz’, ‘pp’ or None. If None, returns a tuple containing the 3 directions. Default is None.

Returns:

  • chiValues (array_like) – Grid of the \(\chi\) direction.

  • rzValues (array_like) – Grid of the \(\rho_z\) direction.

  • rpValues (array_like) – Grid of the \(\rho_\Vert\) direction.

Return type:

tuple[ndarray, …] | ndarray

getCompactificationDerivatives(endpoints=False)[source]

Return derivatives of compactified coordinates of grid, with respect to uncompactified derivatives.

Parameters:

endpoints (Bool, optional) – If True, include endpoints of grid. Default is False.

Returns:

  • dchiValues (array_like) – Grid of the \(\partial_\xi\chi\) direction.

  • drzValues (array_like) – Grid of the \(\partial_{p_z}\rho_z\) direction.

  • drpValues (array_like) – Grid of the \(\partial_{p_\Vert}\rho_\Vert\) direction.

Return type:

tuple[ndarray, …]

getCoordinates(endpoints=False)[source]

Return coordinates of grid, not compactified.

Parameters:

endpoints (Bool, optional) – If True, include endpoints of grid. Default is False.

Returns:

  • xiValues (array_like) – Grid of the \(\xi\) direction.

  • pzValues (array_like) – Grid of the \(p_z\) direction.

  • ppValues (array_like) – Grid of the \(p_\Vert\) direction.

Return type:

tuple[ndarray, …]