Skip to content

fixed bug in calculation of percent overshoot #555

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 2 commits into from
Mar 8, 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
12 changes: 4 additions & 8 deletions control/tests/sisotool_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,9 @@ def test_sisotool(self, sys):
initial_point_2, 4)

# Check the step response before moving the point
# new array needed because change in compute step response default time
step_response_original = np.array(
[0. , 0.0069, 0.0448, 0.124 , 0.2427, 0.3933, 0.5653, 0.7473,
0.928 , 1.0969])
#old: np.array([0., 0.0217, 0.1281, 0.3237, 0.5797, 0.8566, 1.116,
# 1.3261, 1.4659, 1.526])
[0. , 0.021 , 0.124 , 0.3146, 0.5653, 0.8385, 1.0969, 1.3095,
1.4549, 1.5231])
assert_array_almost_equal(
ax_step.lines[0].get_data()[1][:10], step_response_original, 4)

Expand Down Expand Up @@ -115,10 +112,9 @@ def test_sisotool(self, sys):
bode_mag_moved, 4)

# Check if the step response has changed
# new array needed because change in compute step response default time
step_response_moved = np.array(
[0., 0.0072, 0.0516, 0.1554, 0.3281, 0.5681, 0.8646, 1.1987,
1.5452, 1.875])
[0. , 0.023 , 0.1554, 0.4401, 0.8646, 1.3722, 1.875 , 2.2709,
2.4633, 2.3827])
assert_array_almost_equal(
ax_step.lines[0].get_data()[1][:10], step_response_moved, 4)

Expand Down
6 changes: 5 additions & 1 deletion control/tests/timeresp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ def test_step_pole_cancellation(self, pole_cancellation,
step_info_no_cancellation = step_info(no_pole_cancellation)
step_info_cancellation = step_info(pole_cancellation)
for key in step_info_no_cancellation:
if key == 'Overshoot':
# skip this test because these systems have no overshoot
# => very sensitive to parameters
continue
np.testing.assert_allclose(step_info_no_cancellation[key],
step_info_cancellation[key], rtol=1e-4)

Expand Down Expand Up @@ -522,7 +526,7 @@ def test_step_robustness(self):

@pytest.mark.parametrize(
"tfsys, tfinal",
[(TransferFunction(1, [1, .5]), 9.21034), # pole at 0.5
[(TransferFunction(1, [1, .5]), 13.81551), # pole at 0.5
(TransferFunction(1, [1, .5]).sample(.1), 25), # discrete pole at 0.5
(TransferFunction(1, [1, .5, 0]), 25)]) # poles at 0.5 and 0
def test_auto_generated_time_vector_tfinal(self, tfsys, tfinal):
Expand Down
6 changes: 3 additions & 3 deletions control/timeresp.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
T, yout = step_response(sys, T)

# Steady state value
InfValue = yout[-1]
InfValue = sys.dcgain()

# RiseTime
tr_lower_index = (np.where(yout >= RiseTimeLimits[0] * InfValue)[0])[0]
Expand All @@ -814,7 +814,7 @@ def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
'SettlingTime': SettlingTime,
'SettlingMin': yout[tr_upper_index:].min(),
'SettlingMax': yout.max(),
'Overshoot': 100. * (yout.max() - InfValue) / (InfValue - yout[0]),
'Overshoot': 100. * (yout.max() - InfValue) / InfValue,
'Undershoot': yout.min(), # not very confident about this
'Peak': yout[PeakIndex],
'PeakTime': T[PeakIndex],
Expand Down Expand Up @@ -1124,7 +1124,7 @@ def _ideal_tfinal_and_dt(sys, is_step=True):
default_dt = 0.1
total_cycles = 5 # number of cycles for oscillating modes
pts_per_cycle = 25 # Number of points divide a period of oscillation
log_decay_percent = np.log(100) # Factor of reduction for real pole decays
log_decay_percent = np.log(1000) # Factor of reduction for real pole decays

if sys._isstatic():
tfinal = default_tfinal
Expand Down