不同阻尼比的图形代码


import numpy as np
import matplotlib.pyplot as plt

# 定义二阶系统参数
omega_n = 1.0  # 无阻尼自然频率
t = np.linspace(0, 20, 1000)

# 不同阻尼比
zeta_values = [0,1, 0.5, 1.0, 2.0]

for zeta in zeta_values:
    if zeta == 1.0:
        # 临界阻尼
        x = (1 + omega_n * t) * np.exp(-omega_n * t)
    elif zeta > 1.0:
        # 过阻尼
        lambda1 = -omega_n * zeta + omega_n * np.sqrt(zeta**2 - 1)
        lambda2 = -omega_n * zeta - omega_n * np.sqrt(zeta**2 - 1)
        x = np.exp(lambda1 * t) + np.exp(lambda2 * t)
    else:
        # 欠阻尼
        w_d = omega_n * np.sqrt(1 - zeta**2)
        x = np.exp(-zeta * omega_n * t) * np.sin(w_d * t)

    plt.plot(t, x, label=f'ζ = {zeta}')

plt.xlabel('Time')
plt.ylabel('Response')
plt.title('Second Order System Response for Different Damping Ratios')
plt.legend()
plt.grid(True)
plt.show()

image

posted @ 2024-11-04 13:25  redufa  阅读(96)  评论(0)    收藏  举报