Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix step_info settling time calculation#1029

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall 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
51 changes: 47 additions & 4 deletionscontrol/tests/timeresp_test.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
"""timeresp_test.py - test time response functions"""

from copy import copy
from math import isclose

import numpy as np
import pytest
import scipy as sp

import control as ct
from control import StateSpace, TransferFunction, c2d, isctime, ss2tf, tf2ss
from control.exception importslycot_check, pandas_check
from control.exception importpandas_check, slycot_check
from control.tests.conftest import slycotonly
from control.timeresp import(_default_time_vector, _ideal_tfinal_and_dt,
forced_response, impulse_response,
initial_response, step_info,step_response)
from control.timeresp import _default_time_vector, _ideal_tfinal_and_dt, \
forced_response, impulse_response, initial_response, step_info, \
step_response


class TSys:
Expand DownExpand Up@@ -1275,3 +1276,45 @@ def test_no_pandas():
# Convert to pandas
with pytest.raises(ImportError, match="pandas"):
df = resp.to_pandas()


# https://github.com/python-control/python-control/issues/1014
def test_step_info_nonstep():
# Pass a constant input
timepts = np.linspace(0, 10, endpoint=False)
y_const = np.ones_like(timepts)

# Constant value of 1
step_info = ct.step_info(y_const, timepts)
assert step_info['RiseTime'] == 0
assert step_info['SettlingTime'] == 0
assert step_info['SettlingMin'] == 1
assert step_info['SettlingMax'] == 1
assert step_info['Overshoot'] == 0
assert step_info['Undershoot'] == 0
assert step_info['Peak'] == 1
assert step_info['PeakTime'] == 0
assert step_info['SteadyStateValue'] == 1

# Constant value of -1
step_info = ct.step_info(-y_const, timepts)
assert step_info['RiseTime'] == 0
assert step_info['SettlingTime'] == 0
assert step_info['SettlingMin'] == -1
assert step_info['SettlingMax'] == -1
assert step_info['Overshoot'] == 0
assert step_info['Undershoot'] == 0
assert step_info['Peak'] == 1
assert step_info['PeakTime'] == 0
assert step_info['SteadyStateValue'] == -1

# Ramp from -1 to 1
step_info = ct.step_info(-1 + 2 * timepts/10, timepts)
assert step_info['RiseTime'] == 3.8
assert step_info['SettlingTime'] == 9.8
assert isclose(step_info['SettlingMin'], 0.88)
assert isclose(step_info['SettlingMax'], 0.96)
assert step_info['Overshoot'] == 0
assert step_info['Peak'] == 1
assert step_info['PeakTime'] == 0
assert isclose(step_info['SteadyStateValue'], 0.96)
10 changes: 6 additions & 4 deletionscontrol/timeresp.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1674,17 +1674,19 @@ def step_info(sysdata, T=None, T_num=None, yfinal=None, params=None,

if not np.isnan(InfValue) and not np.isinf(InfValue):
# RiseTime
tr_lower_index = np.where(
tr_lower_index = np.nonzero(
sgnInf * (yout - RiseTimeLimits[0] * InfValue) >= 0
)[0][0]
tr_upper_index = np.where(
tr_upper_index = np.nonzero(
sgnInf * (yout - RiseTimeLimits[1] * InfValue) >= 0
)[0][0]
rise_time = T[tr_upper_index] - T[tr_lower_index]

# SettlingTime
settled = np.where(
np.abs(yout/InfValue-1) >= SettlingTimeThreshold)[0][-1]+1
outside_threshold = np.nonzero(
np.abs(yout/InfValue - 1) >= SettlingTimeThreshold)[0]
settled = 0 if outside_threshold.size == 0 \
else outside_threshold[-1] + 1
# MIMO systems can have unsettled channels without infinite
# InfValue
if settled < len(T):
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp