Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect eigen vectors on symmetric tensors #173

Closed
fpguillet opened this issue Dec 28, 2021 · 3 comments
Closed

Incorrect eigen vectors on symmetric tensors #173

fpguillet opened this issue Dec 28, 2021 · 3 comments

Comments

@fpguillet
Copy link

On some 2D symmetric tensors with a diagonal term close but not equal to 0, eigen vectors are not computed correctly and are equal.
The error does not occur on the same, equal, general tensor, see below.

julia>a = SymmetricTensor{2, 2, Float64}([0.003 5.8002786937773495e-16 0.003])
2×2 SymmetricTensor{2, 2, Float64, 3}:
0.003 5.80028e-16
5.80028e-16 0.003

julia> eigvecs(a)
2×2 Tensor{2, 2, Float64, 4}:
0.0 0.0
1.0 1.0

julia> a = Tensor{2, 2, Float64}([0.003 +5.8002786937773495e-16 +5.8002786937773495e-16 0.003])
2×2 Tensor{2, 2, Float64, 4}:
0.003 5.80028e-16
5.80028e-16 0.003

julia> eigvecs(a)
2×2 Matrix{Float64}:
-0.707107 0.707107
0.707107 0.707107

@fredrikekre
Copy link
Member

The implementation is borrowed from StaticArrays, so I guess they have the same issue? JuliaArrays/StaticArrays.jl#694 looks relevant for example.

@fpguillet
Copy link
Author

Yes, you're correct, it is the same issue (I checked).
I tried to force eigenvectors to be orthogonal in the Tensors eigen code, which basically works but led to an error when using automatic differentiation (gradient). (indicentally it is probably the same solution as the one considered in JuliaArrays/StaticArrays.jl#694 )
What I need to do is :
-consider a strain tensor (2D or 3D, but 2D at the moment)
-compute the principal strains (eigenvalues) and consider only positive (tension) strains. Negative compressive strains are set to 0.
-compute the modified strain tensor back in original basis (so I need a correct eigen vectors basis and its inverse)
-compute the derivative of modified "positive strains" tensor with respect to original tensor using gradient (resulting in a 4th degree tensor).
I solved the problem considering that any stress tensor component inferior to 1e-8 (absolute value) can be set to 0.0. I may return ot this problem later, but I have to get more familiar with forward differentiation requirements/process as I don't have a clue why the modifications I made to either Tensors code or my code raise an error.

@fredrikekre
Copy link
Member

Fixed upstream:

julia> using Tensors

julia> a = SymmetricTensor{2, 2, Float64}([0.003 5.8002786937773495e-16 0.003])
2×2 SymmetricTensor{2, 2, Float64, 3}:
 0.003        5.80028e-16
 5.80028e-16  0.003

julia> eigvecs(a)
2×2 Tensor{2, 2, Float64, 4}:
 -0.706987  0.706987
  0.707227  0.707227

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants