DocTestSetup = quote
using Random
Random.seed!(1234)
using Tensors
end
Pages = ["other_operators.md"]
The dot product between the transpose of a tensor with itself. Results in a symmetric tensor.
Tensors.tdot
Tensors.dott
The (2)-norm of a tensor is defined for a vector, second order tensor and fourth order tensor as
Tensors.norm
The trace for a second order tensor is defined as the sum of the diagonal elements. This can be written as
Tensors.tr
Determinant for a second order tensor.
Tensors.det
Inverse of a second order tensor such that
where \mathbf{I}
is the second order identitiy tensor.
Tensors.inv
Transpose of tensors is defined by changing the order of the tensor's "legs". The transpose of a vector/symmetric tensor is the vector/tensor itself. The transpose of a second order tensor can be written as:
and for a fourth order tensor the minor transpose can be written as
and the major transpose as
Tensors.transpose
Tensors.minortranspose
Tensors.majortranspose
The symmetric part of a second order tensor is defined by:
The major symmetric part of a fourth order tensor is defined by
The minor symmetric part of a fourth order tensor is defined by
Tensors.symmetric
Tensors.minorsymmetric
Tensors.majorsymmetric
The skew symmetric part of a second order tensor is defined by
The skew symmetric part of a symmetric tensor is zero.
Tensors.skew
The deviatoric part of a second order tensor is defined by
Tensors.dev
The volumetric part of a second order tensor is defined by
Tensors.vol
The cross product between two vectors is defined as
Tensors.cross
The eigenvalues and eigenvectors of a (symmetric) second order tensor, \mathbf{A}
can be solved from the eigenvalue problem
where \lambda_i
are the eigenvalues and \mathbf{v}_i
are the corresponding eigenvectors.
For a symmetric fourth order tensor, \mathsf{A}
the second order eigentensors and eigenvalues
can be solved from
where \lambda_i
are the eigenvalues and \mathbf{V}_i
the corresponding eigentensors.
Tensors.eigen
Tensors.eigvals
Tensors.eigvecs
Square root of a symmetric positive definite second order tensor S
,
defined such that
Tensors.sqrt
Tensors.rotate
Tensors.rotation_tensor
For computing a special dot product between two vectors \mathbf{a}
and \mathbf{b}
with a fourth order symmetric tensor \mathbf{C}
such that a_k C_{ikjl} b_l
there is dotdot(a, C, b)
. This function is useful because it is the expression for the tangent matrix in continuum mechanics when the displacements are approximated by scalar shape functions.
Tensors.dotdot
For some operations it is convenient to easily switch to the so called "Voigt"-format.
For example when solving a local problem in a plasticity model. To simplify the conversion
between tensors and Voigt format, see tovoigt
, tovoigt!
and
fromvoigt
documented below. Care must be exercised when combined with
differentiation, see Differentiation of Voigt format further down.
Tensors.tovoigt
Tensors.tovoigt!
Tensors.fromvoigt
Differentiating with a Voigt representation of a symmetric tensor may lead to incorrect
results when converted back to tensors.
The tomandel
, tomandel!
, and frommandel
versions of
tovoigt
, tovoigt!
, and fromvoigt
can then be used. As
illustrated by the following example, this will give the correct result. In general,
however, direct differentiation of Tensor
s is faster (see
Automatic Differentiation).
julia> using Tensors, ForwardDiff
julia> fun(X::SymmetricTensor{2}) = X;
julia> A = rand(SymmetricTensor{2,2});
# Differentiation of a tensor directly (correct)
julia> tovoigt(gradient(fun, A))
3×3 Matrix{Float64}:
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 0.5
# Converting to Voigt format, perform differentiation, convert back (WRONG!)
julia> ForwardDiff.jacobian(
v -> tovoigt(fun(fromvoigt(SymmetricTensor{2,2}, v))),
tovoigt(A)
)
3×3 Matrix{Float64}:
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
# Converting to Mandel format, perform differentiation, convert back (correct)
julia> tovoigt(
frommandel(SymmetricTensor{4,2},
ForwardDiff.jacobian(
v -> tomandel(fun(frommandel(SymmetricTensor{2,2}, v))),
tomandel(A)
)
)
)
3×3 Matrix{Float64}:
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 0.5