Skip to content
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

Thelen2003Muscle::initMuscleState updated. Algorithm changes: bisecti… #2684

Closed
wants to merge 0 commits into from

Conversation

mjhmilla
Copy link
Contributor

@mjhmilla mjhmilla commented Mar 4, 2020

Fixes issue #<issue_number>

Thomas G's initialization problems (discussed in the meeting 3 March 2020)

Brief summary of changes

  1. Algorithm change : bisection used for good initial conditions for the Newton method.
  2. Algorithm change : A text book Newton method (not the previous version with the line search) polishes the root off.
  3. Numerical change: Problems were being caused earlier when the Newton method encountered a zero gradient: either due to a slack tendon (this case was handled before) or when fv goes to zero (an un handled case). With Thelen's force-velocity curve fv can go to zero quite easily if activation is low. To prevent the gradients from going to zero (and the ensuing Newton method problems) I've constrained the tendon strain and fv to be 10 x larger than the solution tolerance. This is very small, but large enough to prevent these problems.

Testing I've completed

Ran all of the tests in release and debug mode.

Looking for feedback on...

  1. It would be great if Thomas G tested this out on the case that was failing.
  2. The method: the variable names do deviate from the camel_case convention. Shall I update them them?

CHANGELOG.md (choose one)

  • no need to update because: this is deep in the bowels of the code.

This change is Reviewable

Copy link
Member

@chrisdembia chrisdembia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wary of making such big changes to the algorithm; is there a risk that we create other issues that didn't exist before? What about fixing only the force-velocity issue?

Reviewable status: 0 of 1 files reviewed, all discussions resolved

@mjhmilla
Copy link
Contributor Author

mjhmilla commented Mar 5, 2020

Hey Chris,

I see above travis-ci and appveyor had some complaints: is this something I need to worry about? I looked through the details and didn't find anything obvious.

As for the big changes to the algorithm: in principle bisection+Newton should be more robust than the variable-step Newton method I had in there. This is actually what I've been using since my time at Stanford (and perhaps before I left). I originally used a hand-made variable step Newton method (e.g. this is something I made up!) in an effort to save a bit of computation. In hind-sight this was a bad decision. That's why I updated the root solving method.

If you wanted to just fix the force-velocity issue, I think that is straight forward: the "auto velocityFunc" needs to be updated. That's easy to do. In any case, it would be valuable to have the specific case where initMuscleState was failing: then I could verify (in debug mode) how it was failing, we can verify that the fix works, and include that as a test case. Without this new test case you actually cannot be sure that anything we've done is an improvement.

So do you have the test case?

@aseth1
Copy link
Member

aseth1 commented Mar 5, 2020

@mjhmilla @chrisdembia I am not fond of the idea of "fixing" the algorithm when it was not clear if this was even the issue. For example, I used Scott U's case and I was not seeing fv (if you mean the force-velocity multiplier) going to zero. Let me know if you want me to create a separate PR for a test case or add it in here. I should be able to do that this weekend.

@mjhmilla
Copy link
Contributor Author

mjhmilla commented Mar 7, 2020

@aseth1 : Please do add the test case that was failing with the earlier version of initMuscleState in Thelen2003Muscle. I don't think we will reach a fix that everybody is happy with until this test case is in place.

@aseth1
Copy link
Member

aseth1 commented Mar 8, 2020

@mjhmilla see #2687 for the related test case. Feel free to merge and change with this PR as you see fit.

@mjhmilla
Copy link
Contributor Author

mjhmilla commented Mar 9, 2020

@aseth1 Thanks! I'll try to sneak some work on this in the coming week.

@mjhmilla
Copy link
Contributor Author

I have not forgotten about this, but my work on this will be delayed: I've been dropped into a project with paper deadline in just over 2 weeks. I'm currently working 7 days a week and I'm still not certain that we will make the deadline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants