-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blips in simulated muscle variables #3285
Comments
@tkuchida Any idea what maybe wrong here or how to fix/adjust the example so that these curves are smooth? Thanks |
@aymanhab I don't have much time to dig into this; however, the Simbody kerplosion 💥 suggests something more serious than a non-smooth muscle force (even if that is, indeed, an issue). Looking at |
Thanks for the quick response @tkuchida This was created using the latest README which has the corrected inertias. I made a PR to include the TableReporter to demonstrate/reproduce. |
@mjhmilla Is there a chance you can explain what's wrong with the setup? Thanks |
I'm just about to board a plane for a holiday, so I'm out for next couple of weeks. If these are the facts:
then my guess is that something in the model could be putting noise at the position level. Since an elastic tendon muscle model has fiber length as a state, any noise at the position level will result in large force transients when the tendon is stretched. In contrast, a rigid tendon model force output will not be greatly affected by small amounts of position level noise. If I'm correct, then in both cases there will be small discontinuous changes in path length that show up in all simulations at the position level of affected muscles (with wrapping cylinders, perhaps). But what could be causing this type of error? @tkuchida mentioned that there are some bodies with zero inertia, this could be a place to look. Ton mentioned that there are wrapping cylinders used in the model, this could be another place to look. My suspicion is that the muscle wrapping routines are periodically not meeting the desired tolerance and are injecting position errors into the muscle path length. Because path velocity is usually solved separately, these defects might be large at the position level and very small at the velocity level. In contrast, if this is a problem of small masses, the defects would be continuous and would show up in the path length and path velocity outputs. If I had the time, I would look at the path length and velocity profiles of the affected muscles near the occurrences of the blips. After that I'd either update the inertia and/or wrapping (perhaps just eliminating the cylinder wrapping and associated muscles) to confirm the problem. If this is still unresolved when I get back from holiday I'll take a look at it. |
Thanks @mjhmilla Some clarifications:
I understand you're on vacation, just wanted to keep everybody in the loop regarding status. Thank you |
Hi! @aseth1 , @adamkewley and I have been investigating these Blips. It appears that the muscles have all the traits of a numerically stiff problem. Numerical stiffness is a nasty problem, which lacks a formal definition. It is actually directly defined in relation to explicit integrators. However, it is not necessarily an indication that there is something wrong with either the integrator, nor the model. Some differential equations are unfortunately numerically stiff, in which case perfectly fine explicit integrators are not performing well. You should be able to remove the blips by increasing the accuracy: A trademark of numerical stiffness is that this will hardly affect the integrator stepsize. Increasing the fiber-damping will also work, because it makes the problem less stiff, but you will also get a different response. We are still further investigating this issue :) |
Thank you very much @pepbos , @adamkewley , and @aseth1 for digging into this in more detail. There's a good chance that numerical stiffness is the cause: muscle modes are numerically stiff. From here it would be great to confirm that numerical stiffness is the source of the this problem: do the blips go away if one of OpenSim's implicit integrators is used (cpodes)? I see that cpodes is still in Simbody, so this test should be possible. If numerical stiffness is confirmed, the next step is to confirm the source:
If numerical stiffness is not confirmed:
I'm drowning in deadlines right now. I hope I can steal a little time to run this myself once I get a submission out the door in the next week or so. |
Just to add, from @aymanhab first message the statement appears: "Using rigid-tendon muscles shows no such blips and increasing damping to 10 or more eliminates the blips. The properties of the muscle model have little documentation of default values or acceptable ranges of values. " The damping parameter should be small as possible without introducing numerical problems during integration. Why should the damping parameter be small? If you look at the equilibrium equation, it should be clear: the damping element will act as a drag on the CE and slows it down. When the damping parameter is small (say 0.1, or 0.01) the simulated force-velocity curve of the model is very close to force-velocity Bezier curve. If a large damping value is used (like 10, which is ENORMOUS!) the CE won't be anywhere close to following the force-velocity Bezier curve: it will be much slower. This also points to another numerical improvement that can be made to the model: make a new force-velocity curve that compensates for the damping term, at least at maximum activation. This would allow larger damping coefficients to be used without killing the accuracy of the model. The caveat is that this compensation would only be perfect at maximum activation, unless the numerical damping term is also made to scale with activation. |
Just as an update @mjhmilla , we (@aseth1 , @pepbos , and me) are currently looking into this in parallel with other changes (e.g. perf-optimizing the underlying bezier curve implementation: #3481). Apologies if we're a bit slow on responses (I tend to scour GitHub in very sporatic waves) but, from what I understand, we are currently doing the basic background work (e.g. reading your original paper, but also figuring out why models like Rajagopal2015 use a damping parameter of It might be an idea for us to shoot you an email or at least set up some kind of IM system (teams/slack), or a call, once we start to have concrete ideas about what we think might be a good idea! |
Dear @adamkewley , @aseth1, @pepbos, That sounds great. The paper isn't going to tell you much about the Bezier curve implementation, for that you're going to need to look at SegmentedQuinticBezierToolkit's doxygen and associated code. I'd be quite happy to chat muscle code with you when you're ready. In regards to the two issues you described. I assume that the priorities are #1 reduce the chatter, #2 make the curves faster. 1. I'm quite sure we can remove the chattering Ton observed using these two changes: 2. Curve performance improvements: |
@mjhmilla hi, Just to reply on how we verified that the muscle is very likely numerically stiff:
Some of the solutions we are currently exploring for this problem: The fiberdamping has a major effect on the numerical stiffness. We would love to investigate the range of permissable fiberdampings, and how to adjust the curves. As a first step we got our hands on the original data used in 2013, but it would be great if we can sent you an email or something once we have a plan of attack. Curve performance improvements is something we can also pursue. Point 2a makes a lot of sense. |
Hello @pepbos, You've checked all of the numerical boxes for numerically stiff problem. The last time I talked to Sherm about this very issue he mentioned that the numerical integration experts just use 4: if an implicit integrator is much faster than an explicit integrator the problem is numerically stiff. That reminds me: what is the ratio of the tendon slack length to optimal fiber length? Numerical stiffness increases as tendonSlackLength/optimalFiberLength becomes small. According to the build_and_simulate_arm_modified.txt file from Ton's email the optimal fiber length is 60 cm long, and the tendon is 55 cm long. So ...
Ok onto the specifics of your message: The fiberdamping has a major effect on the numerical stiffness. We would love to investigate the range of permissable fiberdampings, and how to adjust the curves. As a first step we got our hands on the original data used in 2013, but it would be great if we can sent you an email or something once we have a plan of attack. I could send you a Matlab prototype to generate the force-velocity curve that I'm thinking of, given a specific fiber damping value. To really test this properly, we'll need to simulate a series of ramp shortening experiments to make sure that the force-velocity curve produced when replicating a force-velocity experiment actually matches what we want. Curve performance improvements is something we can also pursue. Point 2a makes a lot of sense. In that case either option 2a or 2c would be the best long term solution. |
Hi @mjhmilla , The ratio of tendonSlackLength to optimalFiberLength is indeed just below one (~0.92) in this case, and switching to a rigid tendon seems to give a similar response, and greatly reduces the numerical stiffness. However, looking at your paper from 2013 ("Flexing computational muscle"), I concluded that it was found that a rigid-tendon gives a larger modeling error, and would be a less accurate representation of a real muscle. In that paper, as well as others, I gathered that the muscle dynamics behave as a numerically stiff system. I therefore assumed that the rigid-tendon muscle is sort of checked off the list as a solution, because it no longer matched the experiments accurately.
Still, I assume that some muscles will require a non-rigid-tendon model, for which the numerical stiffness poses a challenge. In that regard, getting back to your other points: If the tendonSlackLength/optimalFiberLength is above 1, the tendon damping model I mentioned may also be helpful. Would it be possible for us to access this damped tendon model? It would be interesting to see how big the effect is on the numerical stiffness and response. The pennation model can also make for a numerically stiff problem. But as I see from the file, there is no pennation. The pennation angle dynamics that I see being used is given by I could send you a Matlab prototype to generate the force-velocity curve that I'm thinking of, given a specific fiber damping value. To really test this properly, we'll need to simulate a series of ramp shortening experiments to make sure that the force-velocity curve produced when replicating a force-velocity experiment actually matches what we want. The effect of fiber damping seems an interesting avenue to explore: We would be very interested in a matlab script outlining the curve generation! |
Reported by Ton on the user forum at
https://simtk.org/plugins/phpBB/viewtopicPhpbb.php?f=91&t=15001&p=0&start=0&view=&sid=05adfb8d846e5cd0e9f3b37ed5d3e37d
Preliminary investigation suggests this is related to the muscle model rather than faulty reporting. Using rigid-tendon muscles shows no such blips and increasing damping to 10 or more eliminates the blips. The properties of the muscle model have little documentation of default values or acceptable ranges of values. This could be a bug or just picking bad values to initialize the muscle model in this example. The same issue is reported for Millard and Fregly muscle models in case that helps.
The text was updated successfully, but these errors were encountered: