projectile motion two dimensions - indico.fnal.gov

9
1 Ruth Van de Water Projectile motion in 2D with VPython QCIPU 2021 Projectile motion two dimensions 1 Objectives In this laboratory, you will write simulate the motion of a point-like, massive object in two dimensions under the influence of gravity and — in part 2 — a drag force. After completing this activity, you should be able to: Simulate the motion of an object under the influences of forces. Display and format output using the Python print() function. Validate numerical simulation code by (i) comparing with known analytic results and/or (ii) looking for convergence of the numerical results. Simulating motion under the influence of forces Consider an object located at position moving with velocity . Suppose that we wish to find its new position after a short time interval Δt. If the time interval Δt is sufficiently small, we can approximate the instantaneous velocity by the average velocity, i.e. . We can then employ the relationship between average velocity and displacement: . Rearrangement of this relationship and replacing with yields the position-update equation: . (1) In words, Eq. (1) says that if we know an object’s starting position and velocity, we can find its position a time Δt later. Suppose that we now want to find the next position along the object’s path, . We can simply employ the position-update equation again, this time using as the starting position: . By repeating this process, we can iteratively calculate the path of the object, provided that we know the object’s velocity at each point along the path. This series of repetitive calculations — especially when the number of iterations required is large — is best performed on a computer. What if, however, the object’s velocity is changing due to the application of a force? Then we must first update the velocity using Newton’s Second Law before we update the position. ~ r 0 < l a t e x i t s h a 1 _ b a s e 6 4 = " Y f J u a m E S d X 7 a n h g P B L W A h K g 2 c q E = " > A A A B 8 H i c b V B N S 8 N A E J 3 U r 1 q / q h 6 9 L B a h p 5 J I Q Y 8 F L x 4 r 2 A 9 p Q 9 l s J + 3 S 3 S T s b g o l 9 F d 4 8 a C I V 3 + O N / + N 2 z Y H b X 0 w 8 H h v h p l 5 Q S K 4 N q 7 7 7 R S 2 t n d 2 9 4 r 7 p Y P D o + O T 8 u l Z W 8 e p Y t h i s Y h V N 6 A a B Y + w Z b g R 2 E 0 U U h k I 7 A S T u 4 X f m a L S P I 4 e z S x B X 9 J R x E P O q L H S U 3 + K L F P z g T s o V 9 y a u w T Z J F 5 O K p C j O S h / 9 Y c x S y V G h g m q d c 9 z E + N n V B n O B M 5 L / V R j Q t m E j r B n a U Q l a j 9 b H j w n V 1 Y Z k j B W t i J D l u r v i Y x K r W c y s J 2 S m r F e 9 x b i f 1 4 v N e G t n / E o S Q 1 G b L U o T A U x M V l 8 T 4 Z c I T N i Z g l l i t t b C R t T R Z m x G Z V s C N 7 6 y 5 u k f V 3 z 6 r X 6 Q 7 3 S q O Z x F O E C L q E K H t x A A + 6 h C S 1 g I O E Z X u H N U c 6 L 8 + 5 8 r F o L T j 5 z D n / g f P 4 A z E 2 Q V A = = < / l a t e x i t > ~ v < l a t e x i t s h a 1 _ b a s e 6 4 = " J M g p 5 k E x c m s K c I g R 7 O I Y a U i x 5 U 8 = " > A A A B 7 n i c b V B N S 8 N A E J 3 U r 1 q / q h 6 9 L B a h p 5 J I o R 4 L X j x W s B / Q h r L Z T t q l m 0 3 Y 3 R R K 6 I / w 4 k E R r / 4 e b / 4 b t 2 0 O 2 v p g 4 P H e D D P z g k R w b V z 3 2 y n s 7 O 7 t H x Q P S 0 f H J 6 d n 5 f O L j o 5 T x b D N Y h G r X k A 1 C i 6 x b b g R 2 E s U 0 i g Q 2 A 2 m 9 0 u / O 0 O l e S y f z D x B P 6 J j y U P O q L F S d z B D l s 0 W w 3 L F r b k r k G 3 i 5 a Q C O V r D 8 t d g F L M 0 Q m m Y o F r 3 P T c x f k a V 4 U z g o j R I N S a U T e k Y + 5 Z K G q H 2 s 9 W 5 C 3 J j l R E J Y 2 V L G r J S f 0 9 k N N J 6 H g W 2 M 6 J m o j e 9 p f i f 1 0 9 N e O d n X C a p Q c n W i 8 J U E B O T 5 e 9 k x B U y I + a W U K a 4 v Z W w C V W U G Z t Q y Y b g b b 6 8 T T q 3 N a 9 e q z / W K 8 1 q H k c R r u A a q u B B A 5 r w A C 1 o A 4 M p P M M r v D m J 8 + K 8 O x / r 1 o K T z 1 z C H z i f P 6 l N j 7 U = < / l a t e x i t > ~ r 1 < l a t e x i t s h a 1 _ b a s e 6 4 = " d p f a a n k U m 0 O d Y A p R L w Z + I P g K s L Y = " > A A A B 8 H i c b V B N S 8 N A E J 3 U r 1 q / q h 6 9 L B a h p 5 J I Q Y 8 F L x 4 r 2 A 9 p Q 9 l s J + 3 S 3 S T s b g o l 9 F d 4 8 a C I V 3 + O N / + N 2 z Y H b X 0 w 8 H h v h p l 5 Q S K 4 N q 7 7 7 R S 2 t n d 2 9 4 r 7 p Y P D o + O T 8 u l Z W 8 e p Y t h i s Y h V N 6 A a B Y + w Z b g R 2 E 0 U U h k I 7 A S T u 4 X f m a L S P I 4 e z S x B X 9 J R x E P O q L H S U 3 + K L F P z g T c o V 9 y a u w T Z J F 5 O K p C j O S h / 9 Y c x S y V G h g m q d c 9 z E + N n V B n O B M 5 L / V R j Q t m E j r B n a U Q l a j 9 b H j w n V 1 Y Z k j B W t i J D l u r v i Y x K r W c y s J 2 S m r F e 9 x b i f 1 4 v N e G t n / E o S Q 1 G b L U o T A U x M V l 8 T 4 Z c I T N i Z g l l i t t b C R t T R Z m x G Z V s C N 7 6 y 5 u k f V 3 z 6 r X 6 Q 7 3 S q O Z x F O E C L q E K H t x A A + 6 h C S 1 g I O E Z X u H N U c 6 L 8 + 5 8 r F o L T j 5 z D n / g f P 4 A z d G Q V Q = = < / l a t e x i t > ~ v ~ v avg. < l a t e x i t s h a 1 _ b a s e 6 4 = " Q z G a b G u S F A B Q E j i 0 e L B d z L r V q A M = " > A A A C C 3 i c b V C 7 T s M w F H V 4 l v I K M L J Y r Z A 6 R Q m q B G M l F s Y i 0 Y f U V J H j O q 1 V 2 4 l s J 6 K K s r P w K y w M I M T K D 7 D x N 7 h t B m g 5 0 p W O z 7 l X v v e E C a N K u + 6 3 t b G 5 t b 2 z W 9 m r 7 h 8 c H h 3 b J 6 d d F a c S k w 6 O W S z 7 I V K E U U E 6 m m p G + o k k i I e M 9 M L p z d z v Z U Q q G o t 7 P U v I k K O x o B H F S B s p s G t + R n C e F d B H S S L j B 1 i + g 9 y X H K J s 7 B S B X X c d d w G 4 T r y S 1 E G J d m B / + a M Y p 5 w I j R l S a u C 5 i R 7 m S G q K G S m q f q p I g v A U j c n A U I E 4 U c N 8 c U s B L 4 w y g l E s T Q k N F + r v i R x x p W Y 8 N J 0 c 6 Y l a 9 e b i f 9 4 g 1 d H 1 M K c i S T U R e P l R l D K o Y z g P B o 6 o J F i z m S E I S 2 p 2 h X i C J M L a x F c 1 I X i r J 6 + T 7 q X j N Z 3 m X b P e a p R x V M A 5 q I E G 8 M A V a I F b 0 A Y d g M E j e A a v 4 M 1 6 s l 6 s d + t j 2 b p h l T N n 4 A + s z x + X I J t Q < / l a t e x i t > ~ v avg. = Δ~ r Δt = ~ r 1 - ~ r 0 Δt < l a t e x i t s h a 1 _ b a s e 6 4 = " k q 8 N 5 X K Y s b j 6 V 3 6 D Q d + V Y + i 8 H j w = " > A A A C R X i c b V D L S g M x F M 3 4 t r 6 q L t 0 E i 9 C N Z U Y K u h E E X b i s Y K v Q G Y Z M e q c G M w + S O w N l m J 9 z 4 9 6 d f + D G h S J u N X 0 I 1 X o g c H L O u d z k B K k U G m 3 7 2 Z q b X 1 h c W l 5 Z r a y t b 2 x u V b d 3 O j r J F I c 2 T 2 S i b g O m Q Y o Y 2 i h Q w m 2 q g E W B h J v g / n z o 3 + S g t E j i a x y k 4 E W s H 4 t Q c I Z G 8 q u u m w M v 8 t I v X B V R l v c b J T 2 l b q g Y L 9 w L k M j o K K H K 8 u e O U 4 m x 5 T v 0 8 I f a U z m / W r M b 9 g h 0 l j g T U i M T t P z q k 9 t L e B Z B j F w y r b u O n a J X M I W C S y g r b q Y h Z f y e 9 a F r a M w i 0 F 4 x a q G k B 0 b p 0 T B R 5 s R I R + r 0 R M E i r Q d R Y J I R w z v 9 1 x u K / 3 n d D M M T r x B x m i H E f L w o z C T F h A 4 r p T 2 h g K M c G M K 4 E u a t l N 8 x 0 w + a 4 i u m B O f v l 2 d J 5 6 j h N B v N q 2 b t r D 6 p Y 4 X s k X 1 S J w 4 5 J m f k k r R I m 3 D y Q F 7 I G 3 m 3 H q 1 X 6 8 P 6 H E f n r M n M L v k F 6 + s b X o q y s g = = < / l a t e x i t > ~ v avg. < l a t e x i t s h a 1 _ b a s e 6 4 = " g C f h v d e k E A k H N Z k G I n 4 D R 9 P M H G 4 = " > A A A B + 3 i c b V D L S s N A F J 3 4 r P U V 6 9 L N Y B G 6 C o k U d F l w 4 7 K C f U A T w m Q 6 a Y f O T M L M J F h C f s W N C 0 X c + i P u / B u n b R b a e u D C 4 Z x 7 u f e e K G V U a d f 9 t r a 2 d 3 b 3 9 m s H 9 c O j 4 5 N T + 6 z R V 0 k m M e n h h C V y G C F F G B W k p 6 l m Z J h K g n j E y C C a 3 S 3 8 Q U 6 k o o l 4 1 P O U B B x N B I 0 p R t p I o d 3 w c 4 K L v A w L X 3 K I 8 o l T h n b T d d w l 4 C b x K t I E F b q h / e W P E 5 x x I j R m S K m R 5 6 Y 6 K J D U F D N S 1 v 1 M k R T h G Z q Q k a E C c a K C Y n l 7 C a + M M o Z x I k 0 J D Z f q 7 4 k C c a X m P D K d H O m p W v c W 4 n / e K N P x b V B Q k W a a C L x a F G c M 6 g Q u g o B j K g n W b G 4 I w p K a W y G e I o m w N n H V T Q j e + s u b p H / t e G 2 n / d B u d l p V H D V w A S 5 B C 3 j g B n T A P e i C H s D g C T y D V / B m l d a L 9 W 5 9 r F q 3 r G r m H P y B 9 f k D L I u U c g = = < / l a t e x i t > ~ v < l a t e x i t s h a 1 _ b a s e 6 4 = " J M g p 5 k E x c m s K c I g R 7 O I Y a U i x 5 U 8 = " > A A A B 7 n i c b V B N S 8 N A E J 3 U r 1 q / q h 6 9 L B a h p 5 J I o R 4 L X j x W s B / Q h r L Z T t q l m 0 3 Y 3 R R K 6 I / w 4 k E R r / 4 e b / 4 b t 2 0 O 2 v p g 4 P H e D D P z g k R w b V z 3 2 y n s 7 O 7 t H x Q P S 0 f H J 6 d n 5 f O L j o 5 T x b D N Y h G r X k A 1 C i 6 x b b g R 2 E s U 0 i g Q 2 A 2 m 9 0 u / O 0 O l e S y f z D x B P 6 J j y U P O q L F S d z B D l s 0 W w 3 L F r b k r k G 3 i 5 a Q C O V r D 8 t d g F L M 0 Q m m Y o F r 3 P T c x f k a V 4 U z g o j R I N S a U T e k Y + 5 Z K G q H 2 s 9 W 5 C 3 J j l R E J Y 2 V L G r J S f 0 9 k N N J 6 H g W 2 M 6 J m o j e 9 p f i f 1 0 9 N e O d n X C a p Q c n W i 8 J U E B O T 5 e 9 k x B U y I + a W U K a 4 v Z W w C V W U G Z t Q y Y b g b b 6 8 T T q 3 N a 9 e q z / W K 8 1 q H k c R r u A a q u B B A 5 r w A C 1 o A 4 M p P M M r v D m J 8 + K 8 O x / r 1 o K T z 1 z C H z i f P 6 l N j 7 U = < / l a t e x i t > ~ r 1 = ~ r 0 + ~ vΔt < l a t e x i t s h a 1 _ b a s e 6 4 = " x V E s 5 D t N H 6 R B H 9 y D h w E o f l W d O c k = " > A A A C E X i c b Z D L S g N B E E V 7 f M b 4 G n X p p j E I A S H M S E A 3 Q k A X L i O Y B y R D 6 O l U k i Y 9 D 7 p r A m H I L 7 j x V 9 y 4 U M S t O 3 f + j Z 1 k B E 2 8 0 H C 4 V U V 1 X T + W Q q P j f F k r q 2 v r G 5 u 5 r f z 2 z u 7 e v n 1 w W N d R o j j U e C Q j 1 f S Z B i l C q K F A C c 1 Y A Q t 8 C Q 1 / e D 2 t N 0 a g t I j C e x z H 4 A W s H 4 q e 4 A y N 1 b G L 7 R H w V E 0 6 L r 2 i P + z Q s z m P J r R 9 A x I Z x Y 5 d c E r O T H Q Z 3 A w K J F O 1 Y 3 + 2 u x F P A g i R S 6 Z 1 y 3 V i 9 F K m U H A J k 3 w 7 0 R A z P m R 9 a B k M W Q D a S 2 c X T e i p c b q 0 F y n z Q q Q z 9 / d E y g K t x 4 F v O g O G A 7 1 Y m 5 r / 1 V o J 9 i 6 9 V I R x g h D y + a J e I i l G d B o P 7 Q o F H O X Y A O N K m L 9 S P m C K c T Q h 5 k 0 I 7 u L J y 1 A / L 7 n l U v m u X K g U s z h y 5 J i c k C J x y Q W p k F t S J T X C y Q N 5 I i / k 1 X q 0 n q 0 3 6 3 3 e u m J l M 0 f k j 6 y P b 7 J + n D k = < / l a t e x i t > ~ r 2 < l a t e x i t s h a 1 _ b a s e 6 4 = " v n Q + z O A y 4 X 0 F g S 9 t D 8 4 O + Q T T Y n 8 = " > A A A B 8 H i c b V B N S 8 N A E J 3 4 W e t X 1 a O X x S L 0 V J J S 0 G P B i 8 c K 9 k P a U D b b S b t 0 N w m 7 m 0 I J / R V e P C j i 1 Z / j z X / j t s 1 B W x 8 M P N 6 b Y W Z e k A i u j e t + O 1 v b O 7 t 7 + 4 W D 4 u H R 8 c l p 6 e y 8 r e N U M W y x W M S q G 1 C N g k f Y M t w I 7 C Y K q Q w E d o L J 3 c L v T F F p H k e P Z p a g L + k o 4 i F n 1 F j p q T 9 F l q n 5 o D Y o l d 2 q u w T Z J F 5 O y p C j O S h 9 9 Y c x S y V G h g m q d c 9 z E + N n V B n O B M 6 L / V R j Q t m E j r B n a U Q l a j 9 b H j w n 1 1 Y Z k j B W t i J D l u r v i Y x K r W c y s J 2 S m r F e 9 x b i f 1 4 v N e G t n / E o S Q 1 G b L U o T A U x M V l 8 T 4 Z c I T N i Z g l l i t t b C R t T R Z m x G R V t C N 7 6 y 5 u k X a t 6 9 W r 9 o V 5 u V P I 4 C n A J V 1 A B D 2 6 g A f f Q h B Y w k P A M r / D m K O f F e X c + V q 1 b T j 5 z A X / g f P 4 A z 1 W Q V g = = < / l a t e x i t > ~ r 1 < l a t e x i t s h a 1 _ b a s e 6 4 = " d p f a a n k U m 0 O d Y A p R L w Z + I P g K s L Y = " > A A A B 8 H i c b V B N S 8 N A E J 3 U r 1 q / q h 6 9 L B a h p 5 J I Q Y 8 F L x 4 r 2 A 9 p Q 9 l s J + 3 S 3 S T s b g o l 9 F d 4 8 a C I V 3 + O N / + N 2 z Y H b X 0 w 8 H h v h p l 5 Q S K 4 N q 7 7 7 R S 2 t n d 2 9 4 r 7 p Y P D o + O T 8 u l Z W 8 e p Y t h i s Y h V N 6 A a B Y + w Z b g R 2 E 0 U U h k I 7 A S T u 4 X f m a L S P I 4 e z S x B X 9 J R x E P O q L H S U 3 + K L F P z g T c o V 9 y a u w T Z J F 5 O K p C j O S h / 9 Y c x S y V G h g m q d c 9 z E + N n V B n O B M 5 L / V R j Q t m E j r B n a U Q l a j 9 b H j w n V 1 Y Z k j B W t i J D l u r v i Y x K r W c y s J 2 S m r F e 9 x b i f 1 4 v N e G t n / E o S Q 1 G b L U o T A U x M V l 8 T 4 Z c I T N i Z g l l i t t b C R t T R Z m x G Z V s C N 7 6 y 5 u k f V 3 z 6 r X 6 Q 7 3 S q O Z x F O E C L q E K H t x A A + 6 h C S 1 g I O E Z X u H N U c 6 L 8 + 5 8 r F o L T j 5 z D n / g f P 4 A z d G Q V Q = = < / l a t e x i t > ~ r 2 = ~ r 1 + ~ vΔt < l a t e x i t s h a 1 _ b a s e 6 4 = " L Q Y o Z j 9 a V M V x u i h p 5 W 7 Q Q q h w m O M = " > A A A C E X i c b Z D J S g N B E I Z 7 4 h b j F v X o p T E I A S H M h I B e h I A e P E Y w C y T D 0 N O p J E 1 6 F r p r A m H I K 3 j x V b x 4 U M S r N 2 + + j Z 1 F 0 M Q f G j 7 + q q K 6 f j + W Q q N t f 1 m Z t f W N z a 3 s d m 5 n d 2 / / I H 9 4 1 N B R o j j U e S Q j 1 f K Z B i l C q K N A C a 1 Y A Q t 8 C U 1 / e D 2 t N 0 e g t I j C e x z H 4 A a s H 4 q e 4 A y N 5 e W L n R H w V E 2 8 M r 2 i P + z Q 8 z m P J r R z A x I Z R S 9 f s E v 2 T H Q V n A U U y E I 1 L / / Z 6 U Y 8 C S B E L p n W b c e O 0 U 2 Z Q s E l T H K d R E P M + J D 1 o W 0 w Z A F o N 5 1 d N K F n x u n S X q T M C 5 H O 3 N 8 T K Q u 0 H g e + 6 Q w Y D v R y b W r + V 2 s n 2 L t 0 U x H G C U L I 5 4 t 6 i a Q Y 0 W k 8 t C s U c J R j A 4 w r Y f 5 K + Y A p x t G E m D M h O M s n r 0 K j X H I q p c p d p V A t L u L I k h N y S o r E I R e k S m 5 J j d Q J J w / k i b y Q V + v R e r b e r P d 5 a 8 Z a z B y T P 7 I + v g G 1 u J w 7 < / l a t e x i t > Adapted from VPython Introductory Computational Physics by Ruth Chabay and Bruce Sherwood. 1

Upload: others

Post on 25-Feb-2022

24 views

Category:

Documents


0 download

TRANSCRIPT

1

Ruth Van de Water Projectile motion in 2D with VPython QCIPU 2021

Projectile motion two dimensions 1

Objectives In this laboratory, you will write simulate the motion of a point-like, massive object in two dimensions under the influence of gravity and — in part 2 — a drag force. After completing this activity, you should be able to: • Simulate the motion of an object under the influences of forces. • Display and format output using the Python print() function. • Validate numerical simulation code by (i) comparing with known analytic results and/or

(ii) looking for convergence of the numerical results.

Simulating motion under the influence of forces Consider an object located at position moving with velocity . Suppose that we wish to find its new position after a short time interval Δt. If the time interval Δt is sufficiently small, we can approximate the instantaneous velocity by the average velocity, i.e. . We can then employ the relationship between average velocity and displacement:

.

Rearrangement of this relationship and replacing with yields the position-update equation:

. (1)

In words, Eq. (1) says that if we know an object’s starting position and velocity, we can find its position a time Δt later.

Suppose that we now want to find the next position along the object’s path, . We can simply employ the position-update equation again, this time using as the starting position:

.

By repeating this process, we can iteratively calculate the path of the object, provided that we know the object’s velocity at each point along the path. This series of repetitive calculations — especially when the number of iterations required is large — is best performed on a computer.

What if, however, the object’s velocity is changing due to the application of a force? Then we must first update the velocity using Newton’s Second Law before we update the position.

~r0

<latexit sha1_base64="YfJuamESdX7anhgPBLWAhKg2cqE=">AAAB8HicbVBNS8NAEJ3Ur1q/qh69LBahp5JIQY8FLx4r2A9pQ9lsJ+3S3STsbgol9Fd48aCIV3+ON/+N2zYHbX0w8Hhvhpl5QSK4Nq777RS2tnd294r7pYPDo+OT8ulZW8epYthisYhVN6AaBY+wZbgR2E0UUhkI7ASTu4XfmaLSPI4ezSxBX9JRxEPOqLHSU3+KLFPzgTsoV9yauwTZJF5OKpCjO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DMhOMsnr0KjXHIqpcpdpVAtLuLIkhNySorEIRekSm5JjdQJJw/kibyQV+vRerberPd5a8ZazByTP7I+vgG1uJw7</latexit>

Adapted from VPython Introductory Computational Physics by Ruth Chabay and Bruce Sherwood.1

2

Ruth Van de Water Projectile motion in 2D with VPython QCIPU 2021

The main ideas involved are the following:

• Forces cause an object to accelerate. When an object experiences a net force, its velocity changes according to Newton’s Second Law:

.

• An object’s momentum is related to its velocity by

, (2)

so Newton’s Second Law can also be expressed as

.

• For small time intervals (Δt), we can make the approximation

,

and then rearrange the 2nd Law to obtain the momentum-update equation

. (3)

Therefore, to predict an object’s path over a long time interval given a known force or forces, we can use the algorithm on the following page.

It is important to remember that Eqs. (1) and (3) are approximations, and become more accurate as the time interval Δt becomes smaller, such that the average velocity becomes closer to the instantaneous velocity. By choosing a small time interval in your computer program, not only will you make the positions and momenta calculated from the update equations more exact, but you will also find the object’s location at each step along its path, which you can use to animate the motion.

The above discussion assumes that the net force is constant throughout the object’s motion. Often, however the the force on an object changes with its position (e.g., the spring force) or velocity (e.g., the drag force). Changing forces can be accounted for by updating the net force at each step using the new position and velocity before applying the momentum-update equation, Eq. (3). Therefore, to predict an object’s path over a long time interval given a known set of forces, we can use the algorithm at the top of the following page.

~Fnet = m~a = md~v

dt

<latexit sha1_base64="f3CP89V6IM+ffkNyu9ygZT3XzUY=">AAACHnicbZBNS8NAEIY3flu/qh69LBbBU0mkohdBEMRjBatCW8pmM9HF3U3YnRRKyC/x4l/x4kERwZP+G7dpDn69sPDyzAyz84apFBZ9/9Obmp6ZnZtfWKwtLa+srtXXNy5tkhkOHZ7IxFyHzIIUGjooUMJ1aoCpUMJVeHcyrl8NwViR6AscpdBX7EaLWHCGDg3q+70h8Py0GOQ9o6gGLOgRVbSkrPKxYTyPSjQsijzCYlBv+E2/FP1rgso0SKX2oP7eixKeKdDIJbO2G/gp9nNmUHAJRa2XWUgZv2M30HVWMwW2n5fnFXTHkYjGiXFPIy3p94mcKWtHKnSdiuGt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XxggVDJzK6ZTIgnVJq6KCcFd//ImdK8abrPRfGjWWvUijjI6Rxeojlx0jVroHrVRB1H0hJ7RK3qzMuvFerc+Vq0lq5g5Q39kff4A21SUQA==</latexit>

