pyoculus.toybox.cylindrical_toybox
This module provides functions to calculate equilibrium and perturbation fields in cylindrical coordinates.
The fields are calculated from the vector potential \(A\) as \(B = \nabla \times A\).
- authors:
Ludovic Rais (ludovic.rais@epfl.ch)
Functions
|
Contravariant component of the vector potential \(A\) for the circular current loop perturbation. |
|
Holonomous component of the vector potential \(A\) for the Gaussian distributed perturbation. |
|
Holonomous component of the vector potential \(A\) for the Maxwell-Boltzmann distributed perturbation. |
|
Vector potential \(A_r\) component (giving the poloidal flux \(F\)) for the squared circle equilibrium field. |
|
Holonomous component of the vector potential \(A\) for the squared circle equilibrium field. |
|
Complete elliptic integral of the second kind. |
|
Complete elliptic integral of the first kind. |
|
\(\psi\) flux function generated at \((r, \phi, z)\) by a circular current loop located at position \((R, Z)\). |
|
Gaussian distributed \(\psi\) flux function. |
|
Maxwell-Boltzmann distributed \(\psi\) flux function. |
|
\(\psi\) flux function for the squared circle equilibrium field. |
|
Decorator to calculate the contribution of a \(\psi\) function to a \(B\) field using the relation \(B = \nabla \times A\), with \(A_\phi \textbf{e}_\phi = \psi / r \textbf{e}_\phi\), where \(g(\textbf{e}_\phi, \textbf{e}_\phi) = 1\). |
|
Decorator that calculate the curl in cylindrical coordinates, useful to get the \(B\) field from a vector potential \(A\) using the relation \(B = \nabla \times A\). |
- pyoculus.toybox.cylindrical_toybox.psitob(f)
Decorator to calculate the contribution of a \(\psi\) function to a \(B\) field using the relation \(B = \nabla \times A\), with \(A_\phi \textbf{e}_\phi = \psi / r \textbf{e}_\phi\), where \(g(\textbf{e}_\phi, \textbf{e}_\phi) = 1\).
- Parameters:
f (function) – Function that returns the \(\psi\) field. The function must take the position vector \(\textbf{r}\) as first argument.
- Returns:
Function that returns the \(B\) field.
- Return type:
function
- pyoculus.toybox.cylindrical_toybox.rot(f, from_holonomous=True)
Decorator that calculate the curl in cylindrical coordinates, useful to get the \(B\) field from a vector potential \(A\) using the relation \(B = \nabla \times A\).
- Parameters:
f (function) – Function that returns the vector potential \(A\) field. The function must take the position vector \(\textbf{r}\) as first argument.
from_holonomous (bool) – If True, the input of the function is in holonomous coordinates \(\{\partial_r, \partial_\phi, \partial_z\}\). If False, the input is in non-holonomous coordinates \(\{\textbf{e}_r, \textbf{e}_\phi, \textbf{e}_z\}\).
- Returns:
Function that returns the \(B\) field.
- Return type:
function
- pyoculus.toybox.cylindrical_toybox.psi_squared(rr: array, R: float, Z: float) float64
\(\psi\) flux function for the squared circle equilibrium field. The squared circle equilibrium field is defined as:
\[\psi(r, z) = (r - R)^2 + (z - Z)^2.\]- Parameters:
rr (array) – Position vector in cylindrical coordinates.
R (float) – R coordinate of the center of the squared circle.
Z (float) – Z coordinate of the center of the squared circle.
- Returns:
\(\psi\) flux at position rr.
- Return type:
float
- pyoculus.toybox.cylindrical_toybox.A_r_squared(rr: array, R: float, Z: float, sf: float, shear: float) float64
Vector potential \(A_r\) component (giving the poloidal flux \(F\)) for the squared circle equilibrium field. Using it with the
psi_squaredfunction makes sense ofsfandshearas the \(q\)-factor profile becomes:\[q(r, z) = sf + shear / 2 * ((r - R)^2 + (z - Z)^2).\]- Parameters:
rr (array) – Position vector in cylindrical coordinates.
R (float) – R coordinate of the center of the squared circle.
Z (float) – Z coordinate of the center of the squared circle.
sf (float) – Safety factor at \(\rho = 0\).
shear (float) – Shear of the \(q\)-profile.
- Returns:
\(A_r\) component at position rr.
- Return type:
float
- pyoculus.toybox.cylindrical_toybox.A_squared(rr: array, R: float, Z: float, sf: float, shear: float) Array
Holonomous component of the vector potential \(A\) for the squared circle equilibrium field.
- Parameters:
rr (array) – Position vector in cylindrical coordinates.
R (float) – R coordinate of the center of the squared circle.
Z (float) – Z coordinate of the center of the squared circle.
sf (float) – Safety factor at \(\rho = 0\).
shear (float) – Shear of the \(q\)-profile.
- Returns:
\(A\) field at position rr.
- Return type:
array
- pyoculus.toybox.cylindrical_toybox.psi_maxwellboltzmann(rr: array, R: float, Z: float, d: float, m: int, n: int, phase_poloidal: float = 0.0, phase_toroidal: float = 0.0, A: float = 1.0, B: float = 1.0) float64
Maxwell-Boltzmann distributed \(\psi\) flux function.
- Parameters:
rr (array) – Position vector in cylindrical coordinates.
R (float) – R coordinate of the center of the Maxwell-Boltzmann distribution.
Z (float) – Z coordinate of the center of the Maxwell-Boltzmann distribution.
d (float) – Standard deviation of the Maxwell-Boltzmann distribution.
m (int) – Poloidal mode number.
n (int) – Toroidal mode number.
phase_poloidal (float) – Poloidal phase of the perturbation.
phase_toroidal (float) – Toroidal phase of the perturbation.
A (float) – Scaling factor for the R coordinate.
B (float) – Scaling factor for the Z coordinate.
- Returns:
\(\psi\) flux at position rr.
- Return type:
float
- pyoculus.toybox.cylindrical_toybox.A_maxwellboltzmann(rr: array, R: float, Z: float, d: float, m: int, n: int, phase_poloidal: float = 0.0, phase_toroidal: float = 0.0, A: float = 1.0, B: float = 1.0) Array
Holonomous component of the vector potential \(A\) for the Maxwell-Boltzmann distributed perturbation.
- Parameters:
rr (array) – Position vector in cylindrical coordinates.
R (float) – R coordinate of the center of the Maxwell-Boltzmann distribution.
Z (float) – Z coordinate of the center of the Maxwell-Boltzmann distribution.
d (float) – Standard deviation of the Maxwell-Boltzmann distribution.
m (int) – Poloidal mode number.
n (int) – Toroidal mode number.
phase_poloidal (float) – Poloidal phase of the perturbation.
phase_toroidal (float) – Toroidal phase of the perturbation.
A (float) – Scaling factor for the R coordinate.
B (float) – Scaling factor for the Z coordinate.
- Returns:
\(A\) field at position rr.
- Return type:
array
- pyoculus.toybox.cylindrical_toybox.psi_gaussian(rr: array, R: float, Z: float, mu: float, sigma: float, m: int, n: int, phase_poloidal: float = 0.0, phase_toroidal: float = 0.0, A: float = 1.0, B: float = 1.0) float64
Gaussian distributed \(\psi\) flux function.
- Parameters:
rr (array) – Position vector in cylindrical coordinates.
R (float) – R coordinate of the center of the Gaussian distribution.
Z (float) – Z coordinate of the center of the Gaussian distribution.
mu (float) – Mean of the Gaussian distribution.
sigma (float) – Standard deviation of the Gaussian distribution.
m (int) – Poloidal mode number.
n (int) – Toroidal mode number.
phase_poloidal (float) – Poloidal phase of the perturbation.
phase_toroidal (float) – Toroidal phase of the perturbation.
A (float) – Scaling factor for the R coordinate.
B (float) – Scaling factor for the Z coordinate.
- Returns:
\(\psi\) flux at position rr.
- Return type:
float
- pyoculus.toybox.cylindrical_toybox.A_gaussian(rr: array, R: float, Z: float, mu: float, sigma: float, m: int, n: int, phase_poloidal: float = 0.0, phase_toroidal: float = 0.0, A: float = 1.0, B: float = 1.0) Array
Holonomous component of the vector potential \(A\) for the Gaussian distributed perturbation.
- Parameters:
rr (array) – Position vector in cylindrical coordinates.
R (float) – R coordinate of the center of the Gaussian distribution.
Z (float) – Z coordinate of the center of the Gaussian distribution.
mu (float) – Mean of the Gaussian distribution.
sigma (float) – Standard deviation of the Gaussian distribution.
m (int) – Poloidal mode number.
n (int) – Toroidal mode number.
phase_poloidal (float) – Poloidal phase of the perturbation.
phase_toroidal (float) – Toroidal phase of the perturbation.
A (float) – Scaling factor for the R coordinate.
B (float) – Scaling factor for the Z coordinate.
- Returns:
\(A\) field at position rr.
- Return type:
array
- pyoculus.toybox.cylindrical_toybox.ellpe(m)
Complete elliptic integral of the second kind.
- pyoculus.toybox.cylindrical_toybox.ellpk(m)
Complete elliptic integral of the first kind.
- pyoculus.toybox.cylindrical_toybox.psi_circularcurrentloop(rr: array, R: float, Z: float) float64
\(\psi\) flux function generated at \((r, \phi, z)\) by a circular current loop located at position \((R, Z)\).
- Parameters:
rr (array) – Position vector in cylindrical coordinates.
R (float) – R coordinate of the center of the circular current loop.
Z (float) – Z coordinate of the center of the circular current loop.
- Returns:
\(\psi\) flux at position rr.
- Return type:
float
- pyoculus.toybox.cylindrical_toybox.A_circularcurrentloop(rr: array, R: float, Z: float) Array
Contravariant component of the vector potential \(A\) for the circular current loop perturbation.
- Parameters:
rr (array) – Position vector in cylindrical coordinates.
R (float) – R coordinate of the center of the circular current loop.
Z (float) – Z coordinate of the center of the circular current loop.
- Returns:
\(A\) field at position rr.
- Return type:
array