Link to starter code: https://www.glowscript.org/#/user/pcubed/folder/incompleteprograms/program/SatteliteCode
This is the students first introduction to VPython. In it, they must identify a few lines of code, write a few new lines, and discuss why those lines are written the way they are. Many students are often trepadatious to engage in computational modeling at first. You will need to encourage and coach them (computational anxiety is well-documented in the literature). Students often get the motion of the objects going fairly quickly, but the struggle with the graph. This calculation can really take their time away, but fortunately it is at the end. Encourage them to do this last after they have a working model. Also, encourage saving and “versioning” when they reach a key milestone, so they can always go back to a working model.
The students need to recognize that they must ask for a measurement of both the position and velocity of the asteroid as measured relative to the Voyager: $\vec{r}_{\rm A/V}=\langle-3{\rm e}10,8{\rm e}10,3{\rm e}9\rangle\,{\rm m}$ and $\vec{v}_{\rm A/V}=\langle1{\rm e}5,-9{\rm e}4,0\rangle\,{\rm m/s}.$ They can then use these to add in the initial position and the velocity of the asteroid, relative to ground control:
#Objects Asteroid = sphere(pos = Voyager.pos + vector(-3e10,8e10,3e9), radius=5e9) #Parameters and Initial Conditions vAsteroid = vVoyager + vector(1e5,-9e4,0)
Given this new position and velocity of the asteroid, we need to incorporate a position update in the while loop:
#Calculation loop Asteroid.pos = Asteroid.pos + vAsteroid*dt
In adding the graph, the group should use the PhysGraph bookmark in Safari to figure out how to plot.
#MotionMap/Graph separation = PhysGraph(numPlots=1) #Calculation Loop separation.plot(t,mag(Voyager.pos-Asteroid.pos))
GlowScript 2.9 VPython get_library('https://cdn.rawgit.com/PERLMSU/physutil/master/js/physutil.js') #Objects Voyager = sphere(pos=vector(-5e10,-2e10,-3e9), radius=3e9, color=color.green, make_trail=True) Asteroid = sphere(pos = Voyager.pos + vector(-3e10,8e10,3e9), radius=5e9, color=color.red, make_trail=True) #Parameters and Initial Conditions vVoyager = vector(1e5, 1e4, 1e4) vAsteroid = vVoyager + vector(1e5,-9e4,0) #Time and time step dt = .25e6 t = 0 tf = 1e6 #MotionMap/Graph trackVoyager = MotionMap(Voyager, tf, 5, markerScale=1e5) trackAsteroid = MotionMap(Asteroid, tf, 5, markerSacale=1e5) separation = PhysGraph(numPlots=1) #Calculation Loop while t < tf: rate(10) Voyager.pos = Voyager.pos + vVoyager*dt Asteroid.pos = Asteroid.pos + vAsteroid*dt trackVoyager.update(t,vVoyager) trackAsteroid.update(t,vAsteroid) separation.plot(t,mag(Voyager.pos-Asteroid.pos)) t = t + dt
Link to solution: https://www.glowscript.org/#/user/pcubed/folder/solutions/program/SatteliteCodeSolution