Home › Forum › SOFA › Using SOFA › Best practice for setting up an animation?
Tagged: 64_bits, Linux_mint, SOFA_1812
- This topic has 7 replies, 3 voices, and was last updated 3 years, 6 months ago by Hugo.
-
AuthorPosts
-
3 May 2019 at 12:43 #13450ChristophOtteBlocked
Dear Sofa Community,
i very much appreciate, you guys spending so much time in optimizing and promoting the nice Framework. Thank you a lot for that effort.
Recently i started to play around with sofa to figure out a reasonable approach to model realistic instrument-tissue-interactions.
I came to the conclusion that a free-animation-loop in combination with Tetrahedron-FEM-Force-Fields could do the job quite well, although it’s not the fastest approach.
However, i also figured out, that the result highly depends on the meta parameter of the animation. And this is the point where i’m wondering, if my current approach might be completely rubbish at all.I started out with (from my point of view) realistic values for the mass and youngs-modulus of a gelatin-cylinder and gelatin-ball colliding with each other. I chose thresholds, rayleight-mass, dt etc. based on the available examples.
However in my first approach the ball just flew through the cylinder, without any interaction. I decreased dt and the objects collided, but deformed in a very strange way. By further decreasing dt, nothing happend at all, which was due a high threshold of the mechanical model. After adapting the threshold they collided quite nicely, but still not very realistic. So i started to tune the mechanical parameters but somehow ended up with just stabbing around in the dark.
Since i have not a lot of experience with simulations the following question might be naive, but i would be very glad if you could help me.
– is it “normal” that an animation with the given complexity can’t run in real-time on a mid-class pc (Ryzen 5 2600x) or are my meshes just bad? Actually real-time is not necessary for me at all, i was just wondering about that.
– I still don’t understand the parameter “Contact-Stiffness”. Shouldn’t the collision-reaction be completely determined by the objects mechanical properties (mass, modulus, possion-ratio)? How can i interpete Contact-Stiffness mechanically and how would i set it to get “realistic” behavior?
– Is there any “best-practice” for setting up an animation similar to that what i did here?
I will attach the .xml and meshes in a seperate post, to keep it clean here.
Thanks a lot in advanced for your help.
Best regards
Christoph
3 May 2019 at 12:43 #13451ChristophOtteBlocked<?xml version="1.0"?> <!-- The root node defines the global animation environment--> <Node name="root" dt="0.00001" gravity="0 -981 0"> <FreeMotionAnimationLoop/> <LCPConstraintSolver tolerance="1e-3" maxIt="1000"/> <!-- Defining the global collision pipeline: broad, narrow phase and response --> <CollisionPipeline depth="6" verbose="0" draw="0"/> <BruteForceDetection name="N2"/> <LocalMinDistance name="Proximity" alarmDistance="0.2" contactDistance="0.01"/> <CollisionResponse name="Response" response="FrictionContact"/> <MeshGmshLoader name="meshLoaderSphereCoarse" filename="SphereVolume.msh" /> <MeshGmshLoader name="meshLoaderSphereSurface" filename="SphereSurface.msh" /> <!-- Loading the meshes --> <MeshGmshLoader name="meshLoaderCoarse" filename="CylinderCoarse.msh" /> <MeshGmshLoader name="meshLoaderSurface" filename="CylinderSurface.msh" /> <!--Defining the first object: Cylinder phantom --> <Node name="Cylinder"> <!-- Defining the solvers --> <EulerImplicitSolver /> <CGLinearSolver iterations="15" threshold="0" tolerance="1.0e-9"/> <!-- Defining the geometry --> <Mesh src="@../meshLoaderCoarse"/> <!-- Defining mechanics and force fields --> <MechanicalObject name="myCylinder" src="@../meshLoaderCoarse" dx="0" dy="0" dz="0" rx="0" ry="0" rz="0" scale="1.0"/> <UniformMass totalMass="0.0002"/> <TetrahedronFEMForceField name="FEM" youngModulus="600" poissonRatio="0.49" /> <!--<LinearSolverConstraintCorrection />--> <PrecomputedConstraintCorrection /> <!--Defining the visual model of the cylinder --> <Node name="Visu"> <OglModel name="Visual" src="@../../meshLoaderSurface" /> <BarycentricMapping /> </Node> <!-- Defining the collision model of the cylinder --> <Node name="Collision"> <Mesh src="@../../meshLoaderSurface"/> <MechanicalObject src="@../../meshLoaderSurface" scale="1.0"/> <Triangle /> <Line/> <Point/> <BarycentricMapping /> </Node> <!--Adding fixed contraints to place the fixate the model on the floor --> <BoxROI name="box1" box="-1 -1 -1 1 0.1 1" /> <FixedConstraint indices="@box1.indices"/> </Node> <!--Defining the first object: Cylinder phantom --> <Node name="Sphere"> <!-- Defining the solvers --> <EulerImplicitSolver /> <CGLinearSolver iterations="15" threshold="0" tolerance="1.0e-9"/> <!-- Defining the geometry --> <Mesh src="@../meshLoaderSphereCoarse"/> <!-- Defining mechanics and force fields --> <MechanicalObject name="mySphere" src="@../meshLoaderSphereCoarse" dx="0" dy="5" dz="0" rx="0" ry="0" rz="0" scale="1.0"/> <UniformMass totalMass="0.00043"/> <TetrahedronFEMForceField name="FEM" youngModulus="600" poissonRatio="0.48" computeGlobalMatrix="false" method="polar"/> <!--<LinearSolverConstraintCorrection />--> <PrecomputedConstraintCorrection rotations="true" restDeformations="true" recompute="1"/> <!--Defining the visual model of the cylinder --> <Node name="Visu"> <OglModel name="Visual" src="@../../meshLoaderSphereSurface" color="red" dy="5" scale="1.0"/> <BarycentricMapping input="@.." output="@Visual"/> </Node> <!-- Defining the collision model of the cylinder --> <Node name="Collision"> <Mesh src="@../../meshLoaderSphereSurface"/> <MechanicalObject src="@../../meshLoaderSphereSurface" dy="5" scale="1.0"/> <Triangle /> <Line/> <Point/> <BarycentricMapping /> </Node> </Node> </Node>
4 May 2019 at 00:32 #13452ChristophOtteBlockedOk, unfortunately i’m not able to post the links here, because the server thinks it is spam. Is there any other way to attach the meshes?
best regards
Christoph
4 May 2019 at 07:19 #13453HugoKeymasterHi Christoph
Unfortunately without the mesh files it will be complicated for us to test.
Let us know if you are willing to share it.Modeling a deformable ball falling on a floor is a good first simulation testcase. As you noticed, even if the testcase seems simple, all numerical parameters must be carefully defined and not randomly chosen.
- using litterature value (with coherency to your mesh units) is right
- Rayleigh damping should be used carefully (by default use 0) since it adds numerical damping to your simulation without physical meaning. Too high damping would lead to an excessively-damped system and will prevent you from a accurate solution
- your time step must be also well-chosen to capture the physics. Note that the element size influences the limit time step possible. A simple but empiric method to select your time step is too choose a very (very) small time step and try to increase it while you get the same result.
- depending on the complexity of your physics and the refinement of your mesh, it might not always be possible to achieve interactive/real-time simulations.
- in simulations (like yours) based on Lagrange multiplier resolution, contactStiffness is actually not used: you perfectly understood the way constraints were solved !
- note that the Mass you are using is simplistic (see details about UniformMass here), I’d rather advise to go for a DiagonalMass or better (but more computationnally demanding) MeshMatrixMass
- finally, getting a “realistic” gelatin simulation, requires to have a realistic gelatin model. The TetrahedronFEMForceField is an FEM-based implementation of a linear elastic material. The deformation will remain elastic and it might be complicated to replicate a gelatin like motion. But this model is good to start. Later you could use more advanced models (like Hyperelastic ones).
I hope this helps.
BestHugo
PS: for meshes, you can include a html link towards a Drive or other file transfer tools
4 May 2019 at 08:10 #13456ChristophOtteBlockedHi Hugo,
thank you very much for the advice, this helps a lot. I will have a look for hyperelasticity.
Now i try again to attach the links to the files.
https://www.dropbox.com/s/ccjavls2igu3m7m/meshes.7z?dl=0
Best regards
Christoph
4 May 2019 at 09:37 #13458HugoKeymasterHi Christoph
I just tested the scene, it’s nice simulation that you got there! Congratulations!
You can try the advise mentioned (like indeed hyperelasticity and Mass) above to improve the simulation.
A finer mesh (for the ball) might also be necessary to better capture oscillations of the ball.I forgot to mention, that using a non-diagonal mass (MeshMatrixMass, improving accuracy on the mass integration) might make the pre-computation of the PrecomputedConstraintCorrection. In this case, you can go for an UncoupledConstraintCorrection. This UncoupledConstraintCorrection needs a compliance (data) to be set. You can choose compliance equals to the 1/vertexMass (vertexMass info in MeshMatrixMass).
See the difference between ConstraintCorrection in the online doc.Best,
Hugo
14 May 2021 at 09:05 #19443AryaBlocked@hugo Why is it that you suggested the compliance be set to 1/vertexMass, Can you please explain the theory behind this, as to my understanding the compliance*lagrange-multipliers just defines the corrective part of the constraint violation equation.
In my scene I have a deformable object and a STLIB floor and I have made the STLIB floor a child node of the deformable object but kept it as a seperate collision group in that body, So what I also wanted to know is that will the Solvers and ConstraintCorrectors I use for my deformable body also be used for the child node? And upon setting the compliance in UncoupledConstraintCorrection as 1/vertexmass, the compliance for me comes to around 7000, My scene crashes when doing so..Can you give me some clarity on how this may be tackled?
18 May 2021 at 19:15 #19479HugoKeymasterHi @aryakarani
The kind of ConstraintCorrection you use will affect how the compliance matrix W is built. As you can see from the equation:
W is homogeneous to A-1. In mechanics, A mostly include the mass and possibly stiffness matrix. Therefore, when using the UncoupledConstraintCorrection which is simplifying W as a diagonal constant matrix, I proposed to set the compliance to 1/mass_per_vertex. Do you see my point?
Regarding your scene, it is strange to me to set your floor as a child of the deformable object. Can you share your scene and explain what you expect from your simulation (deformable object / floor)?
Hugo
-
AuthorPosts
- You must be logged in to reply to this topic.