WallGo.grid3Scales.Grid3Scales
- class Grid3Scales(M, N, tailLengthInside, tailLengthOutside, wallThickness, momentumFalloffT, ratioPointsWall=0.5, smoothing=0.1, wallCenter=0, spacing='Spectral')[source]
Bases:
GridRedefinition of the Grid class to take into account the different scales present in the z direction. More specifically, the \(z\) mapping function should scale as
\[\begin{split}z(\chi \to -1) &= \lambda_- \log(1+\chi),\\ z(\chi \to 1) &= -\lambda_+ \log(1-\chi),\end{split}\]where \(\lambda_-\) and \(\lambda_+\) are the lengths of the solution’s tails inside and outside the bubble, respectively. Furthermore, the mapping should be approximately linear in the region \(-r<\chi<r\), where \(r\) is roughly the ratio of points that are used to resolve the wall’s interior. The slope in that region should be \(L/r\), where \(L\) is the wall thickness, so that
\[z'(\chi) \approx \frac{L}{r}, \quad \chi \in [-r, r].\]It is easier to find the derivative of a function that has these properties, and then integrate it. We choose here
\[z'(\chi)=\frac{f(\chi)}{1-\chi^2},\]where \(f(\chi)\) is a smoothed step function equal to
\[\begin{split}f(\chi) \approx \begin{cases} 2\lambda_-,& \chi<-r,\\ L/r,& -r<\chi<r,\\ 2\lambda_+,& \chi>r. \end{cases}\end{split}\]We choose \(f(\chi)\) to be a sum of functions like \(\frac{\chi-\chi_0}{\sqrt{a^2+(\chi-\chi_0)^2}}\), which allows us to find analytically the mapping function with
\[z(\chi) - z(\chi_0) =\int^\chi_{\chi_0} \frac{f(\chi')}{1-\chi'^2} d\chi'.\]The parameter \(a\) can be adjusted to control the smoothness of the mapping function.
- 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.
tailLengthInside (float) – Decay length of the solution’s tail inside the wall. Should be larger than wallThickness*(1/2+smoothing)/ratioPointsWall. Should be expressed in physical units (the units used in EffectivePotential).
tailLengthOutside (float) – Decay length of the solution’s tail outside the wall. Should be larger than wallThickness*(1/2+smoothing)/ratioPointsWall. Should be expressed in physical units (the units used in EffectivePotential).
wallThickness (float) – Thickness of the wall. 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.
ratioPointsWall (float, optional) – Ratio of grid points inside the wall. The remaining points are distributed equally between the 2 tails. The default is 0.5.
smoothing (float, optional) – Controls the smoothness of the mapping function. Its first derivative becomes discontinuous at \(\chi=\pm r\) when smoothness is 0. Should be smaller than 1, otherwise the function would not be linear at \(\chi=0\) anymore. As explained above, the decay length is controlled by adding 2 smoothed step functions. ‘smoothing’ is the value of these functions at the origin, in units of \(L/r\). The default is 0.1.
wallCenter (float, optional) – Position of the wall’s center (in the z coordinates). Default is 0.
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’.
- Return type:
None.
- __init__(M, N, tailLengthInside, tailLengthOutside, wallThickness, momentumFalloffT, ratioPointsWall=0.5, smoothing=0.1, wallCenter=0, spacing='Spectral')[source]
- 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.
tailLengthInside (float) – Decay length of the solution’s tail inside the wall. Should be larger than wallThickness*(1/2+smoothing)/ratioPointsWall. Should be expressed in physical units (the units used in EffectivePotential).
tailLengthOutside (float) – Decay length of the solution’s tail outside the wall. Should be larger than wallThickness*(1/2+smoothing)/ratioPointsWall. Should be expressed in physical units (the units used in EffectivePotential).
wallThickness (float) – Thickness of the wall. 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.
ratioPointsWall (float, optional) – Ratio of grid points inside the wall. The remaining points are distributed equally between the 2 tails. The default is 0.5.
smoothing (float, optional) – Controls the smoothness of the mapping function. Its first derivative becomes discontinuous at \(\chi=\pm r\) when smoothness is 0. Should be smaller than 1, otherwise the function would not be linear at \(\chi=0\) anymore. As explained above, the decay length is controlled by adding 2 smoothed step functions. ‘smoothing’ is the value of these functions at the origin, in units of \(L/r\). The default is 0.1.
wallCenter (float, optional) – Position of the wall’s center (in the z coordinates). Default is 0.
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’.
- Return type:
None.
Methods
__init__(M, N, tailLengthInside, ...[, ...])changeMomentumFalloffScale(newScale)Change the momentum falloff scale.
changePositionFalloffScale(tailLengthInside, ...)Change the position falloff scale.
compactificationDerivatives(zCompact, ...)Derivative of transforms coordinates to [-1, 1] interval
compactify(z, pz, pp)Transforms coordinates to [-1, 1] interval
decompactify(zCompact, pzCompact, ppCompact)Transforms coordinates from [-1, 1] interval (inverse of compactify).
getCompactCoordinates([endpoints, direction])Return compact coordinates of grid.
getCompactificationDerivatives([endpoints])Return derivatives of compactified coordinates of grid, with respect to uncompactified derivatives.
getCoordinates([endpoints])Return coordinates of grid, not compactified.
- changeMomentumFalloffScale(newScale)
Change the momentum falloff scale.
- Parameters:
newScale (float) – New momentum falloff scale.
- Return type:
None
- changePositionFalloffScale(tailLengthInside, tailLengthOutside, wallThickness, wallCenter)[source]
Change the position falloff scale.
- Parameters:
newScale (float) – New position falloff scale.
tailLengthInside (float)
tailLengthOutside (float)
wallThickness (float)
wallCenter (float)
- Return type:
None
- compactificationDerivatives(zCompact, pzCompact, ppCompact)[source]
Derivative of transforms coordinates to [-1, 1] interval
- Parameters:
zCompact (ndarray)
pzCompact (ndarray)
ppCompact (ndarray)
- Return type:
tuple[ndarray, …]
- compactify(z, pz, pp)
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 from [-1, 1] interval (inverse of compactify).
- Parameters:
zCompact (ndarray)
pzCompact (ndarray)
ppCompact (ndarray)
- Return type:
tuple[ndarray, …]
- getCompactCoordinates(endpoints=False, direction=None)
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)
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)
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, …]