~Fnet =d~p

dt

<latexit sha1_base64="oUy5f9yWTbwYVssJ+xQ016maa8I=">AAACEXicbVBNS8NAEN3Ur1q/qh69LBahp5JIQS9CQRCPFWwrNKFsNpN26WYTdjeFEvIXvPhXvHhQxKs3b/4bt20O2vpg4PHeDDPz/IQzpW372yqtrW9sbpW3Kzu7e/sH1cOjropTSaFDYx7LB58o4ExARzPN4SGRQCKfQ88fX8/83gSkYrG419MEvIgMBQsZJdpIg2rdnQDNbvJB5soIC9A5vsJuKAnNgrmV5HkWGHVQrdkNew68SpyC1FCB9qD65QYxTSMQmnKiVN+xE+1lRGpGOeQVN1WQEDomQ+gbKkgEysvmH+X4zCgBDmNpSmg8V39PZCRSahr5pjMieqSWvZn4n9dPdXjpZUwkqQZBF4vClGMd41k8OGASqOZTQwiVzNyK6YiYOLQJsWJCcJZfXiXd84bTbDTvmrVWvYijjE7QKaojB12gFrpFbdRBFD2iZ/SK3qwn68V6tz4WrSWrmDlGf2B9/gAUb528</latexit>

~Fnet ⇡�~p

�t

<latexit sha1_base64="13C5pdD/OtXvSIWhD5Q2dkwnyyA=">AAACInicbVBNSwMxFMz6bf2qevQSLIKnsisF9SYo4lHB2kK3lGz6VoPZbEjeimXZ3+LFv+LFg6KeBH+Mad2Dtg4EJjPzSN5EWgqLvv/pTU3PzM7NLyxWlpZXVteq6xtXNs0MhyZPZWraEbMghYImCpTQ1gZYEkloRbfHQ791B8aKVF3iQEM3YddKxIIzdFKvehjeAc9Pi14emoQqwIKGTGuT3tMwNozn4QlIZKOULorySl2sV635dX8EOkmCktRIifNe9T3spzxLQCGXzNpO4Gvs5syg4BKKSphZ0IzfsmvoOKpYArabj1Ys6I5T+jROjTsK6Uj9PZGzxNpBErlkwvDGjntD8T+vk2F80M2F0hmC4j8PxZmkmNJhX7QvDHCUA0cYN8L9lfIb5ppB12rFlRCMrzxJrvbqQaPeuGjUjnbLOhbIFtkmuyQg++SInJFz0iScPJAn8kJevUfv2XvzPn6iU145s0n+wPv6BtwMpQM=</latexit>

~pf = ~pi + ~Fnet�t

<latexit sha1_base64="vUNmxaH4kklpawnEvFkyA7XGMQs=">AAACG3icbZDLSsNAFIYn3q23qks3g0UoCCWRgm4EQRGXCvYCTQmT6Uk7OJmEmROhhLyHG1/FjQtFXAkufBunF8HbDwMf/zmHM+cPUykMuu6HMzM7N7+wuLRcWlldW98ob241TZJpDg2eyES3Q2ZACgUNFCihnWpgcSihFd6cjuqtW9BGJOoahyl0Y9ZXIhKcobWC8oF/CzxPiyCix/SLBd2f8HkR5L6OqQIsqH8GEhnFoFxxa+5Y9C94U6iQqS6D8pvfS3gWg0IumTEdz02xmzONgksoSn5mIGX8hvWhY1GxGEw3H99W0D3r9GiUaPsU0rH7fSJnsTHDOLSdMcOB+V0bmf/VOhlGR91cqDRDUHyyKMokxYSOgqI9oYGjHFpgXAv7V8oHTDOONs6SDcH7ffJfaB7UvHqtflWvnFSncSyRHbJLqsQjh+SEXJBL0iCc3JEH8kSenXvn0XlxXietM850Zpv8kPP+CTSeoNA=</latexit>

3

Ruth Van de Water Projectile motion in 2D with VPython QCIPU 2021

Part 1: Motion under the influence of a constant net force In this first activity you will simulate the motion of a projectile launched across level ground with an initial speed and initial angle (see the figure) under only the influence of gravity — which is constant near the surface of the Earth. You will modify the provided code to print the starting values, simulation parameters, and range and time-of-flight. You will also validate your code by comparing the simulation range and time-of-flight with those from the analytic expressions derived from the kinematics equations in 2D.

1.Getting started ‣ Log onto GlowScript and create a new program in your QCIPU folder named

“ProjectileMotion” or something similar.

‣ In a separate tab, go to the page https://www.glowscript.org/#/user/ruthsvandewater/folder/QCIPU2021/program/ProjectileMotion/edit

‣ Copy the linked code into your GlowScript editor, but do not run it. Spend 5 or 10 minutes going through the code with your partner(s) making sure that you understand what it does before proceeding to the next step. An explanation of some of the VPython commands that are used in the code is provided at the top of the next page.

‣ Click Run this program. Does the path of the projectile look physically reasonable?

v0 θ0

Simulation algorithm for an object moving under the influence of forces Setup 1. Create variables for the simulation parameters such as g and m.

2. Specify the initial position, , and momentum of the object, .

3. Specify the starting time of the simulation, t0.

4. Create a sphere (or other shape) at the initial position.

5. Specify a time step Δt for your simulation; use a value that is small enough that the object doesn’t move very far during one update.

Simulation 6. Construct a loop that steps through the simulation time in increments of Δt.

In this loop:

• Calculate acting on the system for the current values of and .

• Update the object’s momentum:

• Update the object’s velocity:

• Update the object’s position:

• (If needed) update the net force:

• Increase the simulation time by Δt.

~r0

