I am currently concerned with some hyperelastic problems, where i want to form some invariants containing arbitrary fractional powers of the right Cauchy Green deformation tensor.
Unfortunately i have found no built in tools which are able to do this.
Therefore i have written some code that allows for the spectral representation of some arbitrary symmetric second order tensor.
However, if i want to do some postprocessing or do my own linearization as well using Assemble it takes forever to assemble the bilinearform.
In attachment you will find the code.
How can i circumvent this problem or is there an easier and more efficient way to compute and utilize fractional powers of some second order tensor in the Lagrangian?
thanks for your fast reply. I am aware of the built-in Eig - function.
However when i define the Lagrangian using a simple Neo Hooke model, where i use the first principle invariant of the right Cauchy Green tensor formulated in terms of its eigenvalues using the built-in Eig - function there seems to be a problem with automatic differentiation and non-distinct eigenvalues.
Since solving a simple problem already gives NaN in the first increment.
@Joachim: No, i did not try with Compile. It seems a little weird to me since AssembleLinearization works perfectly fine with my python code and doing my own Linearization with Assemble or Interpolate 1.PK stress Tensor to some MatrixL2 space does not work.
Ok, then let us try where we can get with your Python code.
Can you post a MWE with AssembleLinearization, and a Newton solver ?
Should your own linearization be the exact linearization, what NGSolve also computes ? Or is it some inexact, cheaper approximation ?
What do you mean with interpolating the 1. PK ? Calling Interpolate, maybe to some HDiv**3 space ? Can you give a reference for that method ?
Please just try with .Compile of your expression. Default is ‘soft’ compile, it’s just internal linearization and common sub-expression elimination of the complicated tree. Only calling .Compile(realcompile=True) generates C++ code and calls the compiler.
thanks again for your fast reply.
I will be on easter holiday and out of office until end of next week.
When i am back i will prepare a MWE in a jupyter-notebook, which illustrates the problem(s).
For postprocessing i called interpolate to some MatrixL2 space.
Ultimate goal is to use ngsolve for some large scale 3D multiphysics (rate-independent dissipative magneto-mechanics etc) [50mio+ DoFs] simulations, where i want to utilize some spectral-type invariants in my consitutive model.
in attachment you find a MWE that should illustrate the aforementioned problems: MWE.ipynb (5.6 KB)
There seems to be a problem when formulating the Lagrangian using Eigenvalues of a CF via built-in Eig-function.
Assembling the bilinear form of the given hyperelastic problem using my python code for spectral representation & Assemble() takes forever. The same holds for calling Interpolate for e.g. the 1.PK stress to some MatrixL2 space.
the NewtonMinimization is below a second, right ?
The interpolation of _PK1 takes forever.
You can significantly improve it by (then it takes 9 sec for me):
PK1_pp.Interpolate(_PK1.Compile())
To get an idea what’s going on you can do:
print (NeoHooke_FP(_F))
which gives about 90k lines, printing all nodes of the expression tree recursively.
You get information of the compiled expression with:
thanks for the heads-up. I will have a look at it.
However, for a more efficient implementation it seems wiser to rely on the built-in Eig()-function.
But there seems to be an inherent problem with the Autodiff-functionality in combination with built-in Eig()-function (as also pointed out in my MWE), since it gives wrong results.
you are absolutely right and yes, the code runs faster now.
However, there is still the issue with the Autodiff of functions involving the built-in Eig()-function.
(Second option “Flag=0” in my MWE or alternatively the Matrix_Power function that I defined before)
It unfortunately yields false expressions, when I apply automatic differentiation to them.
just to illustrate the major problem – that autodiff of a CF involving built-in Eig()-function yields completely false results – i attached a minimum working example. MWE_Differentiation.ipynb (6.5 KB)
To this end i computed some error norms that involves the first principle invariant of the right Cauchy Green Tensor computed in different ways: