📅  最后修改于: 2023-12-03 15:11:32.461000             🧑  作者: Mango
简单摆是由一根固定在底部的轻质、无摩擦细线,挂着一个质量为m、长度为l的质点所组成的摆。
简单摆的运动方程可以表示为:
其中:
我们可以通过受力分析推导出上述公式。
假设在t时刻,摆的偏移角度是θ(t)。其受到以下两个力的作用:
其中,j是重力方向的单位向量。
由牛顿第二定律得到关于θ的二阶微分方程:
我们可以使用Python模拟简单摆的运动。下面是一个代码示例:
import numpy as np
import matplotlib.pyplot as plt
g = 9.8 # 重力加速度
l = 1.0 # 摆长
theta0 = np.pi / 3.0 # 初始偏转角度
omega0 = 0.0 # 初始角速度
dt = 0.01 # 时间步长
t = np.arange(0.0, 10.0, dt) # 时间向量
theta = np.zeros_like(t)
omega = np.zeros_like(t)
theta[0] = theta0
omega[0] = omega0
for i in range(1, len(t)):
theta[i] = theta[i-1] + omega[i-1]*dt
omega[i] = omega[i-1] - (g/l)*np.sin(theta[i-1])*dt
plt.plot(t, theta)
plt.xlabel('Time (s)')
plt.ylabel('Theta (radians)')
plt.title('Simple Pendulum')
plt.show()
以下是程序输出的结果: