Modeling motion with VPython Every program that models the motion of physical objects has two main parts:

Similar documents
Name: PHYS 110 Dr. McGovern Spring 2018 Exam 1. Multiple Choice: Circle the answer that best evaluates the statement or completes the statement.

Linear Momentum. Equation 1

Chapter 2. Pythagorean Theorem. Right Hand Rule. Position. Distance Formula

Momentum. Momentum. Impulse. Momentum and Collisions

Physics 105: Mechanics Lecture 13

Page 1. Clicker Question 9: Physics 131: Lecture 15. Today s Agenda. Clicker Question 9: Energy. Energy is Conserved.

GAUTENG DEPARTMENT OF EDUCATION SENIOR SECONDARY INTERVENTION PROGRAMME PHYSICAL SCIENCES GRADE 12 SESSION 1 (LEARNER NOTES)

Physics 101 Lecture 9 Linear Momentum and Collisions

EMU Physics Department.

Lecture 16. Chapter 11. Energy Dissipation Linear Momentum. Physics I. Department of Physics and Applied Physics

Prof. Dr. I. Nasser T /16/2017

Physics 2A Chapter 3 HW Solutions

Chapter 9 Linear Momentum and Collisions

Work is the change in energy of a system (neglecting heat transfer). To examine what could

ONE-DIMENSIONAL COLLISIONS

Motion in One Dimension

Use these variables to select a formula. x = t Average speed = 100 m/s = distance / time t = x/v = ~2 m / 100 m/s = 0.02 s or 20 milliseconds

Problem While being compressed, A) What is the work done on it by gravity? B) What is the work done on it by the spring force?

Physics 207, Lecture 13, Oct. 15. Energy

total If no external forces act, the total linear momentum of the system is conserved. This occurs in collisions and explosions.

Period & Frequency. Work and Energy. Methods of Energy Transfer: Energy. Work-KE Theorem 3/4/16. Ranking: Which has the greatest kinetic energy?

Gravitational Acceleration: A case of constant acceleration (approx. 2 hr.) (6/7/11)

Physics for Scientists and Engineers. Chapter 9 Impulse and Momentum

General Tips on How to Do Well in Physics Exams. 1. Establish a good habit in keeping track of your steps. For example, when you use the equation

Spring Force and Power

How does the momentum before an elastic and an inelastic collision compare to the momentum after the collision?

Physics 2A Chapters 6 - Work & Energy Fall 2017

8.6 The Complex Number System

Physics 207: Lecture 20. Today s Agenda Homework for Monday

Slide. King Saud University College of Science Physics & Astronomy Dept. PHYS 103 (GENERAL PHYSICS) CHAPTER 5: MOTION IN 1-D (PART 2) LECTURE NO.

ENGN 40 Dynamics and Vibrations Homework # 7 Due: Friday, April 15

Conservation Laws (Collisions) Phys101 Lab - 04

Momentum and Collisions. Rosendo Physics 12-B

Physics 131: Lecture 16. Today s Agenda

PHYS 1443 Section 004 Lecture #12 Thursday, Oct. 2, 2014

Moments of Inertia. and reminds us of the analogous equation for linear momentum p= mv, which is of the form. The kinetic energy of the body is.

p p +... = p j + p Conservation Laws in Physics q Physical states, process, and state quantities: Physics 201, Lecture 14 Today s Topics

Section 8.3 Polar Form of Complex Numbers

1 Newton s 2nd and 3rd Laws

AP Physics 1 & 2 Summer Assignment

Conservation of Angular Momentum = "Spin"

PHYS 1101 Practice problem set 12, Chapter 32: 21, 22, 24, 57, 61, 83 Chapter 33: 7, 12, 32, 38, 44, 49, 76

Experiment 5 Elastic and Inelastic Collisions

Physics 2A Chapter 9 HW Solutions

Physic 231 Lecture 14

TIME OF COMPLETION NAME SOLUTION DEPARTMENT OF NATURAL SCIENCES. PHYS 2211, Exam 2 Section 1 Version 1 October 18, 2013 Total Weight: 100 points

Linear Momentum. Center of Mass.

