-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvement on Bode plot phase #312
base: master
Are you sure you want to change the base?
Conversation
If the phase was initially less than -180 degrees, the bode plot would plot with positive initial phase
We use the zero poles (continuous) and poles on the unit circle (discrete) to estimate the phase angle at the left side of the bode plot. Angle unwrap starts from this angle, then the initial angle is not used anymore.
I think this looks reasonable. @baggepinnen @olof3 ? |
I agree that a poorly unwrapped phase is very annoying in Bode diagrams. With two integrators the phase currently starts at -180, but you mean that you have some variation of this where the phase starts at +180? A mwe is always good. Some thoughts,
I would guess that a reasonably robust solution is a bit complicated to get together, but should definitely be doable. |
Good points about the tolerances, those should probably be keyword arguments and documented so that one does not get confused if one has very slow dynamics that gets treated as an integrator. Maybe all the added computations should be opt out so that one can call bode with maximum performance and no surprises. |
Sometimes the use of - would not work because the operands would be a scalar and an array
I have fixed the things commented here as far as I can tell. All the suggestions were fine. To me these were details. Having a code that runs faster will always have lower priority than producing the correct plot. Making a bode plot that plots phase -180 as +180 will just not go down well with most users. The code right now is at the stage I can make it without going really deep into the code. There still are some unresolved questions like why did I have to use zpk_sys.matrix[1] rather than looking at any other values that may be there. Also I have not added any unit tests to this. I'm afraid its out of my time and Julia knowhow budget at this point. I would not be afraid to recommend including this pull request, or at leat reimplement a code to plot bode plots with the correct phase. a simple test code to show an errored phase would be: s=tf("s")
bodeplot(1/s^3) |
I'd guess the behavior is inconsistent for MIMO systems? And an error would still thrown for non-rational systems, e.g., The naming is inconsistent, for example what
Shouldn't the tolerances also include I'm also current method for finding poles and zeros is probably not robust for systems of moderate order (>10 or so). Not sure if deterministic incorrect phase wrapping or unexpected phase wrapping is to be preferred? Perhaps it should only be the default for systems of low order. |
The heuristic used to find the initial phase at w=0 for bode plots does not work for systems of type DelayLtiSystem. So it will default to zero initial phase (which is wrong for many systems, but at least it doesn't blow up).
I agree that all supported kinds should be supported or at least fallback to the original behavior. I don't have an overview over how many types there are. I have omitted a
You are overcomplicating.
As we are in the context of the I must say I am taken aback by the hostile reactions I am getting here, nitpicking at details while there is a glaring hole in the functionality of And honestly thanks for the constructive feedback I have had. |
I am sorry that you feel this way. We very much appriciate input and help for anyone that is interested.
That doesn't mean that we should't implement this.
I want to thank you again for finding this, and helping in creating a solution to the problem. For this package to grow and continue to be useful, we need people. Although far from everything in this package is perfect, we try our best to keep it both efficient and generic enough to be used with other packages in the Julia ecosystem, this is probably why we have so many comments. |
I think Mattias summarizes quite well in his last post. We have developed and maintained this toolbox over quite some years now, and it has lately been driven by what we need (at least for me). We also have a lot of workflows using this toolbox, both in research and in teaching. The reason I gave feedback on potential performance regressions in the implementation of We have also worked quite hard trying to make the toolbox type stable and not performing unintended type promotions. Indeed, one of the largest PRs pulled the last few years handled this specifically Accepting a PR which messes with types and performance just to introduce more maintenance burden to fix it when it breaks some existing workflow is not sustainable, hence the extensive feedback on what seems like "details" to some. To finish off, there definitely should be a test that exposes the previous, unwanted behavior. If our comments came off as hostile, that's very unfortunate, and I don't think anyone intended to alienate anyone. This project is important to many, and the fact that three maintainers gave detailed reviews on a PR within so short time hopefully reflects how keen we are on making this toolbox better. |
The difficult thing about this discussion is that I received both excellect feedback and what I consider nitpicking. It can’t be generalized. I dont consider a bode plot starting at phase +90 degrees for ‘1/s^3’ an aestetic issue. If you believe this, then perhaps ask some people who use ControlSystems to make bode plots. ‘1/s^3’ has 270 degree phase delay. Not 90 degree advance. I can tell you my two colleagues who saw these plots would not consider them seriously for this reason. I guess this ends up a discussion: is there a difference between a double derivation and a double integration for phase. Yes - and thats why you have unwrap! there in the first place Having this problem is also quite a big deal if you plot an uncompensated system along with a compensated system in the same plot. With slightly bad luck (that is most times for the system Im working on) there is almost 360 degree offset between the two phase plots. I appreciate a lot of the feedback I got, and you might see that I already went through many hoops to satisfy your requests. But at one point enough is enough. If you are so nitpicky just say you will do it yourselves. Or decide not to do it, thats ok too. If you want me to continue working on this, perhaps provide constructive feedback such as: «We have several types of systems as defined in files ..., we need the bode function to run for all of these» |
1 similar comment
The difficult thing about this discussion is that I received both excellect feedback and what I consider nitpicking. It can’t be generalized. I dont consider a bode plot starting at phase +90 degrees for ‘1/s^3’ an aestetic issue. If you believe this, then perhaps ask some people who use ControlSystems to make bode plots. ‘1/s^3’ has 270 degree phase delay. Not 90 degree advance. I can tell you my two colleagues who saw these plots would not consider them seriously for this reason. I guess this ends up a discussion: is there a difference between a double derivation and a double integration for phase. Yes - and thats why you have unwrap! there in the first place Having this problem is also quite a big deal if you plot an uncompensated system along with a compensated system in the same plot. With slightly bad luck (that is most times for the system Im working on) there is almost 360 degree offset between the two phase plots. I appreciate a lot of the feedback I got, and you might see that I already went through many hoops to satisfy your requests. But at one point enough is enough. If you are so nitpicky just say you will do it yourselves. Or decide not to do it, thats ok too. If you want me to continue working on this, perhaps provide constructive feedback such as: «We have several types of systems as defined in files ..., we need the bode function to run for all of these» |
We are all very thankful that you take you have taken the time to contribute on a problem that annoys you, in that case there are surely many other people that are annoyed by it. As it turns out there was no trivial fix for this problem, so it is natural that we discuss potential problems and what to do about them. Back to the technical things,
My bad, the naming is consistent, but is the behavior so? Shouldn't
To me it is not clear what |
Couldn't one replace the delays with |
I was not able to figure out how to convert a DelayLtiSystem to a non-delayed system. I could also implement this if I was helped a bit or perhaps figure it out myself later. As the phase is only important for the actual bode plot, perhaps a good option to preserve computing speed for other used of the bode function would be to make the initial phase heuristic optional, then use it as default only in the bodeplot function |
Just added some code to allow bode plots to start with the (heuristic) correct phase angle. Some systems with double integrators would start with phase +180 which makes the plot kind of nonstandard