[关闭]
@XF 2016-12-04T15:20:31.000000Z 字数 9527 阅读 111

第十次作业

作业


1、Abstract

In this exercise, the motion of Hyperion will be discussed according to the instruction of Problem4.21.Hyperion, also known as Saturn VII,is distinguished by its irregular shape,  chaotic rotation, and unexplained dumbball-like appearance.My work on Hyperion is just qualitative, aiming to show its chaotic during its orbit to Saturn.

2、Bankground

As we have known,Hyperion has an unusual shape,leading to its different behavior.Hyperion is shaped more like an egg and its orbit is choatic. We letbe the angle that the rod makes with the x axis and define the associated angular velocity.The center of the mass of the object isand.
After some algebra,we can obtain:


We can obtainby using

3.The Msin body

1.

  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. import math
  4. class hyperion:
  5. def __init__(self,GM=4*math.pi**2,dt=0.0001,time=10):
  6. self.GM=GM
  7. self.x=[1]
  8. self.y=[0]
  9. self.vx=[0]
  10. self.vy=[2*math.pi]
  11. self.dt=dt
  12. self.time=time
  13. self.r=[math.sqrt(self.x[0]**2+self.y[0]**2)]
  14. self.t=[0]
  15. self.w=[0]
  16. self.theta=[0]
  17. def calculate(self):
  18. for i in range(int(self.time//self.dt)):
  19. self.vx.append(self.vx[i]-self.GM*self.x[i]*self.dt/self.r[i]**3)
  20. self.vy.append(self.vy[i]-self.GM*self.y[i]*self.dt/self.r[i]**3)
  21. self.x.append(self.x[i]+self.vx[i+1]*self.dt)
  22. self.y.append(self.y[i]+self.vy[i+1]*self.dt)
  23. self.r.append(math.sqrt(self.x[i+1]**2+self.y[i+1]**2))
  24. self.w.append(self.w[i]-3*self.GM/self.r[i]**5*(self.x[i]*math.sin(self.theta[i])-self.y[i]*math.cos(self.theta[i]))*(self.x[i]*math.cos(self.theta[i])+self.y[i]*math.sin(self.theta[i]))*self.dt)
  25. self.theta.append(self.theta[i]+self.w[i+1]*self.dt)
  26. self.t.append(self.t[i]+self.dt)
  27. if self.theta[i+1]<-math.pi:
  28. self.theta[i+1]=self.theta[i+1]+2*math.pi
  29. if self.theta[i+1]>math.pi:
  30. self.theta[i+1]=self.theta[i+1]-2*math.pi
  31. def show_results(self,color):
  32. ax1=plt.subplot(121)
  33. ax2=plt.subplot(122)
  34. plt.sca(ax1)
  35. plt.plot(self.t,self.theta,'g',label=r'Circular orbit')
  36. plt.title(r'Hyperion $\Theta$ versus time',fontsize=14)
  37. plt.xlabel(u'time(yr)',fontsize=14)
  38. plt.ylabel(u'$\Theta$(radians)',fontsize=14)
  39. plt.sca(ax2)
  40. plt.plot(self.t,self.w,'g',label=r'Circular orbit')
  41. plt.title(r'Hyperion $\omega$ versus time',fontsize=14)
  42. plt.xlabel(u'time(yr)',fontsize=14)
  43. plt.ylabel(u'$\omega$(radians/yr)',fontsize=14)
  44. #plt.xlim(-1,1)
  45. #plt.ylim(-1,1)
  46. plt.legend(fontsize=14,loc='best')
  47. a=hyperion()
  48. a.calculate()
  49. a.show_results('g')
  50. plt.show()

2.

  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. import math
  4. class hyperion:
  5. def __init__(self,GM=4*math.pi**2,dt=0.0001,time=10):
  6. self.GM=GM
  7. self.x=[1]
  8. self.y=[0]
  9. self.vx=[0]
  10. self.vy=[5]
  11. self.dt=dt
  12. self.time=time
  13. self.r=[math.sqrt(self.x[0]**2+self.y[0]**2)]
  14. self.t=[0]
  15. self.w=[0]
  16. self.theta=[0]
  17. def calculate(self):
  18. for i in range(int(self.time//self.dt)):
  19. self.vx.append(self.vx[i]-self.GM*self.x[i]*self.dt/self.r[i]**3)
  20. self.vy.append(self.vy[i]-self.GM*self.y[i]*self.dt/self.r[i]**3)
  21. self.x.append(self.x[i]+self.vx[i+1]*self.dt)
  22. self.y.append(self.y[i]+self.vy[i+1]*self.dt)
  23. self.r.append(math.sqrt(self.x[i+1]**2+self.y[i+1]**2))
  24. self.w.append(self.w[i]-3*self.GM/self.r[i]**5*(self.x[i]*math.sin(self.theta[i])-self.y[i]*math.cos(self.theta[i]))*(self.x[i]*math.cos(self.theta[i])+self.y[i]*math.sin(self.theta[i]))*self.dt)
  25. self.theta.append(self.theta[i]+self.w[i+1]*self.dt)
  26. self.t.append(self.t[i]+self.dt)
  27. if self.theta[i+1]<-math.pi:
  28. self.theta[i+1]=self.theta[i+1]+2*math.pi
  29. if self.theta[i+1]>math.pi:
  30. self.theta[i+1]=self.theta[i+1]-2*math.pi
  31. def show_results(self,color):
  32. ax1=plt.subplot(121)
  33. ax2=plt.subplot(122)
  34. plt.sca(ax1)
  35. plt.plot(self.t,self.theta,'m',label=r'Elliptical orbit')
  36. plt.title(r'Hyperion $\Theta$ versus time',fontsize=14)
  37. plt.xlabel(u'time(yr)',fontsize=14)
  38. plt.ylabel(u'$\Theta$(radians)',fontsize=14)
  39. plt.sca(ax2)
  40. plt.plot(self.t,self.w,'m',label=r'Elliptical orbit')
  41. plt.title(r'Hyperion $\omega$ versus time',fontsize=14)
  42. plt.xlabel(u'time(yr)',fontsize=14)
  43. plt.ylabel(u'$\omega$(radians/yr)',fontsize=14)
  44. #plt.xlim(-1,1)
  45. #plt.ylim(-1,1)
  46. plt.legend(fontsize=14,loc='best')
  47. a=hyperion()
  48. a.calculate()
  49. a.show_results('m')
  50. plt.show()

3.

  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. import math
  4. class hyperion:
  5. def __init__(self,GM=4*math.pi**2,dt=0.0001,time=10):
  6. self.GM=GM
  7. self.x=[[1],[1],[1],[1]]
  8. self.y=[[0],[0],[0],[0]]
  9. self.vx=[[0],[0],[0],[0]]
  10. self.vy=[[5.5],[5],[4],[3]]
  11. self.x1=[[1],[1],[1],[1]]
  12. self.y1=[[0],[0],[0],[0]]
  13. self.vx1=[[0],[0],[0],[0]]
  14. self.vy1=[[5.5],[5],[4],[3]]
  15. self.dt=dt
  16. self.time=time
  17. self.r=[[math.sqrt(self.x[0][0]**2+self.y[0][0]**2)],[math.sqrt(self.x[1][0]**2+self.y[1][0]**2)],[math.sqrt(self.x[2][0]**2+self.y[2][0]**2)],[math.sqrt(self.x[3][0]**2+self.y[3][0]**2)]]
  18. self.t=[[0],[0],[0],[0]]
  19. self.w=[[0],[0],[0],[0]]
  20. self.theta=[[0.05],[0.05],[0.05],[0.05]]
  21. self.r1=[[math.sqrt(self.x1[0][0]**2+self.y1[0][0]**2)],[math.sqrt(self.x1[1][0]**2+self.y1[1][0]**2)],[math.sqrt(self.x1[2][0]**2+self.y1[2][0]**2)],[math.sqrt(self.x1[3][0]**2+self.y1[3][0]**2)]]
  22. self.t1=[[0],[0],[0],[0]]
  23. self.w1=[[0],[0],[0],[0]]
  24. self.theta1=[[0],[0],[0],[0]]
  25. self.d=[[math.log(abs(self.theta[0][0]-self.theta1[0][0]))],[math.log(abs(self.theta[1][0]-self.theta1[1][0]))],[math.log(abs(self.theta[2][0]-self.theta1[2][0]))],[math.log(abs(self.theta[3][0]-self.theta1[3][0]))]]
  26. self.dw=[[abs(self.w[0][0]-self.w1[0][0])],[abs(self.w[1][0]-self.w1[1][0])],[abs(self.w[2][0]-self.w1[2][0])],[abs(self.w[3][0]-self.w1[3][0])]]
  27. def calculate(self):
  28. for n in range(4):
  29. for i in range(int(self.time//self.dt)):
  30. self.vx[n].append(self.vx[n][i]-self.GM*self.x[n][i]*self.dt/self.r[n][i]**3)
  31. self.vy[n].append(self.vy[n][i]-self.GM*self.y[n][i]*self.dt/self.r[n][i]**3)
  32. self.x[n].append(self.x[n][i]+self.vx[n][i+1]*self.dt)
  33. self.y[n].append(self.y[n][i]+self.vy[n][i+1]*self.dt)
  34. self.r[n].append(math.sqrt(self.x[n][i+1]**2+self.y[n][i+1]**2))
  35. self.w[n].append(self.w[n][i]-3*self.GM/self.r[n][i]**5*(self.x[n][i]*math.sin(self.theta[n][i])-self.y[n][i]*math.cos(self.theta[n][i]))*(self.x[n][i]*math.cos(self.theta[n][i])+self.y[n][i]*math.sin(self.theta[n][i]))*self.dt)
  36. self.theta[n].append(self.theta[n][i]+self.w[n][i+1]*self.dt)
  37. self.t[n].append(self.t[n][i]+self.dt)
  38. if self.theta[n][i+1]<-math.pi:
  39. self.theta[n][i+1]=self.theta[n][i+1]+2*math.pi
  40. if self.theta[n][i+1]>math.pi:
  41. self.theta[n][i+1]=self.theta[n][i+1]-2*math.pi
  42. self.vx1[n].append(self.vx1[n][i]-self.GM*self.x1[n][i]*self.dt/self.r1[n][i]**3)
  43. self.vy1[n].append(self.vy1[n][i]-self.GM*self.y1[n][i]*self.dt/self.r1[n][i]**3)
  44. self.x1[n].append(self.x1[n][i]+self.vx1[n][i+1]*self.dt)
  45. self.y1[n].append(self.y1[n][i]+self.vy1[n][i+1]*self.dt)
  46. self.r1[n].append(math.sqrt(self.x1[n][i+1]**2+self.y1[n][i+1]**2))
  47. self.w1[n].append(self.w1[n][i]-3*self.GM/self.r1[n][i]**5*(self.x1[n][i]*math.sin(self.theta1[n][i])-self.y1[n][i]*math.cos(self.theta1[n][i]))*(self.x1[n][i]*math.cos(self.theta1[n][i])+self.y1[n][i]*math.sin(self.theta1[n][i]))*self.dt)
  48. self.theta1[n].append(self.theta1[n][i]+self.w1[n][i+1]*self.dt)
  49. self.t1[n].append(self.t1[n][i]+self.dt)
  50. if self.theta1[n][i+1]<-math.pi:
  51. self.theta1[n][i+1]=self.theta1[n][i+1]+2*math.pi
  52. if self.theta1[n][i+1]>math.pi:
  53. self.theta1[n][i+1]=self.theta1[n][i+1]-2*math.pi
  54. self.d[n].append(math.log(abs(self.theta[n][i]-self.theta1[n][i])))
  55. self.dw[n].append(abs(self.w[n][i]-self.w1[n][i]))
  56. def show_results(self,color):
  57. ax1=plt.subplot(221)
  58. ax2=plt.subplot(222)
  59. ax3=plt.subplot(223)
  60. ax4=plt.subplot(224)
  61. plt.sca(ax1)
  62. plt.plot(self.t[0],self.d[0],'g',label=r'd$\Theta$=0.05,v=5.5 Elliptical orbit')
  63. #plt.plot(self.t[0],self.dw[0],'b',label=r'd$\Theta$=0.05,v=5.5 Elliptical orbit')
  64. plt.title(r'Hyperion $\Delta{\Theta}$ versus time',fontsize=12)
  65. #plt.title(r'Hyperion $\Delta{\omega}$ versus time',fontsize=12)
  66. plt.xlabel(u'time(yr)',fontsize=12)
  67. plt.ylabel(u'$\Delta{\Theta}$(radians)',fontsize=12)
  68. #plt.ylabel(u'$\Delta{\omega}$(radians/yr)',fontsize=12)
  69. plt.legend(fontsize=10,loc='best')
  70. plt.sca(ax2)
  71. plt.plot(self.t[1],self.d[1],'g',label=r'd$\Theta$=0.05,v=5 Elliptical orbit')
  72. #plt.plot(self.t[1],self.dw[1],'b',label=r'd$\Theta$=0.05,v=5 Elliptical orbit')
  73. plt.title(r'Hyperion $\Delta{\Theta}$ versus time',fontsize=12)
  74. #plt.title(r'Hyperion $\Delta{\omega}$ versus time',fontsize=12)
  75. plt.xlabel(u'time(yr)',fontsize=12)
  76. plt.ylabel(u'$\Delta{\Theta}$(radians)',fontsize=12)
  77. #plt.ylabel(u'$\Delta{\omega}$(radians/yr)',fontsize=12)
  78. plt.legend(fontsize=10,loc='best')
  79. plt.sca(ax3)
  80. plt.plot(self.t[2],self.d[2],'g',label=r'd$\Theta$=0.05,v=4 Elliptical orbit')
  81. #plt.plot(self.t[2],self.dw[2],'b',label=r'd$\Theta$=0.05,v=4 Elliptical orbit')
  82. plt.title(r'Hyperion $\Delta{\Theta}$ versus time',fontsize=12)
  83. #plt.title(r'Hyperion $\Delta{\omega}$ versus time',fontsize=12)
  84. plt.xlabel(u'time(yr)',fontsize=12)
  85. plt.ylabel(u'$\Delta{\Theta}$(radians)',fontsize=12)
  86. #plt.ylabel(u'$\Delta{\omega}$(radians/yr)',fontsize=12)
  87. plt.legend(fontsize=10,loc='best')
  88. plt.sca(ax4)
  89. plt.plot(self.t[3],self.d[3],'g',label=r'd$\Theta$=0.05,v=3 Elliptical orbit')
  90. #plt.plot(self.t[3],self.dw[3],'b',label=r'd$\Theta$=0.05,v=3 Elliptical orbit')
  91. plt.title(r'Hyperion $\Delta{\Theta}$ versus time',fontsize=12)
  92. #plt.title(r'Hyperion $\Delta{\omega}$ versus time',fontsize=12)
  93. plt.xlabel(u'time(yr)',fontsize=12)
  94. plt.ylabel(u'$\Delta{\Theta}$(radians)',fontsize=12)
  95. #plt.ylabel(u'$\Delta{\omega}$(radians/yr)',fontsize=12)
  96. plt.legend(fontsize=10,loc='best')
  97. a=hyperion()
  98. a.calculate()
  99. a.show_results('b')
  100. plt.show()

4. Conclusion

for circular and elliptical orbit,reset


and for circular and elliptical orbit reset


not keepin range fromtofor circular and elliptical orbit


change the initial conditions
,change the initial velocity


,change the initial velocity

5 Thanks

感谢杜威同学的帮助!

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