Skip to content
Closed
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
11 changes: 11 additions & 0 deletions control/tests/timeresp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from copy import copy
from math import isclose
import warnings

import numpy as np
import pytest
Expand All @@ -14,6 +15,8 @@
step_response




Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove these extra blank lines before merging. (Normally, only up to 2 blank lines are used to separate top-level blocks in a Python file.)

class TSys:
"""Struct of test system"""
def __init__(self, sys=None, call_kwargs=None):
Expand Down Expand Up @@ -826,6 +829,14 @@ def test_auto_generated_time_vector_tfinal(self, tfsys, tfinal):
np.testing.assert_allclose(ideal_tfinal, tfinal, rtol=1e-4)
T = _default_time_vector(tfsys)
np.testing.assert_allclose(T[-1], tfinal, atol=0.5*ideal_dt)

def test_discrete_time_negative_one_settling(self):
#system with -1 pole
TF = TransferFunction([1,3,0],[1,3,2], dt=True)
with warnings.catch_warnings():
warnings.simplefilter("error")
impulse_response(TF)


@pytest.mark.parametrize("wn, zeta", [(10, 0), (100, 0), (100, .1)])
def test_auto_generated_time_vector_dt_cont1(self, wn, zeta):
Expand Down
2 changes: 1 addition & 1 deletion control/timeresp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,7 @@ def _ideal_tfinal_and_dt(sys, is_step=True):
m_z = np.abs(p) < sqrt_eps
p = p[~m_z]
# Negative reals- treated as oscillatory mode
m_nr = (p.real < 0) & (np.abs(p.imag) < sqrt_eps)
m_nr = (p.real < 0) & (np.abs(p.imag) < sqrt_eps) & (np.abs(p.real+1) > sqrt_eps)
p_nr, p = p[m_nr], p[~m_nr]
if p_nr.size > 0:
t_emp = np.max(log_decay_percent / np.abs((np.log(p_nr)/dt).real))
Expand Down
Loading