Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

PHYS 172 LAB 02 : Position, Velocity & Acceleration FALL 2019

LAST NAME (ALL CAPS) TUVDEN FIRST NAME (ALL CAPS) ORGIL
PUID: 031645257 LAB GROUP NUMBER 28
CIRCLE/HIGHLIGHT DAY & TIME CIRLCE/HIGHLIGHT LAB ROOM
TUE 11:30 1:30 3:30
WED 9:30 11:30 1:30 3:30 PHYS PHYS
THU 9:30 11:30 1:30 Rm 8 Rm 18

FRI 9:30 11:30 1:30 3:30


Goal: After completing this activity, you
should be able to:
• Use loops to model motion iteratively
in VPython.
• Measure 1D position, velocity, and
Fig. 1
acceleration.
• Connect physical experiment and a
VPython model.
Iterative Vector Modeling
A loop is a set of code instructions that runs repeatedly as long as a condition is met. Figure 1 shows an example of a
while loop in VPython. A while loop starts with a condition (e.g. x<10) followed by commands that are executed as long
as that condition is met. When the condition is no longer met (e.g. x≥10) the program moves on to the line of code
following the loop. Note that all of the instruction lines are indented one tab past the while condition. This tells
GlowScript what lines of code are contained within the while loop. Returning to standard non-indented lines indicates
the end of the loop. Let’s look at an actual example in VPython:
If you did NOT create a GlowSscript account during Lab 01, you MUST DO SO NOW…
 From any internet browser, go to http://www.glowscript.org
 Sign in with your Google account (e.g. Gmail, YouTube, etc.). This will create a GlowScript account for you.
 Open your programs by clicking on “You are signed in as ___ and your programs are here.”
 Click on the “MyPrograms” tab in your file manager and copy the URL from the browser bar into the box below. The
link should look like this: http://www.glowscript.org/#/user/YourUsername/folder/MyPrograms/
https://www.glowscript.org/#/user/Orgilt7/folder/MyPrograms/program/Lab02Loops/edit
Copy and Paste your URL Here >>
 Set your MyPrograms folder to PUBLIC by clicking on the public/private toggle button in the upper left, as shown in
the figure below. The word displayed is the current state of the folder (i.e., if you see “PUBLIC,” it is set to public).
This will allow your TA to see your code.

 In your “MyPrograms” folder, create a new program called “Loops”.


 Click on the link below and copy the code from “WhileLoopTutorial” into your new “Loops” program.
http://www.glowscript.org/#/user/phys172.labs/folder/Lab2/
 Uncomment Part 1 by removing one # before each sentence. Lines with ## will continue to remain as comments.
 Examine the code and read through the comments following each line to determine what the code is doing.
Q01: How many times do you predict the loop in Part 1 will execute? Explain why.
20 times, Because the code adds 1 to X every loop.

Q02: Run the code. How many times does the code run? Does this match your prediction? If not, explain why?
The code runs 19 times, It did not match our prediction, because x was coded to be less than 20.

 Re-comment Part 1 of the code by adding one # in front of each line. Uncomment Part 2.
 Examine the code and read through the comments after each line to determine what the code is doing.
Q03: What is the conditional statement checking in Loop 2?
The loop is checking the difference while x is subtracted by y is less than x/2.

Q04: Run the code. How many times does the loop run? What is the value of y when the program stops?
The code runs 35 times. Until the y reaches 25 it doesn’t stop.

Q05: Identify at least one thing in the while loop (lines 30–33) that you could change to make the loop run fewer times.
Describe the change below.
We can increase the constant or the slope, instead of “y=y-1” we can program “y=y-2” to run fewer times.

2
Push Cart VPython Simulation
Now you will use loops to model motion using the position update formula: 𝑟⃗𝑓 = 𝑟⃗𝑖 + 𝑣⃗∆𝑡
Q06: Describe how you think we can use while loops to predict the motion of an object using position update?
We can use the while loop for the time interval, such like first identifying x as the time and give a time interval.
Then the program can calculate position and velocity.

