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)
See also
- 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).
- 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:
See also
- orient_new(*args, **kwargs) Tensor[source]#
Returns a transformed version of the instance.
- Returns:
A new vector.
- Return type:
See also
- 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:
target (numpy.ndarray, Optional) – Target frame.
dcm (numpy.ndarray, Optional) – The DCM matrix of the transformation.
- Returns:
The components of the tensor in a specified frame, or the ambient frame, depending on the arguments.
- Return type:
- 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
- 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