pg_utils.sympy_supp.vector_calculus_3d.CylindricalCoordinates

class pg_utils.sympy_supp.vector_calculus_3d.CylindricalCoordinates(s, p, z, s_name='s', p_name='p', z_name='z')[source]

Bases: OrthogonalCoordinates3D

Cylindrical coordinate system in 3D

Example: define a cylindrical system. The default names for the coordinates are s, p and z:

>>> x1, x2, x3 = sympy.symbols("x_1 x_2 x_3")
>>> cyl3d = CylindricalCoordinates3D(x1, x2, x3)
>>> cyl3d.s   # Invoking the radial coordinate
x_1
>>> cyl3d.p   # Invoking the azimuthal coordinate
x_2

You can also pass in additional names to name the coordinates:

>>> cyl3d = CylindricalCoordinates3D(x1, x2, x3, s_name="r")
>>> cyl3d.r  # Invoking the radial coordinate
x_1
>>> cyl3d.p  # Invoking the azimuthal coordinate
x_2

It also supports indexing:

>>> cyl3d[2]
x_3
__init__(s, p, z, s_name='s', p_name='p', z_name='z') None[source]

Constructor

Parameters:
  • s (sympy.Symbol) – radial coordinate

  • p (sympy.Symbol) – azimuthal coordinate

  • z (sympy.Symbol) – vertical coordinate

  • s_name (str) – optional name for s; if given, the attribute will be named by s_name; else, the attribute will be named “s”.

  • p_name (str) – see s_name

  • z_name (str) – see s_name

Methods

__init__(s, p, z[, s_name, p_name, z_name])

Constructor

curl(vector_in, **kwargs)

Compute the curl of a vector in cylindrical coordinates

div(vector_in, **kwargs)

Compute the divergence of a vector in cylindrical coordinates

grad(scalar_in, **kwargs)

Compute the grad of a scalar in cylindrical coordinates

laplacian(tensor_in[, rank])

Compute the Laplacian of a tensor in cylindrical coordinates

transform_to(v_in, new_sys[, coeffs_new])

Transform vector under cylindrical coordinates to new coordinate system

Attributes

coords

Setter/getter interface for the coordinates, indexable

property coords[source]

Setter/getter interface for the coordinates, indexable

curl(vector_in, **kwargs)[source]

Compute the curl of a vector in cylindrical coordinates

Parameters:
  • vector_in (array-like) – input vector, assumed to be 3-component array, with sympy.Expr as components

  • **kwargs – additional arguments passed to sympy.diff

Returns:

curl, 3-tuple of sympy.Expr, with elements corresponding to (s,p,z) components

div(vector_in, **kwargs)[source]

Compute the divergence of a vector in cylindrical coordinates

Parameters:
  • vector_in (array-like) – input vector, assumed to be 3-component array, with sympy.Expr as components

  • **kwargs – additional arguments passed to sympy.diff

Returns:

divergence scalar, sympy.Expr

grad(scalar_in, **kwargs)[source]

Compute the grad of a scalar in cylindrical coordinates

Parameters:
  • scalar_in (sympy.Expr) – input scalar

  • **kwargs – additional arguments passed to sympy.diff

Returns:

gradient, 3-tuple of sympy.Expr, with elements corresponding to (s,p,z) components

laplacian(tensor_in, rank=0, **kwargs)[source]

Compute the Laplacian of a tensor in cylindrical coordinates

Parameters:
  • tensor_in – input tensor

  • rank (int) – rank of the input tensor, default to 0. Currently, only rank = 0 (scalar Laplacian) is implemented.

  • **kwargs – additional arguments passed to sympy.diff

Returns:

tensor, sympy.Expr or List of sympy.Expr depending on the input tensor rank

transform_to(v_in: Vector3D, new_sys: OrthogonalCoordinates3D, coeffs_new=False) Vector3D[source]

Transform vector under cylindrical coordinates to new coordinate system