Chapter 7: Conservation of Energy

A Tale of Friction Basic Rollercoaster Physics. Fahrenheit Rollercoaster, Hershey, PA max height = 121 ft max speed = 58 mph

Single Variable Optimization

PHYS 1441 Section 002 Lecture #15

Chapter 3. r r. Position, Velocity, and Acceleration Revisited

G = G 1 + G 2 + G 3 G 2 +G 3 G1 G2 G3. Network (a) Network (b) Network (c) Network (d)

PHYS 1441 Section 002 Lecture #16

One Dimension Again. Chapter Fourteen

Energy and Energy Transfer

Kinematics in 2-Dimensions. Projectile Motion

v c motion is neither created nor destroyed, but transferred via interactions. Fri. Wed (.18,.19) Introducing Potential Energy RE 6.

Chapter 3 and Chapter 4

EMU Physics Department

Chapter 07: Kinetic Energy and Work

Page 1. Physics 131: Lecture 14. Today s Agenda. Things that stay the same. Impulse and Momentum Non-constant forces

Week3, Chapter 4. Position and Displacement. Motion in Two Dimensions. Instantaneous Velocity. Average Velocity

PHYS 1443 Section 002

AP Physics Enosburg Falls High School Mr. Bushey. Week 6: Work, Energy, Power

EN40: Dynamics and Vibrations. Homework 7: Rigid Body Kinematics

ˆ (0.10 m) E ( N m /C ) 36 ˆj ( j C m)

36.1 Why is it important to be able to find roots to systems of equations? Up to this point, we have discussed how to find the solution to

Week 9 Chapter 10 Section 1-5

PHYSICS 203-NYA-05 MECHANICS

Physics 40 HW #4 Chapter 4 Key NEATNESS COUNTS! Solve but do not turn in the following problems from Chapter 4 Knight

Conservation of Energy

LINEAR MOMENTUM. product of the mass m and the velocity v r of an object r r

From Newton s 2 nd Law: v v. The time rate of change of the linear momentum of a particle is equal to the net force acting on the particle.

Chapter 8: Potential Energy and The Conservation of Total Energy

τ rf = Iα I point = mr 2 L35 F 11/14/14 a*er lecture 1

G4023 Mid-Term Exam #1 Solutions

Homework Assignment 3 Due in class, Thursday October 15

5/24/2007 Collisions ( F.Robilliard) 1

PES 1120 Spring 2014, Spendier Lecture 6/Page 1

Circuit Variables. Unit: volt (V = J/C)

CS 331 DESIGN AND ANALYSIS OF ALGORITHMS DYNAMIC PROGRAMMING. Dr. Daisy Tang

Physics 207 Lecture 13. Lecture 13

12. The Hamilton-Jacobi Equation Michael Fowler

You will analyze the motion of the block at different moments using the law of conservation of energy.

Unit 5: Quadratic Equations & Functions

Lectures - Week 4 Matrix norms, Conditioning, Vector Spaces, Linear Independence, Spanning sets and Basis, Null space and Range of a Matrix

Chapter 8. Potential Energy and Conservation of Energy

Angular momentum. Instructor: Dr. Hoi Lam TAM ( 譚海嵐 )

MEASUREMENT OF MOMENT OF INERTIA

Chapter 8. Momentum Impulse and Collisions. Analysis of motion: 2 key ideas. Newton s laws of motion. Conservation of Energy

EPR Paradox and the Physical Meaning of an Experiment in Quantum Mechanics. Vesselin C. Noninski

Finite Difference Method

Probability review. Adopted from notes of Andrew W. Moore and Eric Xing from CMU. Copyright Andrew W. Moore Slide 1

Physics 5153 Classical Mechanics. Principle of Virtual Work-1

THE VIBRATIONS OF MOLECULES II THE CARBON DIOXIDE MOLECULE Student Instructions

EN40: Dynamics and Vibrations. Homework 4: Work, Energy and Linear Momentum Due Friday March 1 st

9/19/2013. PHY 113 C General Physics I 11 AM-12:15 PM MWF Olin 101

