Changing a force parameter during a simulation

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Jonathan Perdomo
Posts: 6
Joined: Fri May 28, 2021 7:00 am

Changing a force parameter during a simulation

Post by Jonathan Perdomo » Tue Aug 31, 2021 5:18 pm

Hi everyone,

I am looking for a GUI or C++ tool that will enable me to update a force parameter in the middle of a simulation. Specifically, is it possible to run a simulation from 0-1s, then from 1-2s update the rotational stiffness for a Bushing Force object? https://simtk.org/api_docs/opensim/api_ ... Force.html

Thank you!

-Jon

Tags:

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

Re: Changing a force parameter during a simulation

Post by Thomas Uchida » Wed Sep 01, 2021 3:38 am

If computation time isn't a big issue, you could use the following algorithm:
  1. load model and call initSystem()
  2. run 1-second simulation
  3. edit bushing parameter and call initSystem()
  4. for each state variable, copy value from final time point of first simulation into new state
  5. run 1-second simulation
If computation time is a concern, you should avoid calling initSystem() in the middle---which means that you will need to avoid editing the model. You could try creating two bushings (one with parameter 1 and the other with parameter 2) and using the setAppliesForce() method to turn them on/off (modifying the state rather than the model):
  1. load model and call initSystem()
  2. bushing1.setAppliesForce(state, True)
  3. bushing2.setAppliesForce(state, False)
  4. run 1-second simulation
  5. bushing1.setAppliesForce(state, False)
  6. bushing2.setAppliesForce(state, True)
  7. run 1-second simulation

User avatar
Jonathan Perdomo
Posts: 6
Joined: Fri May 28, 2021 7:00 am

Re: Changing a force parameter during a simulation

Post by Jonathan Perdomo » Wed Sep 01, 2021 3:37 pm

Hi Thomas,

The second solution sounds like it will work great, I will try it. Thank you!

-Jon

POST REPLY