When there is air resistance, one must use smaller timesteps to get reasonable results. I have updated the values of the timesteps you should use in the assignment below. Please check it before doing your analysis. |
Your job in this project: calculate the height and speed of a projectile fired vertically from a cannon, just like last week. This time, however, you are take into account two complicating factors:
The situation is similar to that of the previous week: a gigantic cannon shoots a projectile vertically at high speed. The initial conditions are
What are the height and velocity of the projectile as a function of time?
Case A: realistic gravity only (no air resistance)
Write a Scilab routine which calculates position and velocity as a function of time for this problem. It should look like this:
function cannonball_a(start_velocity, timestep, method, output_file) where start_velocity is the starting velocity, in meters per second timestep is the size of the timestep (t1 - t0) to use in calculations, in seconds method is either the word "euler", or the word "heun"; it indicates the algorithm to use for integration output_file is the name of a file in which you will write values of time, height, and speed
Instead of assuming that the gravitational force on the projectile is constant, use the Law of Universal Gravitation to compute the force at each iteration. Assume for this assignment that the mass of the Earth is 5.98 x 10^(24) kg, and its radius is 6.37 x 10^6 m.
In this case, you should be able to compute the TRUE velocity and TRUE energy corresponding to any height; use the conservation of energy. That means that you know what the velocity should be when the cannonball returns to the Earth's surface.
Tabulate the following properties for each choice of timestep: t = 1.0, 0.5, 0.25 seconds, 0.125 seconds.
Your program should be able to employ either Euler's method or Heun's method to perform this simulation, depending on the value of the third argument. Which does a better job? How does the performance of Euler's method improve when you decrease the timestep by a factor of 2? How does the performance of Heun's method improve when you decrease the timestep by a factor of 2? Be quantitative.
Case B: air resistance only (no change in gravitational force)
(Assume that the gravitational force on the ball is constant for this case).
function cannonball_b(start_velocity, timestep, method, output_file) where start_velocity is the starting velocity, in meters per second timestep is the size of the timestep (t1 - t0) to use in calculations, in seconds method is either the word "euler", or the word "heun"; it indicates the algorithm to use for integration output_file is the name of a file in which you will write values of time, height, and speed
Now, however, there is air resistance pushing against the projectile as it moves through the air. Let us adopt the following rule for calculating the force of air resistance -- it's an approximation, but not a terrible one at moderate speeds.
2 F(air) = C * (density) * (area) * (speed) where F(air) is the force of air resistance (Newtons) C is the drag coeff, C = 1.0 for a smooth ball density is the density of the air at current altitude (see below) area is the cross-section area of the projectile speed is the ball's current speed (meters/sec)
To be realistic, we must include the change of the density of air in the Earth's atmosphere with altitude. We don't ordinarily notice it, because the scale height of the change is much larger than the altitudes we typically cover in a short time. To a decent approximation, the density of air is
(-height/8000 m) rho(height) = (1.21 kg/m^3) * e
It might be very useful to write a very short Scilab function which calculates the density of air given a height above the ground. That might make your main program shorter and easier to understand, since some of the details would be "hidden" in the other function.
Tabulate the following properties for each choice of timestep: t = 0.01, 0.005, 0.0025, 0.00125 seconds.
This time, we don't know (well, I don't know, anyway) the true velocity when the projectile hits the ground, so we can't easily figure out if our results are correct, or how incorrect they might be. Again, use both Euler's method and Heun's method. Does either method appear to converge as the timestep decreases? Be quantitative.
This page maintained by Michael Richmond. Last modified Apr 23, 2007.
Copyright © Michael Richmond. This work is licensed under a Creative Commons License.