error in CMC and forward dynamics: causes?

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Will Johnson
Posts: 3
Joined: Thu Aug 23, 2007 7:52 pm

error in CMC and forward dynamics: causes?

Post by Will Johnson » Mon Nov 10, 2008 6:58 pm

I've been developing a rat hindlimb model with custom knee joints, using OpenSim v1.7. The model performs as expected through the workflow up until CMC, at which point I get the following error in what I assume is the forward integration step:

rdCMC.computeControls: t = 0.23
RKF.step: NAN in state 1 at time 0.23 (dt = 1e-006)

The error repeats with dt decreasing until it reaches the minimum step size. The set of errors is then repeated many times without crashing the program.

My first thought is that there are NaN's in the kinematic input, but I've checked the output of the RRA steps (i.e. *_Kinematics_q.sto), and all coordinates have the correct values. My second thought is that a segment mass or inertia has somehow been set to zero, but I've double checked those as well and they're all positive except for the ground segment, which is zero in some of the example models and doesn't cause the same problem.

The only obvious difference between my input files and the examples is in the motion file input to the RRA step, which in the example includes ground reaction force data. Is it necessary to include the grf data in the motion file or is it sufficient to specify it in the external loads file? In the examples it's included in both inputs.

The same error occurs when any control input is used with the experimental grf data in the forward dynamics step.

I'm currently using "artificial" standing data as a test, that is many rows of identical coordinates, so all velocities and accelerations are zero. It doesn't seem like that should be a problem though.

Anyone encounter a similar error, or do any developers have insight into what commonly causes that error? Any help would be appreciated.

User avatar
Lisa MacFadden
Posts: 14
Joined: Mon Aug 20, 2007 3:01 pm

RE: error in CMC and forward dynamics: causes?

Post by Lisa MacFadden » Fri Apr 10, 2009 10:54 am

Hi Will,

I am having this same problem and was wondering if you had figured out how to overcome the RKF.step NAN error. My error is in state 0 instead of in state 1.

Cheers
Lisa

User avatar
Will Johnson
Posts: 3
Joined: Thu Aug 23, 2007 7:52 pm

RE: error in CMC and forward dynamics: causes?

Post by Will Johnson » Fri Apr 10, 2009 12:41 pm

Never did solve this problem completely. I'm developing a rat model and when I initially had this problem I had a couple muscles with approximately zero tendon length and modeled them with zero length. The musculotendon dynamics require dividing by tendon slack length though, so obviously that's where my NaNs were coming from. I gave all my muscles a minimum tendon length of 1mm, and still get a similar problem but now the NaN's start to crop up in state 37 for example, which is a muscle length state.

I suspect my current problem is a scaling issue. Even non-zero short tendon slack lengths could cause some instability depending on how the musculotendon dynamics are implemented. One potential solution is to scale everything up and use a giant monster rat model but I haven't gotten around to doing that yet, I've just gone with static optimization for the time being, it gives adequate results for my current purposes.

From what I recall another thing that can cause this problem is not correctly defining segment masses or inertias.

User avatar
Lisa MacFadden
Posts: 14
Joined: Mon Aug 20, 2007 3:01 pm

RE: error in CMC and forward dynamics: causes?

Post by Lisa MacFadden » Fri Apr 10, 2009 12:46 pm

Will,

Thanks for your reply. I am using a feline hindlimb model I developed.

1. I am using the wrong muscle model (I am using model 4 instead of modal 9)
2. I have not properly defined the dynamic muscle properties in the model.

Since my error is state 0 instead of state 1, I am assuming that my error is in computing muscle activation instead of muscle length, but will also look into the length problem as you suggest.

Thanks again!
Lisa

User avatar
Will Johnson
Posts: 3
Joined: Thu Aug 23, 2007 7:52 pm

RE: error in CMC and forward dynamics: causes?

Post by Will Johnson » Fri Apr 10, 2009 12:56 pm