<latexit sha1_base64="YfJuamESdX7anhgPBLWAhKg2cqE=">AAAB8HicbVBNS8NAEJ3Ur1q/qh69LBahp5JIQY8FLx4r2A9pQ9lsJ+3S3STsbgol9Fd48aCIV3+ON/+N2zYHbX0w8Hhvhpl5QSK4Nq777RS2tnd294r7pYPDo+OT8ulZW8epYthisYhVN6AaBY+wZbgR2E0UUhkI7ASTu4XfmaLSPI4ezSxBX9JRxEPOqLHSU3+KLFPzgTsoV9yauwTZJF5OKpCjOSh/9YcxSyVGhgmqdc9zE+NnVBnOBM5L/VRjQtmEjrBnaUQlaj9bHjwnV1YZkjBWtiJDlurviYxKrWcysJ2SmrFe9xbif14vNeGtn/EoSQ1GbLUoTAUxMVl8T4ZcITNiZgllittbCRtTRZmxGZVsCN76y5ukfV3z6rX6Q73SqOZxFOECLqEKHtxAA+6hCS1gIOEZXuHNUc6L8+58rFoLTj5zDn/gfP4AzE2QVA==</latexit>

~p0

<latexit sha1_base64="mI/ZhajtfXxz0m2TlMQ694GJ4Yg=">AAAB8HicbVBNS8NAEJ3Ur1q/qh69LBahp5JIQY8FLx4r2A9pQ9lsJ+3S3STsbgol9Fd48aCIV3+ON/+N2zYHbX0w8Hhvhpl5QSK4Nq777RS2tnd294r7pYPDo+OT8ulZW8epYthisYhVN6AaBY+wZbgR2E0UUhkI7ASTu4XfmaLSPI4ez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99W0D3r9GiUaPsU0rH7fSJnsTHDOLSdMcOB+V0bmf/VOhlGR91cqDRDUHyyKMokxYSOgqI9oYGjHFpgXAv7V8oHTDOONs6SDcH7ffJfaB7UvHqtflWvnFSncSyRHbJLqsQjh+SEXJBL0iCc3JEH8kSenXvn0XlxXietM850Zpv8kPP+CTSeoNA=</latexit>

~v = ~p/m

<latexit sha1_base64="86mNACj5zX7Mr7aBmpZrwLqaqeE=">AAAB/HicbZDLSsNAFIYnXmu9Rbt0M1iErmoiBd0IBTcuK9gLtKFMpift0MkkzEwKIdRXceNCEbc+iDvfxmmahbb+MPDxn3M4Z34/5kxpx/m2Nja3tnd2S3vl/YPDo2P75LSjokRSaNOIR7LnEwWcCWhrpjn0Ygkk9Dl0/endot6dgVQsEo86jcELyViwgFGijTW0K4MZ0Gw2x7c4p3h+GQ7tqlN3cuF1cAuookKtof01GEU0CUFoyolSfdeJtZcRqRnlMC8PEgUxoVMyhr5BQUJQXpYfP8cXxhnhIJLmCY1z9/dERkKl0tA3nSHRE7VaW5j/1fqJDm68jIk40SDoclGQcKwjvEgCj5gEqnlqgFDJzK2YTogkVJu8yiYEd/XL69C5qruNeuOhUW3WijhK6Aydoxpy0TVqonvUQm1EUYqe0St6s56sF+vd+li2bljFTAX9kfX5A07DlHk=</latexit>

~rf = ~ri + ~v�t

<latexit sha1_base64="2aRX95mfE2oGrGztyBQ1BmjMby8=">AAACEXicbZDJSgNBEIZ7XGPcoh69NAYhIIQZCehFCOjBYwSzQDIMPZ2apEnPQndNIAx5BS++ihcPinj15s23sbMImvhDw8dfVVTX7ydSaLTtL2tldW19YzO3ld/e2d3bLxwcNnScKg51HstYtXymQYoI6ihQQitRwEJfQtMfXE/qzSEoLeLoHkcJuCHrRSIQnKGxvEKpMwSeqbEX0Cv6w4KezXg4pp0bkMgoeoWiXbanosvgzKFI5qp5hc9ON+ZpCBFyybRuO3aCbsYUCi5hnO+kGhLGB6wHbYMRC0G72fSiMT01TpcGsTIvQjp1f09kLNR6FPqmM2TY14u1iflfrZ1icOlmIkpShIjPFgWppBjTSTy0KxRwlCMDjCth/kp5nynG0YSYNyE4iycvQ+O87FTKlbtKsVqax5Ejx+SElIhDLkiV3JIaqRNOHsgTeSGv1qP1bL1Z77PWFWs+c0T+yPr4BmPrnKc=</latexit>

F net = F net( rf , v )

4

Ruth Van de Water Projectile motion in 2D with VPython QCIPU 2021

‣ Play around: What parameters in the code determine the initial speed and launch angle? Vary these parameters and confirm that the code does what you expect.

‣ Stop to think: Why is the path of the projectile shown as disconnected dots and instead of a curve? What parameter in the code determines the spacing between the dots? Vary this parameter and again confirm that the code does what you expect.

2.Displaying results ‣ At the end of the program, add code to print out the horizontal distance traveled by the

projectile (i.e., the range or xf) and the time at which the projectile hits the ground (i.e., the time-of-flight or tf).

