This preview shows page 201 - 205 out of 255 pages.
To do that, we need to know the acceleration of the jumper over time.Al-though we compute acceleration in the slope function, it is not included in theresults.It might be tempting to record the acceleration each time the slope functionruns, but we should not do that.The ODE solver calls the slope functionmany times with different values ofstateandt.Because of the way thesolver works, not all of the states and times are actually part of the solution.So recording acceleration while the solver is running would not work.Instead, we can use the computed velocities to estimate acceleration as a func-tion of time.Themodsimlibrary providesgradient, which uses NumPy to estimate thederivative of aTimeSeries. Here’s how it works:a = gradient(results.v)In the notebook for this chapter,chap21.ipynb, you can finish this problemby finding the combination ofLandkthat allows the jumper to complete thebungee dunk while minimizing the acceleration they experience. For instruc-tions on downloading and running the code, see Section 0.4.
184Chapter 21Air resistance
Chapter 22Projectiles in 2-DIn the previous chapter we modeled objects moving in one dimension, withand without drag. Now let’s move on to two dimensions, and baseball!In this chapter we model the flight of a baseball including the effect of airresistance.In the next chapter we use this model to solve an optimizationproblem.22.1BaseballTo model the flight of a baseball, we have to make some modeling decisions.To get started, we ignore any spin that might be on the ball, and the resultingMagnus force (see).Under this assumption,the ball travels in a vertical plane, so we’ll run simulations in two dimensions,rather than three.Air resistance has a substantial effect on most projectiles in air, so we willinclude a drag force.To model air resistance, we’ll need the mass, frontal area, and drag coefficientof a baseball. Mass and diameter are easy to find (seebaseball). Drag coefficient is only a little harder; according toThe Physics
186Chapter 22Projectiles in 2-Dof Baseball1, the drag coefficient of a baseball is approximately 0.33 (with nounits).However, this valuedoesdepend on velocity. At low velocities it might be ashigh as 0.5, and at high velocities as low as 0.28. Furthermore, the transitionbetween these regimes typically happens exactly in the range of velocities weare interested in, between 20 m/s and 40 m/s.Nevertheless, we’ll start with a simple model where the drag coefficient doesnot depend on velocity; as an exercise at the end of this chapter, you will havea chance to implement a more detailed model and see what effect is has onthe results.But first we need a new computational tool, theVectorobject.22.2VectorsNow that we are working in two dimensions, we will find it useful to work withvector quantities, that is, quantities that represent both a magnitude and adirection. We will use vectors to represent positions, velocities, accelerations,and forces in two and three dimensions.