FEEDBACK AMPLIFIERS. v i or v s v 0

Module 14: THE INTEGRAL Exploring Calculus

Transcription:

1 Modelng moton wth VPython Eery program that models the moton o physcal objects has two man parts: 1. Beore the loop: The rst part o the program tells the computer to: a. Create numercal alues or constants we mght need b. Create 3D objects c. Ge them ntal postons and momenta 2. The whle loop: The second part o the program, the loop, contans the statements that the computer reads to tell t how to ncrement the poston o the objects oer and oer agan, makng them moe on screen. These statements tell the computer: a. How to calculate the net orce on the objects b. How to calculate the new momentum o each object, usng the net orce and the momentum prncple c. How to nd the new postons o the objects, usng the momenta We wll now ntroduce how to model moton wth a computer. The program you wll wrte wll model the moton o a an cart on a track. A small electrc an mounted on a cart pushes on the ar wth a constant orce, so the ar exerts a constant orce on the an blades. 1. Beore the loop Creatng the objects Open IDLE or Python, and type the usual begnnng statement: rom sual mport * Frst we ll create a box object to represent the track that s one meter long. On the next lne type the ollowng: track = box(pos=ector(0,-.075, 0), sze=(1.0, 0.05,.10)) The pos attrbute o a box object s the poston o the center o the box. The sze attrbute ges the box s length n the x, y and z drectons. To represent the an cart, we wll use a sphere object. (You could use a box you preer, but spheres are somewhat easer to deal wth.) We wll place the cart at the let sde o the track to start. On the next lne type the ollowng: cart = sphere(pos=ector(-0.5,0,0), radus=0.05, color=color.green) Run the program to see the track and cart. Intal condtons Any object that moes needs two ector quanttes declared beore the loop begns: 1. ntal poston; and 2. ntal momentum. We e already gen the cart an ntal poston o 0.5, 0, 0 m. Now we need to ge t an ntal momentum. I you push the cart wth your hand, the ntal momentum s the momentum o the cart just ater t leaes your hand. Snce the denton o momentum, at speeds much less than the speed o lght, s p m, we need to tell the computer the cart s mass and the cart s ntal elocty.

2 On a new lne type the ollowng: cart.m = 0.80 We hae made up a new attrbute named m or the object named cart. The symbol cart.m now stands or the alue 0.80 (a scalar), whch represents the mass o the cart n klograms. Now that we hae the mass, multplyng the mass by the ntal elocty wll ge the ntal momentum. Let s ge the cart an ntal elocty o 0.5, 0, 0 m/s. Then, the ntal momentum would be the mass tmes ths ntal elocty ector. On a new lne type the ollowng: cart.p = cart.m*ector(0.5, 0, 0) Ths now ges the cart an ntal momentum alue that s ( 0.80 kg) 0.5, 0, 0 m/s = 0.4, 0, 0 kg m/s. The symbol cart.p wll stand or the momentum o the cart (a ector) throughout the program. Note: We could hae called the momentum just p, or the mass just m, nstead o cart.p or cart.m. There are no bult n physcs attrbutes p or m or objects lke there are bult-n geometrcal attrbutes pos or radus. We can make any attrbutes we want. It s useul to create attrbutes lke mass or momentum or objects; ths way, we can easly tell apart the masses and momenta o derent objects. Tme step and tme To make the cart moe we wll use the equaton deltat to stand or the tme step t On a new lne type the ollowng: deltat = 0.01 r = r + repeatedly n a loop. We need to dene a arable. Here we wll use the alue t = 0.01 s. Also set a arable t, whch stands or cumulate tme, to start at zero seconds. Each tme through the program loop we wll wrte, we wll ncrement the alue o t by deltat (n ths case, 0.01 seconds). On a new lne type the ollowng: t = 0 In your notebook, wrte the answers to the ollowng questons. Your nstructor wll ask you about them. (1) Calculate how ar the cart wll moe n one tme step (one executon o the loop). (2) How many executons o the loop wll t take or the cart to moe one meter? (3) What wll the tme t be ater mong one meter? CHECKPOINT M1: Ask an nstructor to check your work or credt. You can read ahead whle you re watng to be checked o. Ths completes the rst part o the program, whch tells the computer to: a. Create numercal alues or constants we mght need b. Create 3D objects c. Ge them ntal postons and momenta

3 The whle loop Constant momentum moton Somebody or somethng gae the cart some ntal momentum. We re not concerned here wth how t got that ntal momentum. We ll predct how the cart wll moe n the uture, ater t acqured ts ntal momentum. We wll create a whle loop. Each tme the program runs through ths loop, t wll do two thngs: 1. Use the cart s current momentum to calculate the cart s new poston 2. Increment the cumulate tme t by deltat On a new lne type the ollowng: whle t<3.0: Make sure the statement ends wth :, then press Enter. Note that the cursor s now ndented on the next lne. I t s not, place the cursor just ater the : and press Enter. Ths tells the computer to keep executng the loop whle the cumulate tme s less than 3 seconds. In class, you learned that the new poston o an object ater a short tme nteral r = r + t s gen by where r s the nal poston o the object, and r s ts ntal poston. Ths assumes that the elocty doesn t change ery much durng the short tme nteral t. Snce at low speed p m, or p / m, we can wrte r = r + ( p / m) We wll use ths equaton to ncrement the poston o the cart n the program. Frst, we must translate t so VPython can understand t. On the ndented lne ater the whle statement, type the ollowng: cart.pos = cart.pos + (cart.p/cart.m)*deltat Notce how ths statement corresponds to the algebrac equaton: r = r + ( p / m) cart.pos = cart.pos + (cart.p/cart.m)*deltat Fnal poston Intal poston Velocty Tme step

4 In the program, the nal and ntal poston s wrtten the same way: cart.pos. Ths sn t really an equalty, but an assgnment statement; cart.pos s beng assgned a new alue equal to ts old alue plus (cart.p/cart.m)*deltat. Fnally we need to ncrement the cumulate tme t. On the ndented lne ater the whle statement, type the ollowng: t = t + deltat Now, run the program Slowng down the anmaton When you run the program, you should see the sphere at ts nal pont. The program s executed so rapdly that the entre moton occurs aster than we can see. We can slow down the anmaton rate by addng a rate statement. Place the cursor at the end o the statement that reads whle t<3.0:. Press Enter to nsert a new, ndented statement rght beore the cart.pos statement. On ths new lne, type the ollowng: rate(100) Eery tme the computer executes the loop, when t reads rate(100), t pauses long enough to ensure the loop wll take 1/100 th o a second. Thereore, the computer wll only execute the loop 100 tmes per second. Now, run the program. You should see the sphere trael to the rght at a constant elocty, stoppng beyond the edge o the track. Note: The cart gong beyond the edge o the track sn t a good smulaton o what really happens, but t s what we told the computer to do. There are no bult-n physcal behaors, lke gratatonal orce, n VPython. Rght now, all we e done s tell the program to make the cart moe n a straght lne. I we wanted the cart to all o the edge, we would hae to enter statements nto the program to tell the computer how to do ths. CHECKPOINT M2: Ask an nstructor to check your work or credt. You can read ahead whle you re watng to be checked o. 2. Force and momentum prncple Now we wll mody our program to nclude a orce on the cart. Ths means we wll hae to add statements to the program that tell the computer that there s a orce on the cart, and tell t how to use the momentum prncple to change the cart s momentum due to the orce. Suppose you push a cart, and ater leang your hand t has an ntal momentum to the rght, as beore. But now, the an on the cart s opposng ths ntal momentum, so that there s a net orce on the cart to the let. Ths orce s about 0.4 newtons. In your notebook, wrte the answer to the ollowng queston. (4) Wrte the orce ector that ponts to the let (the -x drecton) wth a magntude o 0.4 N. Let s use our program to model ths stuaton. Frst let s add a statement that creates a orce ector. In the loop, nsert a new statement rght ater the rate(100) statement. Type the ollowng:

5 Fnet = ector(-0.4, 0, 0) Note: Ths orce has a constant (ector) alue; t doesn t change each tme through the loop, unlke the cart s poston. We could hae, thereore, wrtten ths statement beore the loop. But n most o the programs we wrte, orce wll be changng wth tme, so orce calculatons should go nsde the loop. Next, we need to use the momentum prncple. The momentum prncple says the change n an object s momentum n a short tme perod s equal to the net orce on t, tmes the tme nteral (ths assumes that the orce doesn t change much durng the short tme nteral). In symbols, ths s: where p s the cart s momentum, and F net p = p p = F net s the net orce on the cart. We can rewrte ths as: p = p + Fnet We then use ths equaton n the program, whch tells the computer how to calculate a new momentum or the cart. Insert a new statement n the loop, rght ater the lne that reads Fnet = ector(-0.4, 0, 0). On ths new lne, type the ollowng: cart.p = cart.p + Fnet*deltat Note the smlarty between ths statement and the statement that updates the poston. Here s how the algebrac equaton corresponds to the VPython code: p = p + Fnet cart.p = cart.p + Fnet*deltat Fnal momentum Intal momentum Net orce Tme step Run the program. You should see the sphere moe to the rght a small dstance beore changng drecton and mong to the let. Change the ntal momentum o the cart so that t moes a greater dstance to the rght beore changng drecton: make the ntal speed o the cart 0.9 m/s, wth drecton to the rght. Run the program. You should now see the sphere moe much closer to the rght end o the track beore t starts mong to the let.

6 3. Moton n two dmensons Let s try gng the cart a component o ntal momentum n the y-drecton (that s, upward). Let s assume that we are n outer space, where gratatonal orces on the cart are neglgble. We want to explore a stuaton where the moton s two-dmensonal. Change the ntal elocty o the cart to 0.7, 0.1, 0 m/s and run the program. The sphere now makes a path n the shape o a parabola. Let s look more careully at the momentum o the cart durng ts moton by prntng out the momentum ector at each executon o the loop. Insert a new statement n the loop, just ater the lne that reads cart.p = cart.p+fnet*deltat. Type the ollowng on ths new lne: prnt t=, t, cart.p=, cart.p Run the program. The alues o tme t and momentum cart.p are now prnted n the text output wndow at eery executon o the loop. Reer to these alues when dong the ollowng exercses. In your notebook, wrte the answers to the ollowng questons. Your nstructor wll ask you about them. (5) Usng the prnted lst o momentum ectors, calculate p. That s, pck one o the ectors to be the nal momentum, and subtract rom t the ector just aboe t, whch s the ntal momentum: p = p p =?,?,? kg m/s (6) Calculate the ector Fnet. (In the program, ths would be Fnet*deltat.) F net =?,?,? N s (7) Do your calculatons show that the change n momentum p s equal to (8) Look at the prnted lst o momentum ectors agan. Why aren t the y or z components o the momentum changng? Add a tral to the cart, to see ts trajectory clearly. You saw n your ball n a box program that ths noles creatng a cure object beore the whle loop, then appendng the mong object s poston to ths cure object eery tme you go through the loop. I the name o your cure object s cart.tral, the statement to add a pont to the cure s cart.tral.append(pos=cart.pos). In your notebook, make approxmate graphs o p x s. t, p y s. t, and p z s. t. Be prepared to explan your graphs. F net? CHECKPOINT M3: Ask an nstructor to check your work or credt. You can read ahead whle you re watng to be checked o. Ater beng checked o, you can submt your nal program to be graded. 4. Playng around What would you need to do to nclude the eects o graty? The gratatonal orce near the Earth s 0, mg, 0, where g = +9.8 N/kg ( the magntude o the gratatonal eld ; see textbook p. 40). Turn on graty and turn o the an orce, use a small deltat o 0.001 or accuracy, and use an statement to make the cart bounce on the track, as you dd to make a ball bounce o the walls o a box. Ge the cart an ntal elocty o 0.7, 3.0, 0 m/s. Eentually you ll see the cart bouncng o nothng! Can you thnk how to change your program to do somethng more realstc? Hnt: You can combne logcal tests by usng the keywords and and or. For example, the logcal expresson (y < 3 ) and (z > 2) s true only both o these condtons are true.