### Improve the approximation of power from current

```P = Integral from Q1 to Q2 of V(Q)dQ

Use:

(V1 + V2)/2 * (Q2 - Q1)

as the trapezoid rule approximation of this instead of:

V2 * Q2 - V1 * Q1

which doesn't have a clear meaning. If V is constant, both are
the same, but for example, if we had a capacitor with V(Q) = Q/C,
then the old expression would over-estimate by a factor of 2,
while the new expression is asymptotically right for small changes.

https://bugzilla.gnome.org/show_bug.cgi?id=747370```
parent b769f920
 ... ... @@ -455,14 +455,24 @@ gbb_power_statistics_compute (const GbbPowerState *base, } } else if (current->charge_now >= 0 && time_elapsed > 0) { double charge_used = base->charge_now - current->charge_now; double energy_used = base->charge_now * base->voltage_now - current->charge_now * current->voltage_now; if (charge_used > 0) { statistics->current = 3600 * (charge_used) / time_elapsed; statistics->power = 3600 * (energy_used) / time_elapsed; if (base->charge_full >= 0) statistics->battery_life = 3600 * base->charge_full / statistics->current; if (base->charge_full_design >= 0) statistics->battery_life_design = 3600 * base->charge_full_design / statistics->current; /* We can approximate the power used using the current and the voltage; the * more the voltage is constant, the more accurate this will be. We could * improve this by looking at intermediate statistics, but since reporting * capacity in watts is clearly preferred by the relevant standards, too much * complexity to improve this doesn't seem to make sense. */ if (current->voltage_now >= 0) { double average_voltage = (base->voltage_now + current->voltage_now) / 2; statistics->power = 3600 * average_voltage * charge_used / time_elapsed; } } } else if (current->capacity_now >= 0 && time_elapsed > 0) { double capacity_used = base->capacity_now - current->capacity_now; ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment