course_planning:183_projects:s23_week_1_problem_toy_boat_problem_solution

Differences

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

Link to this comparison view

Next revision
Previous revision
course_planning:183_projects:s23_week_1_problem_toy_boat_problem_solution [2022/12/20 21:43] – created hallsteincourse_planning:183_projects:s23_week_1_problem_toy_boat_problem_solution [2023/01/11 15:56] (current) hallstein
Line 31: Line 31:
 To figure out the speed of the boat with respect to the water ($v_{\rm b/w}$), you must first recognize that vectors can be broken down into components.  Since the water has no velocity perpendicular to the shore, if we send the boat directly across the river it will traverse the width $W$ in a time $t_{\rm across}$ having velocity $v_{\rm b/w}$.  So, we send it across and measure the time it takes $t_{\rm across}$.  Since this is constant velocity motion, we have $$x(t)=v\,t\quad\longrightarrow\quad W=v_{\rm b/w}t_{\rm across},$$ which we can simply solve for the desired:  $$v_{\rm b/w}=\frac{W}{t_{\rm across}}.$$  <wrap caution>$t_{\rm across}=2\,{\rm s}$</wrap> $\quad\longrightarrow \quad v_{\rm b/w}=10\,{\rm m/s}.$ To figure out the speed of the boat with respect to the water ($v_{\rm b/w}$), you must first recognize that vectors can be broken down into components.  Since the water has no velocity perpendicular to the shore, if we send the boat directly across the river it will traverse the width $W$ in a time $t_{\rm across}$ having velocity $v_{\rm b/w}$.  So, we send it across and measure the time it takes $t_{\rm across}$.  Since this is constant velocity motion, we have $$x(t)=v\,t\quad\longrightarrow\quad W=v_{\rm b/w}t_{\rm across},$$ which we can simply solve for the desired:  $$v_{\rm b/w}=\frac{W}{t_{\rm across}}.$$  <wrap caution>$t_{\rm across}=2\,{\rm s}$</wrap> $\quad\longrightarrow \quad v_{\rm b/w}=10\,{\rm m/s}.$
  
-To figure out the speed of the river, you must recognize that you can add relative velocity vectors, and you are taking time measurements with respect to the shore: $$\vec{v}_{\rm b/s}=\vec{v}_{\rm b/w}+\vec{v}_{\rm w/s}.$$  Now, since we don't have a ruler, we have to eliminate distance in all measurements.  This is done by sending the boat up and down the river along the same distance (mind you the times will be different).  As we send the boat downstream, we have a speed with respect to the shore $$v_{\rm b/s}^{\rm down}=v_{\rm b/w}+v_{\rm w/s}.$$  As we send the boat upstream, we have a speed with respect to the shore $$v_{\rm b/s}^{\rm up}=v_{\rm b/w}-v_{\rm w/s}.$$  Again, since this is constant velocity, we have $$D=v_{\rm b/s}^{\rm down}t_{\rm down}\qquad\mbox{and}\qquad D=v_{\rm b/s}^{\rm up}t_{\rm up}.$$  Making the requisite substitutions and solving for the desired, we come to find $$v_{\rm w/s}=v_{\rm b/w}\bigg(\frac{t_{\rm up}-t_{\rm down}}{t_{\rm up}+t_{\rm down}}\bigg).$$  <wrap caution>$t_{\rm down}=1\,{\rm s},\,\,\,t_{\rm up}=3\,{\rm s}$</wrap> $\quad\longrightarrow\quad v_{\rm w/s}=5\,{\rm m/s}.$+To figure out the speed of the river, you must recognize that you can add relative velocity vectors, and you are taking time measurements with respect to the shore: $$\vec{v}_{\rm b/s}=\vec{v}_{\rm b/w}+\vec{v}_{\rm w/s}.$$  Now, since we don't have a ruler, we have to eliminate distance in all measurements.  This is done by sending the boat up and down the river along the same distance (mind you the times will be different).  As we send the boat downstream, we have a speed with respect to the shore $$v_{\rm b/s}^{\rm down}=v_{\rm b/w}+v_{\rm w/s}.$$  As we send the boat upstream, we have a speed with respect to the shore $$v_{\rm b/s}^{\rm up}=v_{\rm b/w}-v_{\rm w/s}.$$   
 +<WRAP tip> 
 +== Tutor - Leading Questions == 
 +If students are having a difficult time with this, you can ask the following leading questions: 
 +  * **Question**: When do you expect the boat to move faster relative to the shore: when it is pointed directly upstream/against the current or downstream with the current? 
 +  * **Expected Answer**: ...we expect it to move faster relative to shore when it is pointed with the current... 
 +  * **Question**: Algebraically, what is different? 
 +  * **Expected Answer**: ...when upstream the two velocities are opposite each other and we need to subtract one from the other, but when it is pointed downstream they are in the same direction and add... 
 + 
 +</WRAP> 
 + 
 +Again, since this is constant velocity, we have $$D=v_{\rm b/s}^{\rm down}t_{\rm down}\qquad\mbox{and}\qquad D=v_{\rm b/s}^{\rm up}t_{\rm up}.$$  Making the requisite substitutions and solving for the desired, we come to find $$v_{\rm w/s}=v_{\rm b/w}\bigg(\frac{t_{\rm up}-t_{\rm down}}{t_{\rm up}+t_{\rm down}}\bigg).$$  <wrap caution>$t_{\rm down}=1\,{\rm s},\,\,\,t_{\rm up}=3\,{\rm s}$</wrap> $\quad\longrightarrow\quad v_{\rm w/s}=5\,{\rm m/s}.$
  
 <WRAP tip> <WRAP tip>
