sofa-framework / sofa

Real-time multi-physics simulation with an emphasis on medical simulation.
https://www.sofa-framework.org
GNU Lesser General Public License v2.1
867 stars 296 forks source link

[HyperElastic] Introduce stable Neo Hookean hyperelastic material #4603

Closed alxbilger closed 3 weeks ago

alxbilger commented 1 month ago

On top of the introduction of the stable Neo Hookean hyperelastic material (from Smith, Breannan, Fernando De Goes, and Theodore Kim. "Stable neo-hookean flesh simulation." ACM Transactions on Graphics (TOG) 37.2 (2018): 1-15.), I rewrote the St Venant-Kirchhoff and Neo Hookean materials to make it clearer to read. I also added unit tests, validating some material constitutive equations.

I added an example having inverted tetrahedra:

invertedTets

Based on https://github.com/sofa-framework/sofa/pull/4600

$$ \alpha = 1 + \frac{\mu}{\lambda + \mu} $$

Strain Energy Density Function

$$ \psi = \frac{1}{2} \left(\mu (I_C - 3) + (\lambda + \mu) (J - \alpha)^2 \right) $$

Second Piola-Kirchoff stress tensor

$$ S = \mu I_3 + \left((\lambda + \mu) J (J - \alpha)\right) C^{-1} $$

Elasticity tensor

$$ \mathbb{C} = (\lambda + \mu) \left(-2 J (J - \alpha) C^{-1} \underline{\overline{\otimes}} C^{-1} + J (2 J-\alpha) C^{-1} \otimes C^{-1} \right) $$


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

hugtalbot commented 1 month ago

Poke @fjourdes @bakpaul ;)

TODO :

alxbilger commented 1 month ago

The simulation diverges at dt=0.00006 (compared to being stable at dt=0.00005), independently on the method used to fix points.

alxbilger commented 1 month ago

[ci-build][with-all-tests]

alxbilger commented 1 month ago

@hugtalbot @bakpaul I don't really understand why there is a factor 2 here: https://github.com/sofa-framework/sofa/blob/975b4ab35149b23915490e715da0fb3cdcc3bb92/Sofa/Component/SolidMechanics/FEM/HyperElastic/tests/Material_test.cpp#L250

And here:

https://github.com/sofa-framework/sofa/blob/975b4ab35149b23915490e715da0fb3cdcc3bb92/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/material/StableNeoHookean.h#L193

I don't understand how C_H_C relates to $C^{-1} \underline{\overline{\otimes}} C^{-1}$ and trC_HC_ relates to $C^{-1} \otimes C^{-1}$

hugtalbot commented 1 month ago

Let me invoke @fjourdes

fjourdes commented 1 month ago

That looks great ! I did not have the time yet to test. Maybe we could have a look at the following implementation for the test bench ? HOBAK the code repository used by the paper authors Libgl implementation of Stable Neo hookean energy

alxbilger commented 1 month ago

Hi @fjourdes, thanks for the suggestion. I used HOBAK for the implementation, adapting it to SOFA TetrahedronHyperelasticityFEMForceField. I implemented only the material. Therefore, everything outside of the material, such as matrix clamping, is not yet implemented. Note that HOBAK has also a test suite, with some similarities with mine (test derivative against finite differences). I guess we can check that both test suites match for the same input.