Lab 4, Exercise 1: Adding Air Resistance
As our rocket moves through the Earth's atmosphere, it experiences a resistive force directed opposite of its motion, i.e., opposite the direction of the rocket's velocity vector. In this lab we will assume the air resistance has the form
where b is a constant, the drag coefficient, that depends on the viscosity of the air and the cross-sectional area of the rocket. A typical value in SI units is 0.17 (this assumes a cross-sectional diameter of 10 m for our rocket.)
The differential equation that describes the rocket's motion is now
The analytic solutions for speed and position are
We will use these equations to check the accuracy of our numerical model. But first, we must create our numerical model. We can't use the same code from the previous labs because our force equation has changed. However, we can proceed just as we did in previous labs. First, we write our second-order differential equation as two first-order equations:
Rewrite both expressions:
Replace the infinitesimals with finite differences:
We can now write expressions that relate the speed and position at the next integration step (i+1) to the speed and position at the current integration step (i):
Open your final working program from Lab 3, and rename the file YourName_Lab4_PHYS495_1.py. Edit the scene title:
scene.title = "VPython: Euler's Method with Air Resistance (Lab 4)"
Make the following changes to your program:
- Prompt the user for a value of b. A typical value in SI units is 0.17, assuming a 10-meter cross-section for our rocket.
- Change the equations that update the position and speed of the rocket to reflect the new numerical model developed here.
- Change the equations that calculate the analytic solutions for the position and speed.
- Edit the code for the flight-data box to display data to nine digits.
Once your program is working, perform the following experiment:
- Set the time step to 0.1 seconds, and note the total flight time.
- Set the simulation max time (t_max) to half the total flight time.
- Run the simulation for the following time steps, calculating the percent error between the analytic and numerical values of y and vy for each time step: 0.5 seconds, 0.1 seconds, 0.05 seconds, 0.01 seconds.
Turn in your percent error calculations to Dr. Dunning at the end of the lab. Do not turn in the program from this exercise.