Evolution of the wear state variables in the PneumaticValveWithWear
model
#572
-
Hello! I am playing around a little bit, discovering the library and looked into the code for the valve with wear model. From what I understand, in the If yes, looking at the def next_state(self, x, u, dt: float):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
self.parameters['wb'] = x['wb']
self.parameters['wi'] = x['wi']
self.parameters['wk'] = x['wk']
self.parameters['wr'] = x['wr']
self.parameters['wt'] = x['wt']
next_x = PneumaticValveBase.next_state(self, x, u, dt)
# Append this way because the keys in the structure but the values are
# missing - this is due to the behavior of subclassed models calling
# their parent functions.
next_x.matrix = np.vstack((next_x.matrix, np.array([
np.atleast_1d(x['wb']),
np.atleast_1d(x['wi']),
np.atleast_1d(x['wk']),
np.atleast_1d(x['wr']),
np.atleast_1d(x['wt'])
])))
return next_x So here we update the wear parameters to be the same as those in the current state. This is because the params are used in the next state calculation (as we use the base model function, in which the wear rate is a parameter and not part of the state). Relevant code below. Then, we compute the next state using the base model function. But then, here we have Full def next_state(self, x, u, dt: float):
params = self.parameters # optimization
# ...
kdot = -params['wk']*abs(x['v']*springForce)
rdot = params['wr']*abs(x['v']*friction)
Aidot = params['wi']*abs(x['v']*friction)
# ...
return self.StateContainer(np.array([
np.atleast_1d(x['Aeb'] + params['wb'] * dt), # Aeb
np.atleast_1d(x['Aet'] + params['wt'] * dt), # Aet
np.atleast_1d(x['Ai'] + Aidot * dt), # Ai
# ...
])) Thanks in advance for any help on understanding what is happening here. Sorry if I missed something obvious! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @chefmtt, Thanks for your question. You're right that the wear is added as a state so it can change freely. However,t doesn't (as the model is now) change within a simulation. In next_state, the wear parameters are added back in, unchanged. This might seem odd for someone learning prog_models, as it will behave functionally identically as having the wear rates as parameters. Where this makes a difference is when combined with prog_algs. Some users are trying to estimate the wear parameters online using a StateEstimator (see https://nasa.github.io/progpy/prog_algs_guide.html#state-estimation). For these users, having the wear parameters in the state allows the state estimator to estimate those wear rates with the other states. This is more of an edge case. Most users estimate the wear parameters using parameter estimation and then simulate forward using the base PneumaticValve model. Some users may even update those parameters occasionally by re-running estimate_params. But the *WithWear models are included for the subset of users who would like to update the wear rates online with a state estimator. Does that answer your question? Let me know if you have any additional questions. |
Beta Was this translation helpful? Give feedback.
Hello @chefmtt,
Thanks for your question. You're right that the wear is added as a state so it can change freely. However,t doesn't (as the model is now) change within a simulation. In next_state, the wear parameters are added back in, unchanged.
This might seem odd for someone learning prog_models, as it will behave functionally identically as having the wear rates as parameters. Where this makes a difference is when combined with prog_algs. Some users are trying to estimate the wear parameters online using a StateEstimator (see https://nasa.github.io/progpy/prog_algs_guide.html#state-estimation). For these users, having the wear parameters in the state allows the state estimator to esti…