diskmargin: auto-compute MIMO frequency-grid bounds by default#151
Merged
Conversation
The MIMO diskmargin searched a fixed grid l=1e-3..u=1e3 rad/s. When the
worst-case margin lay near a bound, the reported worst-case frequency pinned
to the grid edge (e.g. exactly 1000.0 rad/s), corrupting derived quantities
such as the delay margin (phase_margin/ω_crit).
Default l and u to `nothing`; when unset, derive them from the poles/zeros of
L via ControlSystemsBase._bounds_and_features(L, Val{:nyquist}()), the same
heuristic used for Bode/Nyquist plots. Explicit l/u still override.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #151 +/- ##
==========================================
+ Coverage 91.84% 91.85% +0.01%
==========================================
Files 20 20
Lines 3067 3071 +4
==========================================
+ Hits 2817 2821 +4
Misses 250 250
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Motivation
The MIMO
diskmarginsearched a fixed log-spaced frequency gridl=1e-3 … u=1e3rad/s (500 points). When the worst-case disk margin lies near or beyond a bound, the reported worst-case frequency lands exactly on the grid edge (e.g.u=1000.0rad/s) — a grid artifact rather than a true interior minimum. This corrupts derived quantities, in particular the delay margin (phase_margin / ω_crit), where dividing by an artificially-fixed crossover frequency gives a misleading value.Change
landutonothingindiskmargin(L; l, u)andsim_diskmargin(L, σ, l, u).nothing, derive it from the poles/zeros ofLviaControlSystemsBase._bounds_and_features(L, Val{:nyquist}())— the same heuristic ControlSystems uses to pick frequency ranges for Bode/Nyquist plots, padded around the extreme dynamics with high-frequency headroom and clamped to Nyquist for discrete systems.l/ustill override (backward compatible)._bounds_and_featuresspecialization inuncertainty_interface.jl.Only the scalar-
l/upath is affected; allAbstractVector-grid callers (e.g.diskmargin(P,C,σ,w)) are unchanged.Tests
test/test_diskmargin.jlpasses locally. The discrete default-grid regression test's reference grid was made dense and Nyquist-relative so the comparison is robust to the now system-derived bounds.🤖 Generated with Claude Code