无标题文章

@author: xyh

"""

import math

import matplotlib.pyplot as plt

GM=4(math.pi*2)

class precession:

def init(self,e=0.5,time=9,dt=0.0001,vcoefficient=1,beta=2,alpha=0,intial_w=0,intial_sita=0):

self.intial_sita=intial_sita

self.alpha=alpha

self.beta=beta

self.vcoefficient=vcoefficient

self.e=e

self.a=1/(1+e)

self.x0=self.a*(1+e)

self.y0=0

self.vx0=0

self.vy0=self.vcoefficientmath.sqrt((GM(1-e))/(self.a*(1+e)))

self.X=[self.x0]

self.Y=[self.y0]

self.Vx=[self.vx0]

self.Vy=[self.vy0]

self.w=[intial_w]

self.sita=[intial_sita]

self.T=[0]

self.dt=dt

self.time=time

self.ThetaPrecession=[]

self.TimePrecession=[]

def calculate_reset(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/r2)self.X[-1]/r*(1+self.beta))self.dt

newX=self.X[-1]+newVx*self.dt

newVy=self.Vy[-1]-(GM(1+self.alpha/r2)self.Y[-1]/r*(1+self.beta))self.dt

newY=self.Y[-1]+newVy*self.dt

newW=self.w[-1]-3GM/(r5)(self.X[-1]math.sin(self.sita[-1])-self.Y[-1]math.cos(self.sita[-1]))(self.X[-1]math.cos(self.sita[-1])+self.Y[-1]math.sin(self.sita[-1]))self.dt

newSita=self.dt*self.w[-1]+self.sita[-1]

self.Vx.append(newVx)

self.Vy.append(newVy)

self.X.append(newX)

self.Y.append(newY)

self.w.append(newW)

self.sita.append(newSita)

self.T.append(self.T[-1]+self.dt)

while self.sita[-1]>=1*math.pi:

self.sita[-1]=self.sita[-1]-2*math.pi

while self.sita[-1]<=-1*math.pi:

self.sita[-1]=self.sita[-1]+2*math.pi

def plot(self,slogan=''):

plt.scatter(self.sita,self.w,label=slogan,s=0.1)

plt.legend(loc='upper right',frameon=False,fontsize='small')

plt.grid(True)

plt.title('Hyperion(Elliptical orbit) $\omega$ versus $\theta$')

plt.ylabel('$\omega(radians/yr)$')

plt.xlabel('$\theta(radians)$')

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • import matplotlib.pyplot as plt import numpy as np class ...
    大乔治阅读 201评论 0 0
  • """ Created on Wed Nov 16 21:04:04 2016 @author: TanMingj...
    大乔治阅读 221评论 0 0
  • import matplotlib.pyplot as plt import numpy as np class ...
    大乔治阅读 215评论 0 0
  • 本文主要摘抄整理自Rickjin的《LDA数学八卦》 统计模拟中一个很重要的问题就是给定一个概率分布$p(x)$,...
    iV0id阅读 452评论 0 1
  • 目录 [TOC] 引言 量化交易是指以先进的数学模型替代人为的主观判断,利用计算机技术从庞大的历史数据中海选能带来...
    雷达熊阅读 1,023评论 0 2