pyoculus.utils.cyl_cart_transform

This module provides functions to transform vectors and matrices between cylindrical and cartesian coordinates.

authors:

Functions

dinvJ_matrix(vec, r, phi, z)

Computes the matrix due to the evolution of the basis in cylindrical coordinates.

mat_cart2cyl(mat, r, phi, z)

Transforms a matrix \(A\) from cartesian coordinates to cylindrical coordinates at \((r, \phi, z)\).

mat_cyl2cart(mat, x, y, z)

Transforms a matrix \(A\) from cylindrical coordinates to cartesian coordinates at \((x, y, z)\).

njit(func)

rphiz(x, y, z)

Transforms cartesian coordinates \((x, y, z)\) to cylindrical coordinates \((r, \phi, z)\).

rphiz_inv_jac(x, y, z)

Inverse Jacobian of the map \((r, \phi, z) \to (x, y, z)\) at \((x, y, z)\).

rphiz_jac(x, y, z)

Jacobian of the map \((x, y, z) \to (r, \phi, z)\) at \((x, y, z)\).

vec_cart2cyl(vec, r, phi, z)

Transforms the (contravariant) cartesian components of a vector to the contravariant cylindrical components at \((r, \phi, z)\).

vec_cyl2cart(vec, x, y, z)

Transforms the contravariant cylindrical components to the (contravariant) cartesian components of a vector at \((x, y, z)\).

xyz(r, phi, z)

Transforms cylindrical coordinates \((r, \phi, z)\) to cartesian coordinates \((x, y, z)\).

xyz_inv_jac(r, phi, z)

Inverse Jacobian of the map \((r, \phi, z) \to (x, y, z)\) at \((r, \phi, z)\).

xyz_jac(r, phi, z)

Jacobian of the map \((x, y, z) \to (r, \phi, z)\) at \((r, \phi, z)\).

pyoculus.utils.cyl_cart_transform.xyz_jac(r: float, phi: float, z: float) array

Jacobian of the map \((x, y, z) \to (r, \phi, z)\) at \((r, \phi, z)\).

\[\begin{split}J(r, \phi, z) = \begin{bmatrix} \partial_x r & \partial_y r & \partial_z r \\ \partial_x \phi & \partial_y \phi & \partial_z \phi \\ \partial_x z & \partial_y z & \partial_z z \\ \end{bmatrix}\end{split}\]
pyoculus.utils.cyl_cart_transform.rphiz_jac(x: float, y: float, z: float) array

Jacobian of the map \((x, y, z) \to (r, \phi, z)\) at \((x, y, z)\).

pyoculus.utils.cyl_cart_transform.xyz_inv_jac(r: float, phi: float, z: float) array

Inverse Jacobian of the map \((r, \phi, z) \to (x, y, z)\) at \((r, \phi, z)\).

pyoculus.utils.cyl_cart_transform.rphiz_inv_jac(x: float, y: float, z: float) array

Inverse Jacobian of the map \((r, \phi, z) \to (x, y, z)\) at \((x, y, z)\).

pyoculus.utils.cyl_cart_transform.xyz(r: float, phi: float, z: float) array

Transforms cylindrical coordinates \((r, \phi, z)\) to cartesian coordinates \((x, y, z)\).

pyoculus.utils.cyl_cart_transform.rphiz(x: float, y: float, z: float) array

Transforms cartesian coordinates \((x, y, z)\) to cylindrical coordinates \((r, \phi, z)\).

pyoculus.utils.cyl_cart_transform.vec_cart2cyl(vec: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], r: float, phi: float, z: float) array

Transforms the (contravariant) cartesian components of a vector to the contravariant cylindrical components at \((r, \phi, z)\).

\[\begin{split}\begin{bmatrix} v^r \\ v^{\phi} \\ v^z \end{bmatrix} = \begin{bmatrix} \partial_x r & \partial_y r & \partial_z r \\ \partial_x \phi & \partial_y \phi & \partial_z \phi \\ \partial_x z & \partial_y z & \partial_z z \\ \end{bmatrix} \begin{bmatrix} v^x \\ v^y \\ v^z \end{bmatrix}.\end{split}\]
Parameters:
  • vec (array) – The cartesian components of a vector.

  • r (float) – The radial coordinate.

  • phi (float) – The azimuthal coordinate.

  • z (float) – The vertical coordinate.

Returns:

The contravariant cylindrical components of the vector.

Return type:

array

pyoculus.utils.cyl_cart_transform.vec_cyl2cart(vec: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], x: float, y: float, z: float) array

Transforms the contravariant cylindrical components to the (contravariant) cartesian components of a vector at \((x, y, z)\).

pyoculus.utils.cyl_cart_transform.mat_cart2cyl(mat: array, r: float, phi: float, z: float) array

Transforms a matrix \(A\) from cartesian coordinates to cylindrical coordinates at \((r, \phi, z)\).

\[\begin{split}\begin{bmatrix} A^r_r & A^r_\phi & A^r_z \\ A^\phi_r & A^\phi_\phi & A^\phi_z \\ A^z_r & A^z_\phi & A^z_z \\ \end{bmatrix} = \begin{bmatrix} \partial_x r & \partial_y r & \partial_z r \\ \partial_x \phi & \partial_y \phi & \partial_z \phi \\ \partial_x z & \partial_y z & \partial_z z \\ \end{bmatrix} \begin{bmatrix} A^x_x & A^x_y & A^x_z \\ A^y_x & A^y_y & A^y_z \\ A^z_x & A^z_y & A^z_z \\ \end{bmatrix} \begin{bmatrix} \partial_r x & \partial_\phi x & \partial_z x \\ \partial_r y & \partial_\phi y & \partial_z y \\ \partial_r z & \partial_\phi z & \partial_z z \\ \end{bmatrix}.\end{split}\]
Parameters:
  • mat (array) – The matrix \(A\) in cartesian coordinates.

  • r (float) – The radial coordinate.

  • phi (float) – The azimuthal coordinate.

  • z (float) – The vertical coordinate.

Returns:

The matrix \(A\) in cylindrical coordinates.

Return type:

array

pyoculus.utils.cyl_cart_transform.mat_cyl2cart(mat: array, x: float, y: float, z: float) array

Transforms a matrix \(A\) from cylindrical coordinates to cartesian coordinates at \((x, y, z)\).

pyoculus.utils.cyl_cart_transform.dinvJ_matrix(vec: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], r: float, phi: float, z: float) array

Computes the matrix due to the evolution of the basis in cylindrical coordinates.

The Christoffel symbols \(\Gamma^k_{ij} = \frac{\textbf{e}_i}{x^j}\cdot g^{km}\textbf{e}_m\), where \(g^{km}\) is the inverse metric tensor, are used to compute the derivative of the basis vectors. Then for a vector \(X = X^i\textbf{e}_i\), the covariant derivative is given by:

\[\nabla_i X^k = \partial_i X^k - \Gamma^k_{ij} X^j.\]

To get the partial derivatives such as \(\partial_\phi v^r\), we can use the above formula, the independance of basis of \(\nabla v\) and a change of basis to get the desired components. We can write the part we need to substract in matrix form as:

\[\text{to write}.\]
Parameters:
  • vec (array) – The vector \(v\) in cartesian coordinates.

  • r (float) – The radial coordinate.

  • phi (float) – The azimuthal coordinate.

  • z (float) – The vertical coordinate.

Returns:

The matrix due to the evolution of the basis in cylindrical coordinates.

Return type:

array