@@ -704,24 +704,19 @@ def disk_margins(L, omega, skew = 0.0, returnall = False):
704704 (not gmidx != - 1 and float ('inf' )) or DGM [gmidx ][0 ],
705705 (not DPM .shape [0 ] and float ('inf' )) or DPM [pmidx ][0 ])
706706
707- def disk_margin_plot (alpha_max , skew = 0.0 , ax = None , ntheta = 500 ,
708- shade = True , shade_alpha = 0.25 ):
709- """Compute disk-based stability margins for SISO or MIMO LTI system.
707+ def disk_margin_plot (alpha_max , skew = 0.0 , ax = None ):
708+ """Plot region of allowable gain/phase variation, given worst-case disk margin.
710709
711710 Parameters
712711 ----------
713- L : SISO or MIMO LTI system representing the loop transfer function
714- omega : ndarray
715- 1d array of (non-negative) frequencies (rad/s) at which to evaluate
716- the disk-based stability margins
717- skew : (optional, default = 0) skew parameter for disk margin calculation.
712+ alpha_max : worst-case disk margin(s) across all (relevant) frequencies.
713+ Note that skew may be a scalar or list.
714+ skew : (optional, default = 0) skew parameter(s) for disk margin calculation.
718715 skew = 0 uses the "balanced" sensitivity function 0.5*(S - T)
719716 skew = 1 uses the sensitivity function S
720717 skew = -1 uses the complementary sensitivity function T
721- returnall : bool, optional
722- If true, return all margins found. If False (default), return only the
723- minimum stability margins. Only margins in the given frequency region
724- can be found and returned.
718+ Note that skew may be a scalar or list.
719+ ax : axes to plot bounding curve(s) onto
725720
726721 Returns
727722 -------
@@ -746,10 +741,13 @@ def disk_margin_plot(alpha_max, skew = 0.0, ax = None, ntheta = 500,
746741 >>
747742 >> s = control.tf('s') # Laplace variable
748743 >> L = 6.25*(s + 3)*(s + 5)/(s*(s + 1)**2*(s**2 + 0.18*s + 100)) # loop transfer function
749- >> DM, GM, PM = control.disk_margins(L, omega, skew = 0.0,) # balanced (S - T)
750744 >>
745+ >> DM_plot = []
746+ >> DM_plot.append(control.disk_margins(L, omega, skew = -1.0)[0]) # T-based (T)
747+ >> DM_plot.append(control.disk_margins(L, omega, skew = 0.0)[0]) # balanced (S - T)
748+ >> DM_plot.append(control.disk_margins(L, omega, skew = 1.0)[0]) # S-based (S)
751749 >> plt.figure(1)
752- >> disk_margin_plot(0.75 , skew = [0 .0, 1 .0, - 1.0])
750+ >> control. disk_margin_plot(DM_plot , skew = [-1 .0, 0 .0, 1.0])
753751 >> plt.show()
754752
755753 References
@@ -775,11 +773,12 @@ def disk_margin_plot(alpha_max, skew = 0.0, ax = None, ntheta = 500,
775773 else :
776774 skew = np .asarray (skew )
777775
778-
779- theta = np .linspace (0 , np .pi , ntheta )
776+ # Add a plot for each (alpha, skew) pair present
777+ theta = np .linspace (0 , np .pi , 500 )
780778 legend_list = []
781779 for ii in range (0 , skew .shape [0 ]):
782- legend_str = "$\\ sigma$ = %.1f, $\\ alpha_{max}$ = %.2f" % (skew [ii ], alpha_max [ii ])
780+ legend_str = "$\\ sigma$ = %.1f, $\\ alpha_{max}$ = %.2f" % (
781+ skew [ii ], alpha_max [ii ])
783782 legend_list .append (legend_str )
784783
785784 # Complex bounding curve of stable gain/phase variations
@@ -791,15 +790,10 @@ def disk_margin_plot(alpha_max, skew = 0.0, ax = None, ntheta = 500,
791790 phi_deg = np .rad2deg (np .angle (f )) # phase margin (deg)
792791
793792 # Plot the allowable combined gain/phase variations
794- if shade :
795- out = ax .plot (gamma_dB , phi_deg ,
796- alpha = shade_alpha , label = '_nolegend_' )
797- ax .fill_between (
798- ax .lines [ii ].get_xydata ()[:,0 ],
799- ax .lines [ii ].get_xydata ()[:,1 ],
800- alpha = shade_alpha )
801- else :
802- out = ax .plot (gamma_dB , phi_deg )
793+ out = ax .plot (gamma_dB , phi_deg , alpha = 0.25 ,
794+ label = '_nolegend_' )
795+ ax .fill_between (ax .lines [ii ].get_xydata ()[:,0 ],
796+ ax .lines [ii ].get_xydata ()[:,1 ], alpha = 0.25 )
803797
804798 plt .ylabel ('Gain Variation (dB)' )
805799 plt .xlabel ('Phase Variation (deg)' )
0 commit comments