Elasticipy.SecondOrderTensor module
- class Elasticipy.SecondOrderTensor.SecondOrderTensor(matrix)[source]
Bases:
objectTemplate class for manipulation of second order tensors or arrays of second order tensors
- matrix
(…,3,3) matrix storing all the components of the tensor
- Type:
np.ndarray
- property C
Return tensor components
For instance T.C[i,j] returns all the (i,j)-th components of each tensor in the array.
- Returns:
Tensor components
- Return type:
np.ndarray
- property I1
First invariant of the tensor (trace)
- Returns:
First invariant(s) of the tensor(s)
- Return type:
np.ndarray or float
- property I2
Second invariant of the tensor
For a matrix M, it is defined as:
I_2 = 0.5 * ( np.trace(M)**2 + np.trace(np.matmul(M, M.T)) )
- Returns:
Second invariant(s) of the tensor(s)
- Return type:
np.array or float
- property I3
Third invariant of the tensor (determinant)
- Returns:
Third invariant(s) of the tensor(s)
- Return type:
np.array or float
- property T
Transpose the array of tensors.
It is actually an alias for transposeArray()
- Returns:
Transposed array
- Return type:
- ddot(other)[source]
Double dot product (contraction of tensor product, usually denoted “:”) of two tensors.
For two tensors whose matrices are M1 and M2:
M1.ddot(M2) == np.trace(np.matmul(M1, M2))
- Parameters:
other (SecondOrderTensor or np.ndarray) – Tensor or tensor array to multiply by before contraction.
- Returns:
Result of double dot product
- Return type:
float or np.ndarray
See also
matmulmatrix-like product between two tensor arrays.
- deviatoricPart()[source]
Deviatoric part of the tensor
- Return type:
See also
sphericalPartspherical part of the tensor
- eig()[source]
Eigenvalues of the tensor
- Returns:
lambda (np.ndarray) – Eigenvalues of each tensor.
v (np.ndarray) – Eigenvectors of teach tensor.
See also
principalDirectionsreturn only the principal directions (without eigenvalues)
- classmethod eye(shape=())[source]
Create an array of tensors populated with identity matrices
- Parameters:
shape (tuple or int, default ()) – If not provided, it just creates a single identity tensor. Otherwise, the tensor array will be of the specified shape.
- Returns:
Array of identity tensors
- Return type:
- flatten()[source]
Flatten the array of tensors.
If T is of shape [s1, s2, …, sn], the shape for T.flatten() is [s1*s2*…*sn].
- Returns:
Flattened array (vector) of tensor
- Return type:
- matmul(other)[source]
Perform matrix-like product between tensor arrays. Each “product” is a matrix product between the tensor components.
If A.shape=(a1, a2, …, an) and B.shape=(b1, b2, …, bn), with C=A.matmul(B), we have:
C.shape = (a1, a2, ..., an, b1, b2, ..., bn)
and:
C[i,j,k,...,p,q,r...] = np.matmul(A[i,j,k,...], B[p,q,r,...])
- Parameters:
other (SecondOrderTensor or np.ndarray or Rotation) – Tensor array or rotation to right-multiply by. If Rotation is provided, the rotations are applied on each tensor.
- Returns:
Tensor array
- Return type:
See also
__mul__Element-wise matrix product
- max(axis=None)[source]
Maximum value
- Parameters:
axis (int or None, default None) – Axis to compute maximum along with. If None, returns the overall maximum (max of flattened array)
- Returns:
Maximum value of tensors
- Return type:
- mean(axis=None)[source]
Arithmetic mean value
- Parameters:
axis (int or None, default None) – Axis to compute the mean along with. If None, returns the overall mean (mean of flattened array)
- Returns:
Mean tensor
- Return type:
- min(axis=None)[source]
Minimum value
- Parameters:
axis (int or None, default None) – Axis to compute minimum along with. If None, returns the overall minimum (min of flattened array)
- Returns:
Minimum value of tensors
- Return type:
- name = 'Second-order tensor'
Name to use when printing the tensor
- property ndim
Return the number of dimensions of the tensor array
- Returns:
number of dimensions
- Return type:
float
See also
shapeshape of tensor array
- classmethod ones(shape=())[source]
Create an array of tensors populated with matrices of full of ones.
- Parameters:
shape (tuple or int, default ()) – If not provided, it just creates a single tensor of ones. Otherwise, the tensor array will be of the specified shape.
- Returns:
Array of ones tensors
- Return type:
- principalDirections()[source]
Principal directions of the tensors
- Returns:
Principal directions of each tensor of the tensor array
- Return type:
np.nparray
See also
eigReturn both eigenvalues and corresponding principal directions
- property shape
Return the shape of the tensor array
- Returns:
Shape of array
- Return type:
tuple
See also
ndimnumber of dimensions
- classmethod shear(u, v, magnitude)[source]
Create an array of tensors corresponding to shear state along two orthogonal directions.
- Parameters:
u (np.ndarray or list) – First direction. Must be a 3D vector.
v (np.ndarray or list) – Second direction. Must be a 3D vector.
magnitude (float or np.ndarray or list) – Magnitude of the shear state to consider. If a list or an array is provided, the shape of the tensor array will be of the same shape as magnitude.
- Returns:
tensor or tensor array
- Return type:
- sphericalPart()[source]
Spherical (hydrostatic) part of the tensor
- Returns:
Spherical part
- Return type:
See also
I1compute the first invariant of the tensor
deviatoricPartdeviatoric the part of the tensor
- std(axis=None)[source]
Standard deviation
- Parameters:
axis (int or None, default None) – Axis to compute standard deviation along with. If None, returns the overall standard deviation (std of flattened array)
- Returns:
Tensor of standard deviation
- Return type:
- symmetricPart()[source]
Symmetric part of the tensor
- Returns:
Symmetric tensor
- Return type:
See also
skewPartSkew-symmetric part of the tensor
- classmethod tensile(u, magnitude)[source]
Create an array of tensors corresponding to tensile state along a given direction.
- Parameters:
u (np.ndarray or list) – Tensile direction. Must be a 3D vector.
magnitude (float or np.ndarray or list) – Magnitude of the tensile state to consider. If a list or an array is provided, the shape of the tensor array will be of the same shape as magnitude.
- Returns:
tensor or tensor array
- Return type:
- trace()[source]
Return the traces of the tensor array
- Returns:
traces of each tensor of the tensor array
- Return type:
np.ndarray or float
- transposeArray()[source]
Transpose the array of tensors
If A is a tensor array of shape [s1, s2, …, sn], A.T is of shape [sn, …, s2, s1].
- Returns:
Transposed array
- Return type:
See also
Ttranspose the tensor array (not the components)
- transposeTensor()[source]
Transpose of tensors of the tensor array
- Returns:
Array of transposed tensors of the tensor array
- Return type:
See also
Transposetranspose the array (not the components)
- classmethod zeros(shape=())[source]
Create an array of tensors populated with matrices full of zeros.
- Parameters:
shape (tuple or int, default ()) – If not provided, it just creates a single tensor of ones. Otherwise, the tensor array will be of the specified shape.
- Returns:
Array of ones tensors
- Return type:
- class Elasticipy.SecondOrderTensor.SymmetricSecondOrderTensor(mat)[source]
Bases:
SecondOrderTensor- classmethod from_Voigt(array)[source]
Construct a SymmetricSecondOrderTensor from a Voigt vector, or slices of Voigt vectors.
If the array is of shape (6,), a single tensor is returned. If the array is of shape (m,n,o,…,6), the tensor will be of shape (m,n,o,…).
- Parameters:
array (np.ndarray or list) – array to build the SymmetricSecondOrderTensor from. We must have array.ndim>0 and array.shape[-1]==6.
- Return type:
Examples
>>> SymmetricSecondOrderTensor.from_Voigt([11, 22, 33, 23, 13, 12]) Second-order tensor [[11. 12. 13.] [12. 22. 23.] [13. 23. 33.]]
- classmethod shear(u, v, magnitude)[source]
Create an array of tensors corresponding to shear state along two orthogonal directions.
- Parameters:
u (np.ndarray or list) – First direction. Must be a 3D vector.
v (np.ndarray or list) – Second direction. Must be a 3D vector.
magnitude (float or np.ndarray or list) – Magnitude of the shear state to consider. If a list or an array is provided, the shape of the tensor array will be of the same shape as magnitude.
- Returns:
tensor or tensor array
- Return type:
- voigt_map = [1, 1, 1, 1, 1, 1]
List of factors to use for building a tensor from Voigt vector(s)