Tensors#

class sigmaepsilon.math.linalg.Tensor(*args, frame: FrameLike | None = None, bulk: bool | None = None, rank: int | None = None, **kwargs)[source]#

A class to handle tensors.

Parameters:
  • args (tuple, Optional) – Positional arguments forwarded to numpy.ndarray.

  • frame (numpy.ndarray, Optional) – The reference frame the vector is represented by its coordinates.

  • kwargs (dict, Optional) – Keyword arguments forwarded to numpy.ndarray.

Examples

Import the necessary classes:

>>> from sigmaepsilon.math.linalg import Tensor, ReferenceFrame
>>> from numpy.random import rand

Create a Tensor of order 6 in a frame with random components

>>> frame = ReferenceFrame(dim=3)
>>> array = rand(3, 3, 3, 3, 3, 3)
>>> A = Tensor(array, frame=frame)

Get the tensor in the dual frame:

>>> A_dual = A.dual()

Create an other tensor, in this case a 5th-order one, and calculate their generalized dot product, which is a 9th-order tensor:

>>> from sigmaepsilon.math.linalg import dot
>>> array = rand(3, 3, 3, 3, 3)
>>> B = Tensor(array, frame=frame)
>>> C = dot(A, B, axes=[0, 0])
>>> assert C.rank == (A.rank + B.rank - 2)
copy(deep: bool = False, name: str = None) Tensor[source]#

Returns a shallow or deep copy of this object, depending of the argument deepcopy (default is False).

deepcopy(name: str = None) Tensor[source]#

Returns a deep copy of the frame.

dual() Tensor2[source]#

Returns the tensor described in the dual (or reciprocal) frame.

orient(*args, **kwargs) Tensor[source]#

Orients the vector inplace. All arguments are forwarded to orient_new.

Returns:

The same vector the function is called upon.

Return type:

Vector

See also

orient_new()

orient_new(*args, **kwargs) Tensor[source]#

Returns a transformed version of the instance.

Returns:

A new vector.

Return type:

Vector

See also

orient()

show(target: ReferenceFrame = None, *, dcm: ndarray = None) ndarray[source]#

Returns the components in a target frame. If the target is None, the components are returned in the ambient frame.

The transformation can also be specified with a proper DCM matrix.

Parameters:
Returns:

The components of the tensor in a specified frame, or the ambient frame, depending on the arguments.

Return type:

numpy.ndarray

transform_components(Q: ndarray) ndarray[source]#

Returns the components of the tensor transformed by the matrix Q.

class sigmaepsilon.math.linalg.Tensor2(*args, frame: FrameLike | None = None, bulk: bool | None = None, rank: int | None = None, **kwargs)[source]#

A class to handle second-order tensors. Some operations have dedicated implementations that provide higher performence utilizing implicit parallelization. Examples for tensors of this class include the metric tensor, or the stress and strain tensors of elasticity.

See also

Tensor2x3

transform_components(Q: ndarray) ndarray[source]#

Returns the components of the tensor transformed by the matrix Q.

class sigmaepsilon.math.linalg.Tensor2x3(*args, **kwargs)[source]#

Dedicated class for second-order tensors, with 3 indices per axis. Since the shape of the tensor is known, instances are able to automatically detect if the provided components resemble a single item or a collection.

class sigmaepsilon.math.linalg.Tensor4(*args, frame: FrameLike | None = None, bulk: bool | None = None, rank: int | None = None, **kwargs)[source]#

A class to handle fourth-order tensors. Some operations have dedicated implementations that provide higher performence utilizing implicit parallelization. Examples of this class include the piezo-optical tensor, the elasto-optical tensor, the flexoelectric tensor or the elasticity tensor.

See also

Tensor4x3

transform_components(dcm: ndarray) ndarray[source]#

Returns the components of the transformed numerical tensor, based on the provided direction cosine matrix.

class sigmaepsilon.math.linalg.Tensor4x3(*args, **kwargs)[source]#

Dedicated class for fourth order tensors, with 3 indices per axis. Since the shape of the tensor is known, instances are able to automatically detect if the provided components resemble a single item or a collection.