Disk margin calculations#1146
Conversation
…andler comment, fix typo in skew description of disk_margins docstring
…e function to plot allowable gain/phase variations.
…n the margins module
calculation of 'f', the bounding complex curve. Seems to look correct for balanced (skew = 0) case, still verifying the skewed equivalent.
…on-control into jdelange/disk-margins
…ol/tests/margin_test.py
|
I fixed the docstrings and implemented the linter's recommendations so that automated workflows finally pass. One thing I previously hadn't appreciated was the complexity of the control plotting code, so to make this PR simpler I'm only proposing to add a library function to calculate the disk-based margins. All other plotting is left to user code (or future PRs), e.g. the local function |
murrayrm
left a comment
There was a problem hiding this comment.
Some additional suggestions attached, mainly focused on coding style (to be consistent with the standard style in the package).
…reference on disk/ellipse-based margin calculations.
|
@murrayrm (and @slivingston) thanks for taking time to review. I think everything's addressed - but let me know of anything else! |
murrayrm
left a comment
There was a problem hiding this comment.
Found a few more style issues.
|
@murrayrm thanks and latest formatting issues are now fixed. The one failing check "Slycot from source / build-linux (pull_request)" does not seem to be the disk margin tests. |
|
Agreed. Tracking the failed unit test in #1161. I'll go ahead and merge this since the fail check is unrelated. |
Am relatively new to this toolbox, have been using it here and there and found #726.
This is an initial prototype Python implementation of disk margins, built on top of$\mu$ at each discrete frequency. The function
python-controlandslycot. The code should work both for SISO and MIMO systems, the latter of which requiresslycot(for SLICOT'sAB13MD) to compute the upper bound ofdisk_marginscomputes disk margins (and corresponding disk-based gain/phase margins), optionally returning the whole frequency-dependent vectors for further plotting.It's been verified against the example SISO loop transfer functions in the published paper and the "spinning satellite" MIMO example from the MathWorks documentation. I also confirmed SISO disk margins match the relevant output of existing function
stability_marginscorresponding to the Nyquist plot's distance to -1. All seem to match within a few significant digits, so the general behavior seems correct. Might be good to get another set of eyes to double check/test further.I tried to base as much as possible (e.g. style conventions) on existing code in
control/margins.py. Example usage (seeexamples/disk_margin.py):Output:
The example script also shows how to plot the allowable/stable region of gain and phase variations which will not destabilize the loop, in a local function
plot_allowable_region, e.g.