题目
在粗糙水平面上的一个弹簧振子,物体质量为$m$,弹簧的劲度系数为$k$,物体和水平表面之间的动摩擦因素为$\mu$,起始时物体的位置坐标为$x=A$,且速度为0,问:物体会停止在弹簧没有伸缩的地点吗?物体能振动多少次?
程序演示
程序源码
from vpython import *
m=0.5
k=10
dt=0.001
t=0
u=0.05
g=9.8
spring_length=1.5
scene=canvas(width=300,height=300,background=vec(0.5,0.6,0.5))
floor=box(pos=vec(0,0,0),length=3,height=0.01,width=1)
wall=box(pos=vec(-1.5,0.25-0.005,0),length=0.01,height=0.5,width=1)
square=box(pos=vec(0.5,0.1,0),length=0.2,height=0.2,width=0.2,texture=textures.wood,v=vec(0,0,0))
spring=helix(pos=vec(-1.5,0.1,0),radius=0.06,coils=15,thickness=0.03)
spring.axis=square.pos-spring.pos
figure=graph(width=300,height=300)
xtfigure=gcurve(graph=figure,color=color.red)
while t<5000:
rate(1000)
a=-(k*(spring.length-spring_length)/m)*spring.axis.norm()-u*g*square.v.norm()
square.v=square.v+a*dt
square.pos=square.pos+square.v*dt
spring.axis=square.pos-spring.pos
xtfigure.plot(t,square.v.x)
t=t+dt
评论 (0)