@2014301020054
2016-11-27T17:59:00.000000Z
字数 3667
阅读 1949
python physics
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.

According to the Newton's law of the gravitation the magnitude of this force is given by
From the Newton's secnd law, we have
Thus
can follow our usual approach and write each of the second-order differential equations as two first-order differential equations.
The orbital trajectory for a body of reduced mass is given in polar coordinates by
Also the momentum L is a constant,
Thus we have
Problem4.10 Calculate the precession of the perihelion of Mercury, following the approach described in this section.
(Problem4.11)
import mathimport matplotlib.pyplot as pltGM=4*(math.pi**2)perihelion=0.39*(1-0.206)class Precession:def __init__(self,e=0.206,time=1,dt=0.0001,vcoefficient=1.1,beta=2.1,alpha=0.01):self.alpha=alphaself.beta=betaself.vcoefficient=vcoefficientself.e=eself.a=perihelion/(1-e)self.x0=self.a*(1+e)#self.x0=1self.y0=0self.vx0=0self.vy0=self.vcoefficient*math.sqrt((GM*(1-self.e))/(self.a*(1+self.e)))#self.vy0=2*math.piself.X=[self.x0]self.Y=[self.y0]self.Vx=[self.vx0]self.Vy=[self.vy0]self.T=[0]self.dt=dtself.time=timeself.ThetaPrecession=[]self.TimePrecession=[]def run(self):while self.T[-1]<self.time:r=math.sqrt(self.X[-1]**2+self.Y[-1]**2)newVx=self.Vx[-1]-(GM*(1+self.alpha/r**2)*self.X[-1]/r**(1+self.beta))*self.dtnewX=self.X[-1]+newVx*self.dtnewVy=self.Vy[-1]-(GM*(1+self.alpha/r**2)*self.Y[-1]/r**(1+self.beta))*self.dtnewY=self.Y[-1]+newVy*self.dtif abs(newX*newVx+newY*newVy)<0.0014 and r<self.a:theta=math.acos(self.X[-1]/r)*180/math.piif (self.Y[-1]/r)<0:theta=360-thetatheta=abs(theta-180)self.ThetaPrecession.append(theta)self.TimePrecession.append(self.T[-1])self.Vx.append(newVx)self.Vy.append(newVy)self.X.append(newX)self.Y.append(newY)self.T.append(self.T[-1]+self.dt)def show_results(self):plt.plot(self.X,self.Y,'g')plt.legend(loc='upper right',frameon=False,fontsize='small')plt.grid(True)plt.title('Simulation of the precession of Mercury')plt.xlabel('x(AU)')plt.ylabel('y(AU)')ax = plt.gca()ax.set_aspect(1)#plt.xlim(-1,1)#plt.ylim(-0.6,0.6)#plt.scatter(0,0)A = Precession()A.run()A.show_results()
Result
We can plot the Precession of the Perihelion of Mercury.
First, we can chose that


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

Then we can choose

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.