import numpy as np
import scipy.signal as signal
import matplotlib.pyplot as plt
# 2차 시스템 예시: G(s) = 4 / (s^2 + 2.8s + 4)
num = [4]
den = [1, 2.8, 4]
system = signal.TransferFunction(num, den)
# 시간 응답
t = np.linspace(0, 10, 1000)
t_out, y_out = signal.step(system, T=t)
# 목표값 (최종값): 계단 입력이므로 이상적으로는 1
final_value = y_out[-1]
# 오버슈트 계산
overshoot = (np.max(y_out) - final_value) / final_value * 100
# 정착 시간 계산 (5% 기준)
tolerance = 0.05 * final_value
settling_index = np.where(np.abs(y_out - final_value) > tolerance)[0]
settling_time = t_out[settling_index[-1] + 1] if len(settling_index) > 0 else 0
# 상승 시간 계산 (10% ~ 90%)
rise_start = 0.1 * final_value
rise_end = 0.9 * final_value
rise_indices = np.where((y_out >= rise_start) & (y_out <= rise_end))[0]
rise_time = t_out[rise_indices[-1]] - t_out[rise_indices[0]] if len(rise_indices) > 0 else 0
# 출력
{
"최종값": round(final_value, 4),
"오버슈트 (%)": round(overshoot, 2),
"정착 시간 (s)": round(settling_time, 3),
"상승 시간 (s)": round(rise_time, 3),
}
결과
{'최종값': 1.0, '오버슈트 (%)': 4.6, '정착 시간 (s)': 1.451, '상승 시간 (s)': 1.051}
'Engineering > 제어공학' 카테고리의 다른 글
| PID 제어기의 수식 유도 (0) | 2025.06.21 |
|---|---|
| PID 제어기 시뮬레이션 코드 (0) | 2025.06.21 |
| 제어공학에서 말하는 감쇠(감쇠비, damping) 의 개념 (0) | 2025.06.20 |
| 시스템 응답 분석 (0) | 2025.06.20 |
| 1차 시스템의 단위 계단 응답 Python 시뮬레이션 (0) | 2025.06.20 |