Line 74: Line 85:
 Impressed with your skills, the head of the Zevo Simulation Division tasks you with the completion of a "projected trajectory simulator" for the toy boat and river. You are not sure why this would be necessary, but you decide to proceed with the project. This simulator must display the motion of a toy boat crossing the river, with respect to the shore. The previous design team has already done the majority of the work, but they mysteriously disappeared without completing it... The head of the division suggests you complete the project as quickly as possible! Impressed with your skills, the head of the Zevo Simulation Division tasks you with the completion of a "projected trajectory simulator" for the toy boat and river. You are not sure why this would be necessary, but you decide to proceed with the project. This simulator must display the motion of a toy boat crossing the river, with respect to the shore. The previous design team has already done the majority of the work, but they mysteriously disappeared without completing it... The head of the division suggests you complete the project as quickly as possible!
  
-<WRAP download 35%> Code for Project 1:  Part B\\ Keep them in the same directory.\\ {{:183_projects:boat.py|Project 1 Code (boat.py)}}\\ {{:183_projects:physutil.py|PhysUtil Module}}</WRAP>+<WRAP download 60%>Code for Project 1: part B\\ https://www.glowscript.org/#/user/pcubed/folder/incompleteprograms/program/RiverCrossing</WRAP> 
 + 
  
 ====== Project 1 Solution: Part B: Zevo toy boats ====== ====== Project 1 Solution: Part B: Zevo toy boats ======
Line 125: Line 138:
 </WRAP> </WRAP>
  
-<code Python boat_sol.py> +<WRAP download 60%>Solution code for Project 1: part B\\ https://www.glowscript.org/#/user/pcubed/folder/solutions/program/RiverCrossingSolution/edit</WRAP>
-from __future__ import division +
-from visual import * +
-from physutil import *+
  
 +
 +Solution Code:
 +
 +<code>
 +GlowScript 2.9 VPython
 + 
 +get_library('https://cdn.rawgit.com/PERLMSU/physutil/master/js/physutil.js')
 + 
 scene.width = 900 scene.width = 900
 scene.height = 500 scene.height = 500
 scene.range = 20 scene.range = 20
 + 
 #Objects #Objects
 W = 20 W = 20
 origin = cylinder(pos=vector(0,0,0), axis=vector(0,0,5), radius=0.2, color=color.red) origin = cylinder(pos=vector(0,0,0), axis=vector(0,0,5), radius=0.2, color=color.red)
