提问人:方耀廷 提问时间:5/21/2023 更新时间:5/21/2023 访问量:22
关于 vpython 的非线性摆问题
About vpython for non-linear pendulum problem
问:
阻尼解决方案有什么问题,我需要改变什么,我有定义错误吗?还是数学模型错了?
from vpython import sphere, cylinder, color, rate, vector, gcurve, canvas, graph
# set up the curve objects for the plots
anglecurve = gcurve(graph=graph1, color=color.cyan) # a graphics curve for the angular displacement
velcurve = gcurve(graph=graph1, color=color.red) # a graphics curve for the angular velocity
phasecurvedamp = gcurve(graph=graph2, color=color.magenta) # a graphics phase space curve for the damped pendulum
phasecurveundamp = gcurve(graph=graph2, color=color.green) # a graphics phase space curve for the undamped pendulum
### Run the animation ###
# Loop over the solutions calculated
for i in range(0,N):
angle = rsol[0,i] # undamped solution
angle_d = rsol_damp[0,i] # damped solution
rod.axis = vector(L*np.sin(angle), -L*np.cos(angle), 0)
bob.pos = vector(L*np.sin(angle), -L*np.cos(angle), 0)
# update damped system
rod_d.axis = vector(L*np.sin(angle_d), -L*np.cos(angle_d), 0)
bob_d.pos = vector(L*np.sin(angle_d), -L*np.cos(angle_d), 0)
tpoint = i * tend / N # scale the t-component manually
# update graph of angular displacement against time
# anglecurve.plot(tpoint, rsol[0,i]) # undamped system
anglecurve.plot(tpoint, rsol_damp[0,i]) # damped system
# velcurve.plot(tpoint, rsol[1,i]) # undamped system
velcurve.plot(tpoint, rsol_damp[1,i]) # damped system
# update graph of phase space
phasecurveundamp.plot(rsol[0,i], rsol[1,i]) # undamped system
phasecurvedamp.plot(rsol_damp[0,i], rsol_damp[1,i]) # damped system
rate(50) # framerate for all windows
print("End")
发生错误:意外的标记 punc «,», expected punc «]» at line 55: angle = rsol[0,i]
答: 暂无答案
评论