Next we analyze a computational model of push cart that you will be use in the next section. In the simulation, the cart is
moving along the track for 1m at a constant velocity.
 In your Public GlowScript folder, create a new program called “PushCartSimulation”
 Copy the code from the link below into your new program.
http://www.glowscript.org/#/user/phys172.labs/folder/Lab2/
 Take a careful look through PushCartSimulation code.
Q07: Add comments to the code to explain what each part does. Ignore the part of the code where you are NOT asked
to comment i.e. the part of the code that creates the visual display.
Q08: Which section of the code is used to calculate the motion of our push cart [Not the visual display, but the
calculation]? Explain why.
The final section of the code is calculated to find the motion, The pushCart.pos = pushcart.pos + velocity + deltaT,
Because this calculations give you position of update and you can find distance traveled.

 Run the code and observe what happens.


Q09: At what time after starting the simulation does the push cart pass the 0.5m mark? Explain why.
1.55 second mark is our estimate, because once we run the program there is a table on the bottom that tells
position of the cart in certain time but it only tells every .15 seconds.

 Modify the code so that it provides a more accurate estimate of the time at 0.5m.
Q10: Describe below what changes you made to the code. Explain why.
We can change deltaT to .01 instead of .1 to get one more decimal place to get a closer and more accurate
estimate.

3
Q11: How does the rate at which we record (or generate) data influence our results? Explain why.
Once we change the deltaT to a smaller number we can a better and more precise result.

 Now imagine that our simulation was tracking the motion of a proton that has been accelerated to constant
terminal velocity trough a linear particle accelerator.
Q12: If we wanted to accurately estimate the time at which the proton passes through a specific checkpoint in the
accelerator, what might need to differ from the push cart example above? Why?
Make deltaT smaller so that we get more accurate estimate.

Push Cart Physical Experiment


You will now compare the VPython simulation above, with a real experiment.
 Plug in the motion sensor into the interface
 Open the PASCO Capstone program and check that the motion sensor is detected
 Set three graphs to measure position, velocity, and acceleration vs time simultaneously
a) Open a Graph display: double click on the “Graph” button in the Displays’ bar of the screen
b) Add two new plot areas to the Graph display, click on the correspond tool on the top bar
c) Select the measurements for each plot in the Graph display. Time on the horizontal axis; and
position, velocity, and acceleration on the vertical (click on “<Select Measurement>” button beside
the axes and select the respective measurements)
 Dock the motion sensor at one end of the dynamic cart track
 Put the dynamic cart on the track at the opposite end of the motion sensor.
Make sure the vertical metal sheet on the cart is facing the motion sensor
 Make sure the motion sensor is in “cart” mode, by setting the switch on the
motion sensor toward the cart symbol.
 With the dynamic cart and the motion sensor at the same end of the track but
separated by about 15 cm, start to collect data by clicking on the “Record”
button in the control bar in the bottom of the
screen. Just after you start to record, give a
gentle push on the dynamic cart such that it
starts to move at a kind of constant velocity
(moving away from the sensor). Stop the
recording after a little while.
 Analyze with your colleagues the three
different paths in each plot (position, velocity,
and acceleration).

4
Q13: Identify in the velocity graph an interval of time where the velocity of the cart was
approximately constant. [Hint: If your data is too irregular, you can use the “Smoothing” tool on the tool
bar in the Graph display to smooth the data of your experiment so that you can easily decide in which
period of time the path is closest to constant velocity] What interval of time is that? and What is the
value of that “constant” velocity? [HINT: You can find the mean of the velocity in the period that
you chose, using the tool to calculate statistics of the active data  Click on the capital ”Sigma”
button in the Tools bar on the top of the Graph display. NOTE: to select a specific interval of data,
you need to use the tool Highlight range in the same bar of tools used in the last item.]
The path that was closest to constant velocity was during the time interval of [1,2], The “constant” velocity is .17 m/s.

