Dave Waterworth has fixed my implementation of W'bal to
remove my "optimisations" and fix the math.
The W'bal is now computed in a single pass and is just
as fast as the differential form from Andy Froncioni but
has the benefit that is still uses Tau.
Many thanks to Dave, and I'll write this up shortly.
.. previously we have computed below cp work as only that
work when power was at or below CP
.. since we want to track energy from CP and W' it makes more
sense to make below CP work include all work not from W' stores.
.. when computing W'bal decay -- since we know the half-life
for the decay we might as well use it rather than a pretty
big constant of 1 hour !
.. it saves about 35% of time to compute metrics
.. forgot to remove the threaded integrator which is no longer
needed and then found it is still being used by the minForCP()
method, so tidied that up.
Using Andy Froncioni's modification to the original
formula that removes the need for Tau and also lets
the exponentials drop out.
Massive speed improvement!
Added a few new training stress metrics whilst discussing
and working on a multicomponent view of training stress.
This is all a wip falling out of discussions around stress
metrics beyond the old TSS/BikeScore models.
For now this just includes;
1. Aerobic Training Impact Scoring System on PM/PMC
2. Work (Kj) above/below CP on PM/PMC
3. Aerobic TISS on the Ride Plot
There is lots more to come; specifically around Anaerobic TISS,
looking again at polarised training and personalised training stress
based upon the individual's CP model.
.. the calculation assumed 1s recording (or was just wrong)
joules are now calculated properly, this is especially
important for SRM recordings of 0.5s samples
.. No more cutoff of the decay. Since we use threads its
not such a big deal as before.
.. We now get a full, smooth decay till the end of the ride
which was much more noticeable when predicting W'bal for
a workout, than it was for a ride.
.. to save on computing cost the W'bal decay was only
calculated to 20mins and also bounds checked to a
decay of 0.1w, but of course, the decay is more like
25 minutes and 0.1w * 1500 samples is a lot... so
I've removed them.
.. the key optimisation is the way the decay is integrated
and that is skipped for samples where W' exp is zero ..
that optimisation reduces the amount of computing cost
to 25% of doing it for all samples.
For maximum W' capacity expended i.e. Min W'bal
expressed as a percentage of W'.
So if W' is 20 kJ and W'bal is 2kJ then 18 kJ
have been expended, which when expressed as a
percentage of W' (18/20 %) would be;
Max W' Exp of 90%
I also cleaned up a few extra instances of WPrime
being created when calculatinf metrics which was
not a big deal for the Metric refresh but would make
interval metrics painful.
.. if duration is overly large we don't want to get some
massive array, it will exhaust heap and cause a crash ..
and it is likely to just be bad data.
.. don't be so keen to add zero values interpolating gaps
in recording when the gap is less than 2 samples wide.
.. previously we were adding way too may zero values at
subsecond intervals that caused an interpolated value
returned by the spline to be /practically/ zero.
.. offset needed to be a double not an int to ensure
we handle recording gaps from powertap etc where
it is not an whole number of seconds
.. Thanks for Armando Mastracci for highlighting this
and providing a test file to recreate
Fixes#773
.. just speeding up the autosolve by only looking in increments
of 3w, should speed up by a factor of 3 but will mean the result
is correct to +/- 3w .. which given the W' is usually only right
to +/- 2kJ should be about right.
.. don't rely on WPrime to compute it, its pretty simple
to compute as long as CP is set
.. add to the summary totals so always there to compare
against the total work
.. the optimisation was a little eager and took out
the integration step !
.. access to PCP is now hidden behind a function so
it is only computed when neccessary.
.. the calculation is still significantly faster than
the old one but not as instant as the non-integrating
version (but then it wasn't working either!).
.. on ride plot, when W'bal is plotted we put a mesage to say
that CP is wrong, and autosolve for W'bal to zero.
.. this patch also optimises WPrime to make it a member of the
ridefile class and this always available (even for intervals).
.. fixed a SEGV when computing metrics for intervals by shifting
the timestamps to always start from zero.
Instead of just reimplementing the spreadsheet we now
implement according to the original formulas as defined
in the W'bal paper.
This means there is no longer a 1200s limit to the decay
which was not part of the original paper.
We should be able to add some W'bal metrics now.