[关闭]
@74849b 2017-02-28T13:31:58.000000Z 字数 2226 阅读 959

exercise 08

problem 3.31


正文

We consider a problem of a ball moving without friction on a perfect billiard table.Between collisions the velocity is constant so we have

After locatingthe collision point,We must next obtain the unit vector normal to the wall at the point of collision,.It is then useful to calculate the components of parallel and perpendicular to the wall.These are just
Hence,the velocity after reflection from the wall is

结果

1.for circle boundary:

  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
此处输入图片的描述
此处输入图片的描述
此处输入图片的描述

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