Reputation: 319
I'd like to do some analysis downstream of my trajectory as described here
https://openmdao.github.io/dymos/faq/downstream_analysis.html
What I want to do is slightly different - I don't want to connect the end or beginning (or some fixed index) of a phase to some downstream component. What I want to do is find the node / time where a specific state is at its maximum value within a phase, and then connect various state variables for that time / node to my downstream analysis. The node / time where the max occurs will be change based on whatever the inputs to the problem are, so it can't really be known in advance
To be specific what I'm trying to do some analysis at point of maximum dynamic pressure (Max-Q) for the ascent of launch vehicle. I could probably just look at every single point in the phase where max-Q occurs, but maybe it's not necessary.
I could just use a "max" function on the array of dynamic pressure values of the phase, get the index and the other states of interest at that index. But then how do you differentiate that?
Upvotes: 1
Views: 95
Reputation: 2704
The way we handle this situation is to end a phase when the derivative of the variable reaching a maximum reaches zero, and then continue the nominal trajectory from there in a second phase. For instance, with Max-Q you would make an equation for the derivative of dynamic pressure (q_dot
) and then use a final boundary constraint to make that phase end when q_dot
is zero.
A second phase is continuous from that point and carries on the nominal trajectory.
Using this technique you know the exact conditions at max-Q.
One feature we could add, although we would need to think it through, is to allow approximated derivatives of timeseries outputs. For instance, we could multiply the timeseries values of q
by this differentiation matrix to get a reasonably close approximation of q_dot
. We could then apply boundary and path constraints to this value, and the user wouldn't have to derive their own expression for q_dot
in the ODE.
Upvotes: 2
Reputation: 5710
You're correct that a max function is not differentiable. However, there is a similar function that we provide which is: the KS function
Its not a perfect replacement for a max, but in this context is it very good. You can pass in the entire time series and then it will output a close approximation of the maximum value from that array.
There is a rho
option which controls how close to a max function your approximation gets. A larger value is more max-like, but also has poorer numerical conditioning because the derivatives around the max start to get very larger. The default value of 50 is probably fine, but you can experiment with that value if you need to.
Upvotes: 2