Physics Practicals

# Projectile Motion 2 Student Guide

Computational Projectile Motion With Python Student Guide Nov. 16, 2023, 9:42 a.m.

In this module we will investigate projectile motion, with and without air resistance.

• There are questions asked of you throughout this assignment, labeled Question 1, Question 2, etc.  Include the answers to these questions in your notebook.
• If you are working with a partner, the two of you must reach a consensus about an answer before moving on to the next part. Feel free to ask the TA for help if a consensus cannot be reached.
• All quantities are in SI units; distance in meters (m), time in seconds (s), velocity in m/s, acceleration in m/s2, and mass in kg.

## Activity A: Projectile Motion in a Vacuum

Here is a problem which we will consider today:

You throw a tennis ball horizontally at a speed of 20 m/s off the top of a building which is 50 m tall.  How far from the base of the building will the ball first hit the ground?

Question A.1: Assuming that air resistance is negligible, what is the theoretical answer to the problem?  Also, how long does it take the ball to hit the ground?

Download the program rangeTemp.py and save it on your computer.  You can open it with Spyder, which should be an icon on your desktop.  Read the code carefully. Remember that any line which starts with # is just a comment for the reader, and is ignored by the computer when it runs the code. There is a “bug” somewhere in this code.  There is only one major bug on one line that is making the code crash with a syntax error.

Question A.2: Debug the code so that it no longer crashes.  Describe in your booklet what the old and new line were that you fixed.  Make sure you save this code somewhere safe as lastnameActivityA.py, and submit it on Quercus for marks.   Include in the comments your name and the name of your partner if you have one.

Now that the code is running properly address the following questions:

Question  A.3: Does the code seem to produce the same results as the theoretical ones you predicted above?  What happens if you change the time-step, dt?   If you want to get range and time-of-flight results to within 0.1%, what is a good value for dt?

The code also outputs a comma-separated-value file “rangeOutput.csv” which you can read into Excel and make a chart of the trajectory. In addition, the code also plots the simulated trajectory within Python.  In Spyder, the plot can be viewed in the "Plots" tab on the right hand side.

Question A.4: Make a chart plotting the physical trajectory of the ball in a vacuum.  Print it and staple it in your notebook, along with the relevant parameters of the numerical integration.

## Activity B: Projectile Motion with Air Resistance

When a real ball flies through the air, there is air resistance.  Air resistance is studied in fluid dynamics and its origins are complex, but for most normal speeds and ordinary-sized objects here on earth that are not rotating, air resistance can be modeled by the drag equation (Eq.6.15 from Knight):

$$F_D = \frac{1}{2} C \rho A v^2$$

Here FD is the magnitude of the drag force in Newtons.  The direction of $$\vec{F}_D$$ is opposite the direction of the ball’s velocity relative to the air, $$\vec{v}$$.    ρ is the density of the air, which is around ρ = 1.2 kg/m3.  $$v^2 = {v_x}^2 + {v_y}^2$$ is the square of the speed of the ball in m2/s2A is the cross-sectional area of the ball in m2C is the drag coefficient - a dimensionless coefficient related to the object's geometry and taking into account both skin friction and form drag (http://en.wikipedia.org/wiki/Drag_equation).   Note that for a tennis ball going between 20 and 50 m/s, the drag coefficient is approximately C = 0.53.

As the ball flies through the air, there are two forces acting: the drag force and gravity.  The net force on the ball is the vector sum: $$\vec{F}_{\rm net} = \vec{F}_D + \vec{F}_g$$.

Modify the code from Activity A to include the drag force.  You will need to know that the mass of a tennis ball is about 58 grams, and the radius of a tennis ball is about 3.4 cm.

In your booklet, write down the theory that you use to find:

• The direction of the velocity.
• The direction of the drag force.
• The x and y components of the net force.
• The x and y components of the acceleration, given the x and y components of the velocity.

Some facts about Python code which might be good to know:

• To raise something to a power, use **, not ^.  (Ie, x2 is x**2)
• Trig functions are sin(), cos() and tan().  Inverse trig functions are arcsin(), arccos() and arctan().  Units of angle are always assumed to be radians.
• pi is a defined number in python which is about 3.14159, and you would expect.
• Python will not overwrite a file that is currently open in another program. So if you are viewing the output .csv file with Excel, you have to close Excel before you can re-run the python code.

When your code is running properly, make sure you save this code somewhere safe as lastnameActivityB.py, and submit it on Quercus for marks.   Include in the comments your name and the name of your partner if you have one.

Question B.1  What is the distance, and how does it compare to the value with no air resistance?  What is the time of flight, and how does it compare to the value with no air resistance?   Plot the trajectory and include it in your notebook.   How does it compare in shape to the parabola with no air resistance (ie can you notice a difference?)  You may recall that Professor Wilson published a couple of models in the solutions to Written Homework 5.  Which model best matches your numerical integration?

Question B.2  Try running your code with different properties for the tennis ball.  If the mass of the ball is higher, how does that affect the distance traveled and time of flight?   If, instead, the radius of the ball is more, how does that affect the distance traveled and time of flight?  Alternatively, if the tennis ball had the same properties, but was launched from a building that is higher than 50 m tall, how does that affect the distance traveled and time of flight?

Question B.3 What if the tennis ball (mass 58 grams, radius 3.4 cm) had been launched at 20 m/s at an angle of $$45^\circ$$ above the horizontal?  How far would it travel?  If you change the launch angle above or below $$45^\circ$$, how does that change the distance?  Can you estimate the best angle for maximum distance?  [Remember that all of the trigonometric functions in python use radians, not degrees.  You can use 45*pi/180 to convert 45 degrees to radians.]

[This Module was written by Jason Harlow November 2023. ]