Repository navigation
Do not report a gain margin at zero frequency for systems with a zero in the origin - #1078
Merged
Merged
Conversation
… in the origin margin evaluates the frequency response at ω = 0 in order to detect crossings of the negative real axis at zero frequency (#1045). For a system with more zeros than poles in the origin, the frequency response at ω = 0 is zero, and its computed value is determined by rounding error. When this value is a negative real number, its phase is ±180°, and sisomargin reported a gain margin at ω = 0 with a magnitude of the order of the reciprocal machine epsilon. Such crossings are now removed, using the same classification of zeros and poles in the origin as integrator_excess. For a DelayLtiSystem, the classification is applied to the delay-free system, whose frequency response at ω = 0 coincides with that of the delay system. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
This is an automated message.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1078 +/- ##
==========================================
+ Coverage 91.69% 91.70% +0.01%
==========================================
Files 42 42
Lines 5789 5796 +7
==========================================
+ Hits 5308 5315 +7
Misses 481 481 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
baggepinnen
referenced
this pull request
Oct 8, 2026
Claude-Session: https://claude.ai/code/session_01HigNnun4aJKMoWmY7wyULn Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.








marginprepends the frequency-0.0to the frequency grid (_add_zero). This detects crossings of the negative real axis at zero frequency, as in #1045. For a system with more zeros than poles in the origin, the frequency response atω = 0is zero, and its computed value is determined by rounding error. When this value is a negative real number, its phase is±180°._findCrossingsthen reports a phase crossover atω = 0, andsisomarginreturns a gain margin1/|G(0)|of the order1e15–1e17.This PR removes such crossings. A crossover at
ω = 0is discarded when the system has more zeros than poles in the origin (z = 1in discrete time). The decision usesintegrator_excess, i.e., the same classification as the phase adjustment insisomargin. For aDelayLtiSystem, every delay equals the identity atω = 0, so the classification is applied to the delay-free systemlft(sys.P.P, I).G(0)as computedwgm,gmbalreal(ss(s/(s+1)^2))[1]-1.5e-16[-0.0],[6.5e15]balreal(ss(s^2/((s+1)*(s^2 + 0.2s + 4))))[1]-3.0e-17[-0.0],[8.3e16]c2d(ss(s/(s+1)^2), 0.1)-7.1e-16[-0.0, 31.4],[1.3e15, 20.1][31.4],[20.1]balreal(ss(s/(s+1)^2))[1] * delay(0.1)-1.1e-16[-0.0, 16.9, 78.8],[9.0e15, 17.0, 78.8][16.9, 78.8],[17.0, 78.8]-(s+1)/((s+2)*(s+3))(genuine crossing)-0.17[-0.0, 1.0],[6.0, 5.0]The tests use
zpk([1e-17], [-1, -1], 1)andzpk([1 + 1e-15], [0.5, 0.5], 1, 0.1)with and without delays. For these systems the computedG(0)is negative independently of the eigenvalue solver. With the check disabled, 8 of the 9 new assertions fail; the ninth checks the remaining gain margin. The test of #1045 and the new tests with a negative DC gain verify that genuine crossings atω = 0are retained.This problem was found while reviewing #1076, which changes the same function in other lines.
Tests
Linux, Julia 1.13.0, with this branch of ControlSystemsBase developed into each environment:
DyadControlSystems is the only one of RobustAndOptimalControl, ControlSystemsMTK, ModelPredictiveControl and DyadControlSystems that calls
margin. Its failures are an allocation test, a convergence tolerance of the linear MPC, and theMethodErrorofbodeplotfor aControlSystemIdentification.FRDdescribed in #1077.Host:
demeter2, session2071354d-b6c5-40db-a9b8-ccbe8a7d8c38, working directory~/.julia/dev/ControlSystems/.claude/worktrees/joyful-gathering-pumpkin🤖 Generated with Claude Code