Friday, May 25, 2012

Space Voyage Part 1

     The purpose of this lab is to model the trajectory of an object as it passes by a large body such as a planet, moon, or star. Once the model is complete, it will be possible to explore the affect the initial velocity has on the trajectory.

Picture of predictions

     Initially a barely working code is provided. The lab group was asked to make two predictions. The predictions were what would happen if the program was executed in its current state and what should the motion look like in real life.  The following is the barely working code.

#Physics 4A Lab: Space Voyage Lab Part 1
#April 12th 2012
#Chris Cosio
#This is the first part to a space voyage simulation.
from __future__ import division
from visual import*

scene.width =800
scene.height = 800

#CONSTANTS
G = 6.7e-11
mEarth = 6e24
mcraft = 15e3
deltat = 60
#OBJECTS AND INITIAL VALUES
Earth = sphere(pos=vector(0,0,0), radius=6.4e6, color=color.cyan)
craft = sphere(pos=vector(-10*Earth.radius, 0,0), radius=1e6, color=color.yellow)
trail = curve(color=craft.color)    ## for leaving a trail behind the craft
vcraft = vector(0,2e3,0)
pcraft = mcraft*vcraft
t = 0
#CALCULATION LOOP: ALL REPEATED CALCULATIONS GO INSIDE THE LOOP
while t < 10*365*24*60*60:
   rate(100)     ## slow down motion to make animation look nicer
   craft.pos = craft.pos + (pcraft/mcraft)*deltat
   trail.append(pos=craft.pos) ## this leaves a trail behind the spacecraft
   t = t+deltat

     The previous two labs provided the frame work for repairing the sample code. The fancart lab provided a loop that updates momentum and the gravitational force lab provided the coding for gravitational forces.

     The following is the updated code and a sample video where in the initial velocity is set for a minimal elliptical orbit.

#Physics 4A Lab: Space Voyage Lab Part 1
#April 12th 2012
#Chris Cosio
#This is the first part to a space voyage simulaion.
from __future__ import division
from visual import*

scene.width =800
scene.height = 800

#CONSTANTS
G = 6.7e-11
mEarth = 6.7e24
mcraft = 15e3
deltat = 1
#OBJECTS AND INITIAL VALUES
Earth = sphere(pos=vector(0,0,0), radius=6.4e6, color=color.cyan)
craft = sphere(pos=vector(-5*Earth.radius, -5*Earth.radius,0), radius=1e6, color=color.yellow)
trail = curve(color=craft.color)    ## for leaving a trail behind the craft
pvector = arrow(color=color.red)
vcraft = vector(0,3050,0)
# 3050
pcraft = vcraft*mcraft
t = 0
#CALCULATION LOOP: ALL REPEATED CALCULATIONS GO INSIDE THE LOOP
while t < 10*365*24*60*60:
   rate(10000)                   ## slow down motion to make animation look nicer
   r = craft.pos-Earth.pos # craft position vector
   pvector.pos = craft.pos # momentum arrow
   rmag = mag(r)# magnitude of vector r
   rhat = norm(r) # unit vector in r direction
   F_grav_mag=G*mcraft*mEarth/(rmag**2)# magnitude of gravitational force
   Fgrav=-F_grav_mag*rhat # gravitational force
   vcraft = vcraft+(Fgrav/mcraft)*deltat # craft velocity
   pcraft = pcraft+Fgrav*deltat # craft momentum
   pvector.axis = 1*pcraft
   craft.pos = craft.pos + (pcraft/mcraft)*deltat
   trail.append(pos=craft.pos) ## this leaves a trail behind the spacecraft
   t = t+deltat






     There are a few observations to be made about this model. First, the vector on the orbiting body models the momentum. The vector is tangential to the ellipse. The momentum vector gets larger as the object approaches the planet and the momentum vector gets smaller as the object travels away from the planet. The change in the momentum vector is due to a impulse acting on the orbiting object. The gravitational force is the cause of the impulse. The object can escape the orbit with an initial velocity of <0,8375,0> meters per second. The object can also have a circular orbit with an initial velocity of <3750,0,> meters per second when the object starts at a distance five times the radius of the planet away. Both the escape velocity and circular orbit velocity show the large impact the initial velocity has on the trajectory of the orbiting object. The initial velocity determines the initial momentum and that momentum is affected by the impulse due to gravitational forces. If the object moves with a large initial velocity, the distance between the planet and the object grows enough for the gravitational force to impact the momentum much less. If the initial velocity of the object is too small the gravitational force will overtake the initial momentum and cause the two object to collide. The initial velocity imparted onto the orbiting object determines if it will crash into the planet, be slingshot-ed off in an elliptical orbit, or escape the gravitational pull of the larger object.

No comments:

Post a Comment