Course 2.2Lesson 5 of 5
A project that uses the whole chapter: a ball is thrown at 40 metres per second at 45 degrees, and air resistance makes the force on it proportional to the square of its speed. The state is the position and the velocity, four numbers, and solve_ivp follows them with a rate function. An event function that returns the height, with terminal true and direction minus 1, stops the solution when the ball reaches the ground. Without air the range is 163.3 metres, equal to v squared over g, and with the drag constant 0.0089 per metre the range is only 82.5 metres, the flight is shorter and the height is lower. A scan of the angles shows that the best angle without air is 45 degrees and with air it is lower, 40 degrees.
Try the code and the simulations beside the lesson.
After this lesson you can
solve_ivp,In chapter 1, you found the best angle for a throw: 45 degrees, and the range . But that was for a ball in empty space. A real ball moves in air, which slows it down. A cricket ball, a football and an arrow all feel the drag, and for quick objects it is not small. What are the range, the time and the height, and is 45 degrees still the best angle?
There is no simple formula. For this kind of problem, the computer is the tool.
The force of the air on a body in fast motion is proportional to the square of the speed, and it points against the velocity. As an acceleration:
where is the speed and is a constant that depends on the shape, the size and the mass: , where kg/m is the density of air, is the drag coefficient, is the area, and the mass. For a ball with , m and kg (a baseball), per metre. Gravity adds the acceleration in the vertical direction.
The motion has four quantities: the position and the velocity . Their rates of change are:
Notice that the equations for the and directions are coupled: the speed contains both and . This is why there is no simple formula.
Predict first. Without air, the range at 40 m/s and 45 degrees is m. What do you expect with the air? Half? A tenth? Then run it.
The output:
Predict first. With air, will the best angle be larger than 45 degrees, equal to it, or smaller?
Why is the best angle smaller with air? A ball thrown at a high angle spends a long time in the air, going up and coming down, and the air slows it for all that time. A flatter throw stays in the air for a shorter time, and loses less speed. So it is better to throw a little lower. This is what athletes know: a javelin or a long jump has a take-off angle that is below 45 degrees. The difference in range between 40 and 45 degrees is only about 1 m, so the best angle is not sharp, but the computer found a real physical effect that the simple formula could not.
The small difference between the program and the formula comes from the size of dt. Make dt smaller in the code and it shrinks.
A numerical model should always be checked. We did three checks:
rtol and atol smaller. (Try it.)Also ask: are the numbers sensible? A baseball hit at 40 m/s (about 144 km/h) does travel about 80 to 100 m in air. The result is in the right range.
np.sin and np.cos. Change it to radians.Start with two quick questions. Each New numbers gives you a fresh one, so you can practise as long as you like.
Then the labs and the problems:
flight that gives the range, the time and the height.s and returns a list of the rates.terminal = True and a direction stops the solution when something happens, such as a landing.Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
landed.direction = -1 mean?k = 0 make a good check?Every lesson is open to read. Enrolling also lets you:
Log in to join the discussion.
Loading…
This lesson is free to read. Enroll free to keep your place and take the tests.