Ferrite-FEM / Tensors.jl

Efficient computations with symmetric and non-symmetric tensors with support for automatic differentiation.
https://ferrite-fem.github.io/Tensors.jl/
Other
170 stars 38 forks source link

Error when using AD on eigen #219

Open lijas opened 3 days ago

lijas commented 3 days ago

This has worked before, but seems to be broken now. Probably related to https://github.com/JuliaDiff/ForwardDiff.jl/pull/703 , but I don't understand how to fix it.

# add Tensors 
using Tensors    
function myfunk(e)
      p, n = Tensors.eigen(e)
      return otimes(n[:,1])
end;
e = rand(SymmetricTensor{2,3});
Tensors.gradient(myfunk, e)

Gives this error:

ERROR: setindex!(::StaticArraysCore.SMatrix{3, 3, Float64, 9}, value, ::Int) is not defined.
 Hint: Use `MArray` or `SizedArray` to create a mutable static array
KnutAM commented 3 days ago

Realized that this actually works due to https://github.com/JuliaDiff/ForwardDiff.jl/pull/703, but the problem is that that one isn't released in ForwardDiff, because ForwardDiff is stuck on 0.10 and seems to be very unclear when changes on master will be released...

I could get the above example to work by (need to trick Tensors.jl to allow (ForwardDiff v0.11.0-DEV)