Page 1 of 1

Error with force velocity curve in Millard_equilibrium model

Posted: Fri May 22, 2020 7:24 am
by saurabh
Hi All,

When loading the attached model file, I am getting the following error:

Code: Select all

SimTK Exception thrown at SmoothSegmentedFunctionFactory.cpp:303:  Error detected by Simbody method 
SmoothSegmentedFunctionFactory::createFiberForceVelocityCurve: ForceVelocityInverseCurve: dydxNearE must be greater than or equal to dydxEand less than fmaxE-1 (0.4000) 
(Required condition '(dydxNearE >= dydxE && dydxNearE < (fmaxE-1))' was not met.)
But in the model, I have kept following parameters for force-velocity curve:
eccentric_slope_at_vmax = 0
eccentric_slope_near_vmax = 0.09
max_eccentric_velocity_force_multiplier = 1.4

Clearly these parameters satisfy the conditions. Is there a bug? How can I fix it?

Thanks,
Saurabh

Re: Error with force velocity curve in Millard_equilibrium model

Posted: Sun May 24, 2020 5:07 am
by tkuchida
The parameters you quoted (for "LeftMuscle") seem to be appropriate, but the issue may be with "RightMuscle". For example, on line 280 you are providing a value for a "min_concentric_slope" property, but no such property exists. If you are modifying the model file in a text editor, you can use the XML Browser in the GUI (Help menu -> XML Browser -> select "ForceVelocityCurve" or "ForceVelocityInverseCurve" for the Class Name) to find the appropriate XML code. Also see the documentation here:
- ForceVelocityCurve: https://simtk.org/api_docs/opensim/api_ ... ml#details
- ForceVelocityInverseCurve: https://simtk.org/api_docs/opensim/api_ ... ml#details

Re: Error with force velocity curve in Millard_equilibrium model

Posted: Sun May 24, 2020 10:49 am
by saurabh
Dear Thomas,

I have changed the model to have identical properties for the left and right muscles. The problem still persists. I have also tried changing force-velocity curve parameters in other models which uses Millard_equilibrium muscles and got the same error there too.

Interestingly, I have found that when I put eccentric_slope_near_max >= 0.1, there is no such error. But for less than 0.1, it shows error.

I have also tried to change the force-velocity curve in python using opensim.ForceVelocityCurve(), there I don't get any error, but when it is added to the Millard_equilibrium muscle the error shows up. Not sure why this is the case.

Thanks,
Saurabh

Re: Error with force velocity curve in Millard_equilibrium model

Posted: Sat May 30, 2020 5:34 am
by saurabh
Hi All,

I am still unable to fix this problem. Is there any solution to this?

Thanks,
Saurabh

Re: Error with force velocity curve in Millard_equilibrium model

Posted: Thu Jun 04, 2020 1:01 am
by mjhmilla
Dear Saurabh,

The problem on lines 138-141 of Millard2012EquilibriumMuscle.cpp in Millard2012EquilibriumMuscle::extendFinalizeFromProperties:

- if the eccentric_slope_at_vmax or concentric_slope_at_vmax are less than 0.1 they are set to this minimum
- this update, however, is made without also updating the eccentric_slope_near_vmax or concentric_slope_near_vmax.

Thus when the "LeftMuscle" loads from your example:

- Initially the parameters are fine: eccentric_slope_at_vmax = 0, and eccentric_slope_near_vmax = 0.09.
- When extendFinalizeFromProperties is called (after the properties from the osim file are loaded) then in this function secretly eccentric_slope_at_vmax is set to 0.1 while eccentric_slope_near_vmax is left at 0.09: and this causes the error.

To verify that this is indeed the problem I have edited the exampleMain code (attached) so that it loads the osim file you sent and stepped through the code manually: the interpretation above is correct. It is worth noting that the parameters have been secretly changed on a curve that is only used if you do not used the damped model. If you are using the damped model the ForceVelocityCurve parameters are used exactly as you have entered them (though the bug will still cause an error to be thrown).

There is a lot of maintenance and work that goes on behind the scenes so that these sophisticated tools are as easy as possible to use. I can imagine some good reasons for including the offending if statement. I might have included this in the original implementation - I honestly cannot remember. In any case, I'm going to submit an issue to OpenSim's github page so this doesn't get lost, and issue a pull request with a fix.

In the meantime provided that these two conditions are met by your model parameters

eccentric_slope_near_vmax > 0.1
concentric_slope_near_vmax > 0.1

then you shouldn't see any problems. In addition, if you are using the damped model you can be confident that if you set eccentric_slope_at_vmax < 0.1, or concentric_slope_at_vmax < 0.1 the force velocity curve that is used will follow these parameters.

With kind regards,

Matt