[关闭]
@2014301020054 2016-11-27T17:59:00.000000Z 字数 3667 阅读 1949

Exercise 10 : Precession of the Perihelion of Mercury

python physics


Abstract

In the present chapter we will consider several problems that arise in the study of plantary motion. We begin with the simplest situation, a sun and a single planet, and investigate a few of the properties of this model solar system. While a computational approach is not required in this case, the algorithm we develop will prove useful for later problems. Additionally, comparisions of the numerical results obtained with this algorithm with exact solutions will provide valuable insight into the nature of our approximations.


Background

Kepler's Laws


Main Body

Problem4.10 Calculate the precession of the perihelion of Mercury, following the approach described in this section.

(Problem4.11)

  1. import math
  2. import matplotlib.pyplot as plt
  3. GM=4*(math.pi**2)
  4. perihelion=0.39*(1-0.206)
  5. class Precession:
  6. def __init__(self,e=0.206,time=1,dt=0.0001,vcoefficient=1.1,beta=2.1,alpha=0.01):
  7. self.alpha=alpha
  8. self.beta=beta
  9. self.vcoefficient=vcoefficient
  10. self.e=e
  11. self.a=perihelion/(1-e)
  12. self.x0=self.a*(1+e)
  13. #self.x0=1
  14. self.y0=0
  15. self.vx0=0
  16. self.vy0=self.vcoefficient*math.sqrt((GM*(1-self.e))/(self.a*(1+self.e)))
  17. #self.vy0=2*math.pi
  18. self.X=[self.x0]
  19. self.Y=[self.y0]
  20. self.Vx=[self.vx0]
  21. self.Vy=[self.vy0]
  22. self.T=[0]
  23. self.dt=dt
  24. self.time=time
  25. self.ThetaPrecession=[]
  26. self.TimePrecession=[]
  27. def run(self):
  28. while self.T[-1]<self.time:
  29. r=math.sqrt(self.X[-1]**2+self.Y[-1]**2)
  30. newVx=self.Vx[-1]-(GM*(1+self.alpha/r**2)*self.X[-1]/r**(1+self.beta))*self.dt
  31. newX=self.X[-1]+newVx*self.dt
  32. newVy=self.Vy[-1]-(GM*(1+self.alpha/r**2)*self.Y[-1]/r**(1+self.beta))*self.dt
  33. newY=self.Y[-1]+newVy*self.dt
  34. if abs(newX*newVx+newY*newVy)<0.0014 and r<self.a:
  35. theta=math.acos(self.X[-1]/r)*180/math.pi
  36. if (self.Y[-1]/r)<0:
  37. theta=360-theta
  38. theta=abs(theta-180)
  39. self.ThetaPrecession.append(theta)
  40. self.TimePrecession.append(self.T[-1])
  41. self.Vx.append(newVx)
  42. self.Vy.append(newVy)
  43. self.X.append(newX)
  44. self.Y.append(newY)
  45. self.T.append(self.T[-1]+self.dt)
  46. def show_results(self):
  47. plt.plot(self.X,self.Y,'g')
  48. plt.legend(loc='upper right',frameon=False,fontsize='small')
  49. plt.grid(True)
  50. plt.title('Simulation of the precession of Mercury')
  51. plt.xlabel('x(AU)')
  52. plt.ylabel('y(AU)')
  53. ax = plt.gca()
  54. ax.set_aspect(1)
  55. #plt.xlim(-1,1)
  56. #plt.ylim(-0.6,0.6)
  57. #plt.scatter(0,0)
  58. A = Precession()
  59. A.run()
  60. A.show_results()

Then we can chose a different to do the work again.
we chose

Then we can choose


Conclusion

With the help of Kepler's Laws and the Euler-Cromer method, we can solve the motion of the simplest situation where a sun and a single planet get moved with interaction. And we can try to plot the figure of the precession of perihelion of Mercury.


Acknowledgment

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