EACH STUDENT MUST TAKE A SCREEN CAPTURE OF THE RELEVANT PORTION OF GRAPH & PASTE IT BELOW.

Q14: In the velocity graph, using the value of average (“constant”) velocity and the time interval in the velocity vs.
time graph, predict the change in position [HINT: Use ∆𝑟⃗ = 𝑣⃗𝑎𝑣𝑔 ∆𝑡]
The change in position is .17 meters.

 In the position graph, select the same time interval that you chose in the velocity graph above.
Q15: Use the position graph to determine the change in position, during that time interval [i.e. ∆𝑟⃗ during time of the
period where you consider the cart is moving with constant velocity.]

5
The position at time 2 is .47m the position at time 1 is .30m

EACH STUDENT MUST TAKE A SCREEN CAPTURE OF THE RELEVANT PORTION OF GRAPH & PASTE IT BELOW.

Q16: How do the values of the change in position as measured using the two methods above (one using ∆𝑟⃗ = 𝑣⃗𝑎𝑣𝑔 ∆𝑡
from the velocity graph and the other using ∆𝑟⃗ directly from the position graph) compare with each other?
They both equal to each other by .17 meters.

Connecting the VPython Model with the Physical Experiment


Now that you have collected data in a real experiment to measure position, velocity, and acceleration, it is possible
modify the computational model from Part 2 to model the physical experiment during the time interval that you
identified as constant velocity.
 Take your code from the push cart program and copy it into a new file in your Public folder (“PushCartSimulation2”).
 Adjust the numerical values (velocity, delta T, initial time, initial position, etc.) in the code to model the physical
experiment done with the dynamic cart, during the period where the cart had a motion with constant velocity.
 Compare the graphs obtained in the real experiment with the ones obtained with the new model in VPython.
Q17: How do the two graphs -- VPython model and physical experiment – differ from each other?

6
The first graph (PushCartSimulation) starts at position 0 and the second graph (PushCartSimulation2) starts at .15m
because placed the cart 15cm away from the origin before we pushed it. The first graph has steeper slope because
of its constant velocity being higher .3m/s and second graph was less steep because of its slope or constant
velocity being .17m/s. Also we use the constant velocity without taking other forces into count on the Vpython
Model vs. the physical experiment so in the physical experiment velocity decreases and the cart will eventually
stop. But in the VPython model position graph w

Q18: What assumptions about the cart system does the computational model make? Are these valid assumptions?
The computational model assumes that there are no other outside forces slowing down the cart after initial push
because we used the avg velocity from a certain time interval as the constant force. These aren’t valid assumptions
because there are other forces acting on the cart in the simulation that computational model doesn’t’ take into a
count.

Q19: How do these assumptions affect the accuracy of our results? For the push cart simulation, are the errors in the
results due to these assumptions negligible? Why or why not?
These assumptions affect the accuracy of our results by not taking other outside forces acting on the cart into
count. Yes, because we used an average velocity as constant force throughout the whole interval.

 To conclude today’s lab, EACH STUDENT MUST share the link to their finished programs.
Q20: To share your programs, navigate to your Public folder tab, copy the URL from the browser bar into the box below:
https://www.glowscript.org/#/user/Orgilt7/folder/MyPrograms/program/PushCartSimulation/edit
https://www.glowscript.org/#/user/Orgilt7/folder/MyPrograms/program/PushCartSimulation2/edit

7
Group Members’ Signatures Lab TA Signature BEFORE LEAVING, EACH PERSON IN GROUP MUST
(Make sure all sign off on work) (Either GTA or UTA)  Get signatures of every group member and a TA in
Orgil Tuvden Haotian the boxes on the left. If you are using the Word
version have each person type in their name.
Tara Reddy  If you have printed it off, take photos of each page,
and combine them into a single PDF.
Lillian Starkey Upload the completed file (Word of PDF) into
Blackboard by 11:59 PM SATURDAY

You might also like