course_planning:computation:scratch_work

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
course_planning:computation:scratch_work [2016/03/12 23:03] – [Code] obsniukmcourse_planning:computation:scratch_work [2016/03/25 18:40] (current) – [Code] obsniukm
Line 30: Line 30:
 <code python> <code python>
 #Objects #Objects
-runawaycraft = sphere(pos=vector(-200,400,0), radius=10, color=color.red)+hovercraft = sphere(pos=vector(-200,400,0), radius=1)
  
 #Parameters and Initial Conditions #Parameters and Initial Conditions
 g = vector(0,-9.81,0) g = vector(0,-9.81,0)
  
-runawaycraftm = 1500 +hovercraftm = 1500 
-runawaycraftv = vector(53.64,0,0) +hovercraftv = vector(53.64,0,0) 
-runawaycraftp = runawaycraftm*runawaycraftv+hovercraftp = runawaycraftm*runawaycraftv
  
 #Time and time step #Time and time step
Line 45: Line 45:
  
 #MotionMap/Graph #MotionMap/Graph
-runawaycraftMotionMap = MotionMap(runawaycraft, tf, 5, markerScale=1, labelMarkerOrder=False, markerColor=color.orange)+hovercraftMotionMap = MotionMap(hovercraft, tf, 5)
  
 #Calculation Loop #Calculation Loop
-while runawaycraft.pos.x < 0: +while hovercraft.pos.x < 0: 
- rate(500)+    Fgrav = hovercraftm*g 
 +    Fground = -Fgrav 
 +    Fnet = Fgrav + Fground
  
- Fgrav runawaycraftm*g +    hovercraftp hovercraftp + Fnet*dt 
- Fground -Fgrav +    hovercraft.pos hovercraft.pos (hovercraftp/hovercraftm)*dt
- Fnet = Fgrav Fground+
  
- runawaycraftp = runawaycraftp + Fnet*dt +    hovercraftMotionMap.update(t, hovercraftp/hovercraftm)
- runawaycraft.pos = runawaycraft.pos + (runawaycraftp/runawaycraftm)*dt+
  
- runawaycraftMotionMap.update(t, runawaycraftp/runawaycraftm) +    t = t + dt
- +
- t = t + dt+
 </code> </code>
 +
 +<WRAP tip>
 +== Tutor Questions ==
 +  * **Question:**  What assumptions did you make about the motion of the hovercrafts?
 +  * **Expected Answer:**  That the runaway craft has a constant velocity, and the rescue craft starts from rest with a constant acceleration.
 +
 +  * **Question:**  Are these velocities and accelerations calculated from the numbers given exact?
 +  * **Expected Answer:**  No, these are only average numbers, not instantaneous.  In order to get more "exact" numbers, we would need more data.
 +
 +  * **Question:**  Is the predicted position of the rescue craft a good one?
 +  * **Expected Answer:**  Not really, basing the trajectory off the first 20 seconds of data is probably not the best -- but it is all we have to work with.
 +
 +  * **Questions:**  Can you draw a plot of position vs. time for both crafts?  What are the important features of this graph?
 +  * **Expected Answer:**  The point where the two curves cross is when we should jump.  One should be linear, the other quadratic.
 +
 +  * **Questions:**  Can you draw a plot of velocity vs. time for both crafts?  What are the important features of this graph?
 +  * **Expected Answer:**  The acceleration is the slope of each curve (constant in both cases).
 +</WRAP>
  • course_planning/computation/scratch_work.1457823828.txt.gz
  • Last modified: 2016/03/12 23:03
  • by obsniukm