I recall trying models 4 and 9 (Schutte and Thalen I believe) and getting slightly different errors, but in the same general place, so I suspect the root cause is the same.

Are you getting errors in RRA (with only generalized torque actuators) as well as CMC? If that's the case you may have a problem other than muscle definitions as the musculotendon dynamics wouldn't come into play at that point.

Not defining some of the dynamic muscle properties, or using approximate values definitely seems like it could cause the problems you're seeing. The dynamic equations can be pretty sensitive to some parameters (e.g. optimal fiber and tendon lengths).

will

User avatar
Lisa MacFadden
Posts: 14
Joined: Mon Aug 20, 2007 3:01 pm

RE: error in CMC and forward dynamics: causes?

Post by Lisa MacFadden » Fri Apr 10, 2009 1:00 pm

Thanks for the info. I have successfully run Scaling, IK, ID, static opt, and RRA and now just have issues with CMC. So I think it has to be the muscles, and since I am not having issues with Static Optimization I think it has to be some of the dynamic properties including time constants, etc that are causing my simulation to crash.

I am pretty confident in my pennation angle, optimal fiber length, tendon slack length, and max isometric force, however i think the dynamic properties of the muscles are undefined which could cause problems. I seem to recall in SIMM that it would cause errors if you ran simulations without those properties properly defined when you were running even static optimization.

I will probably get around to changing those parameters over the weekend and let you know if I have success!

Thanks for your suggestions and sharing your experiences with me!

Lisa

User avatar
Lisa MacFadden
Posts: 14
Joined: Mon Aug 20, 2007 3:01 pm

RE: error in CMC and forward dynamics: causes?

Post by Lisa MacFadden » Fri Apr 10, 2009 1:18 pm

Will,

Just updated all of the dynamic parameters in muscle model 4 (time scale, activation1, and activation 2) and now that problem has disappeared. Now the optimization cannot find a solution, but at least that solved the previous problem

Thanks for your help
Lisa

User avatar
Tim Dorn
Posts: 125
Joined: Tue Feb 26, 2008 10:14 pm

RE: error in CMC and forward dynamics: causes?

Post by Tim Dorn » Thu Sep 10, 2009 12:08 am

Following up on this integrator error:

Where would be the best place to start "debugging" the model/simulation if we get an integration error like the one below?

RKF.step: NAN in state 1 at time 0.23 (dt = 1e-006)

I'm having trouble locating the start point of the error. It would be usful to have an idea as to how this comes about.

Tim

User avatar
Ayman Habib
Posts: 2235
Joined: Fri Apr 01, 2005 12:24 pm

RE: error in CMC and forward dynamics: causes?

Post by Ayman Habib » Sat Sep 12, 2009 12:06 am

Tim,

Whenever I see a NAN particularly in a state that corresponds to a "u" I'd suspect something wrong with either the masses/inertia that leads to a force being applied to a massless body or something wrong with the forces being applied.

Unfortunately some of these messages are benign and are not a problem on their own since they are issued while the integrator is just "trying" to take a step, however in many cases the integrator responds by cutting the step size and proceeds successfully.

-Ayman

User avatar
Daniele Tregnaghi
Posts: 19
Joined: Tue Sep 22, 2009 12:45 am

RE: error in CMC and forward dynamics: causes?

Post by Daniele Tregnaghi » Wed Oct 28, 2009 3:47 am

Hi, I've a problem during the execution of CMC.
The following message appear: rdCMC.computeControls: t = 0
WARN- small force range for tfl_r (0.222173 to 0.232212)
SimTK Exception thrown at InteriorPointOptimizer.cpp:249:
Optimizer failed: Ipopt: Maximum iterations exceeded (status -1)
OPTIMIZATION FAILED...
rdCMC.computeControls: WARN- The optimizer could not find a solution at time = 0.000000.
If using the fast target, try using the slow target.
Starting at a slightly different initial time may also help.
What can I do?
Thanks

POST REPLY