Partial Derivative of a state variable with respect to a parameter value of a model component

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Nat Wannawas
Posts: 2
Joined: Fri Apr 12, 2019 1:41 pm

Partial Derivative of a state variable with respect to a parameter value of a model component

Post by Nat Wannawas » Wed Feb 24, 2021 1:23 pm

Is there any way to get a partial derivative of a state variable with respect to a parameter value of a model component?
For example, if I work with this model.
Is there a way to get the value of the partial derivative of theta_dot of the elbow with respect to the mass of the lower arm 'm' at a certain state?
Image

Tags:

User avatar
Thomas Uchida
Posts: 1793
Joined: Wed May 16, 2012 11:40 am

Re: Partial Derivative of a state variable with respect to a parameter value of a model component

Post by Thomas Uchida » Wed Feb 24, 2021 5:32 pm

OpenSim does not export symbolic expressions. However, you could approximate partial(variable)/partial(parameter) numerically by increasing/decreasing the parameter value, calculating the variable value with OpenSim in each case, and computing a central difference. It would be quite slow if you were to use this strategy at each time step of a simulation since changing a model parameter (like mass) requires you to call initSystem() which is computationally expensive. Instead, you could create two models, one with mass = m+delta and one with mass = m-delta. At each time step, set the states of these two models to be the same (presumably, you have already generated these states over time), compute theta_dot from each model, and then compute the central difference.

User avatar
Nat Wannawas
Posts: 2
Joined: Fri Apr 12, 2019 1:41 pm

Re: Partial Derivative of a state variable with respect to a parameter value of a model component

Post by Nat Wannawas » Thu Feb 25, 2021 4:22 am

Very clear and helpful answer. Thank you so much.

POST REPLY