Syndicate this site: (RSS)

Weekend projects

My project for the weekend was to create a simple program to model the flight of batted baseballs. This really is a perfect weekend project, in that it has the ability to spiral completely out of control, with learning about drag and lift, choosing spin models, deciding what Reynolds number to use (lots of papers out there; executive summary: nobody else knows either).

As is my habit, I'm trying to work TestFirst. TestFirst can be painful when you don't actually know for sure what the result ought to be. So I first modeled the baseball as a free particle, to make sure the mechanics of the engine worked as I expected, then added gravitational corrections - because I know the right answer for those.

Now I had a choice of drag or spin. I've been working with Watts & Bahill as a reference, and in fact they provide an example with just gravity, gravity plus drag, and several different lift effects.

Now, I'm not entirely happy with the choices that they made, but I figure if I can duplicate their results, then I know the code is right, and can tweak the models as necessary.

First the drag free case. Their answer is 700, mine just over 705. The bigest part of that can be traced (via comments in the text) to the fact that they are hitting the ball off the ground, where I'm hitting a ball in the middle of the strike zone (3 feet above the ground). I'm still a touch high - which surprises me a little bit as I deliberately coded the cutoff short. I can accept a 0.2% error for the moment, so I move on.

With drag... the answer is just wrong. The text says "only about half as far" as the previous case, but that's a rather gross distortion. They go on to say that the maximum distance for this velocity (with no lift) is 335.

My answer is over 410. Not in the ballpark.

So I criss crossed through the book a few times, worked my way through the drag equation, and discover that their drag coefficient and mine are very different. I hadn't bothered to work out a drag coefficient, actually, but instead worked backwards from experimental results of the terminal velocity. The text computed drag from the Reynolds number - which is 0.5 over most of the flight of the ball.

But not, of course, at terminal velocity. More digging turned up Sawicki, Hubbard & Stronge and the information that terminal velocity occurs after the drag crisis. The drag coefficient at that speed is 0.3.

Aha, says I - my drag force is too small. But I can shortcut the recalculation for the moment but just multiplying my drag force by the correcting ratio and Tada! I get 335ft.

Unfortunately, that's still too high. To get the right answers, I need to use a wonky correction like .5228, which is much too big.

Then I find buried in a paragraph that they are using a third order Runge-Kutta formulation.

My engine is using a straightforward Euler approximation, so now I have to go research RK formulations (third order? Who uses third order for anything?)

January 18, 2004 6:39 PM | TrackBack

Comments
Post a comment




Who are you?