Home › Forum › SOFA › Using SOFA › SofaPython Simulation NaN'ing after runtime model changes
Tagged: 64_bits, Compliant, Linux_ubuntu, segmentation fault, SOFA_1612, SofaPython
- This topic has 1 reply, 2 voices, and was last updated 6 years, 2 months ago by Hugo.
-
AuthorPosts
-
17 July 2018 at 11:38 #11347mmabroukBlocked
Hello,
I am modeling a molecular system (protein folding) using SOFA. The model is a simple spheres and springs model. It is implemented using SofaPython. After the simulation starts, I add and remove springs on runtime using SofaPython depending on the state of the simulation. Some of the springs are 1D implemented as UniformCompliances or MeshSpringForceField, while others are 6D implemented as DiagonalCompliances from the Compliant plugin. I use the CompliantImplicitSolver as the main solver of the simulation.
My simulation worked very well before starting to use DiagonalCompliances (for 6D springs). But as soon as I start using them, I have the following problem:
The simulation would go to NaN or end in a segmentation fault as soon as I make runtime spring changes to my model (remove or add any type of springs). From my limited understanding, the issue seems to lie in the AssemblyVisitor in the Compliant plugin. Somehow the changes in the model are not propagated to the AssemblyVisitor:assemble() function.I have tried running obj.init() on every part of my model after changing the model with no avail. Note here that the simulation works just fine if I don’t make any modification to the model on runtime.
Here is the spring update function I use:
def update_springs_in_sofa(self, springs): """ Update the springs in sofa Args: springs: list({res1, res2, rest_length, compliance, damping}) self.contact_springs_node: The node in sofa """ compliances = " ".join([str(spring["compliance"]) for spring in springs]) dampings = " ".join([str(spring["damping"]) for spring in springs]) edges = " ".join(["%s %s" % (spring["res1"], spring["res2"]) for spring in springs]) rest_lengths = " ".join([str(spring["rest_length"]) for spring in springs]) edgesettopologycontainer_node = self.contact_springs_node.getObjects()[ 1] distancemapping_node = self.contact_springs_node.getObjects()[2] compliance_node = self.contact_springs_node.getObjects()[3] compliance_node.findData("compliance").value = compliances compliance_node.findData("damping").value = dampings edgesettopologycontainer_node.findData("edges").value = edges distancemapping_node.findData("restLengths").value = rest_lengths self.contact_springs_node.init()
Any help or pointers would be greatly appreciated!
Yours,
Mahmoud28 August 2018 at 22:36 #11749HugoKeymasterHi Mahmoud
I am sorry for the delay of my reply but I am really no expert of the Compliance/Flexible plugin. I would guess that your issue is due to the fact that the DiagonalCompliances (for 6D springs) does not support updates (addition or removal of springs).
Do you have a very basic example of it?
Best,
Hugo
-
AuthorPosts
- You must be logged in to reply to this topic.