@@ -746,7 +746,8 @@ def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
746
746
747
747
Parameters
748
748
----------
749
- sys : StateSpace or TransferFunction
749
+ sys : SISO dynamic system model. Dynamic systems that you can use include:
750
+ StateSpace or TransferFunction
750
751
LTI system to simulate
751
752
752
753
T : array_like or float, optional
@@ -785,14 +786,20 @@ def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
785
786
--------
786
787
>>> info = step_info(sys, T)
787
788
'''
788
- _ , sys = _get_ss_simo (sys )
789
+
790
+ if not sys .issiso ():
791
+ sys = _mimo2siso (sys ,0 ,0 )
792
+ warnings .warn (" Internal conversion from a MIMO system to a SISO system,"
793
+ " the first input and the first output were used (u1 -> y1);"
794
+ " it may not be the result you are looking for" )
795
+
789
796
if T is None or np .asarray (T ).size == 1 :
790
797
T = _default_time_vector (sys , N = T_num , tfinal = T , is_step = True )
791
798
792
799
T , yout = step_response (sys , T )
793
800
794
801
# Steady state value
795
- InfValue = sys .dcgain ()
802
+ InfValue = sys .dcgain (). real
796
803
797
804
# TODO: this could be a function step_info4data(t,y,yfinal)
798
805
rise_time : float = np .NaN
@@ -803,8 +810,11 @@ def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
803
810
peak_time : float = np .Inf
804
811
undershoot : float = np .NaN
805
812
overshoot : float = np .NaN
806
-
813
+ steady_state_value : float = np .NaN
814
+
807
815
if not np .isnan (InfValue ) and not np .isinf (InfValue ):
816
+ # SteadyStateValue
817
+ steady_state_value = InfValue
808
818
# Peak
809
819
peak_index = np .abs (yout ).argmax ()
810
820
peak_value = np .abs (yout [peak_index ])
@@ -813,29 +823,26 @@
10000
def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
813
823
sup_margin = (1. + SettlingTimeThreshold ) * InfValue
814
824
inf_margin = (1. - SettlingTimeThreshold ) * InfValue
815
825
816
- if InfValue < 0.0 :
817
- # RiseTime
818
- tr_lower_index = (np .where (yout <= RiseTimeLimits [0 ] * InfValue )[0 ])[0 ]
819
- tr_upper_index = (np .where (yout <= RiseTimeLimits [1 ] * InfValue )[0 ])[0 ]
820
- # SettlingTime
821
- for i in reversed (range (T .size - 1 )):
822
- if (- yout [i ] <= np .abs (inf_margin )) | (- yout [i ] >= np .abs (sup_margin )):
823
- settling_time = T [i + 1 ]
824
- break
825
- # Overshoot and Undershoot
826
- overshoot = np .abs (100. * ((- yout ).max () - np .abs (InfValue )) / np .abs (InfValue ))
827
- undershoot = np .abs (100. * (- yout ).min () / np .abs (InfValue ))
826
+ # RiseTime
827
+ tr_lower_index = (np .where (np .sign (InfValue .real ) * (yout - RiseTimeLimits [0 ] * InfValue ) >= 0 )[0 ])[0 ]
828
+ tr_upper_index = (np .where (np .sign (InfValue .real ) * yout >= np .sign (InfValue .real ) * RiseTimeLimits [1 ] * InfValue )[0 ])[0 ]
829
+
830
+ # SettlingTime
831
+ settling_time = T [np .where (np .abs (yout - InfValue ) >= np .abs (SettlingTimeThreshold * InfValue ))[0 ][- 1 ]+ 1 ]
832
+ # Overshoot and Undershoot
833
+ y_os = (np .sign (InfValue .real )* yout ).max ()
834
+ dy_os = np .abs (y_os ) - np .abs (InfValue )
835
+ if dy_os > 0 :
836
+ overshoot = np .abs (100. * dy_os / InfValue )
837
+ else :
838
+ overshoot = 0
839
+
840
+ y_us = (np .sign (InfValue .real )* yout ).min ()
841
+ dy_us = np .abs (y_us )
842
+ if dy_us > 0 :
843
+ undershoot = np .abs (100. * dy_us / InfValue )
828
844
else :
829
- tr_lower_index = (np .where (yout >= RiseTimeLimits [0 ] * InfValue )[0 ])[0 ]
830
- tr_upper_index = (np .where (yout >= RiseTimeLimits [1 ] * InfValue )[0 ])[0 ]
831
- # SettlingTime
832
- for i in reversed (range (T .size - 1 )):
833
- if (yout [i ] <= inf_margin ) | (yout [i ] >= sup_margin ):
834
- settling_time = T [i + 1 ]
835
- break
836
- # Overshoot and Undershoot
837
- overshoot = np .abs (100. * (yout .max () - InfValue ) / InfValue )
838
- undershoot = np .abs (100. * yout .min () / InfValue )
845
+ undershoot = 0
839
846
840
847
# RiseTime
841
848
rise_time = T [tr_upper_index ] - T [tr_lower_index ]
@@ -852,7 +859,7 @@ def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
852
859
'Undershoot' : undershoot ,
853
860
'Peak' : peak_value ,
854
861
'PeakTime' : peak_time ,
855
- 'SteadyStateValue' : InfValue
862
+ 'SteadyStateValue' : steady_state_value
856
863
}
857
864
858
865
def initial_response (sys , T = None , X0 = 0. , input = 0 , output = None , T_num = None ,
0 commit comments