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 22:44] – [Project 2: Part C] obsniukmcourse_planning:computation:scratch_work [2016/03/25 18:40] (current) – [Code] obsniukm
Line 23: Line 23:
  
 <WRAP download 60%> Code for Project 2: Part C\\ Keep them in the same directory.\\ {{:183_projects:hovercraft.py|Project 2 Code (hovercraft.py)}}\\ {{:183_projects:physutil.py|PhysUtil Module}}</WRAP>  <WRAP download 60%> Code for Project 2: Part C\\ Keep them in the same directory.\\ {{:183_projects:hovercraft.py|Project 2 Code (hovercraft.py)}}\\ {{:183_projects:physutil.py|PhysUtil Module}}</WRAP> 
 +
 +
 +
 +====== Code ======
 +
 +<code python>
 +#Objects
 +hovercraft = sphere(pos=vector(-200,400,0), radius=1)
 +
 +#Parameters and Initial Conditions
 +g = vector(0,-9.81,0)
 +
 +hovercraftm = 1500
 +hovercraftv = vector(53.64,0,0)
 +hovercraftp = runawaycraftm*runawaycraftv
 +
 +#Time and time step
 +t=0
 +tf=10
 +dt = 0.01
 +
 +#MotionMap/Graph
 +hovercraftMotionMap = MotionMap(hovercraft, tf, 5)
 +
 +#Calculation Loop
 +while hovercraft.pos.x < 0:
 +    Fgrav = hovercraftm*g
 +    Fground = -Fgrav
 +    Fnet = Fgrav + Fground
 +
 +    hovercraftp = hovercraftp + Fnet*dt
 +    hovercraft.pos = hovercraft.pos + (hovercraftp/hovercraftm)*dt
 +
 +    hovercraftMotionMap.update(t, hovercraftp/hovercraftm)
 +
 +    t = t + dt
 +</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.1457822678.txt.gz
  • Last modified: 2016/03/12 22:44
  • by obsniukm