3.Checking results One important way to check that a numerical simulation code is working correctly is to compare it to known analytic expressions, if such closed-form solutions are available. As you saw in introductory mechanics, the motion of a projectile in two dimensions under only the influence of gravity is described by a set of kinematics equations. (For a refresher, see, e.g., https://openstax.org/books/university-physics-volume-1/pages/4-3-projectile-motion.) Therefore, in this case, you can indeed validate your simulation by comparing with theoretical expectations.

‣ In your code (not on pencil and paper!), calculate the range and time of flight that that are predicted by the 2D kinematics equations for your starting conditions. Print these results. If all of your code is working correctly, the simulation and predicted values should at this point be roughly similar.

‣ In your code, write a function to calculate the percentage difference between two values,

, % difference =x1 − x2

(x1 + x2)/2× 100 %

Check in with an instructor before continuing.

Some useful VPython Commands

v = vec(vx, vy, vz) creates a vector with components , , and The

The components of v are accessed with the methods v.x, v.y, and v.z

mag(v) gives the magnitude of a vector

hat(v) creates a unit vector along the direction of the vector

ball = sphere(pos=vector(x,y,z), radius=R) creates a sphere of radius R at the

location

The position of ball is accessed with the method ball.pos

v vx vy vz

vv

r = (x, y, z)

5

Ruth Van de Water Projectile motion in 2D with VPython QCIPU 2021

and place it near the top of your code.

‣ Use this function to calculate the percentage differences between the simulation results and predicted values for the horizontal range and the time of flight. Print these percentage differences.

‣ You are now ready to quantitatively check your numerical simulation code. Using your simulation code, fill out Table 1 for a projectile with m=10 kg. Set the initial speed and launch angle to and

‣ How small does the step size dt in your code have to be to obtain agreement with the analytical results to within 1%? What about to within 0.1% or 0.01%?

You have now seen that there is an important tradeoff between the accuracy of your simulation and the time that it takes to perform the computation. In practice, one typically has a target precision that they wish to achieve. One then chooses simulation parameters that are sufficient to obtain the needed the precision goal, but do not unnecessarily waste computer cycles.

Part 2: Motion including a resistive force In the second activity you will simulate the motion of a projectile launched across level ground with an initial speed and initial angle under the influence of gravity and a drag force that depends upon the object’s current velocity. As before, you will modify the provided code to print the starting values, simulation parameters, and range and time-of-flight. Additionally, you will have to add the drag force to the appropriate locations in the code and update the net force in the simulation loop accordingly.

v0 = 20 m /s θi = 45∘

v0 θ0

Check in with an instructor upon completion of Part 1.

0.1

0.05

0.01

0.005

0.001

Table 1. Using your simulation code, fill out the table for a projectile with m=10 kg given an initial speed and launch angle of and .v0 = 20 m /s θi = 45∘

Δt (s) % difference in xf % difference in tf

6

Ruth Van de Water Projectile motion in 2D with VPython QCIPU 2021

With the drag force present, there are no longer closed-form analytic expressions for the object’s trajectory with which to compare. Therefore, you will instead validate your code by reducing the step size in your simulation until the calculated range and time-of-flight no longer change within a certain amount. This incremental approach to the correct answer as the simulation step size decreases is called convergence. Because, in real life, time is continuous (i.e., there is no “step size”), the object’s true trajectory cannot depend upon the value of that you use in your computer simulation. Therefore, for simulations that proceed in discrete steps, you must always check that your final result is stable to the desired number of significant digits when you further decrease the step size. Checking for convergence is a standard validation procedure in all numerical simulations of this kind.

4.Adding a drag force The drag force is a resistive force that opposes the motion of an object. Therefore, the direction of the drag force is opposite the direction of the velocity vector. The drag force on a reasonably-sized object (like a soccer ball) in air around sea-level is approximately proportional to the speed of the object squared. In other words,

,

where cd is a measurable parameter that depends upon the object’s properties (shape, size, etc.)

‣ In your QCIPU folder, create a new program named “ProjectileWithDrag” or something similar. Copy your code from Part 1 into this new code. (Close the tab with your code from Part 1 so the you do not accidentally edit it instead of the new program.)

‣ In this new program, remove the calculation of the analytic results for the range and time of flight, as well as the percentage differences. These do not apply in the presence of a drag force. Also reset the step size dt to 0.1 seconds.

‣ In suitable places in your program, add code to calculate the drag force according the the equation above. Choose cd=0.3 for now. What are the units of cd?

‣ Sanity check: Change the starting velocity to 100 m/s and run your code. Does the behavior of the projectile look reasonable? If not, fix your code so that it does.

5.Code validation ‣ Add to your loop a counter that counts the number of iterations that the computer does

during the simulation. Print out this number of iterations.

‣ Using your simulation, fill out Table 2 on the following page for a projectile with m=10 kg and cd=0.3. Set the initial speed and launch angle to and

Δt

Δt

F drag = − cdv2 v

v0 = 100 m /s θi = 45∘

Check in with an instructor before continuing.

7

Ruth Van de Water Projectile motion in 2D with VPython QCIPU 2021

‣ How small does dt have to be for the simulation to converge to 2 significant digits? What about to 3 or 4 significant digits?

Part 3: An improved simulation algorithm As you just saw in the previous section, even the simulation of a simple system such as a projectile in 2D with drag can require a very small step size (dt, in this case) and thousands of iterations to converge to 3- or 4-digit accuracy. As the step size is reduced and the number of iterations increases, the time it takes to run the simulation of course increases too. You can therefore imagine that, at some point, it will simply become impractical to improve your simulation with the “brute-force” approach of decreasing the step size.

Fortunately, however, there is another way to improve numerical computer simulations besides running longer: you can improve the algorithm. Mathematicians since at least the 17th century — possibly earlier — have spent countless hours developing and improving algorithms to solve differential equations (of which Newton’s Second Law is one) numerically, with computer scientists jumping in on the action more recently. The algorithm that you employed in Parts 1 and 2 of this laboratory was devised by Leonhard Euler (1707–1783) and 2

is known as Euler’s method. In Part 3, you will program and test an improved version of

https://en.wikipedia.org/wiki/Leonhard_Euler 2

# of iterations

0.1

0.1

0.05

0.01

0.005

0.001

0.0005

Table 2. Using your simulation code, fill out the table for a projectile with m=10 kg and a drag coefficient given an initial speed and

launch angle of and .

cdrag = 0.3m−1

v0 = 100 m /s θi = 45∘

(m)xf (s)tfΔt (s)

Check in with an instructor upon completion of Part 2.

8

Ruth Van de Water Projectile motion in 2D with VPython QCIPU 2021

Euler’s method developed by Lewis Fry Richardson (1881-1953) and known as the Euler-3

Richardson method. 4

To improve upon Euler’s method, it is useful to revisit the position and momentum-update equations,

and .

In these equations, and are the position and momentum at the beginning of a time interval (time ), while and are the position and momentum at the end of the same

time interval (time ). The velocity and net force, however, do not have any

“initial” or “final” subscripts, so what and should we use to update the position and momenta?

In parts 1 and 2 — although you may not have explicitly thought about it — you used the velocity and net force at the beginning of the time interval, and , in the position- and momentum-update equations. A better approximation for the average velocity and average net force in the interval between and , however, would

probably be obtained by using the velocity and and net force at the midpoint of the time interval, and . This is the essence of the Euler-Richardson method. The exact algorithm is provided at the top of the next page.

6.Improving the simulation ‣ In your QCIPU folder, create a new program named “ProjectileImproved” or something

similar. Copy your code from Part 2 into this new code. (Close the tab with your code from Part 2 so the you do not accidentally edit it instead of the new program.)

‣ Reset the step size dt to 0.1 seconds. Modify the loop in your code that calculates the trajectory of the ball to employ the improved algorithm at the top of the following page.

‣ Sanity check: If your new code is working correctly, you will likely not notice a difference in the motion of the ball when you run it. Your calculated range and time-of-flight should also be in the same ballpark as before.

‣ Once you believe that the improved algorithm is working, fill out Table 3 on the following page using the same parameters as for Table 2. (This will allow you to directly compare the two.)

‣ Is the Euler-Richardson algorithm from Part 3 more accurate than the Euler algorithm from Parts 1 and 2? How can you tell?

rf = ri + v Δt p f = p i + F netΔt

ri p iti rf p f

tf = ti + Δtv F net

v (ti) F net(ti, vi )

ti tf = ti + Δt

v midF net(tmid, v mid)

https://en.wikipedia.org/wiki/Lewis_Fry_Richardson3

L. F. Ricardson. The approximate arithmetical solution by finite differences of physical problems 4

involving differential equations, with an application to the stresses in a masonry dam. Philosophical Transactions of the Royal Society of London, 210:307–357, 1911

9

Ruth Van de Water Projectile motion in 2D with VPython QCIPU 2021

Improved algorithm for an object moving under the influence of forces (Steps 1—5 are the same as at the top of p. 3.)

6. Construct a loop that steps through the simulation time in increments of Δt. In this loop:

• Calculate acting on the system for the current values of and .

• Use the velocity and net force at the beginning of the interval to estimate the position and velocity at the middle of the time interval: and

• Use the position and velocity at the middle of the interval to estimate the net force at the middle of the interval:

• Use the velocity and net force at the middle of the interval to estimate the position and velocity at the end of the time interval: and

• Use the position and velocity at the end of the interval to estimate the net

force at the end of the interval:

• Increase the simulation time by Δt.

~Fnet

<latexit sha1_base64="bpsR2WvYo60AtnEvjEBEf3yU+Yg=">AAAB+nicbVBNS8NAEN34WetXqkcvi0XoqSRS0GNBEI8V7Ae0IWy2k3bpZhN2N5US81O8eFDEq7/Em//GbZuDtj4YeLw3w8y8IOFMacf5tjY2t7Z3dkt75f2Dw6Nju3LSUXEqKbRpzGPZC4gCzgS0NdMceokEEgUcusHkZu53pyAVi8WDniXgRWQkWMgo0Uby7cpgCjS7zf1sICMsQOe+XXXqzgJ4nbgFqaICLd/+GgxjmkYgNOVEqb7rJNrLiNSMcsjLg1RBQuiEjKBvqCARKC9bnJ7jC6MMcRhLU0Ljhfp7IiORUrMoMJ0R0WO16s3F/7x+qsNrL2MiSTUIulwUphzrGM9zwEMmgWo+M4RQycytmI6JJFSbtMomBHf15XXSuay7jXrjvlFt1oo4SugMnaMactEVaqI71EJtRNEjekav6M16sl6sd+tj2bphFTOn6A+szx993pQT</latexit>

~r

<latexit sha1_base64="IVBKhCSM+4qEUqLOXnoV8PjFJWw=">AAAB7nicbVBNS8NAEJ3Ur1q/qh69LBahp5JIoR4LXjxWsB/QhrLZTtqlm03Y3RRK6I/w4kERr/4eb/4bt20O2vpg4PHeDDPzgkRwbVz32yns7O7tHxQPS0fHJ6dn5fOLjo5TxbDNYhGrXkA1Ci6xbbgR2EsU0igQ2A2m90u/O0OleSyfzDxBP6JjyUPOqLFSdzBDlqnFsFxxa+4KZJt4OalAjtaw/DUYxSyNUBomqNZ9z02Mn1FlOBO4KA1SjQllUzrGvqWSRqj9bHXugtxYZUTCWNmShqzU3xMZjbSeR4HtjKiZ6E1vKf7n9VMT3vkZl0lqULL1ojAVxMRk+TsZcYXMiLkllClubyVsQhVlxiZUsiF4my9vk85tzavX6o/1SrOax1GEK7iGKnjQgCY8QAvawGAKz/AKb07ivDjvzse6teDkM5fwB87nD6M5j7E=</latexit>

~v

<latexit sha1_base64="JMgp5kExcmsKcIgR7OIYaUix5U8=">AAAB7nicbVBNS8NAEJ3Ur1q/qh69LBahp5JIoR4LXjxWsB/QhrLZTtqlm03Y3RRK6I/w4kERr/4eb/4bt20O2vpg4PHeDDPzgkRwbVz32yns7O7tHxQPS0fHJ6dn5fOLjo5TxbDNYhGrXkA1Ci6xbbgR2EsU0igQ2A2m90u/O0OleSyfzDxBP6JjyUPOqLFSdzBDls0Ww3LFrbkrkG3i5aQCOVrD8tdgFLM0QmmYoFr3PTcxfkaV4UzgojRINSaUTekY+5ZKGqH2s9W5C3JjlREJY2VLGrJSf09kNNJ6HgW2M6Jmoje9pfif109NeOdnXCapQcnWi8JUEBOT5e9kxBUyI+aWUKa4vZWwCVWUGZtQyYbgbb68TTq3Na9eqz/WK81qHkcRruAaquBBA5rwAC1oA4MpPMMrvDmJ8+K8Ox/r1oKTz1zCHzifP6lNj7U=</latexit>

x mid = x i + v i(Δt /2) p mid = p i + ( F net)i(Δt /2)

( F net)mid = F net ( rmid, v mid)

x f = x mid + v mid(Δt /2) p f = p mid + ( F net)mid(Δt /2)

( F net)f = F net ( rf , v f)

# of iterations

0.1

0.1

0.05

0.01

0.005

0.001

0.0005

Table 3. Using your improved simulation code, fill out the table for a projectile with m=10 kg and a drag coefficient given an initial

speed and launch angle of and .

cdrag = 0.3m−1

v0 = 100 m /s θi = 45∘

(m)xf (s)tfΔt (s)

Check in with an instructor upon completion of Part 3.