pg_utils.sympy_supp.vector_calculus_3d.CartesianCoordinates3D

class pg_utils.sympy_supp.vector_calculus_3d.CartesianCoordinates3D(x, y, z, x_name='x', y_name='y', z_name='z')[source]

Bases: OrthogonalCoordinates3D

Cartesian coordinate system in 3D

Example: define a Cartesian system. The default names for the coordinates are x, y and z:

>>> x1, x2, x3 = sympy.symbols("x_1 x_2 x_3")
>>> cart3d = CartesianCoordinates3D(x1, x2, x3)
>>> cart3d.x   # Invoking the x coordinate
x_1
>>> cart3d.y   # Invoking the y coordinate
x_2

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

>>> cart3d = CartesianCoordinates3D(x1, x2, x3, x_name="x1", y_name="x2", zname="x3")
>>> cart3d.x1  # Invoking the x coordinate
x_1
>>> cart3d.x2  # Invoking the y coordinate
x_2

It also supports indexing:

>>> cart3d[0]
x_1
__init__(x, y, z, x_name='x', y_name='y', z_name='z') None[source]

Constructor

Parameters:
  • x (sympy.Symbol) – x coordinate

  • y (sympy.Symbol) – y coordinate

  • z (sympy.Symbol) – z coordinate

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

  • y_name (str) – see x_name

  • z_name (str) – see x_name

Methods

__init__(x, y, z[, x_name, y_name, z_name])

Constructor

curl(vector_in, **kwargs)

Compute the curl of a vector in 3-D Cartesian coords

div(vector_in, **kwargs)

Vector divergence, to be implemented

grad(scalar_in, **kwargs)

Compute the grad of a scalar in 3-D Cartesian coords

laplacian(tensor_in[, rank])

Compute the Laplacian of a tensor

transform_to(tensor_in, new_sys[, coeffs_new])

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 3-D Cartesian coords

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

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

Returns:

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

div(vector_in, **kwargs)[source]

Vector divergence, to be implemented

grad(scalar_in, **kwargs)[source]

Compute the grad of a scalar in 3-D Cartesian coords

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 (x,y,z) components

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

Compute the Laplacian of a tensor

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:

Laplacian, same shape as the input tensor