Skip to content

enhance step_info to MIMO and time series of response data #577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 46 additions & 23 deletions control/matlab/timeresp.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,38 +64,59 @@ def step(sys, T=None, X0=0., input=0, output=None, return_x=False):
transpose=True, return_x=return_x)
return (out[1], out[0], out[2]) if return_x else (out[1], out[0])

def stepinfo(sys, T=None, SettlingTimeThreshold=0.02,

def stepinfo(sysdata, T=None, yfinal=None, SettlingTimeThreshold=0.02,
RiseTimeLimits=(0.1, 0.9)):
'''
"""
Step response characteristics (Rise time, Settling Time, Peak and others).

Parameters
----------
sys: StateSpace, or TransferFunction
LTI system to simulate

T: array-like or number, optional
sysdata : StateSpace or TransferFunction or array_like
The system data. Either LTI system to similate (StateSpace,
TransferFunction), or a time series of step response data.
T : array_like or float, optional
Time vector, or simulation time duration if a number (time vector is
autocomputed if not given)

SettlingTimeThreshold: float value, optional
autocomputed if not given).
Required, if sysdata is a time series of response data.
yfinal : scalar or array_like, optional
Steady-state response. If not given, sysdata.dcgain() is used for
systems to simulate and the last value of the the response data is
used for a given time series of response data. Scalar for SISO,
(noutputs, ninputs) array_like for MIMO systems.
SettlingTimeThreshold : float, optional
Defines the error to compute settling time (default = 0.02)

RiseTimeLimits: tuple (lower_threshold, upper_theshold)
RiseTimeLimits : tuple (lower_threshold, upper_theshold)
Defines the lower and upper threshold for RiseTime computation

Returns
-------
S: a dictionary containing:
RiseTime: Time from 10% to 90% of the steady-state value.
SettlingTime: Time to enter inside a default error of 2%
SettlingMin: Minimum value after RiseTime
SettlingMax: Maximum value after RiseTime
Overshoot: Percentage of the Peak relative to steady value
Undershoot: Percentage of undershoot
Peak: Absolute peak value
PeakTime: time of the Peak
SteadyStateValue: Steady-state value
S : dict or list of list of dict
If `sysdata` corresponds to a SISO system, S is a dictionary
containing:

RiseTime:
Time from 10% to 90% of the steady-state value.
SettlingTime:
Time to enter inside a default error of 2%
SettlingMin:
Minimum value after RiseTime
SettlingMax:
Maximum value after RiseTime
Overshoot:
Percentage of the Peak relative to steady value
Undershoot:
Percentage of undershoot
Peak:
Absolute peak value
PeakTime:
time of the Peak
SteadyStateValue:
Steady-state value

If `sysdata` corresponds to a MIMO system, `S` is a 2D list of dicts.
To get the step response characteristics from the j-th input to the
i-th output, access ``S[i][j]``


See Also
Expand All @@ -105,11 +126,13 @@ def stepinfo(sys, T=None, SettlingTimeThreshold=0.02,
Examples
--------
>>> S = stepinfo(sys, T)
'''
"""
from ..timeresp import step_info

# Call step_info with MATLAB defaults
S = step_info(sys, T, None, SettlingTimeThreshold, RiseTimeLimits)
S = step_info(sysdata, T=T, T_num=None, yfinal=yfinal,
SettlingTimeThreshold=SettlingTimeThreshold,
RiseTimeLimits=RiseTimeLimits)

return S

Expand Down
12 changes: 4 additions & 8 deletions control/tests/sisotool_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def test_sisotool(self, sys):

# Check the step response before moving the point
step_response_original = np.array(
[0. , 0.021 , 0.124 , 0.3146, 0.5653, 0.8385, 1.0969, 1.3095,
1.4549, 1.5231])
[0. , 0.0216, 0.1271, 0.3215, 0.5762, 0.8522, 1.1114, 1.3221,
1.4633, 1.5254])
assert_array_almost_equal(
ax_step.lines[0].get_data()[1][:10], step_response_original, 4)

Expand Down Expand Up @@ -113,8 +113,8 @@ def test_sisotool(self, sys):

# Check if the step response has changed
step_response_moved = np.array(
[0. , 0.023 , 0.1554, 0.4401, 0.8646, 1.3722, 1.875 , 2.2709,
2.4633, 2.3827])
[0. , 0.0237, 0.1596, 0.4511, 0.884 , 1.3985, 1.9031, 2.2922,
2.4676, 2.3606])
assert_array_almost_equal(
ax_step.lines[0].get_data()[1][:10], step_response_moved, 4)

Expand Down Expand Up @@ -157,7 +157,3 @@ def test_sisotool_mimo(self, sys222, sys221):
# but 2 input, 1 output should
with pytest.raises(ControlMIMONotImplemented):
sisotool(sys221)




Loading