Phew! Ok, I managed to hack something together in perl to compute Crr
and CdA using the Virtual Elevation Method, or my best attempt at it. I
used a lot of the data in Robert Chung's recent Wattage Forum
spreadsheet repost.
(It's important to acknowledge that this work is completely taken from
the stuff that's regularly shared on the Wattage Forum. Without that
forum, we would have a really tough time doing all this cool stuff.)
Here's how it works:
Features:
----------------------------------------------------------------------------------------------------------------------------
- computes Crr and CdA from power file and elevation profile
- stably tries to match the profiles using a global L2 norm
- full equations used for Newton's 2nd law (no small-angle approximations):
F - m g sin(theta) - Crr m g cos(theta) - CdA rho v^2 / 2 = m a
- regular iteration solver for slope to cope with nonlinear trig equation
- full Newton-Raphson using numerical derivatives for outer solver
To Do:
----------------------------------------------------------------------------------------------------------------------------
+ recheck numerics over and over to make sure they're right
+ implement Chung method for use when no elevation profile is available
+ provide unit tests to bolt-down the validation of the code
+ add calculation for rho, air density
Executable:
----------------------------------------------------------------------------------------------------------------------------
Perl program,
ve.pl, attached.
Perl dependencies:
----------------------------------------------------------------------------------------------------------------------------
require Math::Trig;
Inputs:
----------------------------------------------------------------------------------------------------------------------------
A PowerTap CSV file, pt_data.csv, attached.
An associated elevation file, elevation.csv, attached.
Mass of rider + bike, m. ( Here, 89kg)
Time-sampling interval, dt. ( Here, 1.26s )
Density of air, rho ( Here 1.236kg/m^3)
Conversion factor from speed in file to m/s, v_factor (Here, 3.600 )
Starting elevation, elev_start. (Here, 7.59m)
Command line usage:
----------------------------------------------------------------------------------------------------------------------------
%
ve.pl <power_tap_file> <elevation_file> <m> <rho> <dt> <v_factor>
<elev_start>
Example:
----------------------------------------------------------------------------------------------------------------------------
%
ve.pl pt_data.csv elevation.csv 89 1.236 1.26 3.6 7.59
crr= -0.00896848, cda= 0.71414735 RESIDUALS: 0.051821
121720394637.221100
crr= -0.01887355, cda= 0.74727538 RESIDUALS: 0.043221
24240094726.978828
crr= -0.06140901, cda= 1.32495998 RESIDUALS: 0.724061
4847607668.734711
crr= 0.04881965, cda= -0.23143669 RESIDUALS: 1.950369
970123080.834633
crr= 0.01233395, cda= 0.28146843 RESIDUALS: 0.642751
195195026.279830
crr= 0.00621468, cda= 0.36746316 RESIDUALS: 0.107765
39145221.731429
crr= 0.00499893, cda= 0.38454789 RESIDUALS: 0.021410
7829464.327135
crr= 0.00475554, cda= 0.38796827 RESIDUALS: 0.004286
1565869.723166
crr= 0.00470688, cda= 0.38865210 RESIDUALS: 0.000857
313175.156131
crr= 0.00469715, cda= 0.38878888 RESIDUALS: 0.000171
62634.927414
crr= 0.00469520, cda= 0.38881621 RESIDUALS: 0.000034
12527.026148
crr= 0.00469481, cda= 0.38882167 RESIDUALS:
0.000007 2505.412917
crr= 0.00469473, cda= 0.38882276 RESIDUALS:
0.000001 501.082018
crr= 0.00469472, cda= 0.38882298 RESIDUALS:
0.000000 100.216611
crr= 0.00469472, cda= 0.38882303 RESIDUALS:
0.000000 20.043254
crr= 0.00469471, cda= 0.38882303 RESIDUALS:
0.000000 4.008642
crr= 0.00469471, cda= 0.38882304 RESIDUALS:
0.000000 0.801726
crr= 0.00469471, cda= 0.38882304 RESIDUALS:
0.000000 0.160310
crr= 0.00469471, cda= 0.38882304 RESIDUALS:
0.000000 0.032088
crr= 0.00469471, cda= 0.38882304 RESIDUALS:
0.000000 0.006452
crr= 0.00469471, cda= 0.38882304 RESIDUALS:
0.000000 0.001279
crr= 0.00469471, cda= 0.38882304 RESIDUALS:
0.000000 0.000221
Cheers!
Andy