Physics 2211 Fall 2009 Lab #3 Determining the Average Force on a Moving Object 1 Purpose In this lab, you will generate snapshots of the motion of a particle under the influence of an unknown force. You will: • determine the average momentum vector between successive locations in time, • create arrows representing those vectors, • determine the average force acting on the particle, • create arrow representing those force vectors, • and use the program you developed to produce snapshots for particular types of motion. Stroboscopic photographs are often used to illustrate the position of objects at equal time intervals. The figure below shows a stroboscopic photograph of a basketball bouncing on the ground. These snapshots are taken at equal time intervals and the position vectors may be used to determine the net force acting on the basketball. In your program you will be generating the same type of snapshots. 2 Interacting with the shell You may retrieve the shell for this program from the WebAssign assignment. Before going any further, read through the program and the comments. You may ignore the lines which set up mouse interaction. In the shell, scroll down to the section after the “DO NOT EDIT ABOVE THIS LINE” comment. This is where you will be adding code. Run the shell to see how you will interact with the program. • Click anywhere on the space and a sphere will appear. The sphere is assigned a number starting with ‘0’. 1 • Click again and another sphere appears. • Continue clicking until you can no longer generate any spheres. This is how you will generate your own stroboscopic picture. How many spheres were made? Where in the program is this number set? • Change this value to something larger (about 10 spheres is plenty) and rerun it. • Return the number to its original value. In this lab you will be using two loops. The first loop will help you compute and display arrows representing the average momentum vectors for the particle trajectory you have generated. The second will be used to determine the average force exerted on that particle. 3 Calculating and displaying momentum vectors In this section you will use the method from a previous lab to determine the average momentum vector between successive locations. You will represent those momentum vectors by green arrows. 3.1 Calculating the average momentum vector When you click to make your spheres, the program creates a list for you called list of locations. This list stores the position vectors for each sphere you created. To determine the average momentum, you will need to determine the vector displacement, ∆~r. First, you should remind yourself how to reference an element of list. • Using a ‘for’ loop, print all the position vectors for the spheres you will create. • If you need help with this refer to the previous lab in which you learned about lists. • After writing the code, run it. Does your code print the full position vectors? Using a method similar to the one in the previous lab, you will calculate and print the average momentum vectors. How many average momentum vectors will you calculate? Set the variable jmax to the number of average momentum vectors. Instead of using the numeric value, this value should be determined by the number of position vectors. Reference this number symbolically. You will determine the average momentum vector between each pair of successive spheres that you generate. The instructions below are repeated in the shell, • First, calculate the displacement vector. Make sure that you are using the ‘indices’. • Calculate the average momentum vector. Each sphere represents a snapshot of the motion at equally spaced time intervals, deltat. • Add the average momentum vector to the list of momentum vectors. You will need these later, so make sure to put them in the list. • Finally, print the average momentum vector. 2 3.2 Displaying the average momentum vector as an arrow A function has been built for you to handle displaying the arrows. This function, arrowGenerator, accepts three variables. The first is the position of the arrow’s tail, the second is its axis, and the arrow’s color (e.g., color.green). Use arrowGenerator to generate the arrows that represent the average momentum vectors. To do so you must answer the following questions, • Where is the tail of this arrow located. Hint: Think about the position update formula. • What does the axis of this arrow represent? You can use function by typing, arrowGenerator(arrowPosition,arrowAxis,arrowColor) where arrowPosition is replaced by the appropriate position vector, arrowAxis is replaced by the appropriate vector and arrowColor is replaced by color.green. Run your program. Do the momentum vectors look correct? Compare to Figure 1.31 in your text. You might have to run the program a few times, tweaking the location of your spheres to get arrows that “make sense”. It’s best to use a simple and smooth trajectory at first. Stop and Ask: When you are convinced that your program depicts the momentum vectors properly, call your TA over to check it. This is important because WebAssign will ask you to answer questions based on your code. 4 Calculating and displaying the average force vector In this section you will use a method similar to the one in Section 3 to determine the average force vector between two successive measures of momentum. You will represent those force vectors by red arrows. 4.1 Calculating the average force vector To determine the average force, you will need to determine the change in momentum, ∆~ p. Using a method similar to the one in Section 3.1, you will calculate and print the average force vectors. How many average force vectors will you calculate? Set the variable kmax to the number of average momentum vectors. Instead of using the numeric value, this value should be determined by the number of position vectors. Reference this number symbolically. You will determine the average force vector between each pair of successive momentum vectors that you calculated and displayed in Section 3. The instructions below are repeated in the shell, • First, calculate the change in the momentum vector. Make sure that you are using the ‘indices’. 3 • Calculate the average vector force exerted on the particle. Each sphere represents a snapshot of the motion at equally spaced time intervals, deltat. • Add the average force vector to the list of force vectors. You will need these later, so make sure to put them in the list. • Finally, print the average force vector. 4.2 Displaying the average force vector as an arrow A function has been built for you to handle displaying the arrows as stated in Section 3.2. Use arrowGenerator to generate the arrows that represent the average force vectors. To do so you must answer the following questions, • Where is the tail of this arrow located. Hint: Think about the average force and how many positions were required for each calculation. • What does the axis of this arrow represent? You can use function by typing, arrowGenerator(arrowPosition,arrowAxis,arrowColor) where arrowPosition is replaced by the appropriate position vector, arrowAxis is replaced by the appropriate vector and arrowColor is replaced by color.red. Run your program. Do the force vectors look correct? Compare to Figure 2.14 in your text. You might have to run the program a few times, tweaking the location of your spheres to get arrows that “make sense”. It’s best to use a simple and smooth trajectory at first. Stop and Ask: When you are convinced that your program depicts the force vectors properly, call your TA over to check it. This is important because WebAssign will ask you to answer questions based on your code. 4.3 Scaling arrows The point of a scale factor is to make it possible to see everything in the display at once. You should see an arrow pointing in the appropriate direction. However, you might not be able to see the spheres representing the particle, or some other arrows representing the momentum or force vectors. The arrow is so big that when VPython positions the “camera” so we can see the arrow, the arrow might overtake the view. At the moment, the axis of the arrow is a vector equal to the momentum or force you are calculating. We need to “scale down” the arrow so it is not gigantic compared to the sphere or other arrows. To do this, we need to multiply the arrow axis by a scalar, thus changing the magnitude of the arrow axis without changing the direction of the arrow. You must use the same scale factor for all arrows of a given type. We will use a “scale factor” to scale down (or up) the arrows if need be. You will find near the top of the code to scale factors defined, 4 pscale=1 fscale=1 Each of these factor represents a multiplicative factor, by which, you can change the length of your arrows. Although you may be able to find an appropriate scale factor by trial and error, it may be much faster to print the magnitude of p~ or F~ , which you already asked to do, and use this to figure out an appropriate scalar multiplier. If you don’t have this problem with your current trajectory, you need to generate one that does. You do this by generating a snapshot that creates arrows too large for the space. You will attempt to recreate a similar snapshot, after changing the scale factor. • Generate a snapshot the produces either momentum or force vectors too large for the space. Take note of the locations of these spheres. • Attempt to scale down these arrows by multiplying the appropriate vector by the scale factor before sending it to arrowGenerator. • Run your program to see if it worked. 5 Displaying the trajectory in “real-time” You will now display the trajectory you generated. The final section of the code is commented out. You may now uncomment the lines that read, print ‘Click to display trajectory.’ clickHold(n,list of locations,list of avgmomenta,pscale) This function display the spheres at the locations you chose. Run the program. A blue line is drawn between each representing the approximate trajectory for your particle. The green arrows represent your average momentum vectors that are used to update the object’s position, ~rf = ~ri + 6 p~ ∆t m Modeling Experiments Complete this section without comparing results or discussing with other groups. Using your working code, generate the following situations, 1. A trajectory in which the average momentum vectors are near zero. 2. A trajectory in which the average force vectors are near zero, but the average momentum vectors are not. 3. A trajectory in which the average force points in the direction of the average momentum. 4. A trajectory in which the average force point opposite the direction of the average momentum. 5. A trajectory in which the object moves in a circle You will need more spheres ∼15 for this. 5 You should make note of how you generated these. Your TA will ask you to produce them. Stop and Ask: After you have completed this section, call your TA over to look at each of these situations. Once he/she has ok’ed your work everyone should turn in this program in WebAssign. You might be asked more questions or to change values before submitting your work. 6.1 Saving images of your trajectories WebAssign will ask you to upload jpg’s of your trajectories (specifically, trajectories 3 and 4 from above). You will do this by taking a screenshot of the trajectory and saving it as a jpg file. If you already know how to do this using ’Print Screen’, please do so. Otherwise, these directions are to guide you. These directions are for systems using Microsoft Windows. For Mac, use the “Grab” utility available in the Applications directory. • Bring the trajectory into view. This is the image with only the green arrows. • Tap the “Print Screen” key (sometimes marked ‘PrtScn’). • Open Microsoft Paint and from the File menu select “New”. This opens a palette the same size as the screen. • Then select from the Edit menu “Paste”. This pastes the screenshot. • Now you can crop to the window showing the trajectory and save the file as a .jpg. Last edited: Sunday 30th August, 2009 at 5:26pm 6