Page 1 of 1
Changing a force parameter during a simulation
Posted: Tue Aug 31, 2021 5:18 pm
by jonperdomo
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
Re: Changing a force parameter during a simulation
Posted: Wed Sep 01, 2021 3:38 am
by tkuchida
If computation time isn't a big issue, you could use the following algorithm:
- load model and call initSystem()
- run 1-second simulation
- edit bushing parameter and call initSystem()
- for each state variable, copy value from final time point of first simulation into new state
- 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):
- load model and call initSystem()
- bushing1.setAppliesForce(state, True)
- bushing2.setAppliesForce(state, False)
- run 1-second simulation
- bushing1.setAppliesForce(state, False)
- bushing2.setAppliesForce(state, True)
- run 1-second simulation
Re: Changing a force parameter during a simulation
Posted: Wed Sep 01, 2021 3:37 pm
by jonperdomo
Hi Thomas,
The second solution sounds like it will work great, I will try it. Thank you!
-Jon