[关闭]
@XF 2016-11-20T16:08:02.000000Z 字数 2344 阅读 205

Exercise09

homewodk


exercise3.31

摘要

Study the tratrajectory of a small ball which can be considered as a point and will bounce at the boundary of a 'stadium' whose shape can be determined freely.

背景

Study the tratrajectory of a small ball which can be considered as a point and will bounce at the boundary of a 'stadium' whose shape can be determined freely.

正文

我们思考一个球在一个完美的台球桌上没有摩擦的问题,在碰撞之间的速度是恒定的,所以我们有



碰撞点确定后,接下来我们必须得到单位向量法在墙上的碰撞, 然后计算平行和垂直于墙的分量 我们有


故从墙上反射会带的速度为

结果

1.圆边界:

  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. import math
  4. class tabel:
  5. def__init__(self,x_0=0.2,y_0=0,vx_0=-0.2,vy_0=-0.5,dt_1=0.001,total_time=1000):
  6. self.x=[x_0]
  7. self.y=[y_0]
  8. self.vx=[vx_0]
  9. self.vy=[vy_0]
  10. self.dt=dt_1
  11. self.time=total_time
  12. self.t=[0]
  13. def calculate(self):
  14. for i in range(int(self.time/self.dt)):
  15. self.x.append(self.x[i]+self.vx[i]*self.dt)
  16. self.y.append(self.y[i]+self.vy[i]*self.dt)
  17. self.vx.append(self.vx[i])
  18. self.vy.append(self.vy[i])
  19. if ((self.x[i+1]**2+self.y[i+1]**2>1):
  20. X=(self.x[i]+self.x[i+1])/2
  21. Y=(self.y[i]+self.y[i+1])/2
  22. x1=X/(X**2+Y**2)**0.5
  23. y1=Y/(X**2+Y**2)**0.5
  24. self.vx[i+1]=(1-2*x1**2)*self.vx[i]-2*x1*y1*self.vy[i]
  25. self.vy[i+1]=(1-2*y1**2)*self.vy[i]-2*x1*y1*self.vx[i]
  26. if X**2+Y**2>1:
  27. self.x[i+1]=X
  28. self.y[i+1]=Y
  29. continue
  30. else:
  31. self.x[i]=X
  32. self.y[i]=Y
  33. continue
  34. x_1=[-1]
  35. y_1=[0]
  36. x_2=[-1]
  37. y_2=[0]
  38. dx=0.0001
  39. def bound(self):
  40. for k in range(20000):
  41. x_1.append(x_1[k]+dx)
  42. y_1.append((1-x_1[k+1]**2)**0.5)
  43. x_2.append(x_2[k]+dx)
  44. y_2.append(-(1-x_2[k+1]**2)**0.5)
  45. def show_results(self):
  46. plt.plot(self.x,self.y,'--',label='trajectory')
  47. plt.plot(x_1,y_1,'--',label='bound')
  48. plt.plot(x_2,y_2,'--',label='bound')
  49. plt.xlabel(u'x')
  50. plt.ylabel(u'y')
  51. a=tabel()
  52. a.calculate()
  53. a.show_results()
  54. b=tabel
  55. b.bound()
  56. b.show_results()
  57. plt.show()

the results:for t=50,100,1000



the corresponding phase:

2.elliptical tabel:
The equation is:


the code which need to change:

  1. if ((self.x[i+1]**2/4+self.y[I+1]**2)>1):
  2. X=(self.x[i]+self.x[i+1])/2
  3. Y=(self.y[i]+self.y[i+1])/2
  4. x1=(X/2)/(X**2/4+Y**2)**0.5
  5. x2=Y/(X**2/4+Y**2)**0.5
  6. self.vx[i+1]=(1-2*x1**2)*self.vx[i]-2*x1*y1*self.vy[i]
  7. self.vy[i+1]=(1-2*y1**2)*self.vy[i]-2*x1*y1*self.vx[i]

for t=100,1000,7000:



the phase:

big circle contains small elliptical
for t=100,1000,5000


致谢

感谢罗佳佳同学对我本次作业的帮助。十分感谢!

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注