Wednesday, January 16, 2013

heuristic bike speed formula

Recently I wanted to estimate how long a "typical" cyclist would take to ride a certain course.

You could assume the rider would ride at a constant power, but that's not realistic: we tend to ride at higher power uphill, a bit less on the flats, and low, zero, or even negative power on descents. And on the uphill, there's an optimal grade for power output: if the road gets too steep for a rider's gears or balance, power tends to drop.

So rather than a physically based model, I chose a heuristic one: one which has the correct behavior under the different conditions, and connects them analytically.

I've described the following model here before, where I used it in a formula for rating climbs:

v = vmax / [1 + ln | 1 + exp(50 g) |],
where g is a modified road grade (the sine, rather than the tangent, of the road angle) and vmax is the maximum speed the rider is willing to go on descents. For example, for a brisk rider, I chose vmax = 15 meters/second. For a rider going a relaxed pace, I chose 10 meters/second.

This formula has the behavior that or negative grades (descents) it approaches an asymptotic speed vmax, while for positive grades it approaches an asymptotic rate of vertical ascent vmax / 50. However, this fails at extreme grades: climbing roads on order 30% is typical slow due to the difficulties of riding a typical bike up a road that steep, while descending a super-steep road is difficult due to the safety hazard. Actually, I have difficulty controlling my speed at all at descents of 25%, but if my brakes worked better, I'd certainly want to go relatively slow for steeper roads.

So to handle this situation, I want to modify the equation with a factor which rapidly reduces speed further at large positive or negative grades, but which over a broad range of grades preceding has little effect. The following modification seemed to work nicely:

v = vmax / ( exp[−(3 g)4] [1 + ln | 1 + exp(50 g) | ] ),

An issue with this term is it requires good altitude numbers. If there is large point-to-point altitude errors for example due to using altitudes taken from a map in hilly terrain where small position errors can yield altitude differences, extremely large grades can result and this formula will have the rider come to a molasses-like stop. So for data where the altitude isn't reliable, the previous version is safer.

I compare these formulas here for different values of vmax: 10 m/sec corresponds to relaxed riding, 15 m/sec a brisk non-racing pace, and 20 m/sec someone who's riding hard, especially up the hills. To adhere to convention, I've converted "effective grade", the sine of the angle which is easier for calculations, to grade, the tangent of the angle which is better suited for surveying.

speed vs grade

The plot shows the formulas with and without the steep grade term. The effect of the steep grade term is clearly evident for descending grades, less than zero. For climbing, the effect is clearest when looking at VAM, which I plot here using the conventional meters/hour, for positive grades only:

VAM vs grade

With this heuristic formula the maximum VAM is at a 14.1% grade. This could be tuned with the various coefficients used, but seems plausible for a rider with wide-range gears (compact crank) which are the best overall choice in known-steep terrain. When descending the maximum speed is at a -10.0% grade. This also seems reasonable: much steeper and I worry about my ability to control the bike.

One other issue I recently encountered with this is the rider's pace on descents didn't depend on how twisting the descent was. The original application was for rating hills based on the profile for which heading wasn't available, but in this case I was using full map data and I wanted to predict how long a typical rider would take to ride it. To overcome this limitation, I decided to model the effect of corners as a given delay per unit angle. So for a given point surrounded by two connecting segments, I determine the magnitude of the course change between the two segments. Then I calculate the following delay:

Δtturn = (2 seconds) |Δheading| (v / vmax)2.

I assume turning one radian at vmax delays the rider 2 seconds due to braking then re-accelerating. For the rider going slower, the delay is less. At uphill speeds, for example, turns cause essentially no delay. Since time is calculated across segments and not points, I allocate half of this delay to the segment preceding, and half to the segment following. The result is a rider doing a quick 360 from maximum speed would be delayed 12.6 seconds relative to a rider who just blasted ahead full-blast. That seems fairly accurate.

I really like heuristic-based modeling in many instances. Rather than focus on developing a model based on fundamental underlying physics, focus on matching the observed large-scale behavior and make sure the model interpolates smoothly between simple cases (in this case, steep climbing and steep descending). The resulting coefficients don't necessarily have direct physical meaning but the resulting model can be simple and effective.

1 comment:

djconnel said...

I originally made a typo in the formula, putting 50 exp(g) instead of exp(50 g). I fixed it.