Skip to content

Deviatoric and volumetric part of second order tensor for dimension not equal to 3 #214

@TmNmr

Description

@TmNmr

Hi,
I just stumbled over an issue which might lead to unexpected results for second order tensors with dimensions not equal to $3$.

To the best of my knowledge, the deviatoric part for a second order tensor $X \in \mathbb{R}^{d \times d}$ is defined by
$$\mathrm{dev}_d (X) = X - \frac{1}{d} \mathrm{tr} (X) I_d$$ with $I_d \in \mathbb{R}^{d\times d}$ denoting the identity tensor. My guess is that the denominator $3$ in the functions dev and mean could be changed to dim in order to make them applicable for general dimensions.

Tensors.jl/src/math_ops.jl

Lines 297 to 306 in 258540f

@inline function dev(S::SecondOrderTensor)
Tt = get_base(typeof(S))
trace = tr(S) / 3
Tt(
@inline function(i, j)
@inbounds v = i == j ? S[i,j] - trace : S[i,j]
v
end
)
end

Statistics.mean(S::SecondOrderTensor) = tr(S) / 3

If interested I could work on a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions