Repository navigation
Conversation
) A delay adds the phase -w*tau, which on a sparse frequency grid changes by more than 180 degrees between neighbouring frequencies, so unwrapping on the grid itself lost multiples of 360 degrees. For a DelayLtiSystem, the phase is now unwrapped on a grid on which the delays change the phase by at most 90 degrees, and read off at the given frequencies. bodeplot uses this phase instead of unwrapping again on the plotted grid.
Author
|
@baggepinnen, a gentle reminder about this pull request, when you have time. The CI workflows have not run yet: they are waiting for approval, as this is my first contribution here. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #757
A delay τ adds the phase -ωτ. On the default frequency grid, and on any grid that is sparse at high frequencies, the phase then changes by more than 180° between neighbouring frequencies, and unwrapping on the grid itself loses multiples of 360°. For
delay(2) / (s + 1), the phase frombode(sys)on the default grid (240 frequencies) was off by up to 8280° (23 turns).Changes:
bodetakes the unwrapped phase from a new internal function_unwrapped_phase(sys, w, resp). For systems without delays it does whatbodedid before (unwrap!(angle.(resp), 3)).DelayLtiSystem,_unwrapped_phaseinserts frequencies between the given ones, so that the delays (the sum ofsys.Tau) change the phase by at most 90° between neighbouring frequencies. It unwraps on that grid and returns the phase at the given frequencies. If more than 100 000 extra frequencies would be needed (for example a delay of 1e5 on the default grid), it unwraps on the given grid as before.bodeplotnow takes the unwrapped phase frombodeinstead of unwrapping again on the plotted grid. Unwrapping again would undo the correction, because the correct phase may change by more than 180° between plotted frequencies. For systems without delays the plotted phase is the same as before (unwrapping and the shift by a multiple of 360° at the start commute).Tests: a new testset in
test_delayed_systems.jlchecksdelay(2) / (s + 1)on a sparse grid and on the default grid, and two delays in series, against the exact phase. Without the change it fails (error 8280°). I also comparedfeedback(delay(1) / (s + 1)), a 2x2 system with delays 1 and 3, anddelay(10) / (s + 1)with the phase unwrapped on a grid with 50 frequencies per radian of delay phase: they agree. Abodecall on these systems takes about 0.03 s.With the change,
test_delayed_systems,test_freqresp,test_analysis,test_autovecandtest_plotspass (1054 tests, Julia 1.13.2 on Windows).