def __init__(self,
              Ms=None,
              Mp=None,
              ap=None,
              e=0,
              Rs=None,
              Rp=None,
              omega=None,
              i=None,
              apnd=True):
     '''Save Values'''
     self.apnd = apnd
     self.Rs = Rs
     self.Rp = Rp
     self.G = 4 * math.pi**2.
     self.period = np.sqrt(((ap**3.) * ((Ms + Mp)**2.)) / Ms**3.)
     '''Set up Vectors'''
     rpp = ap - e * ap
     rsp = -(Mp / Ms) * rpp
     vpp = math.sqrt(
         ((self.G * Ms**3.) / (ap * (Ms + Mp)**2.)) * ((1. + e) / (1. - e)))
     vsp = -(Mp / Ms) * vpp
     '''Rotate Vectors into Viewer frame'''
     rs = vector.Vector(rsp, 0., 0.)
     rs.rot_z(omega)
     rs.rot_x(i)
     rp = vector.Vector(rpp, 0., 0.)
     rp.rot_z(omega)
     rp.rot_x(i)
     vs = vector.Vector(0., vsp, 0.)
     vs.rot_z(omega)
     vs.rot_x(i)
     vp = vector.Vector(0., vpp, 0.)
     vp.rot_z(omega)
     vp.rot_x(i)
     '''Set Up Sim'''
     star = Body.GravBody(Ms, rs, vs)
     planet = Body.GravBody(Mp, rp, vp)
     self.body = [star, planet]
     solver = Solver.RK2(0.01)
     self.physics = Physics.NBody(solver, self.G)
     self.bodies = [cp.deepcopy(self.body)]
     self.t = [0]
 def __init__(self, M1=None, M2=None, a1=1, e=0, apnd=True):
     '''Build GravBodies'''
     self.G = 4 * math.pi**2.
     r1p = a1 - e * a1
     r2p = -(M1 / M2) * r1p
     v1p = math.sqrt(
         ((self.G * M2**3.) / (a1 * (M1 + M2)**2.)) * ((1. + e) / (1. - e)))
     v2p = -(M1 / M2) * v1p
     r1 = vector.Vector(r1p, 0., 0.)
     r2 = vector.Vector(r2p, 0., 0.)
     v1 = vector.Vector(0., v1p, 0.)
     v2 = vector.Vector(0., v2p, 0.)
     body1 = Body.GravBody(M1, r1, v1)
     body2 = Body.GravBody(M2, r2, v2)
     '''Set up Sim'''
     self.body = [body1, body2]
     solver = Solver.RK2(0.01)
     self.physics = Physics.NBody(solver, self.G)
     self.bodies = [cp.deepcopy(self.body)]
     self.t = [0]
     self.apnd = apnd
Exemplo n.º 3
0
 def __init__(self):
     
     '''Build Grav Bodies'''
     ms = 9. 
     sunr = vector.Vector(0.,0.,0.)
     sunv = vector.Vector(0.,-0.6*np.pi/ms,0.)
     self.sun = Body.GravBody(ms,sunr,sunv)
     
     me = 0.1 
     earthr = vector.Vector(1.,0.,0.)
     earthv = vector.Vector(0.,6.*np.pi,0.)
     self.earth = Body.GravBody(me,earthr,earthv)
     
     mr5 = 0.1 
     rigel5r = vector.Vector(5.,0.,0.)
     rigel5v = vector.Vector(0.,2.*np.pi*np.sqrt(me+ms)/np.sqrt(5.),0.)
     self.rigel5 = Body.GravBody(mr5,rigel5r,rigel5v)
     
     '''Build Sim'''
     planets = [self.sun,self.earth,self.rigel5]
     solver = Solver.RK4(0.01)
     physics = Physics.NBody(solver,G=4.*np.pi**2.)
     self.sim = Simulation.OrbitSim(physics=physics,body=planets,apnd=False)
Exemplo n.º 4
0
    def __init__(self):

        self.solver = Solver.RK4(0.01)
        self.physics = Physics.NBody(self.solver, 4 * math.pi**2)