Forum Replies Created
-
AuthorPosts
-
SarahBlocked
Hi Hugo and Erik!
Thanks for all the tips, has been helpful. Also it is very cool to see the documentation and other options expand. Yes, I’ll close the topic. I think it has been resolved.Best,
Sarah
SarahBlockedHi Hugo,
I looked into some of the code of the AdvancedTimer.cpp. This is what I found:
json TimerData::createJSONArray(int s,json jsonObject, StepData& data) { double value = 0; ctime_t ttotal = stepData[AdvancedTimer::IdStep()].ttotal; // Level : value = strToDouble(getVal(data.level), 4); jsonObject["Level"] = value; // Start value = strToDouble(getTime(data.tstart, data.numIt), 4); jsonObject["Start"] = value; // Num value = strToDouble(getVal(data.num, (s == 0) ? 1 : nbIter), 4); jsonObject["Num"] = value; // TMin value = strToDouble(getTime(data.tmin), 4); jsonObject["Min"] = value; // TMax value = strToDouble(getTime(data.tmax), 4); jsonObject["Max"] = value; // Mean double mean = (double)data.ttotal / data.num; value = strToDouble(getTime((ctime_t)mean), 4); jsonObject["Mean"] = value; // Dev value = strToDouble(getTime((ctime_t)(sqrt((double)data.ttotal2/data.num - mean*mean))), 4); jsonObject["Dev"] = value; // Total value = strToDouble(getTime(data.ttotal, (s == 0) ? 1 : nbIter), 4); jsonObject["Total"] = value; // Percent value = strToDouble(getVal(100.0*data.ttotal / (double) ttotal), 4); jsonObject["Percent"] = value; return jsonObject; }
So the Total (ttotal) is right at least, that the mean is the one that takes the num into consideration. It would seem most clear if num represented the number of itteration but it is also remarkable that ‘nbIter’ is a value and that in the folowing part of the code also introduces ‘numIt’. So am a bit confused about if these three values (num, nbIter, numIt) are referring to the same thing? Also I don’t quite understand yet why NUM is different for the different components in the example, as unless it just did multiple itterations of one of the component they should be the same right. And this makes me wonder wheter it is actually referring to the itterations of the simulation as a whole, or to something different.
class ValData { public: int num, numIt; double vmin; double vmax; double vtotal; double vtotal2; double vtotalIt; int lastIt; ValData() : num(0), numIt(0), vmin(0), vmax(0), vtotal(0), vtotal2(0), vtotalIt(0), lastIt(-1) {} };
So far I ran my simulation, printing the log at every itteration and with that all my NUM are equal to 1, whilst with that avoiding the problem I don’t think the question has completely been answered yet. The interpretation of the statistics may be a useful question or comment to add in the documentation, in particular for the example placed there, as I think this could help many. Thank you! Hope that this is of use to people in the future.
Best,
SarahSarahBlockedHi!
Was just wondering if it would be better to open my previous post as a new topic. Would be great to get to understand the Advanced Timer more.Best, Sarah
SarahBlockedHi Jerry,
It seems to me that you’re just using the export tab in SOFA. But using monitor you export files independent of the export tab in SOFA.
You can use montior as such and then you can choose if you want pos, vel, or force for specific vertices.node.createObject('Monitor', name="filename", indices='@boxROI.indices', template="Vec3d", showPositions=True, PositionsColor="1 0 1 1", ExportPositions=False, showVelocities=False, VelocitiesColor="0.5 0.5 1 1", ExportVelocities=False, showForces=True, ForcesColor="0.8 0.2 0.2 1", ExportForces=True, showTrajectories=False, TrajectoriesPrecision="0.1", TrajectoriesColor="0 1 1 1", sizeFactor="1")
You can find the files under the ‘bin’ in sofa where you can also find runSofa. Hope that helpd.
Best,
Sarah
SarahBlockedHi @Hugo,
I added a non-zero Rayleigh stiffness as else using the trapezoidal scheme my object completely lost its shape, it became unstable. Upon slight damping (as I set in the integration scheme it remained stable). I found this useful link, in particualr the second comment about the EulerImplicit (I’m still rather new to FEM) and it makes sense that a smaller time step will lead to less dissipation and thus a higher amplitude. But what about the frequency? The trapezoidal scheme seems to make sense, but the Newmark still puzzles me would think it would show results similar to both the finer time step as well as to the trapezoidal scheme.
–Much have the question has been answered π
–There are still remaining questions I have:1. Mainly is the higher frequency at a finer timestep also resulting directly from the ImplicitEuler?
2. And could there be any particualr reason that the Newmark is causing such a different response?Hope that is clear. Thanks for the tips and ideas!
Kind regards,
Sarah
SarahBlockedHi Jerry,
I had a similar issue using monitor but found that in using BoxROI as found in the documentation and then referring to those indices in the monitor
'@boxROI.indices'
(where ‘boxROI’ is the name of your object ‘BoxROI’) was an easy way for me to solve it. Hope that helps.Kind regards,
Sarah
SarahBlockedHi Hugo,
This is very interesting. I can imagine that the dissipative nature of Euler scheme is causing this.. I applied these different solvers and got the results as shown in the image. Newmark doesn’t seem to apporximate the situation well. The Euler with trapezoidalScheme does better, but isn’t more dissipative…
In light of this however it does make sense that finer time steps would have less dissipation, as in the image in the initial post. But it is still rather puzzeling.
(in this simulation I used a rayleigh stiffness of 0.001 and mass of 0, this as when both set to 0 the trapezoidal scheme didn’t give stable results.)
Many thanks!
Sarah
SarahBlockedI’m not sure if I can answer all your questions, as I’m not a SOFA expert. But in my experience
1. I don’t think it is not necessary to use a.scn
file.2. I don’t know if you would need to set
RequiredPlugin
in a.scn
file, but from the error message it seems as though you should. And similarly for.py
file but than in pythonrootNode.createObject('RegquiredPlugin', pluginName='...')
3. It is fine to start .py files with createScene(node) and you don’t need to use a PythonScriptController for the initial build up of the scene but can use it to control various parametrs during the simulation.
I’m not sure why the collision in
.py
was not detected. But maybe you could check that is referring to the correct plugin in python and that it can find it, you could also add the SofaPython Plugin but I don’t think it is necessary. I’m not an expert, but I hope this helps a little.SarahBlockedHi Hugo,
I thought I had responded earlier, but for some reason my posts weren’t coming through as they were being recognized as spam (but got that figured out now!).
To answer some of your questions, I was using UniformMass, but see the same behaviour although with a larger displacement for the DiagonalMass. I don’t have any plasticity set, am just using the TetrahedronFEMForceField and besides gravity(set to 10m/s^2 for simplicity) have no other forces acting on the scene. The total mass of the slab is 0.1kg, all my units are in SI. Furthermore, in the graph it should say “(1N)”.
Here is my code. I’ve found that when setting the rayleighMass and the rayleighStiffness to 0.0063 the system is critically damped for dt=0.001 when using mesh, flat2 which is a little coarser then the one from the previous picture, but gives very similar results.
Here is the code using flat2. With the link to flat2.vtkimport Sofa import os #Location of Meshes and objects path = 'details/data/mesh/' volumeMesh='flat2.vtk' def createScene(rootNode): ################# ROOTNODE ################# rootNode.findData('gravity').value='0 0 -10' rootNode.findData('dt').value='0.001' rootNode.createObject('RequiredPlugin', name='soft', pluginName='SoftRobots') rootNode.createObject('RequiredPlugin', name='SofaSparseSolver', pluginName='SofaSparseSolver') rootNode.createObject('DefaultAnimationLoop') ################# flat ################# #Create the flat node, load, store and build the mesh into a Mechanical Object flat = rootNode.createChild('flat') flat.createObject('MeshVTKLoader', name='loader', filename= path + volumeMesh) flat.createObject('Mesh', src='@loader', name='container') flat.createObject('MechanicalObject', name='tetras', template='Vec3d', showObject='true', scale='1') flat.createObject('UniformMass', totalMass='0.1') flat.createObject('TetrahedronFEMForceField', template='Vec3d', name='FEM', method='large', poissonRatio='0.49', youngModulus='1000000') flat.createObject('EulerImplicit', name='odesolver', rayleighStiffness="0.00", rayleighMass="0.00") flat.createObject('SparseLDLSolver', name='directSolver') ################# STATIC BOX ################# flat.createObject('BoxROI', name='boxROI', box='0 0 0 0.01 0.01 0.01 0 0.09 0 0.01 0.1 0.01 0.09 0 0 0.1 0.01 0.01 0.09 0.09 0 0.1 0.1 0.01', drawBoxes=True) flat.createObject('FixedConstraint', name='FixedConstraint', indices='@boxROI.indices') ################# MONITOR ################# flat.createObject('Monitor', name="monitor-displacement-faceNode", indices="45", template="Vec3d", showPositions=True, PositionsColor="1 0 1 1", ExportPositions=True, showVelocities=False, VelocitiesColor="0.5 0.5 1 1", ExportVelocities=False, showForces=True, ForcesColor="0.8 0.2 0.2 1", ExportForces=True, showTrajectories=False, TrajectoriesPrecision="0.1", TrajectoriesColor="0 1 1 1", sizeFactor="1")
Also when I used the CGLinearSolver, for each order of the timestep two oscillations occured; one that was damped and one that remained fluctuating. The latter had a period which was proprtional to the size of the timestep (7 sec, 0.7 sec and 0.07 sec[0.01, 0.001, 0.0001 respectively]), this oscillation however arises because of the itterative solver and doesn’t explain the previous image.
Would be curious to hear your thoughts on where this oscillation could be coming from. Could there be some other form of numerical damoing involved?
16 April 2020 at 18:29 in reply to: [SOLVED] Attach constraint and Fixed constraint difference #15797SarahBlockedHi @Hugo,
I want to build a soft Robot that learns to walk with an optimization algorithm. Currently I’m just wanting to study force propagation in various meshes. So the FixedConstraint should be fine. Thanks! It makes sense and in my tests yield similar results! π
Thanks!16 April 2020 at 14:34 in reply to: [SOLVED] Attach constraint and Fixed constraint difference #15785SarahBlockedHi!
Building upon this topic. I’ve been looking into some of these constraints as well and was using the RestShapeSpringsForceField myself in order to constrain some points. But read in this topic that this would not ‘respect’ the physics: https://www.sofa-framework.org/community/forum/topic/fixed-constraints-not-so-fixed-with-genericconstraintsolver/
Am trying to figure out what the best constraint is to apply to get physical results upon deformation of the mesh object. Would you recommend using the FixedConstraint instead of the RestShapeSpringsForceField, or would it be better to use Attach constraint?Furthermore I was wondering about the constraint solvers the GenericConstraintSolver seems like it would be applicable to any of these three forms of constraints, but what would the reason for using the LCPConstraintSolver be? Would that be more for collision and friction? Thanks for your input the forum has been a really useful tool for me!
Sarah
SarahBlockedHere is the link to the image:
DisplacementSarahBlockedThank you Jean-Nicolas,
Also thank you for the addition you made to the scenegraph. Wasn’t getting them all to run in Sofa yet. But I’ll figure. I’m pretty sure it’s a mesh issue, as it seems to be more generic than just my cube. And using a simple flat mesh under gravity I found some similar issues. A sphere indeed may do well to, but would think it easier to mesh a cube in a symmetric way. I will do a more finer study of the meshes I’m using and with that further explore this issue. Thanks for your support. Have a good Easter weekend.Sarah
SarahBlockedHello again,
Found that this last problem with the rank deficiency was caused because I had also turned the subset of nodes into a Mechanical Object. Which is not necessary. Will run now that I removed that. But still shows rotation.. Am now trying option 3 in combination with 1 as lowering the posson ratio didn’t seem to reveal much change to the issue of rotation the code I have for the various parts is as follows now.
here’s the cavity:cavity = cube.createChild('cavity') cavity.createObject('MeshSubsetEngine', name='engine', inputPosition='@loader.position', inputTriangles='@loader.triangles', inputQuads='@loader.quads', indices=listNodes) cavity.createObject('Mesh', src='@engine', name='topo') cavity.createObject('SurfacePressureConstraint', name='SurfacePressureConstraint', template='Vec3d', value='0.0', triangles='@topo.triangles', valueType='volumeGrowth', flipNormal=True)
Thanks! some tips on the
TetrahedronHyperelasticityFEMForceField
would also be appreciated but for now am going through the example scenes and the forum. πSarahBlockedHi @jnbrunet,
Thank you for your suggestions!
Have been extracting the propper nodes in order to directly apply the surface pressure to the volume mesh. THis is a promising idea. However, I fell upon a different error… Mainly that SOFA says that [SparseLDLSolver] invalid linear system to solve. Please ensure there are enough constraints (not rank deficient). This got me thinking that because I chose those direct nodes I may causing the data issues as these are both the points where the force is being applied to and calculated for.. Does that make sense?
I will explore the scene some more, but thought if I keep you all updated some more ideas may pop up!Many Thanks!SarahBlockedI just tried the triangular squares and found the same behavior again..
SarahBlockedHi Hugo thanks for the update. It can be quite challenging to make hexahedron meshes in gmsh for more complex geometries (such as one with a cavity). Would MeshLab be a useful alternative as I don’t have CGAL plugin?
Are you saying I cannot use trianglar mesh in this simulation, because the tetras are angles out and thus generate a momentum… I’m guessing that could mean one built up out of squares which are each split into two tetras would work better. Thanks a lot for your help! Hope I can get this figured out soon!
SarahBlockedHi!
I relooked at it, and am thinking it may indeed be an issue with the VTK, file.. Do you you have any recommendations for ensuring that one is right. As this changes the situation upon rotation whilst when rotating the stl of the cavity it behaves in the same way as before. I made it in gmsh are there specific things to watch out for besides the coarseness and the normals of the mesh. Thanks for your help and support! Hope you are doing well in the midst of these strange times.SarahBlockedHi Hugo,
I’m using a UniformMass. I checked that face normals are all pointing outwards and then tried the scene with a really basic symmetric mesh (8 triangles on every face of the cube) which I made in gmsh and found the same issue.
Then I opened the turtorial in the SoftRobotics Component for the Pneumatic Gripper in order to check if the system in the turtorial would face the same issue and it did.
And because I was having the issue for my meshes even when I built them up symmetrically and then found the meshed in the turtorial yield similar behavior I got to think it may be more then a mesh issue.Maybe there is an alternative method to build up the pneumatic actuator? Or is there a way in which I can figure out what the issue is?
Here are my files. With a little bit more fine mesh then the one previously discuused.A well as that I placed the cube on a surface.
https://github.com/ALFsarah/SOFA-cube-pneumatic-actuatorThank you for your support.
SarahBlockedYou’re right, I got it to work in the example. But haven’t invested a lot of time to further apply it to my simulation. Thanks
SarahBlockedI found that the monitor is working rahter well now. It exports all the files in the bin and only takes the data points I’m concerned with. The VTKExportr is currently running but consistently exports at the beginning and not at the end even when setting exportAtEnd=”1″, which isn’t very helpful when wanting look at the animation. The gnuplots export well in SOFA. So, I think I’ve found what I’m looking for for now. Despite not having VTKExport doing exactly what I would want yet, I was able to retrieve the data I was looking for. Thank you for the tip!
SarahBlockedNo problem, I can imagine it may cause some delays.
I’m using a python file for my simulation. And would like the exports to happen when I end the animation. And preferably as a txt or csv file so I can use them to plot the data.
Thank you very much!
Sarah -
AuthorPosts