-water = box(pos=vector(-30,0,0), height=W, width=0, length=200, material=materials.wood, color=color.blue, opacity=0.4)+water = box(pos=vector(-30,0,0), height=W, width=0, length=200, color=color.blue, opacity=0.4)
 boat = sphere(pos=vector(0,-W/2,0), radius=0.4, color=color.white) boat = sphere(pos=vector(0,-W/2,0), radius=0.4, color=color.white)
 + 
 #Parameters and Initial Conditions #Parameters and Initial Conditions
 sboatwater = 10 sboatwater = 10
 + 
 thetaindegrees = 90 thetaindegrees = 90
 thetainrad = thetaindegrees*2*pi/360 thetainrad = thetaindegrees*2*pi/360
 + 
 dirboat = vector(cos(thetainrad),sin(thetainrad),0) dirboat = vector(cos(thetainrad),sin(thetainrad),0)
 + 
 vboatwater = sboatwater*dirboat vboatwater = sboatwater*dirboat
 + 
 vwatershore = vector(5,0,0) vwatershore = vector(5,0,0)
- +  
-vboatshore = vboatwater + vwatershore +vboatshore = vboatwater + vwatershore   #ADD calculation of velocity of boat rel to shore 
 +  
 + 
 #Time and time step #Time and time step
 t=0 t=0
 tf=10 tf=10
 dt=0.01 dt=0.01
 + 
 #MotionMap/Graph #MotionMap/Graph
 vboatwaterMotionMap = MotionMap(boat, tf, 15, markerScale=0.5, labelMarkerOrder=False, markerColor=color.orange) vboatwaterMotionMap = MotionMap(boat, tf, 15, markerScale=0.5, labelMarkerOrder=False, markerColor=color.orange)
-vboatshoreMotionMap = MotionMap(boat, tf, 15, markerScale=0.5, labelMarkerOrder=False, markerColor=color.orange+#Use given maotionmap of vboatwater to add motionmaps for vboatshore and vwatershore 
-vwatershoreMotionMap = MotionMap(boat, tf, 15, markerScale=0.5, labelMarkerOrder=False, markerColor=color.orange+vboatshoreMotionMap = MotionMap(boat, tf, 15, markerScale=0.5, labelMarkerOrder=False, markerColor=color.green #Added 
 +vwatershoreMotionMap = MotionMap(boat, tf, 15, markerScale=0.5, labelMarkerOrder=False, markerColor=color.blue#Added 
 + 
 #Calculation Loop #Calculation Loop
 while boat.pos.y <= W/2: while boat.pos.y <= W/2:
- rate(100)+    rate(100) 
 +  
 +    water.pos = water.pos + vwatershore*dt 
 +    boat.pos = boat.pos + vboatshore*dt  #edit final term from vwatershore*dt to vboatshore*dt 
 +  
 +  
 +    vboatwaterMotionMap.update(t, vboatwater) 
 +    #Use vboatwater motionmap as template to add vboatshore and vwatershore motion maps: 
 +    vboatshoreMotionMap.update(t, vboatshore)    #ADD   
 +    vwatershoreMotionMap.update(t, vwatershore)   #ADD 
 +  
 +  
 +    t = t + dt 
 +</code>
  
- water.pos = water.pos + vwatershore*dt +Changes to given code: 
- boat.pos = boat.pos + vboatshore*dt +{{course_planning:project_solutions:boat-codesoln.jpg}}
- +
- vboatwaterMotionMap.update(t, vboatwater) +
- vboatshoreMotionMap.update(t, vboatshore) +
- vwatershoreMotionMap.update(t, vwatershore) +
- +
- t = t + dt +
-</code>+
  • course_planning/183_projects/s23_week_1_problem_toy_boat_problem_solution.1671572589.txt.gz
  • Last modified: 2022/12/20 21:43
  • by hallstein