Step 2: Modeling and simulating deformations

You can download the file associated with this step at:
http://sofamacbuilder.lille.inria.fr/defrost/scenes/Tutorial/step2-ModelingAndSimulatingDeformations/Finger.py

In the previous step we showed how to generate a volumetric representation of the object. We will now explain how this geometric representation can be mechanically simulated. In SOFA This implies to provide a mechanical model of the deformation and a solving method.  In the scene, you can add an ODE (Ordinary Differential Equation) solver for time integration which will allow the finger position to be updated at each timestep. For example, using a first order Euler Implicit solver is obtained by:  

finger.createObject('EulerImplicit', name='odesolver', firstOrder='1')

The next component to add is a FEM forcefield which defines how the object reacts to a loading (i.e. which deformations are created from forces applied onto it). Here, because the finger is made of silicone, its mechanical behavior is assumed elastic. This behavior is available via the TetrahedronFEMForceField component that you need to add in the finger node by adding:

finger.createObject('TetrahedronFEMForceField', template='Vec3d', name='FEM',
                                    method='large', poissonRatio='0.3',  youngModulus='18000')

Poisson’s ratio and Young Modulus are material dependant parameters and should be provided by the user. To be properly simulated and to interact with gravity or inertia forces, an object also needs a mass. You can add a given mass with a uniform distribution for an object by adding a UniformMass component to the finger node:    

finger.createObject('UniformMass', totalmass='0.5')

Reload your scene into SOFA and click on the “Animate” button. You can now interact with the finger object by pressing SHIFT and clicking on the mouse left button.

FingerRepos.png FingerEtire.png