{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

[Phys172 Lab05]orbits

# [Phys172 Lab05]orbits - rhat_cE = r_cE/rmag_cE Fmag_cE =...

This preview shows pages 1–2. Sign up to view the full content.

from __future__ import division from visual import* f 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) Moon =sphere(pos=vector(4e8,0,0),radius=1.75e6,color=color.white) trail = curve(color=craft.color) t Fscale = 42e4 pscale = 8 p G = 6.67e-11 #Units of N m^2/kg^2 Earth.m = 6e24 #kg craft.m = 15e3 #kg Moon.m = 7e22 #kg M #2.5e3 is a nice circle, 3.3e3 is the provided value craft.v = vector(0,3.267e3,0) # m/s craft.p =craft.v*craft.m# kg m/s c #arr_p_c = arrow(color=color.blue) #momentum of craft arr_f_c = arrow(color=color.red,shaftwidth=2e6) #net force on craft arr_f_cE =arrow(color=color.cyan,shaftwidth=2e6) #net force from earth arr_f_cM =arrow(color=color.white,shaftwidth=2e6) #net force from moon a scene.autoscale = 0 scene.center = vector(2e8,0,0) t=0 deltat = 10 while t<4*365*24*3600: rate(50000) r_cE = Earth.pos - craft.pos rmag_cE = sqrt(r_cE.x**2+r_cE.y**2+r_cE.z**2)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: rhat_cE = r_cE/rmag_cE Fmag_cE = G*Earth.m*craft.m/rmag_cE**2 F_cE = Fmag_cE*rhat_cE r_cM = Moon.pos - craft.pos rmag_cM = sqrt(r_cM.x**2+r_cM.y**2+r_cM.z**2) rhat_cM = r_cM/rmag_cM Fmag_cM = G*Moon.m*craft.m/rmag_cM**2 F_cM = Fmag_cM*rhat_cM Fnet_c = F_cE + F_cM craft.p = craft.p + Fnet_c*deltat craft.pos = craft.pos + craft.p/craft.m*deltat trail.append(pos=craft.pos) #arr_p_c.pos = craft.pos arr_f_c.pos = craft.pos arr_f_cM.pos = craft.pos arr_f_cE.pos = craft.pos #arr_p_c.axis = craft.p*pscale arr_f_c.axis = Fnet_c *Fscale*2 arr_f_cE.axis = F_cE *Fscale arr_f_cM.axis = F_cM *Fscale*10 if rmag_cE < Earth.radius: print "Crashed into Earth @ t=", t break if rmag_cM < Moon.radius: print "Crashed into Earth @ t=", t break if t%1000000 == 0: print "t=", t, "<", 4*365*24*3600 #print "r_cE = ", r_cE print "F_cE = ", F_cE, "& F_cM = ", F_cM t=deltat+t...
View Full Document

{[ snackBarMessage ]}