@zy-0815
2016-11-20T17:03:25.000000Z
字数 2382
阅读 1402
上次作业研究了参数对混沌现象的影响,而这次作业着重于研究桌球的碰撞问题。
已知运动方程为

1、方形边界
程序为:
import matplotlib.pyplot as pltvx = 3vy = 3.5x = [0.2]y = [0]dt = 0.01for i in range(10000):x.append(x[-1]+vx*dt)y.append(y[-1]+vy*dt)t = i*dtif x[-1]>1:r=(x[-2]-1)/(1-x[-1])y[-1]=(y[-2]+r*y[-1])/(r+1)x[-1]=1vx=-vxif x[-1]<-1:r=-(1+x[-2])/(x[-1]+1)y[-1]=(y[-2]+r*y[-1])/(r+1)x[-1]=-1vx=-vxif y[-1]>1:r=(y[-2]-1)/(1-y[-1])x[-1]=(x[-2]+r*x[-1])/(r+1)y[-1]=1vy=-vyif y[-1]<-1:r=-(1+y[-2])/(y[-1]+1)x[-1]=(x[-2]+r*x[-1])/(r+1)y[-1]=-1vy=-vyplt.plot(x,y)plt.xlabel('x')plt.ylabel('y')
运行结果为
改变速度方向,可得到:
2、圆形边界
(1)一般圆桌碰撞
程序为:
import matplotlib.pyplot as pltimport numpy as npv = 2a = 0.01x = [0.2]y = [0]vx = 2vy = 1.6dt = 0.01for i in range(10000):x.append(x[-1]+vx*dt)y.append(y[-1]+vy*dt)t = i*dtif (x[-1]*x[-1]+y[-1]*y[-1])>1:x[-1] = x[-2] + vx/100*dty[-1] = y[-2] + vy/100*dtm = np.sqrt(x[-1]**2+y[-1]**2)x[-1] = x[-1]/my[-1] = y[-1]/mv = np.sqrt(vx**2+vy**2)cos1 = (vx*x[-1]+vy*y[-1])/vcos2 = (vx*y[-1]-vy*x[-1])/vvt = -v*cos1vc = v*cos2vx = vt*x[-1]+vc*y[-1]vy = vt*y[-1]-vc*x[-1]plt.figure(figsize = (5,5))plt.xlim(-1,1)plt.ylim(-1,1)plt.plot(x,y)plt.xlabel('x')plt.ylabel('y')plt.title('Circular stadium - trajectory')
运行结果为:
(2)从x轴切开距离为2ar
程序为:
import matplotlib.pyplot as pltimport numpy as npv = 2a = 0.01x = [0.2]y = [0]vx = 2vy = 1.6dt = 0.01for i in range(5000):x.append(x[-1]+vx*dt)y.append(y[-1]+vy*dt)t = i*dtif (x[-1]*x[-1]+y[-1]*y[-1])>1 and y[-1]>0.01:while (x[-1]*x[-1]+y[-1]*y[-1])<1:x[-1] = x[-2] + vx/100*dty[-1] = y[-2] + vy/100*dtm = np.sqrt(x[-1]**2+y[-1]**2)x[-1] = x[-1]/my[-1] = (y[-1]-0.01)/m+0.01v = np.sqrt(vx**2+vy**2)cos1 = (vx*x[-1]+vy*(y[-1]-0.01))/vcos2 = (vx*(y[-1]-0.01)-vy*x[-1])/vvt = -v*cos1vc = v*cos2vx = vt*x[-1]+vc*(y[-1]-0.01)vy = vt*(y[-1]-0.01)-vc*x[-1]elif (x[-1]*x[-1]+y[-1]*y[-1])>1 and y[-1]<-0.01:while (x[-1]*x[-1]+y[-1]*y[-1])<1:x[-1] = x[-2] + vx/100*dty[-1] = y[-2] + vy/100*dtm = np.sqrt(x[-1]**2+y[-1]**2)x[-1] = x[-1]/my[-1] = (y[-1]+0.01)/m-0.01v = np.sqrt(vx**2+vy**2)cos1 = (vx*x[-1]+vy*(y[-1]+0.01))/vcos2 = (vx*(y[-1]+0.01)-vy*x[-1])/vvt = -v*cos1vc = v*cos2vx = vt*x[-1]+vc*(y[-1]+0.01)vy = vt*(y[-1]+0.01)-vc*x[-1]elif x[-1]<-1 and y[-1]>-0.01 and y[-1]<0.01:x[-1] = x[-2] + vx/100*dty[-1] = y[-2] + vy/100*dtvx=-vxelif x[-1]>1 and y[-1]>-0.01 and y[-1]<0.01:x[-1] = x[-2] + vx/100*dty[-1] = y[-2] + vy/100*dtvx=-vxplt.figure(figsize = (5,5))plt.xlim(-1,1)plt.ylim(-1,1)plt.plot(x,y)plt.xlabel('x')plt.ylabel('y')plt.title('Stadium billiard a=0.01')
运行结果为:

对于一般圆桌碰撞,无混沌现象;而当a=0.01时,图像会出现不规则的现象。
感谢周璟怡学姐的耐心帮助。