Elasticipy.tensors.fourth_order module

class Elasticipy.tensors.fourth_order.FourthOrderTensor(M, mapping='Kelvin', check_minor_symmetry=True, force_minor_symmetry=False)[source]

Bases: object

Template class for manipulating symmetric fourth-order tensors.

matrix[source]

(6,6) matrix gathering all the components of the tensor, using the Voigt notation.

Type:

np.ndarray

Construct of Fourth-order tensor with minor symmetry.

Parameters:
  • M (np.ndarray) – (6,6) matrix corresponding to the stiffness tensor, written using the Voigt notation, or array of shape (3,3,3,3).

  • mapping (str or list of list, or numpy/ndarray, optional) – Mapping convention to translate the (3,3,3,3) array to (6,6) matrix

  • check_minor_symmetry (bool, optional) – If true (default), check that the input array have minor symmetries (see Notes). Only used if an array of shape (…,3,3,3,3) is passed.

  • force_minor_symmetry – Ensure that the tensor displays minor symmetry.

Notes

The minor symmetry is defined so that:

\[M_{ijkl}=M_{jikl}=M_{jilk}=M_{ijlk}\]
ddot(other, mode='pair')[source]

Perform tensor product contracted twice (“:”) between two fourth-order tensors

Parameters:
  • other (FourthOrderTensor or SecondOrderTensor) – Right-hand side of “:” symbol

  • mode (str, optional) – If mode==”pair”, the tensors must be broadcastable, and the tensor product are performed on the last axes. If mode==”cross”, all cross-combinations are considered.

Returns:

If both the tensors are 0D (no orientation), the return value will be of type SymmetricTensor Otherwise, the return value will be the full tensor, of shape (…,3,3,3,3).

Return type:

FourthOrderTensor or numpy.ndarray

flatten()[source]

Flatten the tensor

If the tensor array is of shape (m,n,o…,r), the flattened array will be of shape (m*n*o*…*r,).

Returns:

Flattened tensor

Return type:

SymmetricFourthOrderTensor

full_tensor()[source]

Returns the full (unvoigted) tensor, as a [3, 3, 3, 3] array

Returns:

Full tensor (4-index notation)

Return type:

np.ndarray

classmethod identity(shape=(), return_full_tensor=False, mapping='Kelvin')[source]

Create a 4th-order identity tensor

Parameters:
  • shape (int or tuple, optional) – Shape of the tensor to create

  • return_full_tensor (bool, optional) – If True, return the full tensor as a (3,3,3,3) or a (…,3,3,3,3) array. Otherwise, the tensor is returned as a SymmetricTensor object.

Returns:

Identity tensor

Return type:

numpy.ndarray or SymmetricTensor

inv()[source]

Invert the tensor. The inverted tensors inherits the properties (if any)

Returns:

Inverse tensor

Return type:

FourthOrderTensor

mean(axis=None)[source]

Compute the mean value of the tensor T

Parameters:

axis (int or list of int or tuple of int, optional) – axis along which to compute the mean. If None, the mean is computed on the flattened tensor

Returns:

If no axis is given, the result will be of shape (3,3,3,3). Otherwise, if T.ndim=m, and len(axis)=n, the returned value will be of shape (…,3,3,3,3), with ndim=m-n+4

Return type:

numpy.ndarray

property ndim[source]

Returns the dimensionality of the tensor (number of dimensions in the orientation array)

Returns:

Number of dimensions

Return type:

int

rotate(rotation)[source]

Apply a single rotation to a tensor, and return its component into the rotated frame.

Parameters:

rotation (Rotation or orix.quaternion.rotation.Rotation) – Rotation to apply

Returns:

Rotated tensor

Return type:

SymmetricFourthOrderTensor

property shape[source]

Return the shape of the tensor array :returns: Shape of the tensor array :rtype: tuple

tensor_name = '4th-order'[source]
transpose_array()[source]

Transpose the orientations of the tensor array

Returns:

The same tensor, but with transposed axes

Return type:

FourthOrderTensor

classmethod zeros(shape=())[source]

Create a fourth-order tensor populated with zeros

Parameters:

shape (int or tuple, optional) – Shape of the tensor to create

Return type:

FourthOrderTensor

class Elasticipy.tensors.fourth_order.SymmetricFourthOrderTensor(M, check_symmetries=True, force_symmetries=False, **kwargs)[source]

Bases: FourthOrderTensor

Construct a fully symmetric fourth-order tensor from a (…,6,6) or a (3,3,3,3) array.

The input matrix must be symmetric, otherwise an error is thrown (except if check_symmetry==False, see below)

Parameters:
  • M (np.ndarray) – (6,6) matrix corresponding to the stiffness tensor, written using the Voigt notation, or array of shape (3,3,3,3).

  • check_symmetries (bool, optional) – Whether to check or not that the tensor to built displays both major and minor symmetries (see Notes).

  • force_symmetries (bool, optional) – If true, ensure that the tensor displays both minor and major symmetries.

Notes

The major symmetry is defined so that:

\[M_{ijkl}=M_{klij}\]

whereas the minor symmetry is:

\[M_{ijkl}=M_{jikl}=M_{jilk}=M_{ijlk}\]
invariants(order='all')[source]

Compute the invariants of the tensor.

Compute the linear or/and quadratic invariant of the fourth-order tensor (see notes)

Parameters:

order (str, optional) – If ‘linear’, only A1 and A2 are returned If ‘quadratic’, A1², A2², B1, B2, B3, B4 and B5 are returned If ‘all’ (default), A1, A2, A1², A2², B1, B2, B3, B4 and B5 are returned

Returns:

invariants of the given order (see above)

Return type:

tuple

Notes

The nomenclature of the invariants follows that of [4]. The linear invariants are:

\[ \begin{align}\begin{aligned}A_1=C_{ijij}\\A_2=C_{iijj}\end{aligned}\end{align} \]

whereas the quadratic invariants are:

\[ \begin{align}\begin{aligned}B_1 = C_{ijkl}C_{ijkl}\\B_2 = C_{iikl}C_{jjkl}\\B_3 = C_{iikl}C_{jkjl}\\B_4 = C_{kiil}C_{kjjl}\\B_5 = C_{ijkl}C_{ikjl}\end{aligned}\end{align} \]

References

tensor_name = 'Symmetric 4th-order'[source]
Elasticipy.tensors.fourth_order.rotate_tensor(full_tensor, r)[source]

Rotate a (full) fourth-order tensor.

Parameters:
  • full_tensor (numpy.ndarray) – array of shape (3,3,3,3) or (…,3,3,3,3) containing all the components

  • r (scipy.spatial.Rotation or orix.quaternion.Rotation) – Rotation, or set of rotations, to apply

Returns:

Rotated tensor. If r is an array, the corresponding axes will be added as first axes in the result array.

Return type:

numpy.ndarray

Elasticipy.tensors.fourth_order.unvoigt_index(i)[source]

Translate the one-index notation to two-index notation

Parameters:

i (int or np.ndarray) – Index to translate

Elasticipy.tensors.fourth_order.voigt_indices(i, j)[source]

Translate the two-index notation to one-index notation

Parameters:
  • i (int or np.ndarray) – First index

  • j (int or np.ndarray) – Second index

Return type:

Index